Exemplo n.º 1
0
def test_run(h2o):
    inp = qcel.models.AtomicInput(molecule=h2o,
                                  driver="properties",
                                  model={
                                      "method": "adc2",
                                      "basis": "sto-3g"
                                  },
                                  keywords={"n_singlets": 3})
    ret = qcng.compute(inp,
                       "adcc",
                       raise_error=True,
                       local_options={"ncores": 1},
                       return_dict=True)

    ref_excitations = np.array(
        [0.0693704245883876, 0.09773854881340478, 0.21481589246935925])
    ref_hf_energy = -74.45975898670224
    ref_mp2_energy = -74.67111187456267
    assert ret["success"] is True

    qcvars = ret["extras"]["qcvars"]

    assert qcvars["EXCITATION KIND"] == "SINGLET"
    assert compare_values(ref_excitations[0], ret["return_result"])
    assert compare_values(ref_hf_energy, ret["properties"]["scf_total_energy"])
    assert compare_values(ref_mp2_energy,
                          ret["properties"]["mp2_total_energy"])
    assert compare_values(ref_excitations, qcvars["ADC2 EXCITATION ENERGIES"])
Exemplo n.º 2
0
def test_homo_lumo(h20v2):
    # Run NH2
    resi = {
        "molecule": h20v2,
        "driver": "energy",
        "model": {"method": "dft", "basis": "3-21g"},
        "keywords": {"dft__xc": "b3lyp"},
    }
    res = qcng.compute(resi, "nwchem", raise_error=True, return_dict=True)

    # Make sure the calculation completed successfully
    assert compare_values(-75.968095, res["return_result"], atol=1e-3)
    assert res["driver"] == "energy"
    assert "provenance" in res
    assert res["success"] is True

    # Check the other status information
    assert res["extras"]["qcvars"]["N ALPHA ELECTRONS"] == "5"
    assert res["extras"]["qcvars"]["N ATOMS"] == "3"
    assert res["extras"]["qcvars"]["N BASIS FUNCTIONS"] == "13"

    # Make sure the properties parsed correctly
    assert compare_values(-75.968095, res["properties"]["return_energy"], atol=1e-3)
    assert res["properties"]["calcinfo_natom"] == 3
    assert res["properties"]["calcinfo_nalpha"] == 5
    assert res["properties"]["calcinfo_nbasis"] == 13
    # Make sure Dipole Moment and center of charge parsed correctly
    assert compare_values(-0.2636515, float(res["extras"]["qcvars"]["H**O"][0]), atol=1e-5)
    assert compare_values(0.08207131, float(res["extras"]["qcvars"]["LUMO"][0]), atol=1e-5)
Exemplo n.º 3
0
def test_mp2d__run_mp2d__2body(inp, subjects, request):
    subject = subjects()[inp['parent']][inp['subject']]
    expected = ref[inp['parent']][inp['lbl']][inp['subject']]
    #gexpected = gref[inp['parent']][inp['lbl']][inp['subject']].ravel()

    if 'qcmol' in request.node.name:
        mol = subject
    else:
        mol = subject.to_schema(dtype=2)

    resinp = {
        'schema_name': 'qcschema_input',
        'schema_version': 1,
        'molecule': mol,
        'driver': 'energy', #gradient',
        'model': {
            'method': inp['name']
        },
        'keywords': {},
    }
    jrec = qcng.compute(resinp, 'mp2d', raise_error=True)
    jrec = jrec.dict()

    #assert len(jrec['extras']['qcvars']) == 8

    assert compare_values(expected, jrec['extras']['qcvars']['CURRENT ENERGY'], atol=1.e-7)
    assert compare_values(expected, jrec['extras']['qcvars']['DISPERSION CORRECTION ENERGY'], atol=1.e-7)
    assert compare_values(expected, jrec['extras']['qcvars'][inp['lbl'] + ' DISPERSION CORRECTION ENERGY'], atol=1.e-7)
