Molpro tutorial

The molpro module contains the Molpro convenience class, which is python wrapper for running the Molpro program with methods for writing input files, running the calculations and parsing the output files.

In [3]:
from chemtools.calculators.molpro import Molpro

Molpro wrapper

Molpro object can be created by either providing the path to the molpro executable with executable keyword argument or name of the environmental variable holding the path through exevar.

In [5]:
molpro = Molpro(exevar="MOLPRO_EXE",
                runopts=["-s", "-n", "1"],
                scratch="/home/lmentel/scratch")

Now we can write some sample molpro input and run in from python using the Molpro object created earlier.

In [6]:
inpstr = '''***,H2O finite field calculations
r=1.85,theta=104                !set geometry parameters
geometry={O;                    !z-matrix input
H1,O,r;
H2,O,r,H1,theta}

basis=avtz                      !define default basis

hf
ccsd(t)
'''

with open('h2o.inp', 'w') as finp:
    finp.write(inpstr)

run method runs the job and returns the ouput file name

In [10]:
output = molpro.run('h2o.inp')
In [11]:
output
Out[11]:
'h2o.out'

Parsing the results

To check if the calculation finished without errors you can use accomplished method

In [13]:
molpro.accomplished(output)
Out[13]:
True
In [15]:
molpro.parse(output, 'hf total energy')
Out[15]:
-76.058288041466
In [16]:
molpro.parse(output, 'mp2 total energy')
In [18]:
molpro.parse(output, 'ccsd(t) total energy')
Out[18]:
-76.341780640047
In [17]:
molpro.parse(output, 'regexp', regularexp=r'NUCLEAR REPULSION ENERGY\s*(-?\d+\.\d+)')
Out[17]:
8.99162654
In [21]:
%version_information chemtools
Out[21]:
SoftwareVersion
Python3.6.3 64bit [GCC 7.2.0]
IPython6.2.1
OSLinux 4.9.0 4 amd64 x86_64 with debian 9.1
chemtools0.8.4
Mon Nov 27 16:49:17 2017 CET