Coverage for /builds/ase/ase/ase/calculators/gamess_us.py: 66.67%
30 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
1# fmt: off
3import warnings
5from ase.calculators.calculator import FileIOCalculator
6from ase.io import read, write
7from ase.io.gamess_us import clean_userscr, get_userscr
10class GAMESSUS(FileIOCalculator):
11 implemented_properties = ['energy', 'forces', 'dipole']
12 _legacy_default_command = 'rungms PREFIX.inp > PREFIX.log 2> PREFIX.err'
13 discard_results_on_any_change = True
15 def __init__(self, restart=None,
16 ignore_bad_restart_file=FileIOCalculator._deprecated,
17 label='gamess_us', atoms=None, command=None, userscr=None,
18 **kwargs):
19 """
20 GAMESS-US keywords are specified using dictionaries of keywords.
21 For example, to run a CCSD(T)/cc-pVDZ calculation, you might use the
22 following arguments:
24 >>> calc = GAMESSUS(contrl={'scftyp': 'rhf', 'cctyp': 'ccsd(t)',
25 >>> 'ispher': 1, 'runtyp': 'energy'},
26 >>> basis={'gbasis': 'CCD'})
28 This will create an input file that looks like the following:
30 >>> $CONTRL
31 >>> SCFTYP=RHF
32 >>> CCTYP=CCSD(T)
33 >>> ISPHER=1
34 >>> RUNTYP=ENERGY
35 >>> $END
36 >>>
37 >>> $BASIS
38 >>> GBASIS=CCSD
39 >>> $END
41 See the INPUT.DOC file provided by GAMESS-US for more information.
43 If `runtyp` is not specified, it will be set automatically.
45 If no basis is specified, 3-21G will be used by default.
46 A dictionary containing literal per-index or per-element basis sets
47 can be passed to the `basis` keyword. This will result in the basis
48 set being printed in the $DATA block, alongside the geometry
49 specification.
50 Otherwise, `basis` is assumed to contain keywords for the $BASIS
51 block, such as GBASIS and NGAUSS.
53 If a multiplicity is not set in contrl['mult'], the multiplicity
54 will be guessed based on the Atoms object's initial magnetic moments.
56 The GAMESSUS calculator has some special keyword:
58 xc: str
59 The exchange-correlation functional to use for DFT calculations.
60 In most circumstances, setting xc is equivalent to setting
61 contrl['dfttyp']. xc will be ignored if a value has also
62 been provided to contrl['dfttyp'].
64 userscr: str
65 The location of the USERSCR directory specified in your
66 `rungms` script. If not provided, an attempt will be made
67 to automatically determine the location of this directory.
68 If this fails, you will need to manually specify the path
69 to this directory to the calculator using this keyword.
71 ecp: dict
72 A per-index or per-element dictionary of ECP specifications.
73 """
75 # Backward compatibility fix:
76 if command is None and 'ASE_GAMESSUS_COMMAND' in self.cfg:
77 command = self.cfg['ASE_GAMESSUS_COMMAND']
79 FileIOCalculator.__init__(self, restart, ignore_bad_restart_file,
80 label, atoms, command, **kwargs)
81 self.userscr = userscr
83 def _get_name(self):
84 return 'gamess_us'
86 def calculate(self, *args, **kwargs):
87 if self.userscr is None:
88 if 'rungms' in self.command:
89 self.userscr = get_userscr(self.prefix, self.command)
91 if self.userscr is None:
92 warnings.warn("Could not determine USERSCR! "
93 "GAMESS may refuse to run more than once for "
94 "this job. Please pass userscr to the GAMESSUS "
95 "Calculator if you run into problems!")
96 else:
97 clean_userscr(self.userscr, self.prefix)
99 FileIOCalculator.calculate(self, *args, **kwargs)
101 def write_input(self, atoms, properties=None, system_changes=None):
102 FileIOCalculator.write_input(self, atoms, properties, system_changes)
103 write(self.label + '.inp', atoms, properties=properties,
104 format='gamess-us-in', **self.parameters)
106 def read_results(self):
107 output = read(self.label + '.log')
108 self.calc = output.calc
109 self.results = output.calc.results