Exemple #1
0
def test_water_631ppgss():
    mol = Molecule(geometry=water, basis='6-31ppgss')
    mol.RHF()
    #p 6D int=acc2e=14 scf(conver=12) rhf/6-31++G** symmetry=none
    assert_allclose(mol.energy.real, -75.9924381487, atol=1e-12)
    ref_dipole = np.array([0.0, 2.4046, 0.0])
    assert_allclose(mol.mu, ref_dipole, atol=1e-4)
def test_mp2_spinorbital():
    helium_dimer = """
    0 1
    He   0.0 0.0 0.0
    He   0.0 0.0 0.75
    """
    
    # init molecule and build integrals
    mol = Molecule(geometry=helium_dimer,basis='cc-pvDZ')
    
    # do the SCF
    mol.RHF()
    
    # do MP2
    PostSCF(mol).MP2()
    emp2_spatial = mol.emp2.real
    PostSCF(mol).MP2(spin_orbital=True)
    emp2_spin = mol.emp2.real
   
    # consistency check 
    assert np.allclose(emp2_spatial,emp2_spin)
    
    # G16 reference SCF energy
    assert np.allclose(-5.29648041091,mol.energy.real)
    
    # G16 reference MP2 energy
    assert np.allclose(-5.3545864180140,emp2_spatial)
Exemple #3
0
def test_formaldehyde_sto3g():
    mol = Molecule(geometry=formaldehyde, basis='sto-3g')
    mol.RHF()
    #p 6D int=acc2e=14 scf(conver=12) rhf/6-31++G** symmetry=none
    assert_allclose(mol.energy.real, -112.351590112, atol=1e-12)
    ref_dipole = np.array([0.0, 0.0, -1.4821])
    assert_allclose(mol.mu, ref_dipole, atol=1e-4)
Exemple #4
0
def test_hydrogen_sto3g():
    mol = Molecule(geometry=hydrogen, basis='sto-3g')
    mol.RHF()
    assert_allclose(mol.energy.real, -1.11675930740, atol=1e-12)
    mol.forces()
    ref_forces = np.array([[0.000000000, -0.000000000, -0.027679601],
                           [-0.000000000, 0.000000000, 0.027679601]])
    assert_allclose(mol._forces, ref_forces, atol=1e-12)
def test_tdhf():

    water = """
    0 1
    O    0.000000      -0.075791844    0.000000
    H    0.866811829    0.601435779    0.000000
    H   -0.866811829    0.601435779    0.000000
    """

    # init molecule and build integrals
    mol = Molecule(geometry=water, basis='sto-3g')

    # do the SCF
    mol.RHF()

    # now do TDHF
    PostSCF(mol).TDHF()

    # G16 reference UTDHF excitation energies (full; no FC, 50-50, nosym)
    # note I have manually expanded triplets in G16 to the full degeneracy
    # because at this moment we don't handle spin conserved excitations
    '''
    # td(nstates=100,50-50,full) nosymm uhf/sto-3g int=acc2e=14
    
    test
    
    0 1
    O    0.000000      -0.075791844    0.000000
    H    0.866811829    0.601435779    0.000000
    H   -0.866811829    0.601435779    0.000000

    '''

    gau_ref = [7.7597,7.7597,7.7597,8.1564,8.1564,8.1564,9.5955,9.5955,9.5955,\
               9.6540]

    assert np.allclose(np.asarray(gau_ref), mol.tdhf_omega[:10])

    ref_omega = mol.tdhf_omega

    # check consistency in solution algorithms for TDHF
    PostSCF(mol).TDHF(alg='reduced')
    assert np.allclose(mol.tdhf_omega, ref_omega)
    PostSCF(mol).TDHF(alg='full')
    assert np.allclose(mol.tdhf_omega, ref_omega)
Exemple #6
0
 def test_Mag4_trivial(self):
     mol = Molecule(geometry=hydrogen, basis='sto-3g')
     rt = RealTime(mol,
                   numsteps=100,
                   stepsize=0.2,
                   field=0.0001,
                   pulse=None)
     initial_energy = rt.mol.energy.real
     rt.Magnus4(direction='z')
     np.testing.assert_allclose(initial_energy * np.ones_like(rt.Energy),
                                rt.Energy)
