Esempio n. 1
0
def test_global_quadratic_from_file_fmo_h2o_anion_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -1.93118022E-01, -2.69116912E-01, -7.635212549312298E+01
    with path("chemtools.data", "h2o_q-1_ub3lyp_ccpvtz.fchk") as fname:
        model1 = GlobalConceptualDFT.from_file(fname, "quadratic")
        model2 = GlobalConceptualDFT.from_file([fname], "quadratic")
    # check quadratic global conceptual DFT model from a fname given as string
    check_global_reactivity_quadratic(model1, ip, ea, energy, 11)
    # check quadratic global conceptual DFT model from a fname given as a list of string
    check_global_reactivity_quadratic(model2, ip, ea, energy, 11)
Esempio n. 2
0
def test_global_linear_from_file_fmo_h2o_anion_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -1.93118022E-01, -2.69116912E-01, -7.635212549312298E+01
    with path('chemtools.data', 'h2o_q-1_ub3lyp_ccpvtz.fchk') as fname:
        model1 = GlobalConceptualDFT.from_file(fname, "linear")
        model2 = GlobalConceptualDFT.from_file([fname], "linear")
    # check from_file
    check_global_reactivity_linear(model1, ip, ea, energy, 11)
    # check from_file given as a list
    check_global_reactivity_linear(model2, ip, ea, energy, 11)
Esempio n. 3
0
def test_global_quadratic_from_file_fmo_h2o_cation_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -(-8.47044131E-01), -(
        -6.19391831E-01), -7.599493522312368E+01
    with path("chemtools.data", "h2o_q+1_ub3lyp_ccpvtz.fchk") as fname:
        model1 = GlobalConceptualDFT.from_file(fname, "quadratic")
        model2 = GlobalConceptualDFT.from_file([fname], "quadratic")
    # check quadratic global conceptual DFT model from a fname given as string
    check_global_reactivity_quadratic(model1, ip, ea, energy, 9)
    # check quadratic global conceptual DFT model from a fname given as a list of string
    check_global_reactivity_quadratic(model2, ip, ea, energy, 9)
Esempio n. 4
0
def test_global_quadratic_from_file_fmo_h2o_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -(
        -3.09871604E-01), -2.48704636E-02, -7.645980351270224E+01
    with path('chemtools.data', 'h2o_q+0_ub3lyp_ccpvtz.fchk') as fname:
        model1 = GlobalConceptualDFT.from_file(fname, "quadratic")
        model2 = GlobalConceptualDFT.from_file([fname], "quadratic")
    # check from_file
    check_global_reactivity_quadratic(model1, ip, ea, energy, 10)
    # check from_file given as a list
    check_global_reactivity_quadratic(model2, ip, ea, energy, 10)
Esempio n. 5
0
def test_global_quadratic_from_file_fmo_ch4_wfn():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -(
        -5.43101269E-01), -1.93295185E-01, -4.019868797400735E+01
    with path('chemtools.data', 'ch4_uhf_ccpvdz.wfn') as fname:
        model1 = GlobalConceptualDFT.from_file(fname, "quadratic")
        model2 = GlobalConceptualDFT.from_file([fname], "quadratic")
    # check from_file
    check_global_reactivity_quadratic(model1, ip, ea, energy, 10)
    # check from_file given as a list
    check_global_reactivity_quadratic(model2, ip, ea, energy, 10)
Esempio n. 6
0
def test_global_linear_from_file_fmo_h2o_cation_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -(-8.47044131E-01), -(
        -6.19391831E-01), -7.599493522312368E+01
    with path('chemtools.data', 'h2o_q+1_ub3lyp_ccpvtz.fchk') as fname:
        model1 = GlobalConceptualDFT.from_file(fname, "linear")
        model2 = GlobalConceptualDFT.from_file([fname], "linear")
    # check from_file
    check_global_reactivity_linear(model1, ip, ea, energy, 9)
    # check from_file given as a list
    check_global_reactivity_linear(model2, ip, ea, energy, 9)
Esempio n. 7
0
def test_global_quadratic_from_molecule_fmo_ch4_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -(
        -5.43101269E-01), -1.93295185E-01, -4.019868797400735E+01
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as fname:
        molecule = Molecule.from_file(fname)
    # check from_molecule
    model = GlobalConceptualDFT.from_molecule(molecule, "quadratic")
    check_global_reactivity_quadratic(model, ip, ea, energy, 10)
    # check from_molecule given as a list
    model = GlobalConceptualDFT.from_molecule([molecule], "quadratic")
    check_global_reactivity_quadratic(model, ip, ea, energy, 10)
Esempio n. 8
0
def test_global_linear_from_molecule_fmo_h2o_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -(
        -3.09871604E-01), -2.48704636E-02, -7.645980351270224E+01
    with path('chemtools.data', 'h2o_q+0_ub3lyp_ccpvtz.fchk') as fname:
        molecule = Molecule.from_file(fname)
    # check from_molecule
    model = GlobalConceptualDFT.from_molecule(molecule, "linear")
    check_global_reactivity_linear(model, ip, ea, energy, 10)
    # check from_molecule given as a list
    model = GlobalConceptualDFT.from_molecule([molecule], "linear")
    check_global_reactivity_linear(model, ip, ea, energy, 10)
Esempio n. 9
0
def test_global_linear_from_file_fmo_ch4_fchk():
    # FMO: ip = -E(H**O) & ea = -E(LUMO)
    ip, ea, energy = -(
        -5.43101269E-01), -1.93295185E-01, -4.019868797400735E+01
    # check from_file
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as fname:
        model = GlobalConceptualDFT.from_file(fname, "linear")
    check_global_reactivity_linear(model, ip, ea, energy, 10)
    # check from_file given as a list
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as fname:
        model = GlobalConceptualDFT.from_file([fname], "linear")
    check_global_reactivity_linear(model, ip, ea, energy, 10)
