Exemplo n.º 1
0
def test_ccsd_h2o():
    # Psi4 Setup
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'STO-3G',
                      'scf_type': 'pk',
                      'mp2_type': 'conv',
                      'freeze_core': 'true',
                      'e_convergence': 1e-12,
                      'd_convergence': 1e-12,
                      'r_convergence': 1e-12,
                      'diis': 1})
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    maxiter = 75
    e_conv = 1e-12
    r_conv = 1e-12
    ccsd = pycc.ccwfn(rhf_wfn)
    eccsd = ccsd.solve_cc(e_conv,r_conv,maxiter)
    epsi4 = -0.070616830152761  
    assert (abs(epsi4 - eccsd) < 1e-11)

    # cc-pVDZ basis set
    psi4.set_options({'basis': 'cc-pVDZ'})
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)
    ccsd = pycc.ccwfn(rhf_wfn)
    eccsd = ccsd.solve_cc(e_conv,r_conv,maxiter)
    epsi4 = -0.222029814166783
    assert (abs(epsi4 - eccsd) < 1e-11)
Exemplo n.º 2
0
def test_density_ccsd_h2o():
    """H2O"""
    # Psi4 Setup
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({
        'basis': 'STO-3G',
        'scf_type': 'pk',
        'mp2_type': 'conv',
        'freeze_core': 'true',
        'e_convergence': 1e-12,
        'd_convergence': 1e-12,
        'r_convergence': 1e-12,
        'diis': 1
    })
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    maxiter = 75
    e_conv = 1e-12
    r_conv = 1e-12

    ccsd = pycc.ccwfn(rhf_wfn)
    eccsd = ccsd.solve_cc(e_conv, r_conv)
    hbar = pycc.cchbar(ccsd)
    cclambda = pycc.cclambda(ccsd, hbar)
    lccsd = cclambda.solve_lambda(e_conv, r_conv)
    epsi4 = -0.070616830152761
    lpsi4 = -0.068826452648939
    ccdensity = pycc.ccdensity(ccsd, cclambda)
    ecc_density = ccdensity.compute_energy()
    assert (abs(epsi4 - eccsd) < 1e-11)
    assert (abs(lpsi4 - lccsd) < 1e-11)
    assert (abs(epsi4 - ecc_density) < 1e-11)

    psi4.set_options({'basis': 'cc-pVDZ'})
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)
    ccsd = pycc.ccwfn(rhf_wfn)
    eccsd = ccsd.solve_cc(e_conv, r_conv)
    hbar = pycc.cchbar(ccsd)
    cclambda = pycc.cclambda(ccsd, hbar)
    lccsd = cclambda.solve_lambda(e_conv, r_conv)
    epsi4 = -0.222029814166783
    lpsi4 = -0.217838951550509
    ccdensity = pycc.ccdensity(ccsd, cclambda)
    ecc_density = ccdensity.compute_energy()
    assert (abs(epsi4 - eccsd) < 1e-11)
    assert (abs(lpsi4 - lccsd) < 1e-11)
    assert (abs(epsi4 - ecc_density) < 1e-11)
Exemplo n.º 3
0
def test_cc2_h2o():
    # Psi4 Setup
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({
        'basis': 'cc-pVDZ',
        'scf_type': 'pk',
        'mp2_type': 'conv',
        'freeze_core': 'false',
        'e_convergence': 1e-12,
        'd_convergence': 1e-12,
        'r_convergence': 1e-12,
        'diis': 1
    })
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    maxiter = 75
    e_conv = 1e-12
    r_conv = 1e-12
    cc = pycc.ccwfn(rhf_wfn, model='CC2')
    ecc = cc.solve_cc(e_conv, r_conv, maxiter)
    epsi4 = -0.215857544656
    assert (abs(epsi4 - ecc) < 1e-11)

    hbar = pycc.cchbar(cc)
    cclambda = pycc.cclambda(cc, hbar)
    lcc = cclambda.solve_lambda(e_conv, r_conv)
    lcc_psi4 = -0.215765740373555
    assert (abs(lcc - lcc_psi4) < 1e-11)