Exemplo n.º 4
0
def test_qchem_orientation():

    mol = qcel.models.Molecule.from_data("""
        He 0.0  0.7  0.7
        He 0.0 -0.7 -0.7
        """)

    # Compare with rotation
    inp = {
        "molecule": mol,
        "driver": "gradient",
        "model": {
            "method": "HF",
            "basis": "6-31g"
        }
    }
    ret = qcng.compute(inp, "qchem", raise_error=True)
    assert compare_values(np.linalg.norm(ret.return_result, axis=0),
                          [0, 0, 0.00791539])

    # Compare without rotations
    mol_noorient = mol.copy(update={"fix_orientation": True})
    inp = {
        "molecule": mol_noorient,
        "driver": "gradient",
        "model": {
            "method": "HF",
            "basis": "6-31g"
        }
    }
    ret = qcng.compute(inp, "qchem", raise_error=True)

    assert compare_values(np.linalg.norm(ret.return_result, axis=0),
                          [0, 0.00559696541, 0.00559696541])
Exemplo n.º 5
0
def test_b3lyp(nh2):
    # Run NH2
    resi = {
        "molecule": nh2,
        "driver": "energy",
        "model": {
            "method": "b3lyp",
            "basis": "3-21g"
        }
    }
    res = qcng.compute(resi, "nwchem", raise_error=True, return_dict=True)

    # Make sure the calculation completed successfully
    assert compare_values(-55.554037, res["return_result"], atol=1e-3)
    assert res["driver"] == "energy"
    assert "provenance" in res
    assert res["success"] is True

    # Check the other status information
    assert res["extras"]["qcvars"]["N ALPHA ELECTRONS"] == "5"
    assert res["extras"]["qcvars"]["N ATOMS"] == "3"
    assert res["extras"]["qcvars"]["N BASIS"] == "13"

    # Make sure the properties parsed correctly
    assert compare_values(-55.554037,
                          res["properties"]["return_energy"],
                          atol=1e-3)
    assert res["properties"]["calcinfo_natom"] == 3
    assert res["properties"]["calcinfo_nalpha"] == 5
    assert res["properties"]["calcinfo_nbasis"] == 13
Exemplo n.º 6
0
def test_energy(h2o):
    mr_kws = {
        "world_prec": 1.0e-3,
        "world_size": 6,
        "world_unit": "bohr",
    }

    inp = qcel.models.AtomicInput(
        molecule=h2o,
        driver="energy",
        model={
            "method": "BLYP",
        },
        keywords=mr_kws,
    )

    res = qcng.compute(inp, "mrchem", raise_error=True, return_dict=True)

    # Make sure the calculation completed successfully
    assert compare_values(-76.4546307, res["return_result"], atol=1e-3)
    assert res["driver"] == "energy"
    assert "provenance" in res
    assert res["success"] is True

    # Make sure the properties parsed correctly
    assert compare_values(-76.4546307,
                          res["properties"]["return_energy"],
                          atol=1e-3)
    assert res["properties"]["calcinfo_natom"] == 3
    assert res["properties"]["calcinfo_nalpha"] == 5
    assert res["properties"]["calcinfo_nbeta"] == 5
    assert res["properties"]["calcinfo_nmo"] == 10
    assert compare_values([-3.766420e-07, 0.0, 0.720473],
                          res["properties"]["scf_dipole_moment"],
                          atol=1e-3)
Exemplo n.º 7
0
def test_hess(nh2):
    resi = {
        "molecule": nh2,
        "driver": "hessian",
        "model": {
            "method": "b3lyp",
            "basis": "3-21g"
        }
    }
    res = qcng.compute(resi, "nwchem", raise_error=True, return_dict=False)
    assert compare_values(-3.5980754370e-02,
                          res.return_result[0, 0],
                          atol=1e-3)
    assert compare_values(0, res.return_result[1, 0], atol=1e-3)
    assert compare_values(0.018208307756, res.return_result[3, 0], atol=1e-3)
    assert np.allclose(res.return_result, res.return_result.T,
                       atol=1e-8)  # Should be symmetric about diagonal

    # Test that the Hessian changes with rotation, but that its determinants remain the same
    shifted_nh2, _ = nh2.scramble(do_shift=False,
                                  do_mirror=False,
                                  do_rotate=True,
                                  do_resort=False)

    resi["molecule"] = shifted_nh2
    res_shifted = qcng.compute(resi,
                               "nwchem",
                               raise_error=True,
                               return_dict=False)
    assert not np.allclose(
        res.return_result, res_shifted.return_result, atol=1e-8)
    assert np.isclose(np.linalg.det(res.return_result),
                      np.linalg.det(res_shifted.return_result))
