Skip to content

Commit

Permalink
- pysctheory: DM21 option
Browse files Browse the repository at this point in the history
- parmed library import prints version
  • Loading branch information
RagnarB83 committed Oct 23, 2024
1 parent a24f92a commit f60fb53
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ash/interfaces/interface_OpenMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def __init__(self, printlevel=2, platform='CPU', numcores=1, topoforce=False, fo
if self.printlevel > 0:
print("Reading OpenMM XML forcefield files and PDB file")
print("xmlfiles:", str(xmlfiles).strip("[]"))
if pdbfile == None:
if pdbfile is None:
print("Error:No pdbfile input provided")
ashexit()
# This would be regular OpenMM Forcefield definition requiring XML file
Expand Down Expand Up @@ -5420,6 +5420,7 @@ def small_molecule_parameterizer(charge=None, xyzfile=None, pdbfile=None, molfil
print("Problem importing parmed Python library")
print("Parmed can be installed using pip: pip install parmed")
ashexit()
print(f"Parmed version {parmed.__version__} imported")
#OpenMMForcefields stuff
try:
import openff
Expand Down
21 changes: 17 additions & 4 deletions ash/interfaces/interface_pyscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def __init__(self, printsetting=False, printlevel=2, numcores=1, label="pyscf",
if scf_type == 'UHF':
print("Changing UHF to UKS")
scf_type='UKS'
if "dm21" in self.functional.lower():
print("A DM21-type functional selected. This requires DM21 installation")
try:
import density_functional_approximation_dm21 as dm21
except ModuleNotFoundError as e:
print("Error importing density_functional_approximation_dm21 library. Exiting")
print("Make sure DM21 is installed in the Python environment. See https://github.com/google-deepmind/deepmind-research/tree/master/density_functional_approximation_dm21")
ashexit()
else:
if scf_type == 'RKS' or scf_type == 'UKS':
print("Error: RKS/UKS chosen but no functional. Exiting")
Expand Down Expand Up @@ -2108,10 +2116,15 @@ def set_DF_mf_options(self,Grad=False):

def set_DFT_options(self):
if self.functional is not None:
#Setting functional
self.mf.xc = self.functional
#TODO: libxc vs. xcfun interface control here
#mf._numint.libxc = xcfun
#DM21
if "dm21" in self.functional.lower():
import density_functional_approximation_dm21 as dm21
self.mf._numint = dm21.NeuralNumInt(dm21.Functional.DM21)
else:
#Setting functional
self.mf.xc = self.functional
#TODO: libxc vs. xcfun interface control here
#mf._numint.libxc = xcfun
#Grid setting
self.mf.grids.level = self.gridlevel

Expand Down

0 comments on commit f60fb53

Please sign in to comment.