示例#1
0
def hide_test_11_energy():
    tnm = sys._getframe().f_code.co_name
    eneyne = qcdb.set_molecule(seneyne)
    eneyne.update_geometry()

    E, jrec = qcdb.energy('d3-b3lyp-d2', return_wfn=True)
    assert compare_values(ref_d2[0], E, 7, 'P: Ethene-Ethyne -D2')
    assert compare_values(ref_d2[0], jrec['qcvars']['DISPERSION CORRECTION ENERGY'].data, 7, tnm)
    assert compare_values(ref_d2[0], jrec['qcvars']['B3LYP-D2 DISPERSION CORRECTION ENERGY'].data, 7, tnm)
示例#2
0
def hide_test_11_b():
    tnm = sys._getframe().f_code.co_name
    eneyne = qcdb.set_molecule(seneyne)
    eneyne.update_geometry()
    mA = eneyne.extract_subsets(1)
    mB = eneyne.extract_subsets(2)

    E, jrec = qcdb.energy('d3-b3lyp-d3bj', return_wfn=True, molecule=mA)
    assert compare_values(ref_d3bj[1], E, 7, tnm)
    assert compare_values(ref_d3bj[1], jrec['qcvars']['DISPERSION CORRECTION ENERGY'].data, 7, tnm)
    assert compare_values(ref_d3bj[1], jrec['qcvars']['B3LYP-D3(BJ) DISPERSION CORRECTION ENERGY'].data, 7, tnm)
示例#3
0
def test_sp_rhf_scf_a(h2o):
    """cfour/sp-rhf-scf/input.dat
    #! single-point HF/qz2p on water

    """
    h2o = qcdb.set_molecule(h2o)

    qcdb.set_options({"cfour_BASIS": "qz2p", "d_convergence": 12})

    e, jrec = qcdb.energy("c4-scf", return_wfn=True)

    ans = -76.0627484601
    assert compare_values(ans, qcdb.variable("scf total energy"), 6,
                          tnm() + " SCF")
    assert compare_values(ans, qcdb.variable("current energy"), 6,
                          tnm() + " SCF")
    assert compare_values(ans, jrec["qcvars"]["SCF TOTAL ENERGY"].data, 6,
                          tnm())
    assert compare_values(ans, jrec["qcvars"]["CURRENT ENERGY"].data, 6, tnm())
示例#4
0
def test_sp_rhf_ccsd(h2o):
    """cfour/sp-rhf-ccsd/input.dat 
    #! single point CCSD/qz2p on water

    """
    h2o = qcdb.set_molecule(h2o)
    qcdb.set_options({
        #'cfour_CALC_level': 'CCSD',
        'BASIS': 'cc-pvtz',
        'nwchem_scf__thresh': 12,
        'nwchem_ccsd__thresh': 12
    })

    e, jrec = qcdb.energy('nwc-ccsd', return_wfn=True, molecule=h2o)

    scftot = -76.057112730196  #qz2p -76.062748460117
    mp2tot = -76.332242848821  #qz2p -76.332940127333
    ccsdcorl = -0.280877944529  #qz2p -0.275705491773
    ccsdtot = -76.337990674725  #qz2p-76.338453951890

    tnm = sys._getframe().f_code.co_name
    assert compare_values(scftot, qcdb.get_variable('hf total energy'), 6,
                          tnm + ' SCF')
    assert compare_values(mp2tot, qcdb.get_variable('mp2 total energy'), 6,
                          tnm + ' MP2')
    assert compare_values(ccsdcorl,
                          qcdb.get_variable('ccsd correlation energy'), 6,
                          tnm + ' CCSD corl')
    assert compare_values(ccsdtot, qcdb.get_variable('ccsd total energy'), 6,
                          tnm + ' CCSD')

    # gradient gives every appearence of working but array should be tested and reorientation to input tested
    e, jrec = qcdb.gradient('nwc-ccsd', return_wfn=True, molecule=h2o)
    assert compare_values(scftot, qcdb.get_variable('hf total energy'), 6,
                          tnm + ' SCF')
    assert compare_values(mp2tot, qcdb.get_variable('mp2 total energy'), 6,
                          tnm + ' MP2')
    assert compare_values(ccsdcorl,
                          qcdb.get_variable('ccsd correlation energy'), 6,
                          tnm + ' CCSD corl')
    assert compare_values(ccsdtot, qcdb.get_variable('ccsd total energy'), 6,
                          tnm + ' CCSD')
示例#5
0
def test_1_hf():
    h2o = qcdb.set_molecule("""
        O     0.000000000000    0.000000000000   -0.065638538099
        H     0.000000000000   -0.757480611647    0.520865616174
        H     0.000000000000    0.757480611647    0.520865616174
        """)

    qcdb.set_options({
        "basis": "6-31g*",
        "scf__e_convergence": 1.0e-8,
        #'nwchem_geometry_center'    : False,
        #'nwchem_geometry_autosym'   : False,
        "nwchem_scf__rhf": True,
        #'nwchem_scf__thresh': 1.0e-8,
        "nwchem_scf__direct": True,
        #'nwchem_task_scf': 'optimize'
    })
    print("Testing HF...")
    val = qcdb.energy("nwc-hf")
    check_rhf(val)
示例#6
0
def test_fci_rhf_psi4():
    #! 6-31G H2O Test FCI Energy Point

    h2o = system_water()
    qcdb.set_options(
        {
            "basis": "6-31G",
            #'psi4_detci__icore': 0,
        }
    )

    E = qcdb.energy("p4-fci", molecule=h2o)

    assert compare_values(_refnuc, h2o.nuclear_repulsion_energy(), 9, "nre")
    assert compare_values(_refscf, qcdb.variable("HF total energy"), 8, "hf total energy")
    assert compare_values(_refci, E, 7, "return E")
    assert compare_values(_refci, qcdb.variable("FCI TOTAL ENERGY"), 7, "fci total energy")
    assert compare_values(_refcorr, qcdb.variable("FCI CORRELATION ENERGY"), 7, "fci correlation energy")
    assert compare_values(_refci, qcdb.variable("CI TOTAL ENERGY"), 7, "ci total energy")
    assert compare_values(_refcorr, qcdb.variable("CI CORRELATION ENERGY"), 7, "ci correlation energy")
示例#7
0
def test_scale_2(h2o_y):
    h2o_y = qcdb.Molecule(h2o_y)
    qcdb.set_options({
        "basis": "cc-pvdz",
        "cfour_spin_scal": "on",
        "cfour_reference": "uhf",
        "cfour_calc_level": "mp2",
        "cfour_deriv_level": "first",
        "CFOUR_DIFF_TYPE": "relaxed",
    })

    val, jrec = qcdb.energy("c4-cfour", return_wfn=True, molecule=h2o_y)
    dip = np.array([
        float(jrec["qcvars"]["CURRENT DIPOLE {}".format(i)].data)
        for i in "XYZ"
    ])

    assert compare_arrays(grad_y, jrec["qcvars"]["CURRENT GRADIENT"].data, 5,
                          tnm() + " grad")
    assert compare_arrays(dip_y, dip, 5, tnm() + " dipole")
示例#8
0
def test_1_eomccsd():
    qcdb.set_options({
        'basis'     :       '6-31g*',
        'memory'    :       '15000 mb',
        'scf__e_convergence'    : 1.0e-10,
        #'nwchem_memory' :   '1500 mb',
        #'nwchem_memory' :   '[total, 1500, stack, 400, heap, 400, global, 700, mb]', #The way nwchem speak for memory may need to change
        #'nwchem_stack_memory'  :   '400 mb',
        #'nwchem_heap_memory'   :   '400 mb',
        #'nwchem_global_memory' :   '700 mb',
        'nwchem_scf__thresh'     :   1.0e-10,
        'nwchem_scf__tol2e'      :   1.0e-10,
        'nwchem_scf__rhf'       :   True,
        'qc_module'             :   'tce',
        'nwchem_tce__ccsd'      :   True,
        'nwchem_tce__nroots'     :   12
        })
    print('Testing EOM-CCSD...')
    val = qcdb.energy('nwc-eom-ccsd')
    check_eomccsd(val)
示例#9
0
def test_tu1b():
    """tu1-h2o-energy/input.dat
    local testing

    """

    #    memory 600 mb

    h2o = qcdb.Molecule("""
  O 
  H 1 0.96
  H 1 0.96 2 104.5
""")

    E, jrec = qcdb.energy('scf/cc-pVDZ', molecule=h2o, return_wfn=True)
    print(qcdb.print_variables(jrec['qcvars']))

    ans1 = -76.0266327341067125
    assert compare_values(ans1, jrec['qcvars']['SCF TOTAL ENERGY'].data, 6,
                          sys._getframe().f_code.co_name)
示例#10
0
def test_sp_rohf_ccsd_t_ao_ecc(nh2):

    nh2 = qcdb.set_molecule(nh2)
    qcdb.set_options(
        {
            "cfour_BASIS": "qz2p",
            "cfour_reference": "rohf",
            "cfour_occupation": [[3, 1, 1, 0], [3, 0, 1, 0]],
            "cfour_SCF_CONV": 12,
            "cfour_CC_CONV": 12,
            "cfour_cc_program": "ecc",
            "cfour_abcdtype": "aobasis",
        }
    )

    e, jrec = qcdb.energy("c4-ccsd(t)", return_wfn=True, molecule=nh2)

    check_rohf(lbl=tnm(), fc=False, prog="ecc")
    assert "CC_PROGRAM           ICCPRO         ECC" in jrec["stdout"]
    assert "ABCDTYPE             IABCDT         AOBASIS" in jrec["stdout"]
示例#11
0
def test_1_ccsd_t():
    h2o = qcdb.set_molecule("""
        O     0.00000000     0.00000000     0.22138519
        H     0.00000000    -1.43013023    -0.88554075
        H     0.00000000     1.43013023    -0.88554075
        units au""")

    qcdb.set_options({
        "basis": "cc-pvdz",
        "nwchem_scf__rhf": True,
        "nwchem_scf__thresh": 1.0e-10,
        "nwchem_scf__tol2e": 1.0e-10,
        "nwchem_scf__singlet": True,
        "nwchem_tce__ccsd(t)": True,
        "qc_module": "TCE",
        "nwchem_tce__io": "ga",
    })

    val = qcdb.energy("nwc-ccsd(t)")
    check_ccsd_t_pr_br(val)
示例#12
0
def test_tu1_rhf_b():
    """tu1-h2o-energy/input.dat
    local testing

    """

    #    memory 600 mb

    h2o = qcdb.Molecule("""
  O 
  H 1 1.8
  H 1 1.8 2 104.5
  units au
""")

    E, jrec = qcdb.energy('nwc-hf/cc-pVDZ', molecule=h2o, return_wfn=True)
    print(qcdb.print_variables(jrec['qcvars']))

    assert compare_values(_ref_h2o_pk_rhf,
                          jrec['qcvars']['HF TOTAL ENERGY'].data, 6, tnm())
示例#13
0
def test_1_a5050_no():
    h2o = qcdb.set_molecule("""
        O     0.000000000000    0.000000000000   -0.065638538099
        H     0.000000000000   -0.757480611647    0.520865616174
        H     0.000000000000    0.757480611647    0.520865616174
        """)

    qcdb.set_options({
        "basis": "cc-pvdz",
        "scf__e_convergence": 1.0e-8,
        "nwchem_mp2__tight": True,
        #'nwchem_scf__thresh': 1.0e-8,
        "nwchem_scf__nopen": 0,
        "nwchem_scf__rhf": True,
        #'nwchem_task_mp2': 'energy'
    })
    print("Testing mp2(df)...")
    # print(jrec['qcvars'])
    val = qcdb.energy("nwc-mp2")  # return_wfn=True)
    check_mp2(val, is5050=False)
示例#14
0
def test_1_1a1():
    h2o = qcdb.set_molecule(
        """
            C    0   0     0
            H    0  1.87  -0.82
            H    0  -1.87  -0.82
            symmetry c2v
            units au"""
    )

    qcdb.set_options(
        {
            "basis": "6-31g**",
            "nwchem_mcscf__active": 6,
            "nwchem_mcscf__actelec": 6,
            "nwchem_mcscf__state": "1a1",
        }
    )
    val = qcdb.energy("nwc-mcscf")
    mcscf_ch2(val)
示例#15
0
def test_sp_rhf_ccsd_t_ao_ecc(h2o):
    """cfour/sp-rhf-ccsd_t_-ao-ecc/input.dat"""

    h2o = qcdb.set_molecule(h2o)
    qcdb.set_options(
        {
            #'cfour_CALC_level': 'CCSD(T)',
            "cfour_BASIS": "qz2p",
            "cfour_abcdtype": "aobasis",
            "cfour_cc_program": "ecc",
            "cfour_SCF_CONV": 12,
            "cfour_CC_CONV": 12,
        }
    )

    e, jrec = qcdb.energy("c4-ccsd(t)", return_wfn=True, molecule=h2o)

    check_rhf(lbl=tnm(), fc=False)
    assert "CC_PROGRAM           ICCPRO         ECC" in jrec["stdout"]
    assert "ABCDTYPE             IABCDT         AOBASIS" in jrec["stdout"]
示例#16
0
def test_1_uccsd():
    h2o = qcdb.set_molecule("""
    1 2
        H
        O H 0.96
        H O 0.96 H 104.0
        """)

    qcdb.set_options({
        "basis": "sto-3g",
        "scf__e_convergence": 1e-10,
        "nwchem_charge": 1,
        "nwchem_scf__uhf": True,
        "nwchem_scf__doublet": True,
        "nwchem_scf__tol2e": 1e-10,
        "qc_module": "TCE",
        "nwchem_tce__ccsd": True,
    })

    val = qcdb.energy("nwc-ccsd")
    tce_uccsd(val)
示例#17
0
def test_1_hf():
    h2o = qcdb.set_molecule(
        """
        O     0.000000000000    0.000000000000   -0.065638538099
        H     0.000000000000   -0.757480611647    0.520865616174
        H     0.000000000000    0.757480611647    0.520865616174
        """
    )

    qcdb.set_options(
        {
            "basis": "cc-pvdz",
            "nwchem_scf__rhf": True,
            "scf__e_convergence": 1.0e-8,
            #'nwchem_scf__thresh': 1.0e-8,
            "nwchem_scf__nopen": 0,
        }
    )
    print("Testing hf...")
    val = qcdb.energy("nwc-hf")
    check_hf(val)
示例#18
0
def test_1_mp2_5050no():
    nh2 = qcdb.set_molecule(
        """
         N        0.08546       -0.00020       -0.05091
         H       -0.25454       -0.62639        0.67895
         H       -0.25454       -0.31918       -0.95813
        """
    )

    qcdb.set_options(
        {
            "basis": "cc-pvdz",
            #'scf__e_convergence': 1.0e-8,
            "nwchem_scf__UHF": True,
            "nwchem_scf__nopen": 1,
            "nwchem_scf__maxiter": 80,
            "nwchem_scf__thresh": 1.0e-8,
        }
    )
    print("Testing hf...")
    val = qcdb.energy("nwc-mp2", local_options={"memory": 3})
    check_uhf_mp2(val, is_5050=False)
示例#19
0
def test_1_ccd():
    h2o = qcdb.set_molecule("""
        H    0.000000000000000   1.079252144093028   1.474611055780858
        O    0.000000000000000   0.000000000000000   0.000000000000000
        H    0.000000000000000   1.079252144093028  -1.474611055780858
        units au""")

    qcdb.set_options({
        "basis": "sto-3g",
        "scf__e_convergence": 1e-10,
        "nwchem_scf__rhf": True,
        "nwchem_scf__maxiter": 50,
        "nwchem_scf__singlet": True,
        "nwchem_scf__tol2e": 1e-10,
        "nwchem_scf__thresh": 1e-10,
        "qc_module": "TCE",
        "nwchem_tce__scf": True,
        "nwchem_tce__ccd": True,
        "nwchem_tce__dipole": True,
    })

    val = qcdb.energy("nwc-ccd")
    tce_ccd(val)
示例#20
0
def test_2_lccsd():
    h2o = qcdb.set_molecule(
        """
    H    0.000000000000000   1.079252144093028   1.474611055780858
    O    0.000000000000000   0.000000000000000   0.000000000000000
    H    0.000000000000000   1.079252144093028  -1.47461105578085
       units au """
    )

    qcdb.set_options(
        {
            "basis": "sto-3g",
            #'scf__e_convergence':   1.0e-10,
            "nwchem_scf__thresh": 1.0e-10,
            "nwchem_scf__tol2e": 1.0e-10,
            "nwchem_scf__singlet": True,
            "nwchem_scf__rhf": True,
            "qc_module": "TCE",
            "nwchem_tce__lccsd": True,
        }
    )
    val = qcdb.energy("nwc-lccsd")
    check_lccsd(val)
示例#21
0
def test_1_cisd():
    h2o = qcdb.set_molecule("""
        O      0.000000000000     0.000000000000    -0.123909374404
        H      0.000000000000     1.429936611037     0.983265845431
        H      0.000000000000    -1.429936611037     0.983265845431
        """)

    qcdb.set_options({
        "basis": "sto-3g",
        "qc_module": "TCE",
        "nwchem_tce__cisd": True,
    })
    val = qcdb.energy("nwc-cisd")

    hf = -74.506112017320
    cisd_tot = -74.746025986067849
    cisd_corl = -0.239913968748276

    assert compare_values(hf, qcdb.variable("HF TOTAL ENERGY"), 5, "hf ref")
    assert compare_values(cisd_tot, qcdb.variable("CISD TOTAL ENERGY"), 5,
                          "cisd tot")
    assert compare_values(cisd_corl, qcdb.variable("CISD CORRELATION ENERGY"),
                          5, "cisd corl")
示例#22
0
def test_tu2_rohf():
    """tu2-ch2-energy/input.dat
    #! Sample ROHF/6-31G** CH2 computation

    """

    ch2 = qcdb.set_molecule("""
  0 3
  C
  H 1 R
  H 1 R 2 A

  R = 2.05
  A = 133.93
units au
""")

    qcdb.set_options({
        'basis': '6-31G**',
        'reference': ' rohf',
        'puream': 'cart',
        #'psi_scf_type': 'pk'})
        'scf_type': 'pk'
    })

    E, jrec = qcdb.energy('p4-hf', return_wfn=True)
    print(qcdb.print_variables())

    assert compare_values(_ref_ch2_pk_rohf,
                          qcdb.get_variable('hf total energy'), 6,
                          sys._getframe().f_code.co_name)
    assert compare_values(_ref_ch2_pk_rohf,
                          qcdb.get_variable('current energy'), 6,
                          sys._getframe().f_code.co_name)
    assert compare_values(_ref_ch2_pk_rohf, E, 6,
                          sys._getframe().f_code.co_name)
示例#23
0
def test_1_ccsdtq():
    h2o = qcdb.set_molecule(
        """
        O 0.000000000000    0.000000000000   -0.065638538099
        H 0.000000000000   -0.757480611647    0.520865616174
        H 0.000000000000    0.757480611647    0.520865616174
        """
    )

    qcdb.set_options(
        {
            "basis": "6-31g*",
            #'nwchem_memory': '[total, 2000, global, 1700,mb]',
            #'nwchem_verify'    : True,
            "nwchem_tce__dft": False,
            "nwchem_tce__scf": True,
            "nwchem_tce__ccsdtq": True,
            "qc_module": "tce",
            "nwchem_tce__thresh": 1.0e-7,
        }
    )
    print("Testing CCSDTQ (df)...")
    val = qcdb.energy("nwc-ccsdtq", local_options={"memory": 2})
    check_ccsdtq(val)
