ForceBalance API  1.3
Automated optimization of force fields and empirical potentials
psi4io.py
Go to the documentation of this file.
1 """ @package forcebalance.psi4io PSI4 force field input/output.
2 
3 This serves as a good template for writing future force matching I/O
4 modules for other programs because it's so simple.
5 
6 @author Lee-Ping Wang
7 @date 01/2012
8 """
9 from __future__ import division
10 from __future__ import print_function
11 
12 from builtins import str
13 from builtins import range
14 import os, sys, glob, shutil
15 from re import match, sub, split, findall
16 from forcebalance.nifty import isint, isfloat, _exec, warn_press_key, printcool_dictionary, wopen
17 import numpy as np
18 from forcebalance.leastsq import LeastSquares, CheckBasis
19 from forcebalance import BaseReader
20 # from string import capitalize
21 from forcebalance.finite_difference import in_fd, f1d2p, f12d3p, fdwrap
22 from collections import defaultdict, OrderedDict
23 import itertools
24 from forcebalance.target import Target
25 from forcebalance.nifty import queue_up_src_dest, getWorkQueue
26 from forcebalance.output import getLogger
27 logger = getLogger(__name__)
28 
29 
33 
34 class GBS_Reader(BaseReader):
35  """Finite state machine for parsing basis set files.
36 
37  """
38 
39  def __init__(self,fnm=None):
40  super(GBS_Reader,self).__init__(fnm)
41  self.element = ''
42  self.amom = ''
43  self.last_amom = ''
44  self.basis_number = defaultdict(int)
46  self.adict={None:None}
47  self.isdata=False
48  self.destroy=False
49 
50  def build_pid(self, pfld):
51  if pfld == 0:
52  ptype = 'Exponent'
53  elif pfld == 1:
54  ptype = 'Contraction'
55  return ptype+":"+"Elem=%s,AMom=%s,Bas=%i,Con=%i" % (self.element, self.amom, self.basis_number[self.element], self.contraction_number)
56 
57  def feed(self, line, linindep=False):
58  """ Feed in a line.
59 
60  @param[in] line The line of data
61 
62  """
63  if linindep:
64  if match('^ *!',line):
65  self.destroy = True
66  else:
67  self.destroy = False
68  line = sub('^ *!','',line)
69 
70  line = line.split('!')[0].strip()
71  s = line.split()
72  self.ln += 1
73  # No sense in doing anything for an empty line or a comment line.
74  if len(s) == 0 or match('^ *!',line): return None, None
75  # Now go through all the cases.
76  if match('^[A-Za-z][A-Za-z]? +[0-9]$',line):
77  # This is supposed to match the element line. For example 'Li 0'
78  self.element = s[0].capitalize()
79  self.isdata = False
80  self.destroy = False
81  elif len(s) == 3 and match('[SPDFGH]+',s[0]) and isint(s[1]) and isfloat(s[2]):
82  self.amom = s[0]
83  if self.amom == self.last_amom:
84  self.basis_number[self.element] += 1
85  else:
86  self.basis_number[self.element] = 0
87  self.last_amom = self.amom
88  self.contraction_number = -1
89  self.isdata = True
90  # This is supposed to match a line like 'P 1 1.00'
91  elif len(s) == 2 and isfloat(s[0]) and isfloat(s[1]):
92  self.contraction_number += 1
93  self.isdata = True
94  else:
95  self.isdata = False
96  self.destroy = False
97 
98 class THCDF_Psi4(LeastSquares):
99 
100  def __init__(self,options,tgt_opts,forcefield):
101  super(THCDF_Psi4,self).__init__(options,tgt_opts,forcefield)
102 
103  # Parse the input.dat file to figure out the elements and molecules
104  MolSection = False
105  ElemList = []
106  self.Molecules = []
107  self.throw_outs = []
108  for line in open(os.path.join(self.root,self.tgtdir,"input.dat")).readlines():
109  line = line.strip()
110  s = line.split()
111  if len(s) >= 3 and s[0].lower() == 'molecule' and s[2] == '{':
112  MolSection = True
113  self.Molecules.append(s[1])
114  elif len(s) >= 1 and s[0] == '}':
115  MolSection = False
116  elif MolSection and len(s) >= 4 and match("^[A-Za-z]+$",s[0]) and isfloat(s[1]) and isfloat(s[2]) and isfloat(s[3]):
117  ElemList.append(s[0].capitalize())
118  self.Elements = set(ElemList)
119  xgrad = []
120  for p in self.pgrad:
121  Pelem = []
122  for pid in self.FF.plist[p].split():
123  # Extract the chemical element.
124  Pelem.append(pid.split(':')[1].split(',')[0].split('=')[1])
125  Pelem = set(Pelem)
126  if len(self.Elements.intersection(Pelem)) == 0:
127  xgrad.append(p)
128  for p in xgrad:
129  self.pgrad.remove(p)
130 
131  gbslist = [i for i in self.FF.fnms if os.path.splitext(i)[1] == '.gbs']
132  if len(gbslist) != 1:
133  warn_press_key("In %s, you should only have exactly one .gbs file in the list of force field files!" % __file__)
134  self.GBSfnm = gbslist[0]
135 
138  datlist = [i for i in self.FF.fnms if os.path.splitext(i)[1] == '.dat']
139  if len(datlist) != 1:
140  warn_press_key("In %s, you should only have exactly one .dat file in the list of force field files!" % __file__)
141  self.DATfnm = datlist[0]
142 
143  self.prepare_temp_directory(options,tgt_opts)
145  def prepare_temp_directory(self, options, tgt_opts):
146  abstempdir = os.path.join(self.root,self.tempdir)
147  o = wopen(os.path.join(abstempdir,"input.dat"))
148  for line in open(os.path.join(self.root,self.tgtdir,"input.dat")).readlines():
149  s = line.split("#")[0].split()
150  if len(s) == 3 and s[0].lower() == 'basis' and s[1].lower() == 'file':
151  print("basis file %s" % self.GBSfnm, file=o)
152  else:
153  print(line, end=' ', file=o)
154  o.close()
155 
156  def indicate(self):
157  MAD = np.mean(np.abs(self.D))
158  logger.info("\rTarget: %-15s Molecules = %-30s %s" % (self.name, str(self.Molecules), "Mean (Max) Error: %8.4f%% (%8.4f%%) Energies: DF %+.3e MP2 %+.3e Delta % .3e Objective = %.5e" % (100*MAD / self.MAQ, 100*np.max(np.abs(self.D)) / self.MAQ, self.DF_Energy, self.MP2_Energy, self.DF_Energy - self.MP2_Energy, self.objective)))
159  return
160 
161  def write_nested_destroy(self, fnm, linedestroy):
162  ln0 = list(range(len(open(fnm).readlines())))
163  for layer in linedestroy:
164  f = open(fnm).readlines()
165  o = wopen('.tmp.gbs')
166  newln = []
167  for ln, line in enumerate(f):
168  if ln not in layer:
169  print(line, end=' ', file=o)
170  newln.append(ln0[ln])
171  ln0 = newln[:]
172  _exec("mv .tmp.gbs %s" % fnm, print_command=False)
173  o.close()
174  return ln0
175 
176  def driver(self):
177 
178  if not in_fd() and CheckBasis():
179  logger.info("Now checking for linear dependencies.\n")
180  _exec("cp %s %s.bak" % (self.GBSfnm, self.GBSfnm), print_command=False)
181  ln0 = self.write_nested_destroy(self.GBSfnm, self.FF.linedestroy_save)
182  o = wopen(".lindep.dat")
183  for line in open(self.DATfnm).readlines():
184  s = line.split("#")[0].split()
185  if len(s) == 3 and s[0].lower() == 'basis' and s[1].lower() == 'file':
186  print("basis file %s" % self.GBSfnm, file=o)
187  else:
188  print(line, end=' ', file=o)
189  o.close()
190  _exec("mv .lindep.dat %s" % self.DATfnm, print_command=False)
191  _exec("psi4 %s" % self.DATfnm, print_command=False)
192  LI = GBS_Reader()
193  LI_lines = {}
194 
195  for line in open('linindep.gbs'):
196  LI.feed(line,linindep=True)
197  key = '.'.join([str(i) for i in (LI.element,LI.amom,LI.basis_number[LI.element],LI.contraction_number)])
198  if LI.isdata:
199  if key in LI_lines:
200  logger.info("Duplicate key found:\n")
201  logger.info("%s\n" % key)
202  logger.info(str(LI_lines[key]))
203  logger.info(line)
204  warn_press_key("In %s, the LI_lines dictionary should not contain repeated keys!" % __file__)
205  LI_lines[key] = (line, LI.destroy)
206 
207  FK = GBS_Reader()
208  FK_lines = []
209  self.FF.linedestroy_this = []
210  self.FF.prmdestroy_this = []
211  for ln, line in enumerate(open(self.GBSfnm).readlines()):
212  FK.feed(line)
213  key = '.'.join([str(i) for i in (FK.element,FK.amom,FK.basis_number[FK.element],FK.contraction_number)])
214  if FK.isdata and key in LI_lines:
215  if LI_lines[key][1]:
216  logger.info("Destroying line %i (originally %i): " % (ln, ln0[ln]))
217  logger.info(line)
218  self.FF.linedestroy_this.append(ln)
219  for p_destroy in [i for i, fld in enumerate(self.FF.pfields) if any([subfld[0] == self.GBSfnm and subfld[1] == ln0[ln] for subfld in fld])]:
220  logger.info("Destroying parameter %i located at line %i (originally %i) with fields given by: %s" % (p_destroy, ln, ln0[ln], str(self.FF.pfields[p_destroy])))
221  self.FF.prmdestroy_this.append(p_destroy)
222  FK_lines.append(LI_lines[key][0])
223  else:
224  FK_lines.append(line)
225  o = wopen('franken.gbs')
226  for line in FK_lines:
227  print(line, end=' ', file=o)
228  o.close()
229  _exec("cp %s.bak %s" % (self.GBSfnm, self.GBSfnm), print_command=False)
230 
231  if len(list(itertools.chain(*(self.FF.linedestroy_save + [self.FF.linedestroy_this])))) > 0:
232  logger.info("All lines removed: " + self.FF.linedestroy_save + [self.FF.linedestroy_this] + '\n')
233  logger.info("All prms removed: " + self.FF.prmdestroy_save + [self.FF.prmdestroy_this] + '\n')
234 
235  self.write_nested_destroy(self.GBSfnm, self.FF.linedestroy_save + [self.FF.linedestroy_this])
236  _exec("psi4", print_command=False, outfnm="psi4.stdout")
237  if not in_fd():
238  for line in open('psi4.stdout').readlines():
239  if "MP2 Energy:" in line:
240  self.MP2_Energy = float(line.split()[-1])
241  elif "DF Energy:" in line:
242  self.DF_Energy = float(line.split()[-1])
243  Ans = np.array([[float(i) for i in line.split()] for line in open("objective.dat").readlines()])
244  os.unlink("objective.dat")
245  return Ans
246 
247 class Grid_Reader(BaseReader):
248  """Finite state machine for parsing DVR grid files.
249 
250  """
251 
252  def __init__(self,fnm=None):
253  super(Grid_Reader,self).__init__(fnm)
254  self.element = ''
255  self.point = 0
256  self.radii = OrderedDict()
257 
258  def build_pid(self, pfld):
259  if pfld == 1:
260  ptype = 'Position'
261  elif pfld == 2:
262  ptype = 'Weight'
263  else:
264  ptype = 'None'
265  return ptype+":"+"Elem=%s,Point=%i" % (self.element, self.point)
266 
267  def feed(self, line, linindep=False):
268  """ Feed in a line.
269 
270  @param[in] line The line of data
271 
272  """
273  line = line.split('!')[0].strip()
274  s = line.split()
275  self.ln += 1
276  # No sense in doing anything for an empty line or a comment line.
277  if len(s) == 0 or match('^ *!',line): return None, None
278  # Now go through all the cases.
279  if match('^[A-Za-z][A-Za-z]? +[0-9]$',line):
280  # This is supposed to match the element line. For example 'Li 0'
281  self.element = s[0].capitalize()
282  self.radii[self.element] = float(s[1])
283  self.isdata = False
284  self.point = 0
285  elif len(s) >= 2 and isint(s[0]) and isfloat(s[1]):
286  self.point += 1
287  self.isdata = True
288  else:
289  self.isdata = False
290 
291 class RDVR3_Psi4(Target):
292 
293  """ Subclass of Target for R-DVR3 grid fitting.
294  Main features:
295  - Multiple molecules are treated as a single target.
296  - R-DVR3 can only print out the objective function, it cannot print out the residual vector.
297  - We should be smart enough to mask derivatives.
298  """
299 
300  def __init__(self,options,tgt_opts,forcefield):
301  super(RDVR3_Psi4,self).__init__(options,tgt_opts,forcefield)
302  #======================================#
303  # Variables which are set here #
304  #======================================#
305 
306  self.objfiles = OrderedDict()
307  self.objvals = OrderedDict()
308  self.elements = OrderedDict()
309  self.molecules = OrderedDict()
310  self.callderivs = OrderedDict()
311  self.factor = 1e6
312  self.bidirect = False
313  for d in sorted(os.listdir(self.tgtdir)):
314  if os.path.isdir(os.path.join(self.tgtdir,d)) and os.path.exists(os.path.join(self.tgtdir,d,'objective.dat')):
315  self.callderivs[d] = [True for i in range(forcefield.np)]
316  self.objfiles[d] = open(os.path.join(self.tgtdir,d,'objective.dat')).readlines()
317  ElemList = []
318  Molecules = []
319  for line in self.objfiles[d]:
320  line = line.strip()
321  s = line.split()
322  if len(s) >= 3 and s[0].lower() == 'molecule' and s[2] == '{':
323  MolSection = True
324  Molecules.append(s[1])
325  elif len(s) >= 1 and s[0] == '}':
326  MolSection = False
327  elif MolSection and len(s) >= 4 and match("^[A-Za-z]+$",s[0]) and isfloat(s[1]) and isfloat(s[2]) and isfloat(s[3]):
328  ElemList.append(s[0].capitalize())
329  self.elements[d] = set(ElemList)
330  self.molecules[d] = Molecules
331  for p in range(self.FF.np):
332  Pelem = []
333  for pid in self.FF.plist[p].split():
334  # Extract the chemical element.
335  Pelem.append(pid.split(':')[1].split(',')[0].split('=')[1])
336  Pelem = set(Pelem)
337  if len(self.elements[d].intersection(Pelem)) == 0:
338  self.callderivs[d][p] = False
339 
340  def indicate(self):
341  PrintDict = OrderedDict()
342  for d in self.objvals:
343  PrintDict[d] = "%15.9f" % self.objvals[d]
344  printcool_dictionary(PrintDict,title="Target: %s\nR-DVR Objective Function, Total = %15.9f\n %-10s %15s" %
345  (self.name, self.objective, "Molecule", "Objective"),keywidth=15)
347  return
348 
349  def submit_jobs(self, mvals, AGrad=True, AHess=True):
350  # This routine is called by Objective.stage() will run before "get".
351  # It submits the jobs to the Work Queue and the stage() function will wait for jobs to complete.
352  #
353  self.tdir = os.getcwd()
354  wq = getWorkQueue()
355  if wq is None:
356  return
357 
358  def submit_psi(this_apath, dname, these_mvals):
359  """ Create a grid file and a psi4 input file in the absolute path and submit it to the work queue. """
360  cwd = os.getcwd()
361  if not os.path.exists(this_apath) : os.makedirs(this_apath)
362  os.chdir(this_apath)
363  self.FF.make(these_mvals)
364  o = wopen('objective.dat')
365  for line in self.objfiles[d]:
366  s = line.split()
367  if len(s) > 2 and s[0] == 'path' and s[1] == '=':
368  print("path = '%s'" % os.getcwd(), file=o)
369  elif len(s) > 2 and s[0] == 'set' and s[1] == 'objective_path':
370  print("opath = '%s'" % os.getcwd(), file=o)
371  print("set objective_path $opath", file=o)
372  else:
373  print(line, end=' ', file=o)
374  o.close()
375  os.system("rm -f objective.out")
376  if wq is None:
377  logger.info("There is no Work Queue!!!\n")
378  sys.exit()
379  else:
380  input_files = [(os.path.join(this_apath, i), i) for i in glob.glob("*")]
381  input_files += [(os.path.join(self.root, self.tgtdir, dname, "build.dat"), "build.dat")]
382  input_files += [(os.path.join(os.path.split(__file__)[0],"data","run_psi_rdvr3_objective.sh"), "run_psi_rdvr3_objective.sh")]
383  logger.info("\r")
384  queue_up_src_dest(wq,"sh run_psi_rdvr3_objective.sh -c %s &> run_psi_rdvr3_objective.log" % os.path.join(self.root, self.tgtdir, dname),
385  input_files=input_files,
386  output_files=[(os.path.join(this_apath, i),i) for i in ["run_psi_rdvr3_objective.log", "output.dat"]], verbose=False)
387  os.chdir(cwd)
388 
389  for d in self.objfiles:
390  logger.info("\rNow working on" + str(d) + 50*' ' + '\r')
391  odir = os.path.join(os.getcwd(),d)
392  #if os.path.exists(odir):
393  # shutil.rmtree(odir)
394  if not os.path.exists(odir): os.makedirs(odir)
395  apath = os.path.join(odir, "current")
396  submit_psi(apath, d, mvals)
397  for p in range(self.FF.np):
398  def subjob(mvals_,h):
399  apath = os.path.join(odir, str(p), str(h))
400  submit_psi(apath, d, mvals_)
401  #logger.info("Will set up a job for %s, parameter %i\n" % (d, p))
402  return 0.0
403  if self.callderivs[d][p]:
404  if AHess:
405  f12d3p(fdwrap(subjob, mvals, p, h=self.h), h = self.h, f0 = 0.0)
406  elif AGrad:
407  if self.bidirect:
408  f12d3p(fdwrap(subjob, mvals, p, h=self.h), h = self.h, f0 = 0.0)
409  else:
410  f1d2p(fdwrap(subjob, mvals, p, h=self.h), h = self.h, f0 = 0.0)
411 
412  def driver(self, mvals, d):
413 
414  pvals = self.FF.make(mvals)
415 
416  odir = os.path.join(os.getcwd(),d)
417  #if os.path.exists(odir):
418  # shutil.rmtree(odir)
419  if not os.path.exists(odir): os.makedirs(odir)
420  os.chdir(odir)
421  o = wopen('objective.dat')
422  for line in self.objfiles[d]:
423  s = line.split()
424  if len(s) > 2 and s[0] == 'path' and s[1] == '=':
425  print("path = '%s'" % self.tdir, file=o)
426  elif len(s) > 2 and s[0] == 'set' and s[1] == 'objective_path':
427  print("opath = '%s'" % os.getcwd(), file=o)
428  print("set objective_path $opath", file=o)
429  else:
430  print(line, end=' ', file=o)
431  o.close()
432  os.system("rm -f objective.out")
433  _exec("psi4 objective.dat", print_command=False)
434  answer = float(open('objective.out').readlines()[0].split()[1])*self.factor
435  os.chdir('..')
436  return answer
437 
438  def get(self, mvals, AGrad=False, AHess=False):
439  """
440  LPW 04-17-2013
441 
442  This subroutine builds the objective function from Psi4.
443 
444  @param[in] mvals Mathematical parameter values
445  @param[in] AGrad Switch to turn on analytic gradient
446  @param[in] AHess Switch to turn on analytic Hessian
447  @return Answer Contribution to the objective function
448  """
449  Answer = {}
450  Fac = 1000000
451  n = len(mvals)
452  X = 0.0
453  G = np.zeros(n)
454  H = np.zeros((n,n))
455  pvals = self.FF.make(mvals)
456  self.tdir = os.getcwd()
457  self.objd = OrderedDict()
458  self.gradd = OrderedDict()
459  self.hdiagd = OrderedDict()
460  wq = getWorkQueue()
461 
462  def fdwrap2(func,mvals0,pidx,qidx,key=None,**kwargs):
463  def func2(arg1,arg2):
464  mvals = list(mvals0)
465  mvals[pidx] += arg1
466  mvals[qidx] += arg2
467  logger.info("\rfdwrap2:" + func.__name__ + "[%i] = % .1e , [%i] = % .1e" % (pidx, arg1, qidx, arg2) + ' '*50)
468  if key is not None:
469  return func(mvals,**kwargs)[key]
470  else:
471  return func(mvals,**kwargs)
472  return func2
473 
474  def f2d5p(f, h):
475  fpp, fpm, fmp, fmm = [f(i*h,j*h) for i,j in [(1,1),(1,-1),(-1,1),(-1,-1)]]
476  fpp = (fpp-fpm-fmp+fmm)/(4*h*h)
477  return fpp
478 
479  def f2d4p(f, h, f0 = None):
480  if f0 is None:
481  fpp, fp0, f0p, f0 = [f(i*h,j*h) for i,j in [(1,1),(1,0),(0,1),(0,0)]]
482  else:
483  fpp, fp0, f0p = [f(i*h,j*h) for i,j in [(1,1),(1,0),(0,1)]]
484  fpp = (fpp-fp0-f0p+f0)/(h*h)
485  return fpp
486 
487  for d in self.objfiles:
488  logger.info("\rNow working on" + str(d) + 50*' ' + '\r')
489  if wq is None:
490  x = self.driver(mvals, d)
491  grad = np.zeros(n)
492  hdiag = np.zeros(n)
493  hess = np.zeros((n,n))
494  apath = os.path.join(self.tdir, d, "current")
495  x = float(open(os.path.join(apath,'objective.out')).readlines()[0].split()[1])*self.factor
496  for p in range(self.FF.np):
497  if self.callderivs[d][p]:
498  def reader(mvals_,h):
499  apath = os.path.join(self.tdir, d, str(p), str(h))
500  answer = float(open(os.path.join(apath,'objective.out')).readlines()[0].split()[1])*self.factor
501  return answer
502  if AHess:
503  if wq is not None:
504  apath = os.path.join(self.tdir, d, "current")
505  x = float(open(os.path.join(apath,'objective.out')).readlines()[0].split()[1])*self.factor
506  grad[p], hdiag[p] = f12d3p(fdwrap(reader, mvals, p, h=self.h), h = self.h, f0 = x)
507  else:
508  grad[p], hdiag[p] = f12d3p(fdwrap(self.driver, mvals, p, d=d), h = self.h, f0 = x)
509  hess[p,p] = hdiag[p]
510  elif AGrad:
511  if self.bidirect:
512  if wq is not None:
513  apath = os.path.join(self.tdir, d, "current")
514  x = float(open(os.path.join(apath,'objective.out')).readlines()[0].split()[1])*self.factor
515  grad[p], _ = f12d3p(fdwrap(reader, mvals, p, h=self.h), h = self.h, f0 = x)
516  else:
517  grad[p], _ = f12d3p(fdwrap(self.driver, mvals, p, d=d), h = self.h, f0 = x)
518  else:
519  if wq is not None:
520  # Since the calculations are submitted as 3-point finite difference, this part of the code
521  # actually only reads from half of the completed calculations.
522  grad[p] = f1d2p(fdwrap(reader, mvals, p, h=self.h), h = self.h, f0 = x)
523  else:
524  grad[p] = f1d2p(fdwrap(self.driver, mvals, p, d=d), h = self.h, f0 = x)
525 
526  self.objd[d] = x
527  self.gradd[d] = grad
528  self.hdiagd[d] = hdiag
529  X += x
530  G += grad
531  #H += np.diag(hdiag)
532  H += hess
533  if not in_fd():
534  self.objective = X
535  self.objvals = self.objd
536  # print self.objd
537  # print self.gradd
538  # print self.hdiagd
539 
540  if float('Inf') in pvals:
541  return {'X' : 1e10, 'G' : G, 'H' : H}
542  return {'X' : X, 'G' : G, 'H' : H}
543 
def build_pid(self, pfld)
Definition: psi4io.py:52
def driver(self, mvals, d)
Definition: psi4io.py:419
def get(self, mvals, AGrad=False, AHess=False)
LPW 04-17-2013.
Definition: psi4io.py:456
def feed(self, line, linindep=False)
Feed in a line.
Definition: psi4io.py:277
def indicate(self)
Definition: psi4io.py:159
Nifty functions, intended to be imported by any module within ForceBalance.
def feed(self, line, linindep=False)
Feed in a line.
Definition: psi4io.py:65
Finite state machine for parsing DVR grid files.
Definition: psi4io.py:254
GBSfnm
Psi4 basis set file.
Definition: psi4io.py:137
MP2_Energy
Actually run PSI4.
Definition: psi4io.py:243
DATfnm
Psi4 input file for calculation of linear dependencies This is actually a file in 'forcefield' until ...
Definition: psi4io.py:144
def isint(word)
ONLY matches integers! If you have a decimal point? None shall pass!
Definition: molecule.py:401
Interaction type -> Parameter Dictionary.
Definition: psi4io.py:39
Subclass of Target for R-DVR3 grid fitting.
Definition: psi4io.py:303
def in_fd()
Invoking this function from anywhere will tell us whether we're being called by a finite-difference f...
def fdwrap(func, mvals0, pidx, key=None, kwargs)
A function wrapper for finite difference designed for differentiating 'get'-type functions.
def CheckBasis()
Definition: leastsq.py:25
def driver(self)
Definition: psi4io.py:179
def queue_up_src_dest(wq, command, input_files, output_files, tag=None, tgt=None, verbose=True, print_time=60)
Submit a job to the Work Queue.
Definition: nifty.py:974
objfiles
Which parameters are differentiated?
Definition: psi4io.py:312
def submit_jobs(self, mvals, AGrad=True, AHess=True)
Create a grid file and a psi4 input file in the absolute path and submit it to the work queue...
Definition: psi4io.py:355
def warn_press_key(warning, timeout=10)
Definition: nifty.py:1599
def printcool_dictionary(Dict, title="Dictionary Keys : Values", bold=False, color=2, keywidth=25, topwidth=50, center=True, leftpad=0)
See documentation for printcool; this is a nice way to print out keys/values in a dictionary...
Definition: nifty.py:366
def write_nested_destroy(self, fnm, linedestroy)
Definition: psi4io.py:164
def prepare_temp_directory(self, options, tgt_opts)
Definition: psi4io.py:148
def __init__(self, fnm=None)
Definition: psi4io.py:256
def __init__(self, options, tgt_opts, forcefield)
Definition: psi4io.py:103
def f12d3p(f, h, f0=None)
A three-point finite difference stencil.
def build_pid(self, pfld)
Definition: psi4io.py:262
def indicate(self)
Definition: psi4io.py:346
def isfloat(word)
Matches ANY number; it can be a decimal, scientific notation, integer, or what have you...
Definition: molecule.py:406
def wopen(dest, binary=False)
If trying to write to a symbolic link, remove it first.
Definition: nifty.py:1304
def getWorkQueue()
Definition: nifty.py:904
def __init__(self, fnm=None)
Definition: psi4io.py:41
def f1d2p(f, h, f0=None)
A two-point finite difference stencil.