def test_forcefield(self): atoms = {'H': 'H', 'C': 'C', 'O': 'O'} bonds = {(u'C', u'O'): [1000, 1.4115], (u'C', u'H'): [1000, 1.1041], (u'C', u'C'): [1000, 1.5075]} angles = {(u'C', u'C', u'H'): [42.9, 110.1], (u'H', u'C', u'H'): [38.5, 109.47], (u'H', u'C', u'O'): [56.0, 109.48], (u'C', u'C', u'O'): [86.0, 108.54], (u'C', u'O', u'C'): [74.5, 108.05]} dihedrals = {(u'H', u'C', u'O', u'C'): [0.0, 0.0, -0.73, 0.0], (u'H', u'C', u'C', u'O'): [0.0, 0.0, 0.28, 0.0], (u'C', u'C', u'O', u'C'): [1.76, 0.67, 0.04, 0.0], (u'H', u'C', u'C', u'H'): [0.0, 0.0, 0.28, 0.0], (u'O', u'C', u'C', u'O'): [0.41, -2.1, -0.6, -0.82]} pairs = {(u'C', u'C'): [14976.0, 0.3236, 637.6], (u'H', u'H'): [2649.6, 0.2674, 27.22], (u'O', u'O'): [75844.8, 0.2461, 396.9]} self.assertEqual(self.forcefield.atoms, atoms) self.assertEqual(self.forcefield.bonds, bonds) self.assertEqual(self.forcefield.angles, angles) self.assertEqual(self.forcefield.dihedrals, dihedrals) self.assertEqual(self.forcefield.pairs, pairs) ff = ForceField.from_dict(self.forcefield.as_dict()) self.assertEqual(ff.atoms, atoms) self.assertEqual(ff.bonds, bonds) self.assertEqual(ff.angles, angles) self.assertEqual(ff.dihedrals, dihedrals) self.assertEqual(ff.pairs, pairs)
def setUp(self): self.polymer_linear = Molecule.from_file( os.path.join(test_dir, "polymer_linear.xyz")) charges = [-0.1187, 0.0861, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.1187, 0.0861, 0.0861, 0.0861] ff_map = ["C3", "H3", "H3", "H3", "O", "C2", "H2", "H2", "C2", "H2", "H2", "O", "C2", "H2", "H2", "C2", "H2", "H2", "O", "C2", "H2", "H2", "C2", "H2", "H2", "O", "C2", "H2", "H2", "C2", "H2", "H2", "O", "C2", "H2", "H2", "C2", "H2", "H2", "O", "C2", "H2", "H2", "C2", "H2", "H2", "O", "C3", "H3", "H3", "H3"] self.polymer_linear.add_site_property("charge", charges) self.polymer_linear.add_site_property("ff_map", ff_map) self.topology = Topology.from_molecule(self.polymer_linear) self.forcefield = ForceField.from_file( os.path.join(test_dir, "ffmap_data.yaml")) box_size = [[0.0, 50], [0.0, 50], [0.0, 50]] self.lammps_ff_data = LammpsForceFieldData.from_forcefield_and_topology( [self.polymer_linear], [1], box_size, self.polymer_linear, self.forcefield, [self.topology])
def setUpClass(cls): polymer_chain = Molecule.from_file(os.path.join(test_dir, "polymer_chain.xyz")) polymer_linear = Molecule.from_file(os.path.join(test_dir, "polymer_linear.xyz")) cls.polymer_matrix = Molecule.from_file(os.path.join(test_dir, "polymer_matrix.xyz")) charges = [-0.1187, 0.0861, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861, 0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.1187, 0.0861, 0.0861, 0.0861] polymer_linear.add_site_property("charge", charges) topology = Topology.from_molecule(polymer_linear) cls.polymer_linear_ff_decorated = Molecule.from_file( os.path.join(test_dir,"polymer_linear.xyz")) ff_map = ['C2', 'H3', 'H2', 'H3', 'O', 'C3', 'H2', 'H3', 'C2', 'H3', 'H2', 'O', 'C2', 'H3', 'H2', 'C3', 'H2', 'H3', 'O', 'C3', 'H2', 'H3', 'C2', 'H3', 'H2', 'O', 'C2', 'H3', 'H2', 'C3', 'H2', 'H3', 'O', 'C3', 'H2', 'H3', 'C2', 'H3', 'H2', 'O', 'C2', 'H3', 'H2', 'C3', 'H2', 'H3', 'O', 'C3', 'H2', 'H3', 'H2'] cls.polymer_linear_ff_decorated.add_site_property("ff_map", ff_map) atoms = OrderedDict([("C", "C"), ("H", "H"), ("O", "O")]) bonds = OrderedDict([((u'C', u'O'), [1000, 1.4115]), ((u'C', u'H'), [1000, 1.1041]), ((u'C', u'C'), [1000, 1.5075])]) pairs = OrderedDict([((u'O', u'O'), [75844.8, 0.2461, 396.9]), ((u'H', u'H'), [2649.6, 0.2674, 27.22]), ((u'C', u'C'), [14976.0, 0.3236, 637.6])]) angles = OrderedDict([((u'C', u'C', u'H'), [42.9, 110.1]), ((u'H', u'C', u'H'), [38.5, 109.47]), ((u'H', u'C', u'O'), [56.0, 109.48]), ((u'C', u'C', u'O'), [86.0, 108.54]), ((u'C', u'O', u'C'), [74.5, 108.05])]) dihedrals = OrderedDict([((u'H', u'C', u'O', u'C'), [0.0, 0.0, -0.73, 0.0]), ((u'H', u'C', u'C', u'H'), [0.0, 0.0, 0.28, 0.0]), ((u'C', u'C', u'O', u'C'), [1.76, 0.67, 0.04, 0.0]), ((u'H', u'C', u'C', u'O'), [0.0, 0.0, 0.28, 0.0]), ((u'O', u'C', u'C', u'O'), [0.41, -2.1, -0.6, -0.82])]) forcefield = ForceField(atoms, bonds, angles, dihedrals=dihedrals, pairs=pairs) cls.molecules = [polymer_chain] * 3 cls.mols_number = [7, 3, 1] box_size = [[0.0, 50], [0.0, 50], [0.0, 50]] cls.topologies = [topology] * len(cls.molecules) cls.lammps_ff_data_1 = LammpsForceFieldData.from_forcefield_and_topology( cls.molecules, cls.mols_number, box_size, cls.polymer_matrix, forcefield, cls.topologies)
def _get_gaussian_ff_top_single(self, filename=None): """ run antechamber using gaussian output file, then run parmchk to generate missing force field parameters. Store and return the force field and topology information in ff_mol. Args: filename: gaussian output file of the molecule Returns: Amberff namedtuple object that contains information on force field and topology """ scratch = tempfile.gettempdir() Amberff = namedtuple("Amberff", ["force_field", "topology"]) with ScratchDir(scratch, copy_from_current_on_enter=True, copy_to_current_on_exit=True) as d: # self._convert_to_pdb(mol, 'mol.pdb') # self.molname = filename.split('.')[0] self._run_antechamber(filename) self._run_parmchk() # if antechamber can't find parameters go to gaff_example.dat try: top = Topology.from_file('mol.rtf') except TopCorruptionException: correct_corrupted_top_files('mol.rtf', 'gaff_data.txt') top = Topology.from_file('mol.rtf') try: gff = ForceField.from_file('mol.frcmod') except FFCorruptionException: correct_corrupted_frcmod_files('ANTECHAMBER.FRCMOD', 'gaff_data.txt') gff = ForceField.from_file('ANTECHAMBER.FRCMOD') # gff.set_atom_mappings('ANTECHAMBER_AC.AC') # gff.read_charges() # decorate the molecule with the sire property "atomname" #mol.add_site_property("atomname", (list(gff.atom_index.values()))) return Amberff(gff, top)
def setUp(self): # DMOE = Dimethoxyethane self.dmoe = Molecule.from_file(os.path.join(test_dir, "dmoe.xyz")) dmoe_charges = [-0.10, 0.09, 0.09, 0.09, -0.34, -0.01, 0.09, 0.09, -0.01, 0.09, 0.09, -0.34, -0.10, 0.09, 0.09, 0.09] self.dmoe.add_site_property("charge", dmoe_charges) ff_map = ["C3", "H3", "H3", "H3", "O", "C2", "H2", "H2", "C2", "H2", "H2", "O", "C3", "H3", "H3", "H3"] self.dmoe.add_site_property("ff_map", ff_map) self.topology = Topology.from_molecule(self.dmoe, ff_map="ff_map") self.forcefield = ForceField.from_file( os.path.join(test_dir, "ffmap_data.yaml")) self.box_size = [[0.0, 10], [0.0, 10], [0.0, 10]] self.lammps_ff_data = \ LammpsForceFieldData.from_forcefield_and_topology( [self.dmoe], [1], self.box_size, self.dmoe, self.forcefield, [self.topology])
def setUpClass(cls): atoms = OrderedDict([('hw', 'h'), ('ow', 'o')]) bonds = OrderedDict([((u'hw', u'ow'), [553.0, 0.957]), ((u'hw', u'hw'), [553.0, 1.513])]) angles = OrderedDict([((u'hw', u'ow', u'hw'), [0.0, 104.52])]) vdws = OrderedDict([(u'hw', [0.0, 0.0]), (u'ow', [1.7683, 0.1520])]) forcefield = ForceField(atoms, bonds, angles, vdws=vdws) h2o_coords = [[9.626, 6.787, 12.673], [9.626, 8.420, 12.673], [10.203, 7.604, 12.673]] h2o = Molecule(["H", "H", "O"], h2o_coords) # h2o, h-o, h-o, h=1, h=2, o=3 top_atoms = [['h', 'hw'], ['o', 'ow']] top_bonds = [[1, 3, ('hw', 'ow')], [2, 3, ('hw', 'ow')]] top_angles = [[1, 3, 2, ('hw', 'ow', 'hw')]] topology = Topology(top_atoms, top_bonds, top_angles) mols = [h2o] mols_number = [1] box_size = [[0.0, 10.0], [0.0, 10.0], [0.0, 10.0]] molecule = h2o topologies = [topology] cls.lammps_ff_data = LammpsForceFieldData.from_forcefield_and_topology( mols, mols_number, box_size, molecule, forcefield, topologies)
def setUpClass(cls): polymer = Molecule.from_file(os.path.join(test_dir, "polymer.xyz")) cls.topology = Topology.from_molecule(polymer, tol=0.1) cls.forcefield = ForceField.from_file(os.path.join(test_dir, "ff_data.yaml"))
def setUpClass(cls): polymer = Molecule.from_file(os.path.join(test_dir, "polymer.xyz")) cls.monomer = Molecule.from_file(os.path.join(test_dir, "monomer.xyz")) cls.topology = Topology.from_molecule(polymer, tol=0.1) cls.forcefield = ForceField.from_file( os.path.join(test_dir, "ff_data.yaml"))
def test_forcefield_serialization(self): ff = ForceField.from_dict(self.forcefield.as_dict()) self.assertDictEqual(self.forcefield.as_dict(), ff.as_dict())