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.
[3]:
from chemtools.calculators.molpro import Molpro
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
.
[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.
[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
[10]:
output = molpro.run('h2o.inp')
[11]:
output
[11]:
'h2o.out'
To check if the calculation finished without errors you can use accomplished
method
[13]:
molpro.accomplished(output)
[13]:
True
[15]:
molpro.parse(output, 'hf total energy')
[15]:
-76.058288041466
[16]:
molpro.parse(output, 'mp2 total energy')
[18]:
molpro.parse(output, 'ccsd(t) total energy')
[18]:
-76.341780640047
[17]:
molpro.parse(output, 'regexp', regularexp=r'NUCLEAR REPULSION ENERGY\s*(-?\d+\.\d+)')
[17]:
8.99162654
[21]:
%version_information chemtools
[21]:
Software | Version |
---|---|
Python | 3.6.3 64bit [GCC 7.2.0] |
IPython | 6.2.1 |
OS | Linux 4.9.0 4 amd64 x86_64 with debian 9.1 |
chemtools | 0.8.4 |
Mon Nov 27 16:49:17 2017 CET |