Exemplo n.º 4
0
def test_lpno_ccsd():
    """H2O LPNO-CCSD Test"""
    # Psi4 Setup
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'cc-pVDZ',
                      'scf_type': 'pk',
                      'mp2_type': 'conv',
                      'freeze_core': 'false',
                      'e_convergence': 1e-13,
                      'd_convergence': 1e-13,
                      'r_convergence': 1e-13,
                      'diis': 1})
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    maxiter = 75
    e_conv = 1e-12
    r_conv = 1e-12
    max_diis = 8

    ccsd = pycc.ccwfn(rhf_wfn, local='LPNO', local_cutoff=1e-5)
    eccsd = ccsd.solve_cc(e_conv, r_conv, maxiter)

    hbar = pycc.cchbar(ccsd)
    cclambda = pycc.cclambda(ccsd, hbar)
    lccsd = cclambda.solve_lambda(e_conv, r_conv, maxiter, max_diis)

    epsi4 = -0.221156413159674
    lpsi4 = -0.217144045119535

    assert (abs(epsi4 - eccsd) < 1e-7)
    assert (abs(lpsi4 - lccsd) < 1e-7)
Exemplo n.º 5
0
def test_pao_h2o():
    """PAO-CCSD Test 2"""
    # Psi4 Setup
    psi4.set_memory('1 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': '6-31g',
                      'scf_type': 'pk',
                      'guess': 'core',
                      'mp2_type': 'conv',
                      'freeze_core': 'False',
                      'e_convergence': 1e-12,
                      'd_convergence': 1e-12,
                      'r_convergence': 1e-12,
                      'diis': 8})
    mol = psi4.geometry(moldict["H2O_Teach"] + "\nnoreorient\nnocom")
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)
    
    maxiter = 75
    e_conv = 1e-7
    r_conv = 1e-7
    max_diis = 8
    
    ccsd = pycc.ccwfn(rhf_wfn, local='PAO', local_cutoff=2e-2)
    
    eccsd = ccsd.solve_cc(e_conv, r_conv, maxiter, max_diis)
    
    # NOTE: the following reference was generated with a custom build of Psi3
    # which removed PAOs based on their norm EVEN IF freeze_core = false
    psi3_ref = -0.149361947815815
    assert (abs(psi3_ref - eccsd) < 1e-7)
Exemplo n.º 6
0
def test_pao_h2o_frzc():
    """PAO-CCSD Frozen Core Test"""
    # Psi4 Setup
    psi4.set_memory('1 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': '6-31g',
                      'scf_type': 'pk',
                      'guess': 'core',
                      'mp2_type': 'conv',
                      'freeze_core': 'True',
                      'e_convergence': 1e-12,
                      'd_convergence': 1e-12,
                      'r_convergence': 1e-12,
                      'diis': 8})
    mol = psi4.geometry(moldict["H2O_Teach"] + "\nnoreorient\nnocom")
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)
    
    maxiter = 75
    e_conv = 1e-7
    r_conv = 1e-7
    max_diis = 8
    
    ccsd = pycc.ccwfn(rhf_wfn, local='PAO', local_cutoff=2e-2)
    
    eccsd = ccsd.solve_cc(e_conv, r_conv, maxiter, max_diis)
    
    psi3_ref = -0.148485522656349

    assert (abs(psi3_ref - eccsd) < 1e-7)
