def save_lammpsdata(self, filename, traj, forcefield, force_overwrite=False, **kwargs): """ """ from foyer.forcefield import apply_forcefield import intermol.lammps as lmp # Create separate file paths for .gro and .top filepath, filename = os.path.split(filename) basename = os.path.splitext(filename)[0] inp_filename = os.path.join(filepath, basename + '.input') intermol_system = self.to_intermol() if forcefield: apply_forcefield(intermol_system, forcefield=forcefield) lmp.save(inp_filename, intermol_system)
def save_gromacs(self, filename, structure, forcefield, force_overwrite=False, **kwargs): """ """ from foyer.forcefield import apply_forcefield # Create separate file paths for .gro and .top filepath, filename = os.path.split(filename) basename = os.path.splitext(filename)[0] top_filename = os.path.join(filepath, basename + '.top') gro_filename = os.path.join(filepath, basename + '.gro') if forcefield: structure = apply_forcefield(structure, forcefield=forcefield) structure.save(top_filename, 'gromacs', **kwargs) structure.save(gro_filename, 'gro', **kwargs)
def test_full_parametrization(self): top = os.path.join(self.resource_dir, 'benzene.top') gro = os.path.join(self.resource_dir, 'benzene.gro') ff = os.path.join(self.resource_dir, 'oplsaa.ff/forcefield.itp') structure = pmd.load_file(top, xyz=gro) parametrized = apply_forcefield(structure, forcefield=ff, debug=False) assert sum((1 for at in parametrized.atoms if at.type == 'opls_145')) == 6 assert sum((1 for at in parametrized.atoms if at.type == 'opls_146')) == 6 assert len(parametrized.bonds) == 12 assert all(x.type for x in parametrized.bonds) assert len(parametrized.angles) == 18 assert all(x.type for x in parametrized.angles) assert len(parametrized.rb_torsions) == 24 assert all(x.type for x in parametrized.dihedrals)
def save_hoomdxml(self, filename, structure, forcefield, box=None, **kwargs): """ """ if forcefield: from foyer.forcefield import apply_forcefield structure = apply_forcefield(structure, forcefield=forcefield) if not box: box = self.boundingbox for dim, val in enumerate(self.periodicity): if val: box.lengths[dim] = val box.maxs[dim] = val box.mins[dim] = 0.0 if not val: box.maxs[dim] += 0.25 box.mins[dim] -= 0.25 box.lengths[dim] += 0.5 write_hoomdxml(structure, filename, forcefield, box, **kwargs)
def test_full_parameterization(self, ethane): #ethane.save('ethane.gro', forcefield='opls-aa') intermol_ethane = ethane._to_intermol(molecule_types=[type(ethane)]) apply_forcefield(intermol_ethane, forcefield='opls-aa', debug=False)
mol_name, top_name, list(zip(range(len(generated_opls_types)), generated_opls_types, known_opls_types))) assert all([a == b for a, b in both]), message print("Passed.\n") @pytest.mark.skipif(True, reason='Not implemented yet') def test_full_parameterization(self, ethane): #ethane.save('ethane.gro', forcefield='opls-aa') intermol_ethane = ethane._to_intermol(molecule_types=[type(ethane)]) apply_forcefield(intermol_ethane, forcefield='opls-aa', debug=False) # detect file extension # save to that MD engine from intermol if __name__ == "__main__": # TestOPLS().test_atomtyping('benzene') # TestOPLS().test_atomtyping() from mbuild.examples.ethane.ethane import Ethane import mbuild as mb ethanes = mb.Compound() for _ in range(3): ethanes.add(Ethane()) intermol_ethane = ethanes._to_intermol(molecule_types=[Ethane]) apply_forcefield(intermol_ethane, forcefield='opls-aa', debug=False) # TestOPLS().test_full_parameterization(ethanes)
import os import parmed as pmd from pkg_resources import resource_filename from foyer.forcefield import apply_forcefield resource_dir = resource_filename('foyer', '../opls_validation') top_filename = os.path.join(resource_dir, 'benzene.top') gro_filename = os.path.join(resource_dir, 'benzene.gro') ff_filename = os.path.join(resource_dir, 'oplsaa.ff/forcefield.itp') structure = pmd.load_file(top_filename, xyz=gro_filename) parametrized = apply_forcefield(structure, forcefield=ff_filename, debug=False) parametrized.save('benzene.gro', overwrite=True) parametrized.save('benzene.top', overwrite=True)
list( zip(range(len(generated_opls_types)), generated_opls_types, known_opls_types))) assert all([a == b for a, b in both]), message print("Passed.\n") @pytest.mark.skipif(True, reason='Not implemented yet') def test_full_parameterization(self, ethane): #ethane.save('ethane.gro', forcefield='opls-aa') intermol_ethane = ethane._to_intermol(molecule_types=[type(ethane)]) apply_forcefield(intermol_ethane, forcefield='opls-aa', debug=False) # detect file extension # save to that MD engine from intermol if __name__ == "__main__": # TestOPLS().test_atomtyping('benzene') # TestOPLS().test_atomtyping() from mbuild.examples.ethane.ethane import Ethane import mbuild as mb ethanes = mb.Compound() for _ in range(3): ethanes.add(Ethane()) intermol_ethane = ethanes._to_intermol(molecule_types=[Ethane]) apply_forcefield(intermol_ethane, forcefield='opls-aa', debug=False) # TestOPLS().test_full_parameterization(ethanes)