Exemplo n.º 8
0
def test_gradient(nh2):
    resi = {
        "molecule": nh2,
        "driver": "gradient",
        "model": {"method": "b3lyp", "basis": "3-21g"},
        "keywords": {"dft__convergence__gradient": "1e-6"},
    }
    res = qcng.compute(resi, "nwchem", raise_error=True, return_dict=True)
    assert compare_values(4.22418267e-2, res["return_result"][2], atol=1e-7)  # Beyond accuracy of NWChem stdout

    # Rotate the molecule and verify that the gradient changes
    shifted_nh2, _ = nh2.scramble(do_shift=False, do_mirror=False, do_rotate=True, do_resort=False)

    resi["molecule"] = shifted_nh2
    res_shifted = qcng.compute(resi, "nwchem", raise_error=True, return_dict=True)

    assert not compare_values(4.22418267e-2, res_shifted["return_result"][2], atol=1e-7)

    # Make sure the two matrices still have the same determinant and norms, as they are just rotations of each other
    #  I am leveraging the fact that the gradients are square, 3x3 matrices just by happenstance of the
    #  test molecule having 3 atoms
    orig_grads = np.reshape(res["return_result"], (-1, 3))
    shif_grads = np.reshape(res_shifted["return_result"], (-1, 3))

    # Test that the magnitude of forces are the same
    assert np.allclose(np.linalg.norm(orig_grads, ord=2, axis=1), np.linalg.norm(shif_grads, ord=2, axis=1))

    # Test that the determinants are the same
    orig_det = np.linalg.det(orig_grads)
    shif_det = np.linalg.det(shif_grads)

    assert np.allclose(orig_det, shif_det)
Exemplo n.º 9
0
def _asserter(asserter_args, contractual_args, contractual_fn):
    """For expectations in `contractual_fn`, check that the QCVars are present in P::e.globals and wfn and match expected ref_block."""

    qcvar_stores, ref_block, atol, ref_block_conv, atol_conv, tnm = asserter_args

    for obj in qcvar_stores:
        for rpv, pv, present in contractual_fn(*contractual_args):
            label = tnm + " " + pv

            if present:
                # verify exact match to method (may be df) and near match to conventional (non-df) method
                tf, errmsg = compare_values(
                    ref_block[rpv], query_qcvar(obj, pv), label, atol=atol, return_message=True, quiet=True
                )
                assert compare_values(ref_block[rpv], query_qcvar(obj, pv), label, atol=atol), errmsg
                tf, errmsg = compare_values(
                    ref_block_conv[rpv], query_qcvar(obj, pv), label, atol=atol_conv, return_message=True, quiet=True,
                )
                assert compare_values(ref_block_conv[rpv], query_qcvar(obj, pv), label, atol=atol_conv), errmsg

                # Note that the double compare_values lines are to collect the errmsg in the first for assertion in the second.
                #   If the errmsg isn't present in the assert, the string isn't accessible through `e.value`.
                #   If a plain bool is compared in the assert, the printed message will show booleans and not numbers.
            else:
                # verify and forgive known contract violations
                assert compare(False, query_has_qcvar(obj, pv), label + " SKIP")
Exemplo n.º 10
0
def test_molecule__run_dftd3__23body(inp, subjects):
    subject = subjects()[inp['parent']][inp['subject']]
    expected = ref[inp['parent']][inp['lbl']][inp['subject']]
    gexpected = gref[inp['parent']][inp['lbl']][inp['subject']]

    E, G = subject.run_dftd3(inp['first'], inp['second'])
    assert compare_values(expected, E, atol=1.e-7)
    assert compare_values(gexpected, G, atol=1.e-7)
Exemplo n.º 11
0
def test_molecule__run_dftd3__23body(inp, subjects):
    subject = subjects()[inp['parent']][inp['subject']]
    expected = ref[inp['parent']][inp['lbl']][inp['subject']]
    gexpected = gref[inp['parent']][inp['lbl']][inp['subject']]

    E, G = subject.run_dftd3(inp['first'], inp['second'])
    assert compare_values(expected, E, atol=1.e-7)
    assert compare_values(gexpected, G, atol=1.e-7)