Exemplo n.º 7
0
def test_ccd_h2o():
    # Psi4 Setup
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'cc-pVDZ',
                      'scf_type': 'pk',
                      'mp2_type': 'conv',
                      'freeze_core': 'false',
                      'e_convergence': 1e-12,
                      'd_convergence': 1e-12,
                      'r_convergence': 1e-12,
                      'diis': 1})
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    maxiter = 75
    e_conv = 1e-12
    r_conv = 1e-12
    cc = pycc.ccwfn(rhf_wfn, model='CCD')
    ecc = cc.solve_cc(e_conv,r_conv,maxiter)
    epsi4 = -0.222559319034  # Checked against CFOUR
    assert (abs(epsi4 - ecc) < 1e-11)

    hbar = pycc.cchbar(cc)
    cclambda = pycc.cclambda(cc, hbar)
    lcc = cclambda.solve_lambda(e_conv, r_conv)
    lcc_cfour = -0.218758826700
    assert (abs(lcc - lcc_cfour) < 1e-11)

    ccdensity = pycc.ccdensity(cc, cclambda)
    ecc = ccdensity.compute_energy()
    assert (abs(epsi4 - ecc) < 1e-11)
Exemplo n.º 8
0
def test_rtcc_he_cc_pvdz():
    """He cc-pVDZ"""
    psi4.set_memory('2 GiB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'cc-pVDZ',
                      'scf_type': 'pk',
                      'mp2_type': 'conv',
                      'freeze_core': 'false',
                      'e_convergence': 1e-13,
                      'd_convergence': 1e-13,
                      'r_convergence': 1e-13,
                      'diis': 1})
    mol = psi4.geometry(moldict["He"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    e_conv = 1e-13
    r_conv = 1e-13

    cc = pycc.ccwfn(rhf_wfn)
    ecc = cc.solve_cc(e_conv, r_conv)

    hbar = pycc.cchbar(cc)

    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)

    ccdensity = pycc.ccdensity(cc, cclambda)

    # Sine squared pulse (a.u.)
    F_str = 1.0
    omega = 2.87
    tprime = 5.0
    V = sine_square_laser(F_str, omega, tprime)

    # RT-CC Setup
    t0 = 0
    tf = 1.0
    h = 0.01
    rtcc = pycc.rtcc(cc, cclambda, ccdensity, V)
    y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128')
    ODE = ode(rtcc.f).set_integrator('vode',atol=1e-13,rtol=1e-13)
    ODE.set_initial_value(y0, t0)

    t1, t2, l1, l2 = rtcc.extract_amps(y0)
    mu0_x, mu0_y, mu0_z = rtcc.dipole(t1, t2, l1, l2)
    ecc0 = rtcc.lagrangian(t0, t1, t2, l1, l2)

    mu_z_ref = 0.008400738202694  # a.u.

    while ODE.successful() and ODE.t < tf:
        y = ODE.integrate(ODE.t+h)
        t = ODE.t
        t1, t2, l1, l2 = rtcc.extract_amps(y)
        mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2)
        ecc = rtcc.lagrangian(t, t1, t2, l1, l2)

    print(mu_z)
    assert (abs(mu_z_ref - mu_z.real) < 1e-10)
Exemplo n.º 9
0
def test_ccsd_t_h2o():
    """H2O cc-pVDZ"""
    # Psi4 Setup
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({
        'basis': 'STO-3G',
        'scf_type': 'pk',
        'mp2_type': 'conv',
        'freeze_core': 'true',
        'e_convergence': 1e-12,
        'd_convergence': 1e-12,
        'r_convergence': 1e-12,
        'diis': 1
    })
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    maxiter = 75
    e_conv = 1e-12
    r_conv = 1e-12
    cc = pycc.ccwfn(rhf_wfn)
    eccsd = cc.solve_cc(e_conv, r_conv, maxiter)
    tcorr = pycc.cctriples(cc)
    et_vik_ijk = tcorr.t_vikings()
    et_vik_abc = tcorr.t_vikings_inverted()
    et_tjl = tcorr.t_tjl()
    epsi4 = -0.000099957499645
    assert (abs(epsi4 - et_vik_ijk) < 1e-11)
    assert (abs(epsi4 - et_vik_abc) < 1e-11)
    assert (abs(epsi4 - et_tjl) < 1e-11)

    psi4.set_options({'basis': 'cc-pVDZ'})
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)
    cc = pycc.ccwfn(rhf_wfn)
    eccsd = cc.solve_cc(e_conv, r_conv, maxiter)
    tcorr = pycc.cctriples(cc)
    et_vik_ijk = tcorr.t_vikings()
    et_vik_abc = tcorr.t_vikings_inverted()
    et_tjl = tcorr.t_tjl()
    epsi4 = -0.003861236558801
    assert (abs(epsi4 - et_vik_ijk) < 1e-11)
    assert (abs(epsi4 - et_vik_abc) < 1e-11)
    assert (abs(epsi4 - et_tjl) < 1e-11)
