diff --git a/hoomd_organics/base/molecule.py b/hoomd_organics/base/molecule.py index f4a3c9e2..808280b5 100644 --- a/hoomd_organics/base/molecule.py +++ b/hoomd_organics/base/molecule.py @@ -261,6 +261,12 @@ def _validate_force_field(self): def assign_mol_name(self, name): for mol in self.molecules: mol.name = name + # TODO: This is a hack to make sure that the name of the children is + # also updated, so that when converting to gmso, all the sites have + # the correct name. This needs additional investigation into gmso's + # convert mbuilder to gmso functionality. + for child in mol.children: + child.name = name class Polymer(Molecule): diff --git a/hoomd_organics/tests/base/test_system.py b/hoomd_organics/tests/base/test_system.py index ce6a1226..2c7672a3 100644 --- a/hoomd_organics/tests/base/test_system.py +++ b/hoomd_organics/tests/base/test_system.py @@ -26,6 +26,7 @@ def test_single_mol_type(self, benzene_molecule): ) assert system.n_mol_types == 1 assert len(system.all_molecules) == len(benzene_mols.molecules) + assert system.gmso_system.is_typed() assert len(system.hoomd_forcefield) > 0 assert system.n_particles == system.hoomd_snapshot.particles.N assert system.hoomd_snapshot.particles.types == ["opls_145", "opls_146"] @@ -47,6 +48,7 @@ def test_multiple_mol_types(self, benzene_molecule, ethane_molecule): ) assert system.all_molecules[0].name == "0" assert system.all_molecules[-1].name == "1" + assert system.gmso_system.is_typed() assert len(system.hoomd_forcefield) > 0 assert system.n_particles == system.hoomd_snapshot.particles.N assert system.hoomd_snapshot.particles.types == [ @@ -74,6 +76,7 @@ def test_multiple_mol_types_different_ff( ) + len(pps_mol.molecules) assert system.all_molecules[0].name == "0" assert system.all_molecules[-1].name == "1" + assert system.gmso_system.is_typed() assert len(system.hoomd_forcefield) > 0 for hoomd_force in system.hoomd_forcefield: if isinstance(hoomd_force, hoomd.md.pair.LJ): @@ -90,6 +93,19 @@ def test_multiple_mol_types_different_ff( "sh", ] + def test_system_from_mol2_mol_parameterization(self, benzene_molecule_mol2): + benzene_mol = benzene_molecule_mol2(n_mols=3) + system = Pack( + molecules=[benzene_mol], + density=0.8, + r_cut=2.5, + force_field=OPLS_AA(), + auto_scale=True, + ) + assert system.gmso_system.is_typed() + assert len(system.hoomd_forcefield) > 0 + assert system.n_particles == system.hoomd_snapshot.particles.N + def test_remove_hydrogen(self, benzene_molecule): benzene_mol = benzene_molecule(n_mols=3) system = Pack( @@ -100,6 +116,7 @@ def test_remove_hydrogen(self, benzene_molecule): auto_scale=True, remove_hydrogens=True, ) + assert system.gmso_system.is_typed() assert len(system.hoomd_forcefield) > 0 assert list(system.hoomd_forcefield[0].params.keys()) == [ ("opls_145", "opls_145") diff --git a/hoomd_organics/tests/base_test.py b/hoomd_organics/tests/base_test.py index f12dec80..a7f1c241 100644 --- a/hoomd_organics/tests/base_test.py +++ b/hoomd_organics/tests/base_test.py @@ -113,6 +113,14 @@ def _benzene_molecule(n_mols): return _benzene_molecule + @pytest.fixture() + def benzene_molecule_mol2(self, benzene_mol2): + def _benzene_molecule(n_mols): + benzene = Molecule(num_mols=n_mols, file=benzene_mol2) + return benzene + + return _benzene_molecule + @pytest.fixture() def ethane_molecule(self, ethane_smiles): def _ethane_molecule(n_mols):