Skip to content

Commit

Permalink
Allow ASE kwargs for user methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgt16-LANL committed Sep 12, 2023
1 parent 39c508e commit 8ce0ad8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ inputDict = {

# Method parameters.
"calculator":None, # ASE calculator class input for usage during construction or for optimization.
"calculator_kwargs":dict(), # ASE calculator kwargs.
"ase_opt_method":None, # ASE optimizer class used for geometry optimizations. Default will use LBFGSLineSearch.
"ase_opt_kwargs":dict(), # ASE optimizer kwargs. Do not include "trajectory" nor "logfile" kwargs.
"fmax":0.1, # eV/Angstrom maximum force to optimize to with ASE optimizer.
"maxsteps":1000, # Maxmimum number of steps for ASE otpimizer to take.
# Note that charge and multiplicity (uhf) are tracked by ase.Atoms.initial_charges and ase.Atoms.initial_magnetic_moments
Expand Down
16 changes: 11 additions & 5 deletions architector/io_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"metal_ox": None, # Oxidation State
"metal_spin": None, # Spin State
"xtb_solvent": 'none', # Add any named XTB solvent!
"calculator_kwargs":dict(), # ASE calculator kwargs.
"ase_opt_kwargs":dict(), # ASE optimizer kwargs.
"xtb_accuracy":1.0, # Numerical Accuracy for XTB calculations
"xtb_electronic_temperature":300, # In K -> fermi smearing - increase for convergence on harder systems
"xtb_max_iterations":250, # Max iterations for xtb SCF.
Expand Down Expand Up @@ -224,7 +226,7 @@ def calculate(self):
self.mol.calc_suggested_spin(params=self.parameters)
obabel_ff_requested = False
if (self.calculator is not None) and ('custom' in self.method): # If ASE calculator passed use that by default
calc = self.calculator
calc = self.calculator(**self.calculator_kwargs)
# Here, if a calculator needs spin/charge information in another way we can assign.
# Or handle as a different use case.
uhf_vect = np.zeros(len(self.mol.ase_atoms))
Expand Down Expand Up @@ -280,16 +282,20 @@ def calculate(self):
if self.logfile is not None:
dyn = self.opt_method(self.mol.ase_atoms,
trajectory='temp.traj',
logfile=self.logfile)
logfile=self.logfile,
**self.ase_opt_kwargs)
else:
dyn = self.opt_method(self.mol.ase_atoms,
trajectory='temp.traj')
trajectory='temp.traj',
**self.ase_opt_kwargs)
else:
if self.logfile is not None:
dyn = self.opt_method(self.mol.ase_atoms,
logfile=self.logfile)
logfile=self.logfile,
**self.ase_opt_kwargs)
else:
dyn = self.opt_method(self.mol.ase_atoms)
dyn = self.opt_method(self.mol.ase_atoms,
**self.ase_opt_kwargs)
dyn.run(fmax=self.fmax,steps=self.maxsteps)
if self.parameters['save_trajectories']:
self.read_traj()
Expand Down
9 changes: 9 additions & 0 deletions architector/io_process_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,15 @@ def inparse(inputDict):
"alternate_metal_spin": None, # Secondary spin state to check.

# Method parameters.
"calculator":None, # ASE calculator class input for usage during construction or for optimization.
"calculator_kwargs":dict(), # ASE calculator kwargs.
"ase_opt_method":None, # ASE optimizer class used for geometry optimizations. Default will use LBFGSLineSearch.
"ase_opt_kwargs":dict(), # ASE optimizer kwargs.
"fmax":0.1, # eV/Angstrom maximum force to optimize to with ASE optimizer.
"maxsteps":1000, # Maxmimum number of steps for ASE otpimizer to take.
# Note that charge and multiplicity (uhf) are tracked by ase.Atoms.initial_charges and ase.Atoms.initial_magnetic_moments
# In the background by Architector. Make sure your ASE calculator either 1. uses these vectors for setting spin/charge or
# 2. has these quantities pre-specified for the spin/charge you'd like to run.
"xtb_solvent": 'none', # Add any named XTB solvent!
"xtb_accuracy":1.0, # Numerical Accuracy for XTB calculations
"xtb_electronic_temperature":300, # In K -> fermi smearing - increase for convergence on harder systems
Expand Down

0 comments on commit 8ce0ad8

Please sign in to comment.