Esempio n. 10
0
def test_global_conceptual_raises():
    # dictionary of energy values
    values = {0.0: 0.0, 1.0: -0.5, 2.0: -0.45}
    # check invalid model
    assert_raises(ValueError, GlobalConceptualDFT, values, "quad")
    assert_raises(ValueError, GlobalConceptualDFT, values, "Gibberish")
    assert_raises(NotImplementedError, GlobalConceptualDFT, values, "general")
    # check invalid coordinates
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear",
                  np.array([0., 0., 0.]))
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear",
                  np.array([[0., 0.]]))
    # check invalid atomic numbers
    coord = np.array([[0., 0., 0.]])
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear", coord, [])
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear", coord,
                  [1, 1])
    # check invalid number of electrons
    values = {"0": 0.0, 1: -0.5, 2: -0.45}
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear", coord)
    assert_raises(ValueError, GlobalConceptualDFT, values, "quadratic", coord)
    values = {0.5: 0.0, 1.3: -0.5, 2: -0.45}
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear", coord)
    assert_raises(ValueError, GlobalConceptualDFT, values, "quadratic", coord)
    values = {0: 0.0, 1: -0.5, 3: -0.45}
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear")
    assert_raises(ValueError, GlobalConceptualDFT, values, "quadratic")
    values = {0: 0.0, 1: -0.5, 2: -0.45, 3: -0.4}
    assert_raises(ValueError, GlobalConceptualDFT, values, "linear", coord)
    assert_raises(ValueError, GlobalConceptualDFT, values, "quadratic", coord)
    # check non-existing attribute
    model = GlobalConceptualDFT({0.0: 0.0, 1.0: -0.5, 2.0: -0.45}, "quadratic")
    assert_raises(AttributeError, getattr, model, "mu_plus")
    assert_raises(AttributeError, getattr, model, "gibberish")
    # check molecule file inconsistency
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as file1:
        with path('chemtools.data', 'o2_uhf.fchk') as file2:
            fnames = [file1, file2]
            assert_raises(ValueError, GlobalConceptualDFT.from_file, fnames,
                          "linear")
            assert_raises(ValueError, GlobalConceptualDFT.from_file, fnames,
                          "quadratic")
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as fname:
        assert_raises(ValueError, GlobalConceptualDFT.from_file,
                      [fname, fname], "linear")
        assert_raises(ValueError, GlobalConceptualDFT.from_file,
                      [fname, fname], "quadratic")
        assert_raises(ValueError, GlobalConceptualDFT.from_file,
                      [fname, fname, fname], "linear")
        assert_raises(ValueError, GlobalConceptualDFT.from_file,
                      [fname, fname, fname], "quadratic")
Esempio n. 11
0
def test_global_quadratic_fd_h2o_fchk():
    ep, e0, en = -7.599493522312368E+01, -7.645980351270224E+01, -7.635212549312298E+01
    ip, ea, energy = ep - e0, e0 - en, e0
    # check quadratic global conceptual DFT model
    with path("chemtools.data", "h2o_q+0_ub3lyp_ccpvtz.fchk") as file1:
        with path("chemtools.data", "h2o_q-1_ub3lyp_ccpvtz.fchk") as file2:
            with path("chemtools.data", "h2o_q+1_ub3lyp_ccpvtz.fchk") as file3:
                fname = [file1, file2, file3]
                model1 = GlobalConceptualDFT.from_file(fname, "quadratic")
                molecule = [Molecule.from_file(item) for item in fname]
                model2 = GlobalConceptualDFT.from_molecule(
                    molecule, "quadratic")
    # cehck from_file
    check_global_reactivity_quadratic(model1, ip, ea, energy, 10)
    # check from_molecule
    check_global_reactivity_quadratic(model2, ip, ea, energy, 10)
    # rearrange input files
    with path("chemtools.data", "h2o_q+1_ub3lyp_ccpvtz.fchk") as file1:
        with path("chemtools.data", "h2o_q+0_ub3lyp_ccpvtz.fchk") as file2:
            with path("chemtools.data", "h2o_q-1_ub3lyp_ccpvtz.fchk") as file3:
                fname = [file1, file2, file3]
                # check from_file
                model1 = GlobalConceptualDFT.from_file(fname, "quadratic")
                molecule = [Molecule.from_file(item) for item in fname]
                model2 = GlobalConceptualDFT.from_molecule(
                    molecule, "quadratic")
    check_global_reactivity_quadratic(model1, ip, ea, energy, 10)
    # check from_molecule
    check_global_reactivity_quadratic(model2, ip, ea, energy, 10)
    # rearrange input files
    with path("chemtools.data", "h2o_q-1_ub3lyp_ccpvtz.fchk") as file1:
        with path("chemtools.data", "h2o_q+1_ub3lyp_ccpvtz.fchk") as file2:
            with path("chemtools.data", "h2o_q+0_ub3lyp_ccpvtz.fchk") as file3:
                fname = [file1, file2, file3]
                model1 = GlobalConceptualDFT.from_file(fname, "quadratic")
                molecule = [Molecule.from_file(item) for item in fname]
                model2 = GlobalConceptualDFT.from_molecule(
                    molecule, "quadratic")
    # check from_file
    check_global_reactivity_quadratic(model1, ip, ea, energy, 10)
    # check from_molecule
    check_global_reactivity_quadratic(model2, ip, ea, energy, 10)