Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gmso xml equation compare and scaling, and extracting specific data from FFs #698

Merged
merged 35 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2ca1a8f
gmso xml equation compare and scaling, and extracting specific data f…
bc118 Oct 14, 2022
8a7bf2d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 14, 2022
9af98ee
changed sympy code sections to be compatible with sympy 1.11
bc118 Oct 28, 2022
42c7b71
Merge branch 'mosdef-hub:main' into eqn_compare_utils
bc118 Nov 30, 2022
bfc8781
added some test cases to specific_ff_to_residue, but still a failing …
bc118 Dec 1, 2022
2dcb2dc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2022
c51a3e4
Fixes for element handling in convert_mbuild and atomtyping sites tha…
CalCraven Dec 2, 2022
7989b61
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2022
8f0f5a6
added tests for equation compare and specific_ff_to_residue
bc118 Dec 6, 2022
af0539d
added tests for equation compare and specific_ff_to_residue
bc118 Dec 6, 2022
0510ed4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2022
2b42969
cleaned up specific_ff_to_residue.py
bc118 Dec 6, 2022
365e8a1
cleaned up specific_ff_to_residue.py
bc118 Dec 6, 2022
2f23032
cleaned up equation_compare.py
bc118 Dec 6, 2022
3d08216
cleaned up equation_compare.py
bc118 Dec 6, 2022
bd65f53
cleaned up equation_compare.py
bc118 Dec 6, 2022
e57d857
cleaned up equation_compare.py
bc118 Dec 6, 2022
8b8a48c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2022
50c9352
cleaned up equation_compare.py
bc118 Dec 6, 2022
3806bdf
cleaned up equation_compare.py
bc118 Dec 6, 2022
145c040
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2022
93a7928
cleaned up equation_compare.py and specific_eqn_to_ff
bc118 Dec 6, 2022
4972448
cleaned up equation_compare.py and specific_eqn_to_ff
bc118 Dec 6, 2022
10c5c01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2022
67dbd58
Merge branch 'main' into eqn_compare_utils
daico007 Dec 8, 2022
a8fdb3f
Merge branch 'main' into eqn_compare_utils
daico007 Dec 14, 2022
81987c5
fix xml test related to newly added XML
daico007 Dec 20, 2022
b4713e9
Merge branch 'main' of https://github.com/mosdef-hub/gmso into eqn_co…
daico007 Jan 4, 2023
2386efa
Clean up print statement, fix SMARTS string of benzene C
daico007 Jan 4, 2023
8200e73
Apply suggestions from code review
daico007 Jan 6, 2023
32f63d4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 6, 2023
7324933
some code refactor
daico007 Jan 9, 2023
6c51615
fix typo
daico007 Jan 9, 2023
10012c7
minor edits
daico007 Jan 10, 2023
ce91160
Merge branch 'main' into eqn_compare_utils
daico007 Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions gmso/core/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,16 @@ def _xml_from_gmso(self, filename, overwrite=False):
)

metadata = etree.SubElement(ff_el, "FFMetaData")
if not self.scaling_factors.get("electrostatics14Scale") is None:
if self.scaling_factors.get("electrostatics14Scale") is not None:
metadata.attrib["electrostatics14Scale"] = str(
self.scaling_factors.get("electrostatics14Scale")
)
if not self.scaling_factors.get("nonBonded14Scale") is None:
if self.scaling_factors.get("nonBonded14Scale") is not None:
metadata.attrib["nonBonded14Scale"] = str(
self.scaling_factors.get("nonBonded14Scale")
)
if self.combining_rule is not None:
metadata.attrib["combiningRule"] = str(self.combining_rule)

# ToDo: ParameterUnitsDefintions and DefaultUnits
if self.units:
Expand Down
18 changes: 14 additions & 4 deletions gmso/external/convert_mbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def from_mbuild(
search_method=element_by_symbol,
parse_label=True,
custom_groups=None,
infer_elements=False,
):
"""Convert an mbuild.Compound to a gmso.Topology.

Expand Down Expand Up @@ -75,6 +76,9 @@ def from_mbuild(
matching name on the way down from compound.children. Only the first match
while moving downwards will be assigned to the site. If parse_label=False,
this argument does nothing.
infer_elements : bool, default=False
Allows the reader to try to load element info from the mbuild Particle.name
instead of only from the populated Particle.element

Returns
-------
Expand Down Expand Up @@ -104,7 +108,9 @@ def from_mbuild(

# Use site map to apply Compound info to Topology.
for part in compound.particles():
site = _parse_site(site_map, part, search_method)
site = _parse_site(
site_map, part, search_method, infer_element=infer_elements
)
top.add_site(site)

for b1, b2 in compound.bonds():
Expand Down Expand Up @@ -247,10 +253,14 @@ def _parse_particle(particle_map, site):
return particle


def _parse_site(site_map, particle, search_method):
"""Parse information for a gmso.Site from a mBuild.Compound adn add it to the site map."""
def _parse_site(site_map, particle, search_method, infer_element=False):
"""Parse information for a gmso.Site from a mBuild.Compound and add it to the site map."""
pos = particle.xyz[0] * u.nm
ele = search_method(particle.element.symbol) if particle.element else None
if particle.element:
ele = search_method(particle.element.symbol)
else:
ele = search_method(particle.name) if infer_element else None

charge = particle.charge * u.elementary_charge if particle.charge else None
mass = particle.mass * u.amu if particle.mass else None

Expand Down
3 changes: 1 addition & 2 deletions gmso/parameterization/foyer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_topology_graph(
if atomdata_populator
else {}
)
if atom.name.startswith("_"):
if atom.name.startswith("_") or not atom.element:
top_graph.add_atom(
name=atom.name,
index=j, # Assumes order is preserved
Expand All @@ -70,7 +70,6 @@ def get_topology_graph(
molecule=atom.molecule.name if atom.molecule else None,
**kwargs,
)

else:
top_graph.add_atom(
name=atom.name,
Expand Down
20 changes: 20 additions & 0 deletions gmso/tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,3 +634,23 @@ def hierarchical_top(self, hierarchical_compound):
top = from_mbuild(hierarchical_compound) # Create GMSO topology
top.identify_connections()
return top

@pytest.fixture
def ethane_gomc(self):
ethane_gomc = mb.load("CC", smiles=True)
ethane_gomc.name = "ETH"

return ethane_gomc

@pytest.fixture
def ethanol_gomc(self):
ethanol_gomc = mb.load("CCO", smiles=True)
ethanol_gomc.name = "ETO"

return ethanol_gomc

@pytest.fixture
def methane_ua_gomc(self):
methane_ua_gomc = mb.Compound(name="_CH4")

return methane_ua_gomc
Loading