示例#24
0
def test_1_dft():
    h2o = qcdb.set_molecule(
        """
        O     0.000000000000    0.000000000000   -0.065638538099
        H     0.000000000000   -0.757480611647    0.520865616174
        H     0.000000000000    0.757480611647    0.520865616174
        """
    )

    qcdb.set_options(
        {
            "basis": "sto-3g",
            #'nwchem_dft__convergence__density': 1.0e-12,
            "nwchem_dft__xc": "b3lyp",
            # add grid options
            "nwchem_tce__dft": True,
            "qc_module": "tce",
            "nwchem_tce__ccsdt": True,
            "nwchem_tce__thresh": 1.0e-12,
        }
    )
    print("Testing CCSDT-DFT energy...")
    val = qcdb.energy("nwc-ccsdt", local_options={"memory": 6})
    check_dft(val, is_dft=True)
示例#25
0
def test_3_cisdtq():
    h2o = qcdb.set_molecule("""
        O      0.000000000000     0.000000000000    -0.123909374404
        H      0.000000000000     1.429936611037     0.983265845431
        H      0.000000000000    -1.429936611037     0.983265845431
        """)

    qcdb.set_options({
        "basis": "sto-3g",
        "qc_module": "TCE",
        "nwchem_tce__cisdtq": True,
    })
    val = qcdb.energy("nwc-cisdtq", local_options={"memory": 1})

    hf = -74.506112017320
    cisdtq_tot = -74.788955327897597
    cisdtq_corl = -0.282843310578009

    assert compare_values(hf, qcdb.variable("HF TOTAL ENERGY"), 5, "hf ref")
    assert compare_values(cisdtq_tot, qcdb.variable("CISDTQ TOTAL ENERGY"), 5,
                          "cisdtq tot")
    assert compare_values(cisdtq_corl,
                          qcdb.variable("CISDTQ CORRELATION ENERGY"), 5,
                          "cisdtq corl")
示例#26
0
def test_2_cisdt():
    h2o = qcdb.set_molecule("""
        O      0.000000000000     0.000000000000    -0.123909374404
        H      0.000000000000     1.429936611037     0.983265845431
        H      0.000000000000    -1.429936611037     0.983265845431
        """)

    qcdb.set_options({
        "basis": "sto-3g",
        "qc_module": "TCE",
        "nwchem_tce__cisdt": True,
    })
    val = qcdb.energy("nwc-cisdt")

    hf = -74.506112017320
    cisdt_tot = -74.746791001337797
    cisdt_corl = -0.240678984018215

    assert compare_values(hf, qcdb.variable("HF TOTAL ENERGY"), 5, "hf ref")
    assert compare_values(cisdt_tot, qcdb.variable("CISDT TOTAL ENERGY"), 5,
                          "cisdt tot")
    assert compare_values(cisdt_corl,
                          qcdb.variable("CISDT CORRELATION ENERGY"), 5,
                          "cisdt corl")
示例#27
0
import qcdb
from qcdb.driver.driver_helpers import get_active_molecule


def {{ cookiecutter.main_function }}(name, **kwargs):
    """ Example Docstring
        input: 
               molecule: Molecule instance
        output: 
               molecule.esp_charges: dictionary of fitted 
                                     esp charges. Modified
                                     in place
        return: None
        output files: mol_results.dat: fitting results
                      mol_grid.dat: grid points in molecule.units
                      mol_grid_esp.dat: QM esp valuese in a.u. 
    """
    molecule = kwargs.pop('molecule', get_active_molecule())
    molecule.update_geometry()

    qopt = qcdb.get_active_options().scroll['{{ cookiecutter.project_slug|upper }}']



    qcdb.get_active_options().require('PSI4', 'E_CONVERGENCE', 6, accession='wert')
    e, jrec = qcdb.energy(name, molecule=molecule, return_wfn=True)
    pprint.pprint(jrec)

    return jrec

示例#28
0
def test_2_pbe96(h2o):
    qcdb.set_options({"basis": "cc-pvdz", "nwchem_dft__xc": "xpbe96 perdew91"})
    val = qcdb.energy("nwc-pbe96", molecule=h2o)
    check_pbe96(val)
示例#29
0
def test_5_blyp(h2o):
    qcdb.set_options({"basis": "cc-pvdz", "nwchem_dft__xc": "becke88 lyp"})
    val = qcdb.energy("nwc-blyp", molecule=h2o)
    check_blyp(val)
