Last active
May 15, 2024 12:17
-
-
Save rlaplaza/c650d1d75be8762b8905baa20fb146a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import numpy as np | |
import ase | |
# New official implementation | |
from tblite.ase import TBLite as XTB3 | |
from ase.io import read | |
from ase.units import fs, Hartree, Bohr, kB | |
from ase.optimize import LBFGS, MDMin | |
from ase.mep import NEB | |
from ase.io.trajectory import Trajectory | |
from ase.constraints import FixBondLengths, Hookean, FixAtoms | |
from ase.filters import ExpCellFilter, FrechetCellFilter | |
from ase.neighborlist import NeighborList, natural_cutoffs | |
import sys | |
path = "test.xyz" | |
name = "test" | |
mol = read(path) | |
# Can set up constraints etc. using ASE, too | |
mol.set_constraint(FixAtoms(indices=[atom.index for atom in mol if atom.symbol == 'C'])) | |
# We could set harmonic constraints in atoms, etc. as | |
#bonds = [] | |
#cutoffs = natural_cutoffs(mol) | |
#nl = NeighborList(cutoffs, self_interaction=False, bothways=True) | |
#nl.update(mol) | |
#cm = nl.get_connectivity_matrix(sparse=False) | |
#for n in range(cm.shape[0]): | |
# for m in range(n+1,cm.shape[1]): | |
# if cm[n,m] : | |
# bonds.append([n,m]) | |
#for bond in bonds: | |
# mol.set_constraint(Hookean(bond[0],bond[1],k=10)) | |
# Or simply fix them | |
#mol.set_constraint(FixBondLengths(bonds)) | |
# Optimize to a minima | |
try: | |
mol.calc = XTB3(method="GFN2-xTB", max_iterations=1000) | |
opt = LBFGS(mol, trajectory=f"opt.traj", logfile=f"opt.log") | |
opt.run(fmax=0.02, steps=100) | |
traj = Trajectory(f"opt.traj") | |
# We can write any frame of the trajectory | |
ase.io.write(f"{name}_opt.xyz", traj[-1]) | |
except Exception as m: | |
print(m) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 | |
-229.10631947 | |
C 5.4083547045 -1.6912384040 -0.5607576677 | |
C 4.9849409368 -2.4715181445 0.5525003406 | |
C 5.8229402954 -3.4361681743 1.1404117752 | |
C 7.0745132572 -3.6049726446 0.5889898338 | |
C 7.5078995938 -2.8437266336 -0.5267655923 | |
C 6.6969405826 -1.8944835391 -1.1039705425 | |
C 4.3574506583 -0.7867263745 -0.8507821508 | |
C 3.3008458758 -1.0994280047 0.0485553474 | |
N 3.7355033641 -2.0829783892 0.9115996766 | |
H 3.1792681187 -2.4627766159 1.6804932085 | |
C 4.1838086112 0.1382700650 -1.9863309401 | |
H 3.8195102168 1.1163159853 -1.6332785550 | |
H 5.1215985088 0.2727296299 -2.5391254543 | |
C 3.0951848292 -0.4210264867 -2.9736503197 | |
H 2.8234053952 0.3625115930 -3.6891140676 | |
H 3.5012946477 -1.2821278387 -3.5166632128 | |
C 2.0453597035 -1.8257567806 -1.3266238240 | |
N 1.9292573399 -0.8251070910 -2.2381437565 | |
H 2.5546307535 -0.3935333359 0.4170893943 | |
H 1.1650591648 -1.8925608647 -0.6805424933 | |
O 0.7119582346 -1.3458119661 1.8822792287 | |
C 1.0015611332 -2.1755184264 2.8040515783 | |
O 2.0143645689 -2.8848502367 2.7933342212 | |
C 0.0265668931 -2.3027162089 3.9678617291 | |
H 0.5209178036 -2.8121914274 4.8085218937 | |
H -0.3330711525 -1.3172378047 4.2850619694 | |
H -0.8354356722 -2.9004774706 3.6534437744 | |
H 5.4975127624 -4.0115884439 2.0056395751 | |
H 8.5089205489 -3.0236988569 -0.9145015345 | |
H 7.0312383222 -1.2971704625 -1.9527166003 | |
C 0.9845545082 0.2445224559 -1.8988639353 | |
H 1.2387819877 0.6842205217 -0.9241947687 | |
H 1.1051132447 1.0401225281 -2.6516535350 | |
C -0.4564448522 -0.1976133856 -1.9128880193 | |
C -0.8995414362 -1.2680135510 -2.6943118939 | |
C -1.3937039390 0.5405357935 -1.1885494901 | |
C -2.2517578776 -1.5831734166 -2.7542718755 | |
H -0.1785728295 -1.8541173756 -3.2663157820 | |
C -2.7539178998 0.2484769150 -1.2731152577 | |
H -1.0537758041 1.3653645780 -0.5574643222 | |
C -3.1845492712 -0.8158469779 -2.0578745139 | |
H -2.5826464645 -2.4261633768 -3.3597633379 | |
H -3.4735415919 0.8606487721 -0.7313164495 | |
H -4.2469888139 -1.0462716640 -2.1270324521 | |
C -2.7141349061 2.0502107334 2.1576595340 | |
C -1.7892489022 0.8824733325 2.1163061934 | |
C -0.6807764494 1.6813036191 2.4209357157 | |
C -1.4934991493 2.9099981026 2.4708001161 | |
O -1.2421531374 4.0854807751 2.6084724903 | |
O -3.8937961588 2.2256797819 1.9812203465 | |
N 0.6142398156 1.3974082933 2.5936985128 | |
C 1.6054057365 2.4427592331 2.7099828588 | |
C 2.7743654594 1.9944936502 3.6246889311 | |
C 2.1914422496 1.6376148484 4.9981619976 | |
C 3.5109118436 0.7802633821 3.0521589453 | |
C 3.7707082494 3.1483238502 3.7851175359 | |
C 2.0545682628 2.8040919844 1.2850133442 | |
N 2.1159928918 4.1028982909 0.9329931821 | |
C 2.5813911029 4.4478700708 -0.4026686006 | |
C 1.8813512278 3.7518674877 -1.5704576225 | |
N 0.5202472400 3.8253160194 -1.6603032263 | |
C -0.4217387610 4.2585189959 -0.6019994908 | |
C -1.7806339739 3.9447846063 -1.1603305132 | |
C -1.5865848859 3.4133977959 -2.4453336704 | |
C -0.2087740392 3.3465538753 -2.7691128460 | |
C 0.1624203675 2.8767076312 -4.0100462746 | |
C -0.8755071218 2.4472309335 -4.8863271606 | |
C -2.2099401372 2.4844550174 -4.5592663465 | |
C -2.6197485539 2.9914647000 -3.2936002354 | |
O 2.5508600580 3.2233834605 -2.4380454583 | |
O 2.2849404860 1.9257913436 0.4544942377 | |
N -1.7923848892 -0.4362779370 1.8393992128 | |
C -2.8397250661 -1.2339218515 1.4100304144 | |
C -4.1767122486 -0.8175518966 1.3848761013 | |
C -5.1521139844 -1.6848017287 0.9055715947 | |
C -6.5721354434 -1.1879165415 0.8346090575 | |
F -6.9433952572 -0.5308291216 1.9334897788 | |
F -6.7446698854 -0.3433539922 -0.1928205080 | |
F -7.4597645742 -2.1714914910 0.6600892627 | |
C -4.8426851991 -2.9608530324 0.4463527652 | |
C -3.5117954291 -3.3703397872 0.4928189184 | |
C -3.1008492611 -4.7228766013 -0.0186230897 | |
F -4.1288541840 -5.5325739446 -0.2782724193 | |
F -2.4018926289 -4.6210301831 -1.1701334933 | |
F -2.3025030405 -5.3685967429 0.8257604443 | |
C -2.5185022084 -2.5279013915 0.9692258949 | |
H 0.9190135951 0.4523290282 2.3163713403 | |
H 1.1078666335 3.3080553030 3.1669403005 | |
H 2.9973958838 1.3587139255 5.6881325739 | |
H 1.4986740938 0.7877765962 4.9189957371 | |
H 1.6457360854 2.4893208298 5.4279768741 | |
H 4.3641907150 0.5251172035 3.6971314233 | |
H 3.8940545550 0.9868834597 2.0443395085 | |
H 2.8597314591 -0.1039911313 3.0062652562 | |
H 4.1659182883 3.4676492270 2.8123456158 | |
H 4.6186428737 2.8229475266 4.4034717114 | |
H 3.3048613376 4.0074913289 4.2863861864 | |
H -0.3159026920 5.3322491860 -0.3928287783 | |
H -0.2290706599 3.7028675876 0.3301978742 | |
H 1.1982737610 2.8361545929 -4.3282453641 | |
H -0.5778574467 2.0689450371 -5.8638097873 | |
H -2.9615404098 2.1331633756 -5.2648623806 | |
H -0.8418436934 -0.8690238359 1.8366930874 | |
H -4.4547433907 0.1817419509 1.7223141705 | |
H -5.6177955958 -3.6248812038 0.0674908420 | |
H -1.4767100189 -2.8618091950 0.9937017972 | |
C 2.4706594767 5.9829602693 -0.4756236056 | |
C 2.5515658481 6.4149883402 0.9878677919 | |
C 1.8510907625 5.2954665098 1.7475593652 | |
H 1.5146924234 6.2844507115 -0.9219448793 | |
H 3.2772810167 6.4098687465 -1.0881111637 | |
H 3.6005873867 6.4788366517 1.2989874398 | |
H 2.0789416604 7.3909492033 1.1638005352 | |
H 2.2635016688 5.1776109675 2.7617765662 | |
H 0.7735415329 5.4599299164 1.8273167954 | |
H 3.6327080186 4.1380951482 -0.4941125344 | |
H 7.7598904571 -4.3348892117 1.0178901376 | |
C -3.9318236479 3.1239661919 -2.7687799969 | |
C -4.1256228311 3.6426254722 -1.5040454770 | |
C -3.0576080623 4.0679618010 -0.6733956541 | |
H -4.7845281514 2.8086956161 -3.3693189346 | |
H -5.1383658553 3.7271850545 -1.1120527939 | |
H -3.2648221710 4.4632326302 0.3192595944 | |
C 2.6332699859 -3.1341142750 -1.6188145845 | |
C 3.7354294404 -3.5737430501 -2.3394510650 | |
H 4.4505408987 -3.0149506577 -2.9327207117 | |
C 2.9011308653 -5.3045788897 -1.4354630598 | |
H 2.7265834779 -6.3355837842 -1.1349264637 | |
N 2.1217691821 -4.2778500602 -1.0279178469 | |
C 0.9688129156 -4.3745839793 -0.1571481249 | |
H 0.7916087386 -5.4326653129 0.0758584909 | |
H 1.1536058588 -3.8364389669 0.7796656895 | |
H 0.0799526553 -3.9683876128 -0.6596589148 | |
N 3.8751046722 -4.9160206449 -2.2235361455 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment