This file is indexed.

/usr/share/psi/python/qcdb/psi4.py is in psi4-data 1:0.3-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#
#@BEGIN LICENSE
#
# PSI4: an ab initio quantum chemistry software package
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#@END LICENSE
#

import re
import math
from collections import defaultdict

from exceptions import *
import qcformat
#import molpro_basissets
import options
from pdict import PreservingDict


def harvest_output(outtext):
    """Function to separate portions of a PSI4 output file *outtext*.

    """
    psivar = PreservingDict()
    psivar_coord = None
    psivar_grad = None

    NUMBER = "((?:[-+]?\\d*\\.\\d+(?:[DdEe][-+]?\\d+)?)|(?:[-+]?\\d+\\.\\d*(?:[DdEe][-+]?\\d+)?))"

    # Process PsiVariables
    mobj = re.search(r'^(?:  Variable Map:)\s*' +
        r'^\s*(?:-+)\s*' +
        r'^(.*?)' +
        r'^(?:\s*?)$',
        outtext, re.MULTILINE | re.DOTALL)

    if mobj:
        for pv in mobj.group(1).split('\n'):
            submobj = re.search(r'^\s+' + r'"(.+?)"' + r'\s+=>\s+' + NUMBER + r'\s*$', pv)
            if submobj:
                psivar['%s' % (submobj.group(1))] = submobj.group(2)

    # Process Completion
    mobj = re.search(r'PSI4 exiting successfully. Buy a developer a beer!',
        outtext, re.MULTILINE)
    if mobj:
        psivar['SUCCESS'] = True

    return psivar, psivar_coord, psivar_grad


class Infile(qcformat.InputFormat2):

    def __init__(self, mem, mol, mtd, der, opt):
        qcformat.InputFormat2.__init__(self, mem, mol, mtd, der, opt)

        print self.method, self.molecule.nactive_fragments()
        if 'sapt' in self.method and self.molecule.nactive_fragments() != 2:
            raise FragmentCountError("""Requested molecule has %d, not 2, fragments.""" % (self.molecule.nactive_fragments()))

#        # memory in MB --> MW
#        self.memory = int(math.ceil(mem / 8.0))
#        # auxiliary basis sets
#        [self.unaugbasis, self.augbasis, self.auxbasis] = self.corresponding_aux_basis()

    def format_infile_string(self):
        """

        """
        # Handle memory and comment
        memcmd, memkw = """# %s\n\nmemory %d mb\n\n""" % (self.molecule.tagline, self.memory), {}

        # Handle molecule and basis set
        molcmd, molkw = self.molecule.format_molecule_for_psi4(), {}

        # format global convergence directions
#        text += self.format_global_parameters()
        _cdscmd, cdskw = muster_cdsgroup_options()

        # Handle calc type and quantum chemical method
        mdccmd, mdckw = procedures['energy'][self.method](self.method, self.dertype)

#        # format options
#        optcmd = qcdb.options.prepare_options_for_psi4(mdckw)

# make options from imdb only user options (currently non-existent). set basis and castup from here.
        # Handle driver vs input/default keyword reconciliation
        userkw = self.options
#        userkw = p4util.prepare_options_for_modules()
        #userkw = qcdb.options.reconcile_options(userkw, memkw)
        #userkw = qcdb.options.reconcile_options(userkw, molkw)
        #userkw = qcdb.options.reconcile_options(userkw, baskw)
        #userkw = qcdb.options.reconcile_options(userkw, psikw)
        userkw = options.reconcile_options2(userkw, cdskw)
        userkw = options.reconcile_options2(userkw, mdckw)

        # Handle conversion of psi4 keyword structure into cfour format
        optcmd = options.prepare_options_for_psi4(userkw)

        # Handle text to be passed untouched to psi4
        litcmd = """\nprint_variables()\n\n"""

        # Assemble infile pieces
        return memcmd + molcmd + optcmd + mdccmd + litcmd

#'hf'
#'df-hf'
#'b3lyp'
#'blyp'
#'bp86'
#'fno-ccsd(t)'
#'df-ccsd(t)'
#'fno-df-ccsd(t)'
#'df-b97-d'
#'df-b97-d3'
#'pbe0-2'
#'dsd-pbep86'
#'wb97x-2'
#'DLdf+d'
#'DLdf+d09'
#'df-b3lyp'
#'df-b3lyp-d'
#'df-b3lyp-d3'
#'df-wb97x-d'


def muster_cdsgroup_options():
    text = ''
    options = defaultdict(lambda: defaultdict(dict))
    options['GLOBALS']['E_CONVERGENCE']['value'] = 8
    options['SCF']['GUESS']['value'] = 'sad'
    options['SCF']['MAXITER']['value'] = 200

    return text, options


