isayev / ASE_ANI

ANI-1 neural net potential with python interface (ASE)
MIT License
220 stars 56 forks source link

Allow passing network location as __init__ parameter to ANI and ANID3 #5

Open zubatyuk opened 7 years ago

zubatyuk commented 7 years ago
--- lib/ase_interface.py        2017-07-13 14:29:18.239944902 -0500
+++ lib/ase_interface_.py       2017-07-13 15:04:52.837327087 -0500
@@ -31,18 +31,18 @@

     nolabel = True
     def __init__(self, build=True,gpuid=0,reslist=[],**kwargs):
-        Calculator.__init__(self, **kwargs)
-
         if build:
             anipath = os.path.dirname(__file__)
-            cnstfile = anipath + '/../ANI-c08f-ntwk/rHCNO-4.6A_16-3.1A_a4-8.params'
-            saefile = anipath + '/../ANI-c08f-ntwk/sae_6-31gd.dat'
-            nnfdir = anipath + '/../ANI-c08f-ntwk/networks/'
+            cnstfile = kwargs.pop('cnstfile', anipath + '/../ANI-c08f-ntwk/rHCNO-4.6A_16-3.1A_a4-8.params')
+            saefile = kwargs.pop('saefile', anipath + '/../ANI-c08f-ntwk/sae_6-31gd.dat')
+            nnfdir = kwargs.pop('nnfdir', anipath + '/../ANI-c08f-ntwk/networks/')
             self.nc = pync.molecule(cnstfile, saefile, nnfdir, gpuid)

         self.Setup=True
         self.reslist=reslist

+        Calculator.__init__(self, **kwargs)
+
     def setnc(self,nc):
         self.nc = nc

@@ -278,19 +278,20 @@
         nolabel = True

         def __init__(self, build=True, **kwargs):
-            Calculator.__init__(self, **kwargs)
             if build:
                 anipath = os.path.dirname(__file__)
-                cnstfile = anipath + '/../ANI-c08e-ntwk/rHCNO-4.6A_16-3.1A_a4-8.params'
-                saefile = anipath + '/../ANI-c08e-ntwk/sae_6-31gd.dat'
-                nnfdir = anipath + '/../ANI-c08e-ntwk/networks/'
-                self.nc = pync.molecule(cnstfile, saefile, nnfdir, 0)
+                cnstfile = kwargs.pop('cnstfile', anipath + '/../ANI-c08f-ntwk/rHCNO-4.6A_16-3.1A_a4-8.params')
+                saefile = kwargs.pop('saefile', anipath + '/../ANI-c08f-ntwk/sae_6-31gd.dat')
+                nnfdir = kwargs.pop('nnfdir', anipath + '/../ANI-c08f-ntwk/networks/')
+                self.nc = pync.molecule(cnstfile, saefile, nnfdir, gpuid)

             self.Setup = True

             def setnc(self, nc):
                 self.nc = nc

+            Calculator.__init__(self, **kwargs)
+
         def calculate(self, atoms=None, properties=['energy'],
                       system_changes=all_changes):
             Calculator.calculate(self, atoms, properties, system_changes)
zubatyuk commented 7 years ago

This will accept cnstfile, saefile and nnfdir params (full path to file/dir), but will not pass these params to Calculator.__init__

isayev commented 7 years ago

@zubatyuk feel free to edit/modify interface code and PR!