Exemplo n.º 10
0
def test_rtpao(datadir):
    """H2O RT-PAO"""
    psi4.set_memory('2 GiB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'cc-pVDZ',
                      'scf_type': 'pk',
                      'mp2_type': 'conv',
                      'freeze_core': 'false',
                      'e_convergence': 1e-13,
                      'd_convergence': 1e-13,
                      'r_convergence': 1e-13,
                      'diis': 1,
                      'local_convergence': 1.e-13})
    mol = psi4.geometry(moldict["H2O"]+"\nnoreorient\nnocom")
    ref_dir = str(datadir.join(f"wfn.npy"))
    rhf_wfn = psi4.core.Wavefunction.from_file(ref_dir)

    maxiter = 75
    e_conv = 1e-13
    r_conv = 1e-13
    max_diis = 8

    cc = pycc.ccwfn(rhf_wfn, local='PAO', local_cutoff=1e-2)
    ecc = cc.solve_cc(e_conv, r_conv, maxiter, max_diis)
    hbar = pycc.cchbar(cc)
    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)
    ccdensity = pycc.ccdensity(cc, cclambda)

    # Narrow Gaussian pulse 
    F_str = 0.001 
    omega = 0
    sigma = 0.01
    center = 0.05
    V = gaussian_laser(F_str, omega, sigma, center=center)

    # RT-CC Setup
    t0 = 0
    tf = 0.5
    h = 0.02
    rtcc = pycc.rtcc(cc, cclambda, ccdensity, V)
    y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128')
    ODE = rk4(h)
    
    # Propagate
    ret = rtcc.propagate(ODE, y0, tf, ti=t0, ref=False)

    # check
    ref = {'ecc': (-84.21540972040579+2.9584453421137937e-16j), 
           'mu_x': (-4.987717148832141e-05-2.5885460555301484e-12j), 
           'mu_y': (-4.707786986481166e-05-1.5660290548026362e-11j), 
           'mu_z': (-0.0783037960868978-1.168135844689433e-11j)}
    for prop in ret['0.50']:
        assert (abs(ret['0.50'][prop] - ref[prop]) < 1e-8) 
Exemplo n.º 11
0
def test_rtpno(datadir):
    """H2O RT-LPNO"""
    psi4.set_memory('2 GiB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'cc-pVDZ',
                      'scf_type': 'pk',
                      'mp2_type': 'conv',
                      'freeze_core': 'false',
                      'e_convergence': 1e-13,
                      'd_convergence': 1e-13,
                      'r_convergence': 1e-13,
                      'diis': 1,
                      'local_convergence': 1.e-13})
    mol = psi4.geometry(moldict["H2O"]+"\nnoreorient\nnocom")
    ref_dir = str(datadir.join(f"wfn.npy"))
    rhf_wfn = psi4.core.Wavefunction.from_file(ref_dir)

    maxiter = 75
    e_conv = 1e-13
    r_conv = 1e-13
    max_diis = 8

    cc = pycc.ccwfn(rhf_wfn, local='LPNO', local_cutoff=1e-5)
    ecc = cc.solve_cc(e_conv, r_conv, maxiter, max_diis)
    hbar = pycc.cchbar(cc)
    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)
    ccdensity = pycc.ccdensity(cc, cclambda)

    # Narrow Gaussian pulse 
    F_str = 0.001 
    omega = 0
    sigma = 0.01
    center = 0.05
    V = gaussian_laser(F_str, omega, sigma, center=center)

    # RT-CC Setup
    t0 = 0
    tf = 0.5
    h = 0.02
    rtcc = pycc.rtcc(cc, cclambda, ccdensity, V)
    y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128')
    ODE = rk4(h)
    
    # Propagate
    ret = rtcc.propagate(ODE, y0, tf, ti=t0, ref=False)

    # check
    ref = {'ecc': (-84.21331867940133+4.925945912792495e-17j), 
           'mu_x': (-5.106207671158796e-05+3.641896436116718e-12j), 
           'mu_y': (-5.001503722097678e-05-1.7436592314191415e-12j), 
           'mu_z': (-0.06905411053873889-9.328439713393588e-12j)}
    for prop in ret['0.50']:
        assert (abs(ret['0.50'][prop] - ref[prop]) < 1e-8) 