Exemple #7
0
def test_fci():

    water = """
    0 1
    O    0.000000      -0.075791844    0.000000
    H    0.866811829    0.601435779    0.000000
    H   -0.866811829    0.601435779    0.000000
    """

    # init molecule and build integrals
    mol = Molecule(geometry=water, basis='sto-3g')

    # do the SCF
    mol.RHF()

    # now do FCI
    PostSCF(mol).FCI()

    # Psi4 reference SCF energy
    assert np.allclose(-74.9420798986, mol.energy.real)

    # Psi4 reference FCI energy
    assert np.allclose(-75.0129801827, mol.efci.real)
def test_cisd():

    water = """
    0 1
    O    0.000000      -0.075791844    0.000000
    H    0.866811829    0.601435779    0.000000
    H   -0.866811829    0.601435779    0.000000
    """

    # init molecule and build integrals
    mol = Molecule(geometry=water, basis='sto-3g')

    # do the SCF
    mol.RHF()

    # now do FCI
    PostSCF(mol).CISD()

    # G16 reference SCF energy
    assert np.allclose(-74.9420799245, mol.energy.real)

    # G16 reference CISD energy
    assert np.allclose(-75.011223006, mol.ecisd.real)
def test_cis():

    water = """
    0 1
    O    0.000000      -0.075791844    0.000000
    H    0.866811829    0.601435779    0.000000
    H   -0.866811829    0.601435779    0.000000
    """

    # init molecule and build integrals
    mol = Molecule(geometry=water, basis='3-21G')

    # do the SCF
    mol.RHF()

    # now do FCI
    PostSCF(mol).CIS()

    # G16 reference UCIS excitation energies (full; no FC, 50-50, nosym)
    # note I have manually expanded triplets in G16 to the full degeneracy
    # because at this moment we don't handle spin conserved excitations
    '''
    #p cis(nstate=40,full) uhf/3-21G int=acc2e=14 nosymm

    water
    
    0 1
    O    0.000000      -0.075791844    0.000000
    H    0.866811829    0.601435779    0.000000
    H   -0.866811829    0.601435779    0.000000

    '''

    gau_ref = [6.5822,6.5822,6.5822,7.7597,7.8156,7.8156,7.8156,8.4377,8.4377, \
               8.4377, 9.0903,9.0903,9.0903,9.3334,10.5493]

    assert np.allclose(np.asarray(gau_ref), mol.cis_omega[:15])
Exemple #10
0
def test_methane_sto3g():
    mol = Molecule(geometry=methane, basis='sto-3g')
    mol.RHF(direct=True)
    assert_allclose(mol.energy.real, -39.726850324347, atol=1e-12)
Exemple #11
0
# Simple example of Born-Oppenheimer Molecular Dynamics
# using minimal basis H2. Shows how you can chain together
# routines to create more complex programs. This runs about
# a a half of a femtosecond of molecular dynamics and plots
# energy as a function of time

# Molecular geometry input
h2 = """
0 1
H 0.0 0.0 0.74
H 0.0 0.0 0.00
"""

# init molecule and build integrals
mol = Molecule(geometry=h2,basis='sto-3g')
mol.build()

# do the SCF, compute initial forces on the atoms
mol.RHF()
mol.forces()

# BOMD parameters
dt = 5     # time step
steps = 100  # number steps

# saved lists for plotting data
X = []
Y = []
Z = []
E = []
Exemple #12
0
def test_water_321g():
    mol = Molecule(geometry=water, basis='3-21g')
    mol.RHF()
    assert_allclose(mol.energy.real, -75.5613125965, atol=1e-12)
import numpy as np
from mmd.molecule import Molecule
from mmd.realtime import RealTime
from mmd.utils.spectrum import genSpectra

hydrogen = """
0 1
H  0.0 0.0 0.0  
H  0.0 0.0 0.74 
"""

# init molecule and build integrals
mol = Molecule(geometry=hydrogen, basis='3-21G')

# do the SCF
mol.RHF()


# define the applied field envelope as a function of time
# here, is is a narrow gaussian envelope centered at t = 0.
def gaussian(t):
    return np.exp(-50 * (t**2))