Exemplo n.º 12
0
def test_kabsch_identity():
    oco10 = qcel.molparse.from_string(soco10)
    oco12 = qcel.molparse.from_string(soco10)

    oco10_geom_au = oco10["qm"]["geom"].reshape((-1, 3)) / qcel.constants.bohr2angstroms
    oco12_geom_au = oco12["qm"]["geom"].reshape((-1, 3)) / qcel.constants.bohr2angstroms

    rmsd, rot, shift = qcel.molutil.kabsch_align(oco10_geom_au, oco12_geom_au)

    assert compare_values(0.0, rmsd, "identical")
    assert compare_values(np.identity(3), rot, "identity rotation matrix")
    assert compare_values(np.zeros(3), shift, "identical COM")
Exemplo n.º 13
0
def test_qc_units():
    au2D = 2.541746451895025916414946904
    au2Q = au2D * 0.52917721067

    onedebye = qcel.Datum("CC dipole", "e a0", np.array([0, 0, 1 / au2D]))
    onebuckingham = qcel.Datum(
        "CC quadrupole", "e a0^2",
        np.array([0, 0, 1 / au2Q, 0, 0, 0, 0, 0, 0]).reshape((3, 3)))

    assert compare_values(np.array([0, 0, 1.0]), onedebye.to_units("D"))
    assert compare_values(np.array([[0, 0, 1.0], [0, 0, 0], [0, 0, 0]]),
                          onebuckingham.to_units("D Å"))
Exemplo n.º 14
0
def test_dftd3__run_dftd3__3body(inp, subjects, request):
    subject = subjects()[inp['parent']][inp['subject']]
    expected = ref[inp['parent']][inp['lbl']][inp['subject']]
    gexpected = gref[inp['parent']][inp['lbl']][inp['subject']].ravel()

    if 'qcmol' in request.node.name:
        subject.update({
            'model': {
                'method': inp['name']
            },
            'driver': 'gradient',
            'keywords': {},
            'schema_name': 'qcschema_input',
            'schema_version': 1
        })
        jrec = dftd3.run_json(subject)
    else:
        jrec = dftd3.run_dftd3(inp['name'], subject, options={}, ptype='gradient')

    assert len(jrec['extras']['qcvars']) == 8

    assert compare_values(expected, jrec['extras']['qcvars']['CURRENT ENERGY'], atol=1.e-7)
    assert compare_values(expected, jrec['extras']['qcvars']['DISPERSION CORRECTION ENERGY'], atol=1.e-7)
    assert compare_values(expected, jrec['extras']['qcvars']['3-BODY DISPERSION CORRECTION ENERGY'], atol=1.e-7)
    assert compare_values(
        expected, jrec['extras']['qcvars']['AXILROD-TELLER-MUTO 3-BODY DISPERSION CORRECTION ENERGY'], atol=1.e-7)

    assert compare_values(gexpected, jrec['extras']['qcvars']['CURRENT GRADIENT'], atol=1.e-7)
    assert compare_values(gexpected, jrec['extras']['qcvars']['DISPERSION CORRECTION GRADIENT'], atol=1.e-7)
    assert compare_values(gexpected, jrec['extras']['qcvars']['3-BODY DISPERSION CORRECTION GRADIENT'], atol=1.e-7)
    assert compare_values(
        gexpected, jrec['extras']['qcvars']['AXILROD-TELLER-MUTO 3-BODY DISPERSION CORRECTION GRADIENT'], atol=1.e-7)
Exemplo n.º 15
0
def test_qcore_methods(method, energy, gradient_norm):

    atomic_input = qcel.models.AtomicInput(
        molecule=qcng.get_molecule("water"),
        model=method,
        driver="gradient",
    )

    atomic_result = qcng.compute(atomic_input, "qcore")

    assert atomic_result.success, atomic_result.error.error_message
    assert compare_values(atomic_result.properties.return_energy, energy)
    assert compare_values(np.linalg.norm(atomic_result.return_result), gradient_norm)
    assert atomic_result.wavefunction is None
