def test_orbital_based_from_molecule_orbital_expression_ch4_uhf_ccpvdz(): # load data computed with Fortran code with path("chemtools.data", "data_fortran_ch4_uhf_ccpvdz.npz") as fname: data = np.load(str(fname)) # test from_molecule initialization with exp_beta & check against Fortran code with path("chemtools.data", "ch4_uhf_ccpvdz.fchk") as fname: molecule = Molecule.from_file(fname) tool = DFTBasedTool(molecule, data["points"]) check_orbital_expression(tool, data) # test from_molecule initialization without exp_beta & check against Fortran code del molecule._exp_beta with path("chemtools.data", "ch4_uhf_ccpvdz.fchk") as fname: molecule = Molecule.from_file(fname) tool = DFTBasedTool(molecule, data["points"]) check_orbital_expression(tool, data)
def test_orbital_based_raises(): # check file name assert_raises(ValueError, DFTBasedTool.from_file, "gibberish", np.array([0.0, 1.0])) with path("chemtools.data", "h2o_dimer_pbe_sto3g.wfn") as fname: assert_raises(ValueError, DFTBasedTool.from_file, fname, np.array([0.0, 1.0])) assert_raises(ValueError, DFTBasedTool.from_file, fname, np.array([0.0, 1.0])) with path("chemtools.data", "h2o_dimer_pbe_sto3g.wfn") as fname: assert_raises(ValueError, DFTBasedTool.from_file, fname, np.array([0.0, 1.0])) assert_raises(ValueError, DFTBasedTool.from_file, fname, np.array([0.0, 1.0, 0.0])) assert_raises(ValueError, DFTBasedTool.from_file, fname, np.array([[0, 1], [1, 0.]])) # check spin argument tool = DFTBasedTool.from_file(fname, np.array([[0., 0., 0.]])) assert_raises(KeyError, tool._compute_orbital_expression, np.array([9]), spin="error") assert_raises(KeyError, tool._compute_orbital_expression, np.array([9]), spin="alph") assert_raises(KeyError, tool._compute_orbital_expression, np.array([9]), spin="bet")
def test_orbital_based_h2o_b3lyp_sto3g(): # points array points = np.array([[-3., -3., -3.], [-3., -3., 0.], [-3., -3., 3.], [-3., 0., -3.], [-3., 0., 0.], [-3., 0., 3.], [-3., 3., -3.], [-3., 3., 0.], [-3., 3., 3.], [0., -3., -3.], [0., -3., 0.], [0., -3., 3.], [0., 0., -3.], [0., 0., 0.], [0., 0., 3.], [0., 3., -3.], [0., 3., 0.], [0., 3., 3.], [3., -3., -3.], [3., -3., 0.], [3., -3., 3.], [3., 0., -3.], [3., 0., 0.], [3., 0., 3.], [3., 3., -3.], [3., 3., 0.], [3., 3., 3.]]) # initialize OrbitalLocalTool from_file with path("chemtools.data", "water_b3lyp_sto3g.fchk") as fname: tool = DFTBasedTool.from_file(fname, points) # check mep against Fortran code expected = np.array([ -0.01239766, -0.02982537, -0.02201149, -0.01787292, -0.05682143, -0.02503563, -0.00405942, -0.00818772, -0.00502268, 0.00321181, -0.03320573, -0.02788605, 0.02741914, 1290.21135500, -0.03319778, 0.01428660, 0.10127092, 0.01518299, 0.01530548, 0.00197975, -0.00894206, 0.04330806, 0.03441681, -0.00203017, 0.02272626, 0.03730846, 0.01463959 ]) assert_array_almost_equal(tool.electrostatic_potential, expected, decimal=6) # check spin chemical potential against manual calculation result = tool.compute_spin_chemical_potential(25000.0) assert_array_almost_equal(result, [0.10821228040, 0.10821228040], decimal=6)
def test_orbital_based_from_file_ch4_uhf_ccpvdz(): # load data computed with Fortran code with path("chemtools.data", "data_fortran_ch4_uhf_ccpvdz.npz") as fname: data = np.load(str(fname)) # test from_file initialization & check against Fortran code with path("chemtools.data", "ch4_uhf_ccpvdz.fchk") as fname: tool = DFTBasedTool.from_file(fname, data["points"]) check_orbital_based_properties(tool, data)