Exemplo n.º 12
0
def test_dipole_h2_2_cc_pvdz():
    """He cc-pVDZ"""
    psi4.set_memory('2 GiB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({
        'basis': 'cc-pVDZ',
        'scf_type': 'pk',
        'mp2_type': 'conv',
        'freeze_core': 'false',
        'e_convergence': 1e-13,
        'd_convergence': 1e-13,
        'r_convergence': 1e-13,
        'diis': 1
    })
    mol = psi4.geometry(moldict["(H2)_2"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    e_conv = 1e-13
    r_conv = 1e-13

    cc = pycc.ccwfn(rhf_wfn)
    ecc = cc.solve_cc(e_conv, r_conv)

    hbar = pycc.cchbar(cc)

    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)

    ccdensity = pycc.ccdensity(cc, cclambda)

    # no laser
    rtcc = pycc.rtcc(cc, cclambda, ccdensity, None, magnetic=True)
    y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1,
                           cclambda.l2).astype('complex128')
    t1, t2, l1, l2 = rtcc.extract_amps(y0)

    ref = [0, 0, 0.005371586416860086]  # au
    mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2)
    opdm = rtcc.ccdensity.compute_onepdm(t1, t2, l1, l2, withref=True)

    assert (abs(ref[0] - mu_x) < 1E-10)
    assert (abs(ref[1] - mu_y) < 1E-10)
    assert (abs(ref[2] - mu_z) < 1E-10)

    ref = [0, 0, -2.3037968376087573E-5]
    m_x, m_y, m_z = rtcc.dipole(t1, t2, l1, l2, magnetic=True)

    assert (abs(ref[0] * 1.0j - m_x) < 1E-10)
    assert (abs(ref[1] * 1.0j - m_y) < 1E-10)
    assert (abs(ref[2] * 1.0j - m_z) < 1E-10)
Exemplo n.º 13
0
def test_pao_H8():
    """PAO-CCSD Test"""
    # Psi4 Setup
    psi4.set_memory('1 GB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'DZ',
                      'scf_type': 'pk',
                      'guess': 'core',
                      'mp2_type': 'conv',
                      'freeze_core': 'False',
                      'e_convergence': 1e-12,
                      'd_convergence': 1e-12,
                      'r_convergence': 1e-12,
                      'diis': 8})
    mol = psi4.geometry("""
        H 0.000000 0.000000 0.000000
        H 0.750000 0.000000 0.000000
        H 0.000000 1.500000 0.000000
        H 0.375000 1.500000 -0.649520
        H 0.000000 3.000000 0.000000
        H -0.375000 3.000000 -0.649520
        H 0.000000 4.500000 -0.000000
        H -0.750000 4.500000 -0.000000
        symmetry c1
        noreorient
        nocom
        """)
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)
    
    maxiter = 75
    e_conv = 1e-12
    r_conv = 1e-12
    max_diis = 8
    
    ccsd = pycc.ccwfn(rhf_wfn, local='PAO', local_cutoff=2e-2)
    
    eccsd = ccsd.solve_cc(e_conv, r_conv, maxiter, max_diis)
    
    # (H2)_4 REFERENCE:
    psi3_ref = -0.108914240219735

    assert (abs(psi3_ref - eccsd) < 1e-7)
Exemplo n.º 14
0
def test_rtcc_water_cc_pvdz():
    """H2O cc-pVDZ"""
    psi4.set_memory('2 GiB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({
        'basis': 'cc-pVDZ',
        'scf_type': 'pk',
        'mp2_type': 'conv',
        'freeze_core': 'false',
        'e_convergence': 1e-13,
        'd_convergence': 1e-13,
        'r_convergence': 1e-13,
        'diis': 1
    })
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    e_conv = 1e-13
    r_conv = 1e-13

    cc = pycc.ccwfn(rhf_wfn)
    ecc = cc.solve_cc(e_conv, r_conv)

    hbar = pycc.cchbar(cc)

    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)

    ccdensity = pycc.ccdensity(cc, cclambda)

    # Gaussian pulse (a.u.)
    F_str = 0.01
    omega = 0
    sigma = 0.01
    center = 0.05
    V = gaussian_laser(F_str, omega, sigma, center)

    # RT-CC Setup
    t0 = 0
    tf = 0.1
    h = 0.01
    t = t0
    rtcc = pycc.rtcc(cc, cclambda, ccdensity, V)
    y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1,
                           cclambda.l2).astype('complex128')
    y = y0
    ODE = rk4(h)
    t1, t2, l1, l2 = rtcc.extract_amps(y0)
    mu0_x, mu0_y, mu0_z = rtcc.dipole(t1, t2, l1, l2)
    ecc0 = rtcc.lagrangian(t0, t1, t2, l1, l2)

    # For saving data at each time step.
    """
    dip_x = []
    dip_y = []
    dip_z = []
    time_points = []
    dip_x.append(mu0_x)
    dip_y.append(mu0_y)
    dip_z.append(mu0_z)
    time_points.append(t)
    """

    while t < tf:
        y = ODE(rtcc.f, t, y)
        t += h
        t1, t2, l1, l2 = rtcc.extract_amps(y)
        mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2)
        ecc = rtcc.lagrangian(t, t1, t2, l1, l2)
        """
        dip_x.append(mu_x)
        dip_y.append(mu_y)
        dip_z.append(mu_z)
        time_points.append(t)
        """

    print(mu_z)
    mu_z_ref = -0.34894577
    assert (abs(mu_z_ref - mu_z.real) < 1e-4)
Exemplo n.º 15
0
def test_dipole_h2_2_field():
    """H2 dimer"""
    psi4.set_memory('2 GiB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({
        'basis': '6-31G',
        'scf_type': 'pk',
        'mp2_type': 'conv',
        'freeze_core': 'false',
        'e_convergence': 1e-13,
        'd_convergence': 1e-13,
        'r_convergence': 1e-13,
        'diis': 1
    })
    mol = psi4.geometry(moldict["(H2)_2"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    e_conv = 1e-13
    r_conv = 1e-13

    cc = pycc.ccwfn(rhf_wfn)
    ecc = cc.solve_cc(e_conv, r_conv)

    hbar = pycc.cchbar(cc)

    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)

    ccdensity = pycc.ccdensity(cc, cclambda)

    # narrow Gaussian pulse
    F_str = 0.01
    sigma = 0.01
    center = 0.05
    V = gaussian_laser(F_str, 0, sigma, center=center)
    rtcc = pycc.rtcc(cc, cclambda, ccdensity, V, magnetic=True)

    mints = psi4.core.MintsHelper(cc.ref.basisset())
    dipole_ints = mints.ao_dipole()
    m_ints = mints.ao_angular_momentum()
    C = np.asarray(cc.ref.Ca_subset("AO", "ACTIVE"))
    ref_mu = []
    ref_m = []
    for axis in range(3):
        ref_mu.append(C.T @ np.asarray(dipole_ints[axis]) @ C)
        ref_m.append(C.T @ (np.asarray(m_ints[axis]) * -0.5) @ C)
        assert np.allclose(ref_mu[axis], rtcc.mu[axis])
        assert np.allclose(ref_m[axis] * 1.0j, rtcc.m[axis])
    ref_mu_tot = sum(ref_mu) / np.sqrt(3.0)

    assert np.allclose(ref_mu_tot, rtcc.mu_tot)

    rtcc = pycc.rtcc(cc, cclambda, ccdensity, V, magnetic=True, kick="Y")

    mints = psi4.core.MintsHelper(cc.ref.basisset())
    dipole_ints = mints.ao_dipole()
    m_ints = mints.ao_angular_momentum()
    C = np.asarray(cc.ref.Ca_subset("AO", "ACTIVE"))
    ref_mu = []
    ref_m = []
    for axis in range(3):
        ref_mu.append(C.T @ np.asarray(dipole_ints[axis]) @ C)
        ref_m.append(C.T @ (np.asarray(m_ints[axis]) * -0.5) @ C)
        assert np.allclose(ref_mu[axis], rtcc.mu[axis])
        assert np.allclose(ref_m[axis] * 1.0j, rtcc.m[axis])

    assert np.allclose(ref_mu[1], rtcc.mu_tot)
Exemplo n.º 16
0
def test_rtcc_water_cc_pvdz():
    """H2O cc-pVDZ"""
    psi4.set_memory('2 GiB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({
        'basis': 'cc-pVDZ',
        'scf_type': 'pk',
        'mp2_type': 'conv',
        'freeze_core': 'false',
        'e_convergence': 1e-13,
        'd_convergence': 1e-13,
        'r_convergence': 1e-13,
        'diis': 1
    })
    mol = psi4.geometry(moldict["H2O"])
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)

    e_conv = 1e-13
    r_conv = 1e-13

    cc = pycc.ccwfn(rhf_wfn)
    ecc = cc.solve_cc(e_conv, r_conv)

    hbar = pycc.cchbar(cc)

    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)

    ccdensity = pycc.ccdensity(cc, cclambda)

    # Gaussian pulse (a.u.)
    F_str = 100
    omega = 0
    # The pulse is chosen to be thinner for less time steps with h_small(see below).
    sigma = 0.0001
    center = 0.0005
    V = gaussian_laser(F_str, omega, sigma, center)
    # Cutoff for the field to decide which step size is used
    e_field = 1e-7

    # RT-CC Setup
    t0 = 0
    tf = 0.1
    h_small = 1e-5
    h = 0.01
    t = t0
    rtcc = pycc.rtcc(cc, cclambda, ccdensity, V)
    y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1,
                           cclambda.l2).astype('complex128')
    y = y0
    ODE1 = rk4(h_small)
    ODE2 = rk4(h)
    t1, t2, l1, l2 = rtcc.extract_amps(y0)
    mu0_x, mu0_y, mu0_z = rtcc.dipole(t1, t2, l1, l2)
    ecc0 = rtcc.lagrangian(t0, t1, t2, l1, l2)

    #mu_z_ref = 0.008400738202694  # a.u.

    # For saving data at each time step.
    """
    dip_x = []
    dip_y = []
    dip_z = []
    time_points = []
    dip_x.append(mu0_x)
    dip_y.append(mu0_y)
    dip_z.append(mu0_z)
    time_points.append(t)
    """

    while t < tf:
        # When the field is on
        if V(t) > e_field:
            y = ODE1(rtcc.f, t, y)
            h_i = h_small
        # When the field is off
        else:
            y = ODE2(rtcc.f, t, y)
            h_i = h
        t += h_i
        t1, t2, l1, l2 = rtcc.extract_amps(y)
        mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2)
        ecc = rtcc.lagrangian(t, t1, t2, l1, l2)
        """
        dip_x.append(mu_x)
        dip_y.append(mu_y)
        dip_z.append(mu_z)
        time_points.append(t)
        """

    print(mu_z)
    mu_z_ref = -0.34894577
    assert (abs(mu_z_ref - mu_z.real) < 1e-1)
