def test_mol2particles_zero(): position = np.zeros((1, 3)) orientation = util.zero_quaternion(1) mol_vector = np.ones((1, 3)) result = dynamics._util.molecule2particles(position, orientation, mol_vector) assert np.allclose(result, np.ones((1, 3)))
def test_large_rotation(): orientation = util.zero_quaternion(10) dyn = dynamics.Dynamics(0, np.ones(3), np.zeros((10, 3)), orientation) for i in range(10): dyn.add( np.zeros((10, 3)), rowan.from_euler( np.ones(10) * np.pi / 4 * i, np.zeros(10), np.zeros(10)), ) assert np.allclose(np.linalg.norm(dyn.delta_rotation, axis=1), np.pi / 4 * 9)
def test_struct(translation, rotation): translation = np.append(translation, np.zeros((1, 1)), axis=1) init_pos = np.zeros((1, 3)) init_orient = util.zero_quaternion(1) dyn = dynamics.Dynamics(0, np.ones(3) * 10, init_pos, init_orient, wave_number=2.9, molecule=Trimer()) orientation = rowan.from_euler(rotation[:, 0], rotation[:, 1], rotation[:, 2]) dyn.add(translation, orientation) assert np.allclose(dyn.delta_rotation, rotation, atol=2e-7) assert np.allclose(dyn.delta_translation, translation, atol=8e-7)
def test_struct_rotation(): init_pos = np.array([[0.0, 0, 0]]) init_orient = util.zero_quaternion(1) dyn = dynamics.Dynamics(0, np.ones(3) * 10, init_pos, init_orient, wave_number=3.14, molecule=Trimer()) pos1 = np.array([[0.1, 0.1, 0]]) dyn.add(pos1) assert dyn.compute_struct_relax() == 1 pos2 = np.array([[0.4, 0.0, 0]]) dyn.add(pos2) assert dyn.compute_struct_relax() == 1 pos2 = np.array([[0.6, 0.0, 0]]) dyn.add(pos2) assert dyn.compute_struct_relax() == 0