示例#30
0
def test_sectionIII():
    """Helper Functions"""
    def gen_rvals(center, stepsize, npoints):
        if npoints % 2 == 0:
            return []
        center_ind = npoints // 2
        rvals = [
            center + stepsize * (ind - center_ind) for ind in range(npoints)
        ]
        return rvals

    """ QCDB Setup """

    bh = qcdb.set_molecule("""
            B
            H 1 R
            units angstrom
            """)

    local_options = {"memory": 35, "nnodes": 1, "ncores": 1}
    qcdb.set_options({
        "e_convergence": 1e-11,
        "scf__d_convergence": 1e-9,
        "nwchem_ccsd__maxiter": 100,
        "psi4_mp2_type": "conv",
        "psi4_scf_type": "direct",
        "psi4_df_scf_guess": "false",
    })
    """ Geometry Scan """

    Re = 1.229980860371199  # self consistent with fci optimization
    dR = 0.005
    npoints = 5

    R_arr = gen_rvals(Re, dR, npoints)

    # energy of base method
    E_base = [0.0] * npoints

    # various corrections to base energy
    dE_basis = [0.0] * npoints
    dE_dboc = [0.0] * npoints
    dE_x2c = [0.0] * npoints
    dE_fci = [0.0] * npoints
    dE_ccsdtq = [0.0] * npoints

    for i, R in enumerate(R_arr):
        print(f"<<<\n<<< POINT {i}\n<<<")

        bh.R = R
        print(f"~~~ Calculation at Re={R} Angstrom ({i+1}/{npoints}) ~~~")

        # read from file in case of restart
        #  if i < 1:
        #  if True:
        #  if i > 0:
        if False:
            #  if i < 4:
            with open(f"dist_{i}", "r+") as f:
                lines = f.readlines()
                lines = [float(line.split()[3]) for line in lines]
                E_base[i] = lines[0]
                dE_basis[i] = lines[1]
                dE_dboc[i] = lines[2]
                dE_x2c[i] = lines[3]
                dE_fci[i] = lines[4]
                dE_ccsdtq[i] = lines[5]
                print(lines)
            continue

        # ccsdtq correction: (CCSDTQ - CCSD(T)) / cc-pVDZ
        qcdb.set_options({
            "cfour_dropmo": [1],
        })
        _, jrec = qcdb.energy("c4-ccsd(t)/cc-pVTZ",
                              return_wfn=True,
                              local_options=local_options)
        E_ccsdpt = float(jrec["qcvars"]["CCSD(T) TOTAL ENERGY"].data)
        _, jrec = qcdb.energy("c4-ccsdtq/cc-pVTZ",
                              return_wfn=True,
                              local_options=local_options)
        E_ccsdtq = float(jrec["qcvars"]["CCSDTQ TOTAL ENERGY"].data)
        qcdb.set_options({"cfour_dropmo": None})
        dE_ccsdtq[i] = E_ccsdtq - E_ccsdpt
        print(
            f"~~~ CCSDTQ Correction={dE_ccsdtq[-1]} Har. ({i+1}/{npoints}) ~~~"
        )

        # base calculation: CCSD(T) / cc-pCV[Q5]Z
        #  qcdb.set_options({'memory': '10 gb'})
        # E, jrec = qcdb.energy('nwc-ccsd(t)/cc-pCV[T,Q]Z', return_wfn=True)
        E, jrec = qcdb.energy("nwc-ccsd(t)/cc-pCVTZ", return_wfn=True)
        #  qcdb.set_options({'memory': '55 gb'})
        E_base[i] = E
        print(f"~~~ Base Energy={E} Har. ({i+1}/{npoints}) ~~~")

        # basis set correction: MP2 / (aug-cc-pCV[56]Z) - cc-pCV[Q5]Z)
        E_small, _ = qcdb.energy("p4-mp2/cc-pCV[T,Q]Z", return_wfn=True)
        E_large, _ = qcdb.energy("p4-mp2/aug-cc-pCV[T,Q]Z", return_wfn=True)
        dE_basis[i] = E_large - E_small
        print(
            f"~~~ Basis Correction={dE_basis[-1]} Har. ({i+1}/{npoints}) ~~~")

        # relativistic correction: (X2C-CCSD(T) - CCSD(T)) / cc-pCVTZ-DK
        qcdb.set_options({"psi4_relativistic": "x2c"})
        E_x2c_on, jrec = qcdb.energy("p4-ccsd(t)/aug-cc-pCVTZ-DK",
                                     return_wfn=True)
        qcdb.set_options({"psi4_relativistic": "no"})
        E_x2c_off, jrec = qcdb.energy("p4-ccsd(t)/aug-cc-pCVTZ-DK",
                                      return_wfn=True)
        dE_x2c[i] = E_x2c_on - E_x2c_off
        print(
            f"~~~ Relativistic Correction={dE_x2c[-1]} Har. ({i+1}/{npoints}) ~~~"
        )

        # fci correction: (FCI - CCSD(T)) / cc-pVDZ
        E_cc, _ = qcdb.energy("gms-ccsd(t)/cc-pVDZ",
                              return_wfn=True,
                              local_options=local_options)
        E_fci, _ = qcdb.energy("gms-fci/cc-pVDZ",
                               return_wfn=True,
                               local_options=local_options)
        dE_fci[i] = E_fci - E_cc
        print(f"~~~ FCI Correction={dE_fci[-1]} Har. ({i+1}/{npoints}) ~~~")

        with open(f"dist_{i}", "a+") as f:
            f.write(f"Re {R_arr[i]} ,E_base     {E_base[i]} ")
            f.write("\n")
            f.write(f"Re {R_arr[i]} ,dE_basis   {dE_basis[i]} ")
            f.write("\n")
            f.write(f"Re {R_arr[i]} ,dE_dboc    {dE_dboc[i]} ")
            f.write("\n")
            f.write(f"Re {R_arr[i]} ,dE_x2c     {dE_x2c[i]} ")
            f.write("\n")
            f.write(f"Re {R_arr[i]} ,dE_fci     {dE_fci[i]} ")
            f.write("\n")
            f.write(f"Re {R_arr[i]} ,dE_ccsdtq  {dE_ccsdtq[i]} ")
            f.write("\n")

        print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
        print(f"Re {R_arr[i]} ,E_base     {E_base[i]}")
        print(f"Re {R_arr[i]} ,dE_basis   {dE_basis[i]}")
        print(f"Re {R_arr[i]} ,dE_x2c     {dE_x2c[i]}")
        print(f"Re {R_arr[i]} ,dE_fci     {dE_fci[i]}")
        print(f"Re {R_arr[i]} ,dE_ccsdtq  {dE_ccsdtq[i]}")
        print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

    # Energy with a single correction
    E_basis = []
    E_dboc = []
    E_x2c = []
    E_fci = []
    E_ccsdtq = []
    # Total energies, using all corrections
    E_tot_fci = []
    E_tot_ccsdtq = []
    for i in range(npoints):

        E_basis.append(E_base[i] + dE_basis[i])
        E_dboc.append(E_base[i] + dE_dboc[i])
        E_x2c.append(E_base[i] + dE_x2c[i])
        E_fci.append(E_base[i] + dE_fci[i])
        E_ccsdtq.append(E_base[i] + dE_ccsdtq[i])

        E_tot_fci.append(E_base[i] + dE_basis[i] + dE_dboc[i] + dE_x2c[i] +
                         dE_fci[i])
        E_tot_ccsdtq.append(E_base[i] + dE_basis[i] + dE_dboc[i] + dE_x2c[i] +
                            dE_ccsdtq[i])

    for i in range(len(R_arr)):
        print(
            "Re",
            R_arr[i],
        )
        print("   E_base", E_base[i])
        print("   dE_basis", dE_basis[i])
        print("   dE_x2c", dE_x2c[i])
        print("   dE_fci", dE_fci[i])
        print("   dE_ccsdtq", dE_ccsdtq[i])
        print("   E_tot_fci", E_tot_fci[i])
        print("   E_tot_ccsdtq", E_tot_ccsdtq[i])
    """ Spectroscopic Constants """

    # need a Psi4 molecule to give atomic masses to the diatomic module
    import psi4

    psi4.geometry("""
            B
            H 1 1000
            units au
            """)

    print("Total correction w/ FCI")
    phys_consts_tot_fci = qcdb.diatomic(R_arr, E_tot_fci, molecule=bh)
    pp.pprint(phys_consts_tot_fci)

    print("Total correction w/ CCSDTQ")
    phys_consts_tot_ccsdtq = qcdb.diatomic(R_arr, E_tot_ccsdtq, molecule=bh)
    pp.pprint(phys_consts_tot_ccsdtq)

    print("Base Energy")
    phys_consts_base = qcdb.diatomic(R_arr, E_base, molecule=bh)
    pp.pprint(phys_consts_base)

    print("Base Energy w/ only basis correction")
    phys_consts_basis = qcdb.diatomic(R_arr, E_basis, molecule=bh)
    pp.pprint(phys_consts_basis)

    print("Base Energy w/ only DBOC")
    phys_consts_dboc = qcdb.diatomic(R_arr, E_dboc, molecule=bh)
    pp.pprint(phys_consts_dboc)

    print("Base Energy w/ only rel. correction")
    phys_consts_x2c = qcdb.diatomic(R_arr, E_x2c, molecule=bh)
    pp.pprint(phys_consts_x2c)

    print("Base Energy w/ only FCI correction")
    phys_consts_fci = qcdb.diatomic(R_arr, E_fci, molecule=bh)
    pp.pprint(phys_consts_fci)

    print("Base Energy w/ only CCSDTQ correction")
    phys_consts_ccsdtq = qcdb.diatomic(R_arr, E_ccsdtq, molecule=bh)
    pp.pprint(phys_consts_ccsdtq)