Exemplo n.º 17
0
    'scf_type': 'pk',
    'mp2_type': 'conv',
    'freeze_core': 'false',
    'e_convergence': 1e-8,
    'd_convergence': 1e-8,
    'r_convergence': 1e-8,
    'diis': 8
})
mol = psi4.geometry(moldict["H2"])
if full:
    rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True)
else:
    rhf_wfn = psi4.core.Wavefunction.from_file('ref_wfn')
e_conv = 1e-8
r_conv = 1e-8
cc = pycc.ccwfn(rhf_wfn)
ecc = cc.solve_cc(e_conv, r_conv)
hbar = pycc.cchbar(cc)
cclambda = pycc.cclambda(cc, hbar)
lecc = cclambda.solve_lambda(e_conv, r_conv)
ccdensity = pycc.ccdensity(cc, cclambda)

# narrow Gaussian pulse
F_str = 0.001
sigma = 0.01
center = 0.05
V = gaussian_laser(F_str, 0, sigma, center=center)

# RTCC
# use tf = 5 to generate checkpoint file
h = 0.1
Exemplo n.º 18
0
def test_chk(datadir):
    # run cc
    psi4.set_memory('600MB')
    psi4.core.set_output_file('output.dat', False)
    psi4.set_options({'basis': 'cc-pVDZ',
                      'scf_type': 'pk',
                      'mp2_type': 'conv',
                      'freeze_core': 'false',
                      'e_convergence': 1e-8,
                      'd_convergence': 1e-8,
                      'r_convergence': 1e-8,
                      'diis': 8})
    mol = psi4.geometry(moldict["H2"])

    # pull ref wfn, psi4 is picky about strings 
    rhf_dir = str(datadir.join(f"ref_wfn.npy"))
    rhf_wfn = psi4.core.Wavefunction.from_file(rhf_dir)

    e_conv = 1e-8
    r_conv = 1e-8
    cc = pycc.ccwfn(rhf_wfn)
    ecc = cc.solve_cc(e_conv, r_conv)
    hbar = pycc.cchbar(cc)
    cclambda = pycc.cclambda(cc, hbar)
    lecc = cclambda.solve_lambda(e_conv, r_conv)
    ccdensity = pycc.ccdensity(cc, cclambda)

    # narrow Gaussian pulse
    F_str = 0.001
    sigma = 0.01
    center = 0.05
    V = gaussian_laser(F_str, 0, sigma, center=center)

    # RTCC setup
    h = 0.1
    tf = 10
    rtcc = pycc.rtcc(cc,cclambda,ccdensity,V,magnetic=True,kick='z')

    # pull chk files for 0-5.1au
    chk_file = datadir.join(f"chk_5.pk")
    with open(chk_file,'rb') as cf:
        chk = pk.load(cf)

    # propagate to 10au
    ODE = rk2(h)
    y0 = chk['y']
    ti = chk['time']
    ofile = datadir.join(f"output.pk")
    tfile = datadir.join(f"t_out.pk")
    ret, ret_t = rtcc.propagate(ODE, y0, tf, ti=ti, ref=False, chk=True, tchk=1,
            ofile=ofile, tfile=tfile, k=2)

    # reference is "full" propagation (0-10au)
    refp_file = datadir.join(f"output_full.pk")
    with open(refp_file,'rb') as pf:
        ref_p = pk.load(pf)
    reft_file = datadir.join(f"t_out_full.pk")
    with open(reft_file,'rb') as ampf:
        ref_t = pk.load(ampf)
        
    # check properties
    pchk = ['ecc','mu_x','mu_y','mu_z','m_x','m_y','m_z']
    for k in ref_p.keys():
        for p in pchk:
            assert np.allclose(ret[k][p],ref_p[k][p])

    # check amplitudes
    tchk = ['t1','t2','l1','l2']
    for k in ref_t.keys():
        for t in tchk:
            assert np.allclose(ret_t[k][t],ref_t[k][t])