The tutorial https://github.com/fishstamp82/moltools/blob/docs/share/tutorial/two_water_example.ipynb
demonstrates the step-by-step process in how the Applequist equations are solved from quantum mechanical properties,
all the information is given explicitly to remove doubts in how the procedure looks.
This tutorial will perform all the above steps in a more compact, and faster way, using the moltools package.
In this tutorial, we will be running Dalton from inside python. For this we will utilize the full path to the Dalton runscript. The location will be '/home/user/repos/dalton/build_gnu/dalton', but is of course custom to every user.
Dalton can be obtained here
Clone the entire repository, which will come with loprop and pd automatically:
$> git clone --recursive https://github.com/fishstamp82/moltools.git
(Optional, but highly recommended) If you want optimized parallel excecution, make sure you have Cython and build the cython extensions of vahtras/pd by running the following script:
$> moltools/scripts/build_cython.sh
See the requirements.txt file for packages needed
Make sure that the path to moltools is in your PYTHONPATH env variable, and run an ipython console
$> ipython
In [1]:
DALTON = '/home/user/repos/dalton/build_gnu/dalton'
In [2]:
from moltools import Water, Molecule, Cluster
The get_standard method creates a Water instance, with the geometry of a TIP3P water model. It's oxygen is placed in origo, the molecule in the xz-plane, with it' electronic dipole pointing in the positive z-axis
In [3]:
w = Water.get_standard()
Take a look at it
In [4]:
w.plot()
the molecular property of this water molecule is accesible via Water.Property or Water.p
In [5]:
print w.p
All properties are zero. Let's obtain properties via QM using Dalton.
In [6]:
w.props_from_qm( method = 'hfqua', #hf is Hartree-Fock, qua is Quadratic response (LoProp Beta)
dalpath = DALTON,
tmpdir = '/tmp',
)
Now the properties are non-zero
In [7]:
print "Charge of the water molecule:" , w.p.q
print "Charge of oxygen:" , w.o.p.q
print "Dipole moment of the water molecule:" , w.p.d
print "Dipole moment of oxygen:" , w.o.p.d
In [8]:
water2 = Water.get_standard().t(0, 0, 5)
water2.props_from_qm( method = 'hfqua',
dalpath = DALTON,
tmpdir = '/tmp',
)
Using Cluster, we group the molecules to produce a list of Applequist point dipoles.
In [9]:
c = Cluster( w, water2 )
c.populate_bonds()
In [10]:
#Uncomment to visualize it, you can imagine how it would look like
#c.plot()
In [11]:
#get_pdlist generates the input format file for PointDipoleList automatically based on the molecules
#in the cluster and their unit of coordinate
pdlist = c.get_pdlist()
print "Beta zzz no Applequist:", c.p.b[9]
print "Beta zzz after Applequist:", pdlist.beta( cython = 1, num_threads = 4 )[2,2,2]
In [12]:
#By default reading in coordinates in angstrom
o2 = Molecule.from_xyz_string( """2\n\nO 0 0 0\nO 0 0 1.3""")
In [13]:
o2.to_AU()
o2.plot()
In [14]:
o2.props_from_qm( method = 'hfqua',
dalpath = DALTON,
tmpdir = '/tmp',
)
In [15]:
print o2.p.a
print np.allclose( np.zeros(10), o2.p.b, atol = 1e-4 )
In [ ]:
In [ ]: