File: gamess_us.py

package info (click to toggle)
python-ase 3.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 15,448 kB
  • sloc: python: 144,945; xml: 2,728; makefile: 113; javascript: 47
file content (107 lines) | stat: -rw-r--r-- 4,278 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import warnings

from ase.calculators.calculator import FileIOCalculator
from ase.io import read, write
from ase.io.gamess_us import clean_userscr, get_userscr


class GAMESSUS(FileIOCalculator):
    implemented_properties = ['energy', 'forces', 'dipole']
    _legacy_default_command = 'rungms PREFIX.inp > PREFIX.log 2> PREFIX.err'
    discard_results_on_any_change = True

    def __init__(self, restart=None,
                 ignore_bad_restart_file=FileIOCalculator._deprecated,
                 label='gamess_us', atoms=None, command=None, userscr=None,
                 **kwargs):
        """
        GAMESS-US keywords are specified using dictionaries of keywords.
        For example, to run a CCSD(T)/cc-pVDZ calculation, you might use the
        following arguments:

            >>> calc = GAMESSUS(contrl={'scftyp': 'rhf', 'cctyp': 'ccsd(t)',
            >>>                         'ispher': 1, 'runtyp': 'energy'},
            >>>                 basis={'gbasis': 'CCD'})

        This will create an input file that looks like the following:

            >>>  $CONTRL
            >>>   SCFTYP=RHF
            >>>   CCTYP=CCSD(T)
            >>>   ISPHER=1
            >>>   RUNTYP=ENERGY
            >>>  $END
            >>>
            >>>  $BASIS
            >>>   GBASIS=CCSD
            >>>  $END

        See the INPUT.DOC file provided by GAMESS-US for more information.

        If `runtyp` is not specified, it will be set automatically.

        If no basis is specified, 3-21G will be used by default.
        A dictionary containing literal per-index or per-element basis sets
        can be passed to the `basis` keyword. This will result in the basis
        set being printed in the $DATA block, alongside the geometry
        specification.
        Otherwise, `basis` is assumed to contain keywords for the $BASIS
        block, such as GBASIS and NGAUSS.

        If a multiplicity is not set in contrl['mult'], the multiplicity
        will be guessed based on the Atoms object's initial magnetic moments.

        The GAMESSUS calculator has some special keyword:

        xc: str
            The exchange-correlation functional to use for DFT calculations.
            In most circumstances, setting xc is equivalent to setting
            contrl['dfttyp']. xc will be ignored if a value has also
            been provided to contrl['dfttyp'].

        userscr: str
            The location of the USERSCR directory specified in your
            `rungms` script. If not provided, an attempt will be made
            to automatically determine the location of this directory.
            If this fails, you will need to manually specify the path
            to this directory to the calculator using this keyword.

        ecp: dict
            A per-index or per-element dictionary of ECP specifications.
        """

        # Backward compatibility fix:
        if command is None and 'ASE_GAMESSUS_COMMAND' in self.cfg:
            command = self.cfg['ASE_GAMESSUS_COMMAND']

        FileIOCalculator.__init__(self, restart, ignore_bad_restart_file,
                                  label, atoms, command, **kwargs)
        self.userscr = userscr

    def _get_name(self):
        return 'gamess_us'

    def calculate(self, *args, **kwargs):
        if self.userscr is None:
            if 'rungms' in self.command:
                self.userscr = get_userscr(self.prefix, self.command)

        if self.userscr is None:
            warnings.warn("Could not determine USERSCR! "
                          "GAMESS may refuse to run more than once for "
                          "this job. Please pass userscr to the GAMESSUS "
                          "Calculator if you run into problems!")
        else:
            clean_userscr(self.userscr, self.prefix)

        FileIOCalculator.calculate(self, *args, **kwargs)

    def write_input(self, atoms, properties=None, system_changes=None):
        FileIOCalculator.write_input(self, atoms, properties, system_changes)
        write(self.label + '.inp', atoms, properties=properties,
              format='gamess-us-in', **self.parameters)

    def read_results(self):
        output = read(self.label + '.log')
        self.calc = output.calc
        self.results = output.calc.results