Skip to content

Commit

Permalink
Merge pull request #35 from RaphaelRobidas/solvation
Browse files Browse the repository at this point in the history
Added solvation for xTB
  • Loading branch information
craldaz authored Oct 20, 2021
2 parents b3bbfe8 + cc15ff4 commit d575ed7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions pygsm/level_of_theories/base_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,22 @@ def default_options():
doc='xTB electronic_temperature'
)

opt.add_option(
key='solvent',
value=None,
required=False,
allowed_types=[str],
doc='xTB solvent'
)

Lot._default_options = opt
return Lot._default_options.copy()

def __init__(self,
options,
):
""" Constructor """

self.options = options

# properties
self.Energy = namedtuple('Energy','value unit')
self.Gradient = namedtuple('Gradient','value unit')
Expand Down Expand Up @@ -248,6 +254,7 @@ def __init__(self,
self.xTB_Hamiltonian = self.options['xTB_Hamiltonian']
self.xTB_accuracy = self.options['xTB_accuracy']
self.xTB_electronic_temperature = self.options['xTB_electronic_temperature']
self.solvent = self.options['solvent']

# Bools for running
self.hasRanForCurrentCoords =False
Expand Down
5 changes: 4 additions & 1 deletion pygsm/level_of_theories/xtb_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import contextlib
from xtb.interface import Calculator
from xtb.utils import get_method
from xtb.utils import get_method, get_solvent
from xtb.interface import Environment
from xtb.libxtb import VERBOSITY_FULL

Expand Down Expand Up @@ -41,6 +41,9 @@ def run(self,geom,multiplicity,state,verbose=False):

calc.set_accuracy(self.xTB_accuracy)
calc.set_electronic_temperature(self.xTB_electronic_temperature)

if self.solvent is not None:
calc.set_solvent(get_solvent(self.solvent))

calc.set_output('lot_jobs_{}.txt'.format(self.node_id))
res = calc.singlepoint() # energy printed is only the electronic part
Expand Down
4 changes: 4 additions & 0 deletions pygsm/wrappers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def parse_arguments(verbose=True):
parser.add_argument('-xTB_accuracy',type=float,default=1.0, help='xTB accuracy',required=False)
parser.add_argument('-xTB_electronic_temperature',type=float,default=300.0, help='xTB electronic temperature',required=False)
parser.add_argument('-xyz_output_format',type=str,default="molden",help='Format of the produced XYZ files',required=False)
parser.add_argument('-solvent',type=str,help='Solvent to use (xTB calculations only)',required=False)
parser.add_argument('-linesearch', type=str, default='NoLineSearch', help='default: %(default)s',
choices=['NoLineSearch', 'backtrack'])
parser.add_argument('-coordinate_type', type=str, default='TRIC', help='Coordinate system (default %(default)s)',
Expand Down Expand Up @@ -160,6 +161,7 @@ def parse_arguments(verbose=True):
'xTB_Hamiltonian': args.xTB_Hamiltonian,
'xTB_accuracy': args.xTB_accuracy,
'xTB_electronic_temperature': args.xTB_electronic_temperature,
'solvent': args.solvent,

# PES
'PES_type': args.pes_type,
Expand Down Expand Up @@ -283,6 +285,8 @@ def create_lot(inpfileq: dict, geom):
xTB_Hamiltonian=inpfileq['xTB_Hamiltonian'],
xTB_accuracy=inpfileq['xTB_accuracy'],
xTB_electronic_temperature=inpfileq['xTB_electronic_temperature'],
solvent=inpfileq['solvent'],
**lot_options,
)
else:
est_package = importlib.import_module("pygsm.level_of_theories." + lot_name.lower())
Expand Down

0 comments on commit d575ed7

Please sign in to comment.