Exemplo n.º 16
0
def test_dftd3__run_dftd3__3body(inp, subjects, request):
    subject = subjects()[inp['parent']][inp['subject']]
    expected = ref[inp['parent']][inp['lbl']][inp['subject']]
    gexpected = gref[inp['parent']][inp['lbl']][inp['subject']]

    if 'qcmol' in request.node.name:
        mol = subject
    else:
        mol = subject.to_schema(dtype=2)

    resinp = {
        'schema_name': 'qcschema_input',
        'schema_version': 1,
        'molecule': mol,
        'driver': 'gradient',
        'model': {
            'method': inp['name']
        },
        'keywords': {},
    }
    jrec = qcng.compute(resinp, 'dftd3', raise_error=True)
    jrec = jrec.dict()

    assert len(jrec['extras']['qcvars']) == 8

    assert compare_values(expected,
                          jrec['extras']['qcvars']['CURRENT ENERGY'],
                          atol=1.e-7)
    assert compare_values(
        expected,
        jrec['extras']['qcvars']['DISPERSION CORRECTION ENERGY'],
        atol=1.e-7)
    assert compare_values(
        expected,
        jrec['extras']['qcvars']['3-BODY DISPERSION CORRECTION ENERGY'],
        atol=1.e-7)
    assert compare_values(
        expected,
        jrec['extras']['qcvars']
        ['AXILROD-TELLER-MUTO 3-BODY DISPERSION CORRECTION ENERGY'],
        atol=1.e-7)

    assert compare_values(gexpected,
                          jrec['extras']['qcvars']['CURRENT GRADIENT'],
                          atol=1.e-7)
    assert compare_values(
        gexpected,
        jrec['extras']['qcvars']['DISPERSION CORRECTION GRADIENT'],
        atol=1.e-7)
    assert compare_values(
        gexpected,
        jrec['extras']['qcvars']['3-BODY DISPERSION CORRECTION GRADIENT'],
        atol=1.e-7)
    assert compare_values(
        gexpected,
        jrec['extras']['qcvars']
        ['AXILROD-TELLER-MUTO 3-BODY DISPERSION CORRECTION GRADIENT'],
        atol=1.e-7)
def test_clbrbutRS():
    mol, data = clbrbutRS.align(clbrbutRR,
                                do_plot=do_plot,
                                verbose=verbose,
                                uno_cutoff=uno_cutoff,
                                run_mirror=run_mirror)
    assert compare_values(1.092, data['rmsd'], '2-chloro-3-bromobutane RR, RS', atol=1.)
Exemplo n.º 18
0
def test_sp_ccsd_rhf_full(program, basis, keywords, h2o):
    """cfour/sp-rhf-ccsd/input.dat
    #! single point CCSD/qz2p on water

    """
    resi = {
        "molecule": h2o,
        "driver": "energy",
        "model": {
            "method": "ccsd",
            "basis": basis
        },
        "keywords": keywords,
    }

    res = qcng.compute(resi, program, raise_error=True, return_dict=True)

    assert res["driver"] == "energy"
    assert "provenance" in res
    assert res["success"] is True

    # aug-cc-pvdz
    scftot = -76.0413815332
    mp2tot = -76.2632792578
    mp2corl = -0.2218977246
    ccsdcorl = -0.2294105794
    ccsdtot = -76.2707921127

    atol = 1.e-6
    #assert compare_values(scftot, qcdb.variable('scf total energy'), tnm() + ' SCF', atol=atol)
    #if not (mtd == 'nwc-ccsd' and keywords.get('qc_module', 'nein').lower() == 'tce'):
    #    assert compare_values(mp2tot, qcdb.variable('mp2 total energy'), tnm() + ' MP2', atol=atol)
    #assert compare_values(ccsdcorl, qcdb.variable('ccsd correlation energy'), tnm() + ' CCSD corl', atol=atol)
    assert compare_values(ccsdtot, res["return_result"], atol=atol)