示例#31
0
def test_sp_ccsd_t_rohf_fc(method, keywords, nh2):
    """cfour/???/input.dat
    #! single point CCSD(T)/qz2p on water

    """
    nh2 = qcdb.set_molecule(nh2)
    qcdb.set_options(keywords)

    e, jrec = qcdb.energy(method, return_wfn=True, molecule=nh2)

    # from Cfour
    scf_tot = -55.58473726
    mp2_tot = -55.76085357
    ccsd_tot = -55.77756954
    ccsd_t_tot = -55.78261742

    ## from NWChem
    #scf_tot = -55.58473726
    #mp2_tot =   ???
    #ccsd_tot = -55.77756347
    #ccsd_t_tot = -55.78275606

    ## from Psi4
    #scf_tot = -55.58473726
    #mp2_tot = -55.76085357
    #ccsd_tot = -55.77756954
    #ccsd_t_tot = -55.78261742

    mp2_corl = mp2_tot - scf_tot
    ccsd_corl = ccsd_tot - scf_tot
    ccsd_t_corl = ccsd_t_tot - scf_tot
    t_corl = ccsd_t_tot - ccsd_tot

    atol = 1.e-6

    # nwc CCSD(T) correlation disagrees with Cfour and Psi4 by ~2.e-4
    # nwc CCSD correlation disagrees with Cfour and Psi4 by ~7.e-6
    # hf is in agreement
    if method.startswith('nwc'):
        atol = 2.e-4

    # cc terms
    assert compare_values(ccsd_t_tot, e, tnm() + ' Returned', atol=atol)
    assert compare_values(ccsd_t_tot, qcdb.variable('current energy'), tnm() + ' Current', atol=atol)
    assert compare_values(ccsd_t_tot, qcdb.variable('ccsd(t) total energy'), tnm() + ' CCSD(T)', atol=atol)

    assert compare_values(ccsd_t_corl, qcdb.variable('current correlation energy'), tnm() + ' CCSD(T)', atol=atol)
    assert compare_values(ccsd_t_corl, qcdb.variable('ccsd(t) correlation energy'), tnm() + ' CCSD(T)', atol=atol)

    assert compare_values(ccsd_tot, qcdb.variable('ccsd total energy'), tnm() + ' CCSD', atol=atol)
    assert compare_values(ccsd_corl, qcdb.variable('ccsd correlation energy'), tnm() + ' CCSD', atol=atol)

    assert compare_values(t_corl, qcdb.variable('(t) correction energy'), tnm() + ' (T)', atol=atol)

    # mp2 terms (not printed for nwc tce)
    if not (method.startswith('nwc') and keywords.get('qc_module', 'nein').lower() == 'tce'):
        assert compare_values(mp2_tot, qcdb.variable('mp2 total energy'), tnm() + ' MP2', atol=atol)
        assert compare_values(mp2_corl, qcdb.variable('mp2 correlation energy'), tnm() + ' MP2', atol=atol)

    # hf terms
    assert compare_values(scf_tot, qcdb.variable('hf total energy'), tnm() + ' SCF', atol=atol)
    assert compare_values(scf_tot, qcdb.variable('scf total energy'), tnm() + ' SCF', atol=atol)