def muster_modelchem(name, dertype):
    """Transform calculation method *name* and derivative level *dertype*
    into options for cfour. While deliberately requested pieces,
    generally |cfour__cfour_deriv_level| and |cfour__cfour_calc_level|,
    are set to complain if contradicted ('clobber' set to True), other
    'recommended' settings, like |cfour__cfour_cc_program|, can be
    countermanded by keywords in input file ('clobber' set to False).
    Occasionally, want these pieces to actually overcome keywords in
    input file ('superclobber' set to True).

    """
    text = ''
    lowername = name.lower()
    options = defaultdict(lambda: defaultdict(dict))

    if dertype == 0:
        text += """energy('"""
    else:
        raise ValidationError("""Requested Psi4 dertype %d is not available.""" % (dertype))

    if lowername == 'mp2':
        options['GLOBALS']['FREEZE_CORE']['value'] = True
        options['SCF']['SCF_TYPE']['value'] = 'direct'
        options['MP2']['MP2_TYPE']['value'] = 'conv'
        text += """mp2')\n\n"""

    elif lowername == 'df-mp2':
        options['GLOBALS']['FREEZE_CORE']['value'] = True
        options['SCF']['SCF_TYPE']['value'] = 'df'
        options['MP2']['MP2_TYPE']['value'] = 'df'
        text += """mp2')\n\n"""

    elif lowername == 'sapt0':
        options['GLOBALS']['FREEZE_CORE']['value'] = True
        options['SCF']['SCF_TYPE']['value'] = 'df'
        text += """sapt0')\n\n"""

    elif lowername == 'sapt2+':
        options['GLOBALS']['FREEZE_CORE']['value'] = True
        options['SCF']['SCF_TYPE']['value'] = 'df'
        options['SAPT']['NAT_ORBS_T2']['value'] = True
        options['SAPT']['NAT_ORBS_T3']['value'] = True
        options['SAPT']['NAT_ORBS_V4']['value'] = True
        options['SAPT']['OCC_TOLERANCE']['value'] = 1.0e-6
        text += """sapt2+')\n\n"""

    elif lowername == 'sapt2+(3)':
        options['GLOBALS']['FREEZE_CORE']['value'] = True
        options['SCF']['SCF_TYPE']['value'] = 'df'
        options['SAPT']['NAT_ORBS_T2']['value'] = True
        options['SAPT']['NAT_ORBS_T3']['value'] = True
        options['SAPT']['NAT_ORBS_V4']['value'] = True
        options['SAPT']['OCC_TOLERANCE']['value'] = 1.0e-6
        text += """sapt2+(3)')\n\n"""

    elif lowername == 'sapt2+3(ccd)':
        options['GLOBALS']['FREEZE_CORE']['value'] = True
        options['SCF']['SCF_TYPE']['value'] = 'df'
        options['SAPT']['NAT_ORBS_T2']['value'] = True
        options['SAPT']['NAT_ORBS_T3']['value'] = True
        options['SAPT']['NAT_ORBS_V4']['value'] = True
        options['SAPT']['OCC_TOLERANCE']['value'] = 1.0e-6
        options['SAPT']['DO_MBPT_DISP']['value'] = True
        text += """sapt2+3(ccd)')\n\n"""

    elif lowername == 'df-b97-d3':
        options['SCF']['SCF_TYPE']['value'] = 'df'
        options['SCF']['DFT_SPHERICAL_POINTS']['value'] = 302
        options['SCF']['DFT_RADIAL_POINTS']['value'] = 100
        text += """b97-d3')\n\n"""

    elif lowername == 'df-wb97x-d':
        options['SCF']['SCF_TYPE']['value'] = 'df'
        options['SCF']['DFT_SPHERICAL_POINTS']['value'] = 302
        options['SCF']['DFT_RADIAL_POINTS']['value'] = 100
        text += """wb97x-d')\n\n"""

    elif lowername == 'df-b3lyp-d3':
        options['SCF']['SCF_TYPE']['value'] = 'df'
        options['SCF']['DFT_SPHERICAL_POINTS']['value'] = 302
        options['SCF']['DFT_RADIAL_POINTS']['value'] = 100
        text += """b3lyp-d3')\n\n"""

    elif lowername == 'ccsd-polarizability':
        options['GLOBALS']['FREEZE_CORE']['value'] = True
        text = """property('ccsd', properties=['polarizability'])\n\n"""

    else:
        raise ValidationError("""Requested Cfour computational methods %d is not available.""" % (lowername))

#    # Set clobbering
#    if 'CFOUR_DERIV_LEVEL' in options['CFOUR']:
#        options['CFOUR']['CFOUR_DERIV_LEVEL']['clobber'] = True
#        options['CFOUR']['CFOUR_DERIV_LEVEL']['superclobber'] = True
#    if 'CFOUR_CALC_LEVEL' in options['CFOUR']:
#        options['CFOUR']['CFOUR_CALC_LEVEL']['clobber'] = True
#        options['CFOUR']['CFOUR_CALC_LEVEL']['superclobber'] = True
#    if 'CFOUR_CC_PROGRAM' in options['CFOUR']:
#        options['CFOUR']['CFOUR_CC_PROGRAM']['clobber'] = False

    return text, options

procedures = {
    'energy': {
        'df-b97-d3'     : muster_modelchem,
        'df-wb97x-d'    : muster_modelchem,
        'df-b3lyp-d3'   : muster_modelchem,
        'mp2'           : muster_modelchem,
        'df-mp2'        : muster_modelchem,
        'sapt0'         : muster_modelchem,
        'sapt2+'        : muster_modelchem,
        'sapt2+(3)'     : muster_modelchem,
        'sapt2+3(ccd)'  : muster_modelchem,
        'ccsd-polarizability'  : muster_modelchem,
    }
}

qcmtdIN = procedures['energy']


def psi4_list():
    """Return an array of Psi4 methods with energies.

    """
    return sorted(procedures['energy'].keys())