Exemplo n.º 19
0
def test_sp_ccsd_rohf_full(program, basis, keywords, nh2):
    resi = {
        "molecule": nh2,
        "driver": "energy",
        "model": {
            "method": "ccsd",
            "basis": basis
        },
        "keywords": keywords,
    }

    res = qcng.compute(resi, program, raise_error=True, return_dict=True)

    assert res["driver"] == "energy"
    assert "provenance" in res
    assert res["success"] is True

    # aug-cc-pvdz
    scftot = -55.570724348574
    ssccsdcorl = -0.0339827
    osccsdcorl = -0.1442533
    ccsdcorl = -0.178236032911
    ccsdtot = -55.748960381485

    atol = 1.e-6
    #assert compare_values(scftot, qcdb.variable('scf total energy'), tnm() + 'SCF', atol=atol)
    #if not (method in ['gms-ccsd', 'nwc-ccsd']):
    #    # cfour isn't splitting out the singles from OS. and psi4 isn't incl the singles in either so SS + OS != corl
    #    # and maybe singles moved from SS to OS in Cfour btwn 2010 and 2014 versions (change in ref)
    #    # assert compare_values(osccsdcorl, qcdb.variable('ccsd opposite-spin correlation energy'), tnm() + ' CCSD OS corl', atol=atol)
    #    assert compare_values(ssccsdcorl, qcdb.variable('ccsd same-spin correlation energy'), tnm() + ' CCSD SS corl', atol=atol)
    #assert compare_values(ccsdcorl, qcdb.variable('ccsd correlation energy'), tnm() + ' CCSD corl', atol=atol)
    #assert compare_values(ccsdtot, qcdb.variable('ccsd total energy'), tnm() + ' CCSD', atol=atol)
    #assert compare_values(ccsdcorl, qcdb.variable('current correlation energy'), tnm() + ' Current corl', atol=atol)
    assert compare_values(ccsdtot, res["return_result"], atol=atol)
Exemplo n.º 20
0
def test_sp_hf_rhf(program, basis, keywords, h2o):
    """cfour/sp-rhf-hf/input.dat
    #! single point HF/adz on water

    """
    resi = {
        "molecule": h2o,
        "driver": "energy",
        "model": {
            "method": "hf",
            "basis": basis
        },
        "keywords": keywords,
    }

    res = qcng.compute(resi, program, raise_error=True, return_dict=True)

    assert res["driver"] == "energy"
    assert "provenance" in res
    assert res["success"] is True

    # aug-cc-pvdz
    scf_tot = -76.0413815332

    atol = 1.e-6
    assert compare_values(scf_tot, res["return_result"], atol=atol)
Exemplo n.º 21
0
def test_molsymm_alone(subject):
    pg = data[subject]["pg"]
    sigma = data[subject]["rsn"]

    if subject.startswith("iso"):
        isbohr = data[subject[3:]].get("au", False)
        molstr = data[subject[3:]]["mol"].format(isoA=data[subject]["A"])
        refgeomang = None
    else:
        isbohr = data[subject].get("au", False)
        molstr = data[subject]["mol"].format(isoA="")
        refgeomang = data[subject]["ref"]

    symmol = qcdb.Molecule(molstr)
    symmol.update_geometry()
    # symmol.axis_representation()

    assert compare(pg, symmol.get_full_point_group(),
                   pg + " point group: " + subject)
    assert compare(sigma, symmol.rotational_symmetry_number(), pg + " sigma")

    if isbohr:
        geom_now = symmol.full_geometry()
    else:
        geom_now = qcdb.util.vecutil.mscale(symmol.full_geometry(),
                                            qcel.constants.bohr2angstroms)

    if refgeomang:
        assert compare_values(refgeomang,
                              geom_now,
                              pg + " orientation",
                              atol=1.0e-6)
def test_dibromobutRS_SS():
    mol, data = dibromobutRS.align(dibromobutSS,
                                   do_plot=do_plot,
                                   verbose=verbose,
                                   uno_cutoff=uno_cutoff,
                                   run_mirror=run_mirror)
    assert compare_values(1.560, data['rmsd'], '2,3-dibromobutane SS, RS', atol=1.e-1)
Exemplo n.º 23
0
 def _test_dihedral(p1, p2, p3, p4, value, degrees=True):
     tmp = qcelemental.util.compute_dihedral(p1,
                                             p2,
                                             p3,
                                             p4,
                                             degrees=degrees)
     assert compare_values(value, float(tmp), label="test_dihedral1")
Exemplo n.º 24
0
def test_model_b787():
    oco10 = qcel.models.Molecule.from_data(soco10)
    oco12 = qcel.models.Molecule.from_data(sooc12)

    mol, data = oco12.align(oco10, verbose=4)

    assert compare_values(ref_rmsd, data["rmsd"], "known rmsd qcel.models.Molecule.align", atol=1.0e-6)
Exemplo n.º 25
0
def test_psz_main():
    """Checks that the main function on the psithonyzer script returns
    the correct values for precomputed psithon outputs."""
    
    root = os.getcwd()
    d = os.path.join(root, "crystalatte", "data", "out")
    os.chdir(d)

    results, crystal_lattice_energy = crystalatte.psz_main(2)


    a = []
    a.append("2mer-0+1                   |   0.87719178 |    6 |   2.63157535 |    2.63157535 | 1.748924e-03 |  2.588 ")
    a.append("3mer-0+1+2                 |   0.03591565 |    3 |   0.03591565 |    2.66749100 | 6.255109e-07 |  2.428  2.588  2.588 ")
    a.append("3mer-0+1+5                 |  -0.10631085 |    3 |  -0.10631085 |    2.56118015 | 6.255109e-07 |  2.588  2.588  2.588 ")
    a.append("4mer-0+1+2+3               |   0.00643113 |    1 |   0.00160778 |    2.56278793 | 9.355871e-12 |  2.428  2.428  2.428  2.588  2.588  2.588 ")
    a.append("5mer-0+1+2+3+4             |  -0.00086359 |    3 |  -0.00051816 |    2.56226977 | 4.005201e-25 |  2.428  2.428  2.428  2.588  2.588  2.588  2.588  2.588  3.945  5.012 ")

    assert compare(a[0], results[0])
    assert compare(a[1], results[1])
    assert compare(a[2], results[2])
    assert compare(a[3], results[3])
    assert compare(a[4], results[4])
    assert compare_values(2.56226977, crystal_lattice_energy, atol=1.e-9)
    
    # Change directory back to root.
    os.chdir(root)

    # Clean-up generated test files.
    subprocess.call(["rm", "crystalatte/data/out/Ammonia.csv"])
def test_sp_mp2_rhf_full(program, basis, keywords, h2o):
    """cfour/sp-rhf-ccsd/input.dat
    #! single point MP2/adz on water

    """
    resi = {
        "molecule": h2o,
        "driver": "energy",
        "model": {
            "method": "mp2",
            "basis": basis
        },
        "keywords": keywords
    }

    res = qcng.compute(resi, program, raise_error=True, return_dict=True)

    assert res["driver"] == "energy"
    assert "provenance" in res
    assert res["success"] is True

    # aug-cc-pvdz
    mp2_tot = -76.2632792578

    atol = 1.0e-6
    assert compare_values(mp2_tot, res["return_result"], atol=atol)
Exemplo n.º 27
0
def test_atom_labels(qcprog, basis, keywords):
    kmol = qcel.models.Molecule.from_data("""
      H       0 0 0
      H5      5 0 0
      H_other 0 5 0
      H_4sq   5 5 0
      units au
    """)

    assert compare(["H", "H", "H", "H"], kmol.symbols, "elem")
    assert compare(["", "5", "_other", "_4sq"], kmol.atom_labels, "elbl")

    atin = qcel.models.AtomicInput(
        **{
            "molecule": kmol,
            "model": {
                "method": "mp2",
                "basis": basis
            },
            "driver": "energy",
            "keywords": keywords
        })

    atres = qcng.compute(atin, qcprog)
    pprint.pprint(atres.dict(), width=200)

    nre = 1.0828427
    assert compare_values(
        nre,
        atres.properties.nuclear_repulsion_energy,
        atol=1.0e-4,
        label="nre"
    ), f"nre: {atres.properties.nuclear_repulsion_energy} != {nre}"

    nmo = 36
    assert compare(
        nmo, atres.properties.calcinfo_nmo,
        label="nmo"), f"nmo: {atres.properties.calcinfo_nmo} != {nmo}"

    scf = -1.656138508
    assert compare_values(
        scf, atres.properties.scf_total_energy, atol=3.0e-6, label="scf ene"
    ), f"scf ene: {atres.properties.scf_total_energy} != {scf}"

    mp2 = -1.7926264513
    assert compare_values(mp2, atres.return_result, atol=3.0e-6,
                          label="ene"), f"ene: {atres.return_result} != {mp2}"
def test_dibromobutRS_SR():
    mol, data = dibromobutRS.align(dibromobutSR,
                                   do_plot=do_plot,
                                   verbose=verbose,
                                   uno_cutoff=uno_cutoff,
                                   run_mirror=True)
    assert compare_values(0.004, data['rmsd'], '2,3-dibromobutane SR, RS', atol=1.e-3)
    assert compare(True, data['mill'].mirror, '2,3-dibromobutane SR, RS identical')
