Skip to content

Commit

Permalink
Tblite migrating.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgt16-LANL committed Dec 19, 2024
1 parent a76cc1a commit 9dae795
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
12 changes: 7 additions & 5 deletions architector/arch_xtb_text_ase_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def calculate(self, atoms=None, *args, **kwargs):
file1.write(" gbsa=true\n")

# Run xtb
execStr = "{} structure.xyz {} --chrg {} --uhf {} --alpb {} -P 1 -a {} --etemp {} --iterations {} --grad -I solv_options.txt> output.xtb".format(
execStr = "{} structure.xyz {} --chrg {} --uhf {} --alpb {} -P 1 -a {} --etemp {} --iterations {} --grad -I solv_options.txt".format(
xtbPath,
methods_dict[self.parameters.get("xtb_method", "GFN2-xTB")],
int(charge),
Expand All @@ -98,7 +98,7 @@ def calculate(self, atoms=None, *args, **kwargs):
self.parameters["xtb_max_iterations"],
)
else:
execStr = "{} structure.xyz {} --chrg {} --uhf {} -P 1 -a {} --etemp {} --iterations {} --grad> output.xtb".format(
execStr = "{} structure.xyz {} --chrg {} --uhf {} -P 1 -a {} --etemp {} --iterations {} --grad".format(
xtbPath,
methods_dict[self.parameters.get("xtb_method", "GFN2-xTB")],
int(charge),
Expand All @@ -108,9 +108,11 @@ def calculate(self, atoms=None, *args, **kwargs):
self.parameters["xtb_max_iterations"],
)

sub.run(
execStr, shell=True, check=True, stderr=sub.DEVNULL, stdout=sub.DEVNULL
)
with open('output.xtb', 'w') as file1:
sub.run(
execStr.split(), check=True,
stderr=sub.DEVNULL, stdout=file1
)

outpath = pathlib.Path(".")

Expand Down
11 changes: 2 additions & 9 deletions architector/io_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,8 @@ def calculate(self):
max_iterations=self.xtb_max_iterations,
electronic_temperature=self.xtb_electronic_temperature,
# spin_polarization=1.0, # Have spin polarization on if desired.
verbosity=self.parameters['debug'])
# No xtb-python
elif (not has_xtb_python) and (self.method != 'GFN-FF'):
print('Warning: Defaulting to TBLite with no solvent since xtb-python is not installed.')
calc = TBLite(method=self.method,
max_iterations=self.xtb_max_iterations,
electronic_temperature=self.xtb_electronic_temperature,
# spin_polarization=1.0, # Have spin polarization on if desired.
verbosity=self.parameters['debug'])
# verbosity=self.parameters['debug'])
verbosity=-1)
elif (not has_xtb_python):
calc = XTB_Calculator(
xtb_method=self.method,
Expand Down
14 changes: 12 additions & 2 deletions architector/io_lig.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@
from ase import Atom
from ase.optimize.bfgslinesearch import BFGSLineSearch
import ase.constraints as ase_con
from xtb.ase.calculator import XTB
has_xtb_python = False
try:
from xtb.ase.calculator import XTB
has_xtb_python = True
except:
pass

from architector.arch_xtb_text_ase_calc import XTB_Calculator
# from tblite.ase import TBLite -> No GFN-FF support yet.
import warnings

Expand Down Expand Up @@ -107,7 +114,10 @@ def set_XTB_calc(ase_atoms):
"""
ase_atoms.set_initial_charges(np.zeros(len(ase_atoms)))
ase_atoms.set_initial_magnetic_moments(np.zeros(len(ase_atoms)))
calc = XTB(method="GFN-FF")
if has_xtb_python:
calc = XTB(method="GFN-FF")
else:
calc = XTB_Calculator(xtb_method="GFN-FF")
# Default to only GFN-FF for ligand conformer relaxation.
ase_atoms.calc = calc
return ase_atoms
Expand Down

0 comments on commit 9dae795

Please sign in to comment.