示例#32
0
def test_scf4(program, keywords):
    #! RHF cc-pVDZ energy for water, automatically scanning the symmetric stretch and bending coordinates
    #! using Python's built-in loop mechanisms.  The geometry is apecified using a Z-matrix with variables
    #! that are updated during the potential energy surface scan, and then the same procedure is performed
    #! using polar coordinates, converted to Cartesian coordinates.
    import math

    refENuc = [
        9.785885838936569,
        9.780670106434425,
        8.807297255042920,
        8.802603095790996,
        8.006633868220828,
        8.002366450719077,
    ]
    refSCF = [
        -76.02132544702374,
        -76.02170973231352,
        -76.02148196912412,
        -76.0214579633461369,
        -75.99010402473729,
        -75.98979578728871,
    ]

    # Define the points on the potential energy surface using standard Python list functions
    Rvals = [0.9, 1.0, 1.1]
    Avals = range(102, 106, 2)

    # Start with a potentital energy scan in Z-matrix coordinates

    h2o = qcdb.Molecule("""
        O
        H 1 R
        H 1 R 2 A
    """)

    print("\n Testing Z-matrix coordinates\n")

    qcdb.set_keywords(keywords)
    model = qcdb.util.program_prefix(program) + "scf/cc-pvdz"

    count = 0
    for R in Rvals:
        h2o.set_variable("R", R)  # alternately, h2o.R = R
        for A in Avals:
            h2o.A = A  # alternately, h2o.set_variable('A', A)
            h2o.update_geometry()

            ene, jrec = qcdb.energy(model, molecule=h2o, return_wfn=True)
            assert compare_values(refSCF[count], ene, 6,
                                  f"Reference energy {count}")
            assert compare_values(refENuc[count] * a2a,
                                  h2o.nuclear_repulsion_energy(), 10,
                                  f"Nuclear repulsion energy {count}")
            assert program == jrec["provenance"]["creator"].lower(
            ), "zmat prov"
            count += 1

    # And now the same thing, using Python's trigonometry functions, and Cartesian input.  This time
    # we want to reset the Cartesian positions every time the angles and bond lengths change, so we
    # define the geometry inside the loops.  N.B. this requires the basis set to be re-specified after
    # every change of geometry

    print("\n Testing polar coordinates\n")

    count = 0
    for R in Rvals:
        for A in Avals:
            h2o = qcdb.Molecule("""
                O   0.0    0.0    0.0
                H   0.0      R    0.0
                H   0.0  RCosA  RSinA
            """)
            # The non-numeric entries above just define placeholders with names.  They still need
            # to be set, which we do below.
            h2o.R = R
            h2o.set_variable("RCosA", R * math.cos(math.radians(A)))
            h2o.RSinA = R * math.sin(math.radians(A))
            h2o.update_geometry()

            ene, jrec = qcdb.energy(model, molecule=h2o, return_wfn=True)
            assert compare_values(refSCF[count], ene, 6,
                                  f"Reference energy {count}")
            assert compare_values(refENuc[count] * a2a,
                                  h2o.nuclear_repulsion_energy(), 10,
                                  f"Nuclear repulsion energy {count}")
            assert program == jrec["provenance"]["creator"].lower(
            ), "polar prov"
            count += 1