Exemplo n.º 29
0
def test_center_supercell():
    """Checks the routine to read the supercell XYZ file and create
    Numpy arrays from it containing the center of the supercell, its
    coordinates and elements."""

    args = [
        '', '-i', 'crystalatte/data/cif/Ammonia.cif', '-o', 'sc.xyz', '-b',
        '1', '1', '1', '-r'
    ]
    crystalatte.cif_main(args)

    # Execute the main function of crystalatte and retrieve the N-mers dictionary.
    scell_geom_max_coords, scell_geom, scell_elem = crystalatte.center_supercell(
        "sc.xyz", 2)

    scgmc = np.array([4.84761994, 4.84761994, 4.84761994])
    sce = np.array([
        'N', 'N', 'N', 'N', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H',
        'H', 'H'
    ])

    l_scg = [[-0.91910799, 3.92851196, 3.16646478],
             [3.92851196, 3.16646478, -0.91910799],
             [3.16646478, -0.91910799, 3.92851196],
             [-1.68115516, -1.68115516, -1.68115516],
             [2.3947252, 3.71327782, 0.],
             [-1.46592103, 4.84761994, 4.70025154],
             [-2.45289475, 3.38169892,
              2.24735679], [0., 2.3947252, 3.71327782],
             [4.84761994, 4.70025154, -1.46592103],
             [3.38169892, 2.24735679, -2.45289475],
             [2.24735679, -2.45289475,
              3.38169892], [3.71327782, 0., 2.3947252],
             [4.70025154, -1.46592103, 4.84761994],
             [-2.60026315, -0.1473684, -1.13434212],
             [-1.13434212, -2.60026315, -0.1473684],
             [-0.1473684, -1.13434212, -2.60026315]]

    scg = np.array(l_scg)

    assert compare_values(scgmc, scell_geom_max_coords)
    assert compare_values(scg, scell_geom)
    assert compare(sce, scell_elem)

    # Clean-up generated test files
    subprocess.call(["rm", "sc.xyz"])
Exemplo n.º 30
0
def test_nonphysical_spec():
    mol = qcel.models.Molecule(symbols=["He"],
                               masses=[100],
                               geometry=[0, 0, 0],
                               nonphysical=True)
    assert compare_values([100.0], mol.masses, "nonphysical mass")

    print(mol.to_string(dtype="psi4"))
def test_dibromobutSS_RR():
    mol, data = dibromobutSS.align(dibromobutRR,
                                   do_plot=do_plot,
                                   verbose=verbose,
                                   uno_cutoff=uno_cutoff,
                                   run_mirror=run_mirror)
    assert compare_values(1.296e-2, data['rmsd'], '2,3-dibromobutane RR, SS', atol=1.e-3)
    assert compare(True, data['mill'].mirror, '2,3-dibromobutane RR, SS enantiomers')
Exemplo n.º 32
0
def test_qcdb__energy_d3():
    eneyne = qcdb.set_molecule(seneyne)
    eneyne.update_geometry()

    E, jrec = qcdb.energy('d3-b3lyp-d2', return_wfn=True)
    assert compare_values(ref['eneyne']['B3LYP-D2']['dimer'], E, 7, 'P: Ethene-Ethyne -D2')
    assert compare_values(ref['eneyne']['B3LYP-D2']['dimer'], jrec['qcvars']['DISPERSION CORRECTION ENERGY'].data, 7,
                          tnm())
    assert compare_values(ref['eneyne']['B3LYP-D2']['dimer'],
                          jrec['qcvars']['B3LYP-D2 DISPERSION CORRECTION ENERGY'].data, 7, tnm())

    mA = eneyne.extract_subsets(1)

    E, jrec = qcdb.energy('d3-b3lyp-d3bj', return_wfn=True, molecule=mA)
    assert compare_values(ref['eneyne']['B3LYP-D3(BJ)']['mA'], E, 7, tnm())
    assert compare_values(ref['eneyne']['B3LYP-D3(BJ)']['mA'], jrec['qcvars']['DISPERSION CORRECTION ENERGY'].data, 7,
                          tnm())
    assert compare_values(ref['eneyne']['B3LYP-D3(BJ)']['mA'],
                          jrec['qcvars']['B3LYP-D3(BJ) DISPERSION CORRECTION ENERGY'].data, 7, tnm())