def test_change_dihedral(self): mol = Geometry(TestGeometry.benz_NO2_Cl) atom_args = ("13", "12", "1", "6") original_dihedral = mol.dihedral(*atom_args) # adjust dihedral by 30 degrees mol.change_dihedral(*atom_args, 30, radians=False, adjust=True) self.assertTrue( is_close(mol.dihedral(*atom_args), original_dihedral + np.deg2rad(30))) # set dihedral to 60 deg mol.change_dihedral(*atom_args, 60, radians=False) self.assertTrue(is_close(mol.dihedral(*atom_args), np.deg2rad(60))) # adjust using just two atoms mol.change_dihedral("12", "1", -30, radians=False, adjust=True) self.assertTrue(is_close(mol.dihedral(*atom_args), np.deg2rad(30)))
else: infile = FileReader(("from stdin", "xyz", f)) geom = Geometry(infile) # set dihedral to specified value for dihedral in args.set_ang: vals = four_atoms_and_a_float(dihedral) a1 = geom.find(str(vals[0]))[0] a2 = geom.find(str(vals[1]))[0] a3 = geom.find(str(vals[2]))[0] a4 = geom.find(str(vals[3]))[0] geom.change_dihedral(a1, a2, a3, a4, vals[4], radians=args.radians, adjust=False, as_group=True) #change dihedral by specified amount for dihedral in args.change: vals = four_atoms_and_a_float(dihedral) a1 = geom.find(str(vals[0]))[0] a2 = geom.find(str(vals[1]))[0] a3 = geom.find(str(vals[2]))[0] a4 = geom.find(str(vals[3]))[0] geom.change_dihedral(a1, a2, a3, a4,