Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import warnings
3from ase.io import read, write
4from ase.io.gamess_us import clean_userscr, get_userscr
5from ase.calculators.calculator import FileIOCalculator
8class GAMESSUS(FileIOCalculator):
9 implemented_properties = ['energy', 'forces', 'dipole']
10 command = 'rungms PREFIX.inp > PREFIX.log 2> PREFIX.err'
11 discard_results_on_any_change = True
13 def __init__(self, restart=None,
14 ignore_bad_restart_file=FileIOCalculator._deprecated,
15 label='gamess_us', atoms=None, command=None, userscr=None,
16 **kwargs):
17 """
18 GAMESS-US keywords are specified using dictionaries of keywords.
19 For example, to run a CCSD(T)/cc-pVDZ calculation, you might use the
20 following arguments:
22 >>> calc = GAMESSUS(contrl={'scftyp': 'rhf', 'cctyp': 'ccsd(t)',
23 >>> 'ispher': 1, 'runtyp': 'energy'},
24 >>> basis={'gbasis': 'CCD'})
26 This will create an input file that looks like the following:
28 >>> $CONTRL
29 >>> SCFTYP=RHF
30 >>> CCTYP=CCSD(T)
31 >>> ISPHER=1
32 >>> RUNTYP=ENERGY
33 >>> $END
34 >>>
35 >>> $BASIS
36 >>> GBASIS=CCSD
37 >>> $END
39 See the INPUT.DOC file provided by GAMESS-US for more information.
41 If `runtyp` is not specified, it will be set automatically.
43 If no basis is specified, 3-21G will be used by default.
44 A dictionary containing literal per-index or per-element basis sets
45 can be passed to the `basis` keyword. This will result in the basis
46 set being printed in the $DATA block, alongside the geometry
47 specification.
48 Otherwise, `basis` is assumed to contain keywords for the $BASIS
49 block, such as GBASIS and NGAUSS.
51 If a multiplicity is not set in contrl['mult'], the multiplicity
52 will be guessed based on the Atoms object's initial magnetic moments.
54 The GAMESSUS calculator has some special keyword:
56 xc: str
57 The exchange-correlation functional to use for DFT calculations.
58 In most circumstances, setting xc is equivalent to setting
59 contrl['dfttyp']. xc will be ignored if a value has also
60 been provided to contrl['dfttyp'].
62 userscr: str
63 The location of the USERSCR directory specified in your
64 `rungms` script. If not provided, an attempt will be made
65 to automatically determine the location of this directory.
66 If this fails, you will need to manually specify the path
67 to this directory to the calculator using this keyword.
69 ecp: dict
70 A per-index or per-element dictionary of ECP specifications.
71 """
72 FileIOCalculator.__init__(self, restart, ignore_bad_restart_file,
73 label, atoms, command, **kwargs)
74 self.userscr = userscr
76 def calculate(self, *args, **kwargs):
77 if self.userscr is None:
78 if 'rungms' in self.command:
79 self.userscr = get_userscr(self.prefix, self.command)
81 if self.userscr is None:
82 warnings.warn("Could not determine USERSCR! "
83 "GAMESS may refuse to run more than once for "
84 "this job. Please pass userscr to the GAMESSUS "
85 "Calculator if you run into problems!")
86 else:
87 clean_userscr(self.userscr, self.prefix)
89 FileIOCalculator.calculate(self, *args, **kwargs)
91 def write_input(self, atoms, properties=None, system_changes=None):
92 FileIOCalculator.write_input(self, atoms, properties, system_changes)
93 write(self.label + '.inp', atoms, properties=properties,
94 format='gamess-us-in', **self.parameters)
96 def read_results(self):
97 output = read(self.label + '.log')
98 self.calc = output.calc
99 self.results = output.calc.results