# create realtime object, setting parameters and pulse envelopes
rt = RealTime(mol, numsteps=1000, stepsize=0.05, field=0.0001, pulse=gaussian)

# propagate with Magnus2
rt.Magnus2(direction='z')
m2 = rt.dipole
Exemple #14
0
def test_helium_ccpvtz():
    mol = Molecule(geometry=helium, basis='cc-pvtz')
    mol.RHF()
    assert_allclose(mol.energy.real, -2.86115357403, atol=1e-12)
Exemple #15
0
from mmd.molecule import Molecule
from mmd.postscf import PostSCF

water = """
0 1
O    0.000000      -0.075791844    0.000000
H    0.866811829    0.601435779    0.000000
H   -0.866811829    0.601435779    0.000000
"""

# init molecule and build integrals
mol = Molecule(geometry=water, basis='sto-3g')

# do the SCF
mol.RHF()

# do MP2
PostSCF(mol).MP2()
Exemple #16
0
def test_water_DZ():
    mol = Molecule(geometry=water, basis='DZ')
    mol.RHF()
    assert_allclose(mol.energy.real, -75.977878975377, atol=1e-12)
    ref_dipole = np.array([0.0, 2.7222, 0.0])
    assert_allclose(mol.mu, ref_dipole, atol=1e-4)
Exemple #17
0
from mmd.molecule import Molecule
from mmd.realtime import RealTime

hydrogen = """
0 1
H  0.0 0.0 0.0  
H  0.0 0.0 0.74 
"""

# init molecule and build integrals
mol = Molecule(geometry=hydrogen, basis='sto-3g')

# do the SCF
mol.RHF()


# define the applied field envelope as a function of time
# here, is is a gaussian entered at t = 0.
def envelope(t):
    gaussian = np.exp(-(t**2))
    return gaussian


# create realtime object, setting parameters and pulse envelopes
rt = RealTime(mol, numsteps=100, stepsize=0.2, field=0.0001, pulse=None)

# propagate with Magnus2
rt.Magnus2(direction='z')
m2 = rt.dipole
# propagate with Magnus4
rt.Magnus4(direction='z')
def test_methane_321g():
    mol = Molecule(geometry=methane, basis='3-21G')
    mol.RHF(direct=False)  # we need the two-electron integrals
    PostSCF(mol).MP2()
    assert_allclose(mol.energy.real, -39.9768654272)
    assert_allclose(mol.emp2.real, -40.076963354817)
Exemple #19
0
from mmd.molecule import Molecule 
from mmd.postscf import PostSCF
import numpy as np

h2 = """
0 1
H    0.000000000    0.000000000   -0.368652
H    0.000000000    0.000000000    0.368652
"""

# init molecule and build integrals
mol = Molecule(geometry=h2,basis='6-311G**')

# do the SCF
mol.RHF()

# do MP2
PostSCF(mol).MP2()

#print(mol.CAP)

np.savetxt("cap_h2.dat",mol.CAP,'%10.6f',delimiter=" ")

#P_MO = np.real(np.dot(np.transpose(mol.CO),np.dot(mol.P,mol.CO)))

#DEN = np.real(np.dot(np.transpose(mol.CO),np.dot(mol.CAP,mol.CO)))

#print(DEN)

#new = np.real(np.dot(mol.CAP,mol.P))
Exemple #20
0
from mmd.molecule import Molecule
from mmd.postscf import PostSCF

water = """
0 1
O    0.000000      -0.075791844    0.000000
H    0.866811829    0.601435779    0.000000
H   -0.866811829    0.601435779    0.000000
"""

# init molecule and build integrals
mol = Molecule(geometry=water, basis='aug-cc-pvdz')

# do the SCF
mol.RHF()

# do MP2
PostSCF(mol).MP2()

print(mol.CAP)
Exemple #21
0
def test_water_sto3g():
    mol = Molecule(geometry=water, basis='sto-3g')
    mol.RHF(conver=1e-14)
    assert_allclose(mol.energy.real, -74.942079928192, atol=1e-12)
    ref_dipole = np.array([0.0, 1.5340, 0.0])
    assert_allclose(mol.mu, ref_dipole, atol=1e-4)