Skip to content

Commit c7ff356

Browse files
committed
Correcting issue #52
1 parent ecae5f0 commit c7ff356

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed
286 KB
Loading

docs/user_interface.rst

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ the Hartree-Fock coefficient optimization procedure in detail.
597597

598598
.. code-block:: python
599599
600-
from pyqint import PyQInt, Molecule, HF
600+
from pyqint import PyQInt, MoleculeBuilder, HF
601601
import numpy as np
602602
import matplotlib.pyplot as plt
603603
from mpl_toolkits.axes_grid1 import make_axes_locatable
@@ -607,46 +607,52 @@ the Hartree-Fock coefficient optimization procedure in detail.
607607
cgfs, coeff = calculate_co()
608608
609609
# visualize orbitals
610-
fig, ax = plt.subplots(2,3, figsize=(18,10))
610+
fig, ax = plt.subplots(2,5, figsize=(12, 5), dpi=144)
611+
sz = 3
611612
for i in range(0,2):
612-
for j in range(0,3):
613-
dens = plot_wavefunction(cgfs, coeff[:,i*3+j])
613+
for j in range(0,5):
614+
dens = plot_wavefunction(cgfs, coeff[:,i*5+j], sz=sz)
614615
limit = max(abs(np.min(dens)), abs(np.max(dens)) )
615-
im = ax[i,j].imshow(dens, origin='lower', interpolation='bilinear',
616-
extent=[-2,2,-2,2], cmap='PiYG', vmin=-limit, vmax=limit)
617-
ax[i,j].set_xlabel('Distance a.u.')
618-
ax[i,j].set_ylabel('Distance a.u.')
619-
divider = make_axes_locatable(ax[i,j])
620-
cax = divider.append_axes('right', size='5%', pad=0.05)
621-
fig.colorbar(im, cax=cax, orientation='vertical')
616+
im = ax[i,j].contourf(dens, origin='lower',
617+
extent=[-sz, sz, -sz, sz], cmap='PiYG', vmin=-limit, vmax=limit,
618+
levels=11)
619+
im = ax[i,j].contour(dens, origin='lower', colors='black',
620+
extent=[-sz, sz, -sz, sz], vmin=-limit, vmax=limit,
621+
levels=11)
622+
ax[i,j].set_xlabel('x [Bohr]')
623+
ax[i,j].set_ylabel('z [Bohr]')
624+
ax[i,j].set_aspect('equal', adjustable='box')
625+
ax[i,j].set_xticks(np.linspace(-3,3, 7))
626+
ax[i,j].set_yticks(np.linspace(-3,3, 7))
627+
ax[i,j].grid(linestyle='--', alpha=0.5)
628+
plt.tight_layout()
629+
plt.show()
622630
623631
def calculate_co():
624-
mol = Molecule()
625-
mol.add_atom('C', 0.0, -0.5, 0.0)
626-
mol.add_atom('O', 0.0, 0.5, 0.0)
632+
mol = MoleculeBuilder().from_name('CO')
627633
628634
result = HF().rhf(mol, 'sto3g')
629635
630636
return result['cgfs'], result['orbc']
631637
632-
def plot_wavefunction(cgfs, coeff):
638+
def plot_wavefunction(cgfs, coeff, sz=3.5):
633639
# build integrator
634640
integrator = PyQInt()
635641
636642
# build grid
637-
x = np.linspace(-2, 2, 100)
638-
y = np.linspace(-2, 2, 100)
639-
xx, yy = np.meshgrid(x,y)
640-
zz = np.zeros(len(x) * len(y))
641-
grid = np.vstack([xx.flatten(), yy.flatten(), zz]).reshape(3,-1).T
642-
res = integrator.plot_wavefunction(grid, coeff, cgfs).reshape((len(y), len(x)))
643+
x = np.linspace(-sz, sz, 150)
644+
z = np.linspace(-sz, sz, 150)
645+
xx, zz = np.meshgrid(x,z)
646+
yy = np.zeros(len(x) * len(z))
647+
grid = np.vstack([xx.flatten(), yy, zz.flatten()]).reshape(3,-1).T
648+
res = integrator.plot_wavefunction(grid, coeff, cgfs).reshape((len(z), len(x)))
643649
644650
return res
645651
646652
if __name__ == '__main__':
647653
main()
648654
649-
.. figure:: _static/img/co.jpg
655+
.. figure:: _static/img/co_orbs_contour.png
650656

651657
Canonical molecular orbitals of CO visualized using contour plots.
652658

@@ -762,6 +768,7 @@ In the example code shown below, the latter is done.
762768

763769
.. code-block:: python
764770
771+
from pyqint import Molecule, HF, cgf
765772
mol = Molecule()
766773
mol.add_atom('H', 0.0000, 0.0000, 0.3561150187, unit='angstrom')
767774
mol.add_atom('H', 0.0000, 0.0000, -0.3561150187, unit='angstrom')
@@ -777,7 +784,7 @@ In the example code shown below, the latter is done.
777784
778785
cgfs.append(_cgf)
779786
780-
res = HF().rhf(mol, basis=cgfs)
787+
res = HF().rhf(mol, basis=cgfs, verbose=True)
781788
782789
.. hint::
783790

0 commit comments

Comments
 (0)