def test_finite_diff_with_water_2(self): with path("saddle.optimizer.test.data", "water.xyz") as mol_path: mol = Utils.load_file(mol_path) red_int = ReducedInternal(mol.coordinates, mol.numbers, 0, 1) red_int.auto_select_ic() with path("saddle.optimizer.test.data", "water_old.fchk") as fchk_file: red_int.energy_from_fchk(fchk_file) assert red_int.energy - 75.99264142 < 1e-6 red_int.select_key_ic(0) ref_v = np.array([ [-1.00000000e00, -4.17292908e-16, 0.00000000e00], [2.10951257e-16, -4.69422035e-01, -8.82973926e-01], [3.39185671e-16, -8.82973926e-01, 4.69422035e-01], ]) ref_v2 = np.dot(ref_v, ref_v.T) assert np.allclose(ref_v2, np.dot(red_int.vspace, red_int.vspace.T)) red_int.set_vspace(ref_v) wt_p1 = PathPoint(red_int=red_int) step = [-0.001, 0, 0] wt_p2 = wt_p1.copy() wt_p2.update_coordinates_with_delta_v(step) # fchk file is for -0.001 with path("saddle.optimizer.test.data", "water_new_2.fchk") as fchk_file_new: wt_p2._instance.energy_from_fchk(fchk_file_new) wt_p2._instance.align_vspace(wt_p1._instance) assert np.allclose(wt_p1.vspace, wt_p2.vspace) result = PathPoint._calculate_finite_diff_h(wt_p1, wt_p2, -0.001) assert np.allclose(result, wt_p1._instance.v_hessian[:, 0], atol=1e-2)
def test_finite_different_with_water_3(self): with path("saddle.optimizer.test.data", "water.xyz") as mol_path: mol = Utils.load_file(mol_path) red_int = ReducedInternal(mol.coordinates, mol.numbers, 0, 1) red_int.auto_select_ic() red_int.add_bond(0, 2) with path("saddle.optimizer.test.data", "water_old.fchk") as fchk_file: red_int.energy_from_fchk(fchk_file) assert red_int.energy - 75.99264142 < 1e-6 red_int.select_key_ic(0) wt_p1 = PathPoint(red_int=red_int) step = [0.001, 0, 0] wt_p2 = wt_p1.copy() wt_p2.update_coordinates_with_delta_v(step) with path("saddle.optimizer.test.data", "water_new_3.fchk") as fchk_file_new: wt_p2._instance.energy_from_fchk(fchk_file_new) wt_p2._instance.align_vspace(wt_p1._instance) assert np.allclose(wt_p1.vspace, wt_p2.vspace, atol=1e-2) result = PathPoint._calculate_finite_diff_h(wt_p1, wt_p2, 0.001) assert np.allclose(result, wt_p1._instance.v_hessian[:, 0], atol=1e-2)
def test_select_key_ic(self): with path("saddle.test.data", "water.xyz") as mol_path: mol = Utils.load_file(mol_path) mol_1 = ReducedInternal(mol.coordinates, mol.numbers, 0, 1) mol_1.add_bond(1, 0) mol_1.add_bond(1, 2) mol_1.add_angle(0, 1, 2) mol_1.select_key_ic(0) assert mol_1.key_ic_number == 1 mol_1.select_key_ic(2) assert mol_1.key_ic_number == 1 mol_1.select_key_ic(0, 1, 2) assert mol_1.key_ic_number == 3