Skip to content

Commit

Permalink
merge and fix conflicts. Pin hoomd<5
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjonesBSU committed Jan 21, 2025
2 parents 4eaf697 + 54e3b13 commit fb161b1
Show file tree
Hide file tree
Showing 34 changed files with 447 additions and 315 deletions.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Report a bug in GMSO

---

**Bug summary**

What were you trying to do and what happened instead? Please copy and paste the stack output


**Code to reproduce the behavior**

Please include a code snippet that can be used to reproduce this bug.

```python
# Paste your code here
#
#
```

**Software versions**

- Which version of GMSO are you using? (`python -c "import gmso; print(gmso.__version__)"`)
- Which version of Python (`python --version`)?
- Which operating system?
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an improvement to GMSO

---

**Describe the behavior you would like added to GMSO**
A clear and concise description of what the proposed idea is.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/QUESTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Questions/discussions
about: For usage questions, important notes, and other discussions.

---

**A summary of the question or discussion topic.**
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### PR Summary:

### PR Checklist
------------
- [ ] Includes appropriate unit test(s)
- [ ] Appropriate docstring(s) are added/updated
- [ ] Code is (approximately) PEP8 compliant
- [ ] Issue(s) raised/addressed?
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ci:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.0
rev: v0.9.2
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ ignore:
- "gmso/paper"
- "gmso/formats/networkx.py"
- "gmso/external/convert_foyer_xml.py"
- "gmso/.github/ISSUE_TEMPLATE"
- "gmso/.github/PULL_REQUEST_TEMPLATE.md"
4 changes: 2 additions & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- pydantic>=2
- networkx
- pytest
- mbuild>=0.17.0
- mbuild>=1.1
- openbabel>=3.0.0
- foyer>=0.11.3
- forcefield-utilities>=0.2.1
Expand All @@ -28,5 +28,5 @@ dependencies:
- pandas
- symengine
- python-symengine
- hoomd
- hoomd>=4.0,<5.0
- importlib_resources
2 changes: 1 addition & 1 deletion gmso/abc/abstract_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def add_tag(self, tag: str, value: Any, overwrite=True) -> None:
"""Add metadata for a particular tag"""
if self.tags.get(tag) and not overwrite:
raise ValueError(
f"Tag {tag} already exists. " f"Please use overwrite=True to overwrite"
f"Tag {tag} already exists. Please use overwrite=True to overwrite"
)
self.tags[tag] = value

Expand Down
2 changes: 1 addition & 1 deletion gmso/core/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _validate_lengths(lengths):
):
if lengths[0] > 0 and lengths[1] > 0:
warnings.warn(
"A c value of 0 was passed. This will be " "interpreted as a 2-D box."
"A c value of 0 was passed. This will be interpreted as a 2-D box."
)
else:
raise ValueError(
Expand Down
5 changes: 2 additions & 3 deletions gmso/core/parametric_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def etree(self, units=None):
f"Please specify member_classes or member_types attribute."
)
for idx, value in enumerate(iterating_attribute):
attrib[f"{prefix}{idx+1}"] = str(value)
attrib[f"{prefix}{idx + 1}"] = str(value)
xml_element = etree.Element(self.__class__.__name__, attrib=attrib)
params = etree.SubElement(xml_element, "Parameters")

Expand Down Expand Up @@ -340,7 +340,6 @@ def member_types(x):

desc = desc.replace(
">",
f", \n parameters: {self.parameters},\n"
f"member types: {member_types(self)}>",
f", \n parameters: {self.parameters},\nmember types: {member_types(self)}>",
)
return desc
5 changes: 2 additions & 3 deletions gmso/core/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,7 @@ def _set_scaling_factor(self, value, molecule_id, interaction, name, index):

if any(np.isnan(value)):
raise ValueError(
f"Cannot assign a nan/NoneType to `{name}`. "
f"Provided value: {org_value}"
f"Cannot assign a nan/NoneType to `{name}`. Provided value: {org_value}"
)

if value.shape != (1,) and value.shape != (3,):
Expand Down Expand Up @@ -1788,7 +1787,7 @@ def _parse_parameter_expression(self, df, parameter, unyts_bool):
getattr(getattr(self, parameter)[0], parameter[:-1] + "_type").parameters
):
df[
f"Parameter {i} ({param}) {getattr(getattr(self, parameter)[0], parameter[:-1]+'_type').parameters[param].units}"
f"Parameter {i} ({param}) {getattr(getattr(self, parameter)[0], parameter[:-1] + '_type').parameters[param].units}"
] = list(
_return_float_for_unyt(
getattr(connection, parameter[:-1] + "_type").parameters[param],
Expand Down
2 changes: 1 addition & 1 deletion gmso/external/convert_foyer_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def _write_nbforces(forcefield, ff_kwargs):
nonBondedAtomTypes,
"AtomType",
attrib_dict={
"name": atom_type.get("name", f"AtomType-{j+1}"),
"name": atom_type.get("name", f"AtomType-{j + 1}"),
"atomclass": atom_type.get("class", ""),
"element": atom_type.get("element", ""),
"charge": atom_type.get("charge", "0.0"),
Expand Down
2 changes: 1 addition & 1 deletion gmso/external/convert_hoomd.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ def _parse_nonbonded_forces(
if i == 0:
exclusions.append("bond")
else:
exclusions.append(f"1-{i+2}")
exclusions.append(f"1-{i + 2}")
nlist = hoomd.md.nlist.Cell(exclusions=exclusions, buffer=nlist_buffer)

nbonded_forces = list()
Expand Down
6 changes: 4 additions & 2 deletions gmso/formats/lammpsdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,9 @@ def _validate_unit_compatibility(top, base_unyts):
float(base_unyts.convert_parameter(parameter, n_decimals=6, name=name)),
parameter.value,
atol=1e-3,
), f"Units System {base_unyts.usystem} is not compatible with {atype} with value {parameter}"
), (
f"Units System {base_unyts.usystem} is not compatible with {atype} with value {parameter}"
)


def _write_header(out_file, top, atom_style, dihedral_parser):
Expand Down Expand Up @@ -1171,7 +1173,7 @@ def _write_conn_data(out_file, top, connStr, sorted_typesList):
if sort_by_types(ele) == ctype_members
]
for index in indexList:
typeStr = f"{i+1:<6d}\t{index+1:<6d}\t"
typeStr = f"{i + 1:<6d}\t{index + 1:<6d}\t"
sorted_membersList = sort_connection_members(conn, sort_by="index", top=top)
indexStr = "\t".join(
[
Expand Down
23 changes: 11 additions & 12 deletions gmso/formats/mcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _write_atom_information(mcf, top, in_ring):
mcf.write("{:d}\n".format(len(top.sites)))
for idx, site in enumerate(top.sites):
mcf.write(
"{:<4d} " "{:<6s} " "{:<2s} " "{:8.4f} " "{:12.8f} ".format(
"{:<4d} {:<6s} {:<2s} {:8.4f} {:12.8f} ".format(
idx + 1,
atypes_list[idx],
names[idx],
Expand All @@ -325,15 +325,15 @@ def _write_atom_information(mcf, top, in_ring):
)
if vdw_style == "LJ":
mcf.write(
"{:3s} " "{:10.5f} " "{:10.5f}".format(
"{:3s} {:10.5f} {:10.5f}".format(
vdw_style,
(site.atom_type.parameters["epsilon"] / u.kb).in_units("K").value,
site.atom_type.parameters["sigma"].in_units("Angstrom").value,
)
)
elif vdw_style == "Mie":
mcf.write(
"{:3s} " "{:10.5f} " "{:10.5f} " "{:8.3f} " "{:8.3f}".format(
"{:3s} {:10.5f} {:10.5f} {:8.3f} {:8.3f}".format(
vdw_style,
(site.atom_type.parameters["epsilon"] / u.kb).in_units("K").value,
site.atom_type.parameters["sigma"].in_units("Angstrom").value,
Expand Down Expand Up @@ -363,7 +363,7 @@ def _write_bond_information(mcf, top):
mcf.write("{:d}\n".format(len(top.bonds)))
for idx, bond in enumerate(top.bonds):
mcf.write(
"{:<4d} " "{:<4d} " "{:<4d} " "{:s} " "{:10.5f}\n".format(
"{:<4d} {:<4d} {:<4d} {:s} {:10.5f}\n".format(
idx + 1,
top.get_index(bond.connection_members[0]) + 1,
top.get_index(bond.connection_members[1]) + 1,
Expand Down Expand Up @@ -403,7 +403,7 @@ def _write_angle_information(mcf, top):
angle_style = _get_angle_style(angle)
if angle_style == "fixed":
mcf.write(
"{:s} " "{:10.5f}\n".format(
"{:s} {:10.5f}\n".format(
angle_style,
angle.connection_type.parameters["theta_eq"]
.in_units(u.degree)
Expand All @@ -412,7 +412,7 @@ def _write_angle_information(mcf, top):
)
elif angle_style == "harmonic":
mcf.write(
"{:s} " "{:10.5f} " "{:10.5f}\n".format(
"{:s} {:10.5f} {:10.5f}\n".format(
angle_style,
(0.5 * angle.connection_type.parameters["k"] / u.kb)
.in_units("K/rad**2")
Expand Down Expand Up @@ -452,7 +452,7 @@ def _write_dihedral_information(mcf, top):
mcf.write("{:d}\n".format(len(top.dihedrals)))
for idx, dihedral in enumerate(top.dihedrals):
mcf.write(
"{:<4d} " "{:<4d} " "{:<4d} " "{:<4d} " "{:<4d} ".format(
"{:<4d} {:<4d} {:<4d} {:<4d} {:<4d} ".format(
idx + 1,
top.get_index(dihedral.connection_members[0]) + 1,
top.get_index(dihedral.connection_members[1]) + 1,
Expand Down Expand Up @@ -488,7 +488,7 @@ def _write_dihedral_information(mcf, top):
# So we need to exclude the last term in the GMSO topology.
dihedral_style = "OPLS"
mcf.write(
"{:s} " "{:10.5f} " "{:10.5f} " "{:10.5f} " "{:10.5f}\n".format(
"{:s} {:10.5f} {:10.5f} {:10.5f} {:10.5f}\n".format(
dihedral_style,
0.5
* dihedral.connection_type.parameters["k0"]
Expand All @@ -510,7 +510,7 @@ def _write_dihedral_information(mcf, top):
)
elif dihedral_style == "CHARMM":
mcf.write(
"{:s} " "{:10.5f} " "{:10.5f} " "{:10.5f}\n".format(
"{:s} {:10.5f} {:10.5f} {:10.5f}\n".format(
dihedral_style,
dihedral.connection_type.parameters["k"].in_units("kJ/mol").value,
dihedral.connection_type.parameters["n"],
Expand All @@ -521,7 +521,7 @@ def _write_dihedral_information(mcf, top):
)
elif dihedral_style == "HARMONIC":
mcf.write(
"{:s} " "{:10.5f} " "{:10.5f}\n".format(
"{:s} {:10.5f} {:10.5f}\n".format(
dihedral_style.lower(),
0.5
* dihedral.connection_type.parameters["k"].in_units("kJ/mol").value,
Expand Down Expand Up @@ -558,8 +558,7 @@ def _write_improper_information(mcf, top):
improper_style = "harmonic"
for i, improper in enumerate(top.impropers):
mcf.write(
"{:<4d} {:<4d} {:<4d} {:<4d} {:<4d}"
" {:s} {:10.5f} {:10.5f}\n".format(
"{:<4d} {:<4d} {:<4d} {:<4d} {:<4d} {:s} {:10.5f} {:10.5f}\n".format(
i + 1,
top.get_index(improper.connection_members[0]) + 1,
top.get_index(improper.connection_members[1]) + 1,
Expand Down
47 changes: 11 additions & 36 deletions gmso/formats/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,10 @@ def write_top(top, filename, top_vars=None):
)
)
out_file.write(
"[ defaults ]\n"
"; nbfunc\t"
"comb-rule\t"
"gen-pairs\t"
"fudgeLJ\t\t"
"fudgeQQ\n"
"[ defaults ]\n; nbfunc\tcomb-rule\tgen-pairs\tfudgeLJ\t\tfudgeQQ\n"
)
out_file.write(
"{0}\t\t" "{1}\t\t" "{2}\t\t" "{3}\t\t" "{4}\n\n".format(
"{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}\n\n".format(
top_vars["nbfunc"],
top_vars["comb-rule"],
top_vars["gen-pairs"],
Expand All @@ -76,25 +71,12 @@ def write_top(top, filename, top_vars=None):
)

out_file.write(
"[ atomtypes ]\n"
"; name\t"
"at.num\t\t"
"mass\t"
"charge\t\t"
"ptype\t"
"sigma\t"
"epsilon\n"
"[ atomtypes ]\n; name\tat.num\t\tmass\tcharge\t\tptype\tsigma\tepsilon\n"
)

for atom_type in top.atom_types(PotentialFilters.UNIQUE_NAME_CLASS):
out_file.write(
"{0:12s}"
"{1:4s}"
"{2:12.5f}"
"{3:12.5f}\t"
"{4:4s}"
"{5:12.5f}"
"{6:12.5f}\n".format(
"{0:12s}{1:4s}{2:12.5f}{3:12.5f}\t{4:4s}{5:12.5f}{6:12.5f}\n".format(
atom_type.name,
str(_lookup_atomic_number(atom_type)),
atom_type.mass.in_units(u.amu).value,
Expand All @@ -115,7 +97,7 @@ def write_top(top, filename, top_vars=None):
"bond_restraints": "\n[ bonds ] ;Harmonic potential restraint\n"
"; ai\taj\tfunct\tb0\t\tkb\n",
"pairs": "\n[ pairs ]\n; ai\taj\tfunct\n",
"angles": "\n[ angles ]\n" "; ai\taj\tak\tfunct\tphi_0\t\tk0\n",
"angles": "\n[ angles ]\n; ai\taj\tak\tfunct\tphi_0\t\tk0\n",
"angle_restraints": (
"\n[ angle_restraints ]\n"
"; ai\taj\tai\tak\tfunct\ttheta_eq\tk\tmultiplicity\n"
Expand All @@ -132,14 +114,14 @@ def write_top(top, filename, top_vars=None):
}
for tag in unique_molecules:
"""Write out nrexcl for each unique molecule."""
out_file.write("\n[ moleculetype ]\n" "; name\tnrexcl\n")
out_file.write("\n[ moleculetype ]\n; name\tnrexcl\n")

# TODO: Lookup and join nrexcl from each molecule object
out_file.write("{0}\t" "{1}\n\n".format(tag, top_vars["nrexcl"]))
out_file.write("{0}\t{1}\n\n".format(tag, top_vars["nrexcl"]))

"""Write out atoms for each unique molecule."""
out_file.write(
"[ atoms ]\n" "; nr\ttype\tresnr\tresidue\t\tatom\tcgnr\tcharge\tmass\n"
"[ atoms ]\n; nr\ttype\tresnr\tresidue\t\tatom\tcgnr\tcharge\tmass\n"
)
# Each unique molecule need to be reindexed (restarting from 0)
# The shifted_idx_map is needed to make sure all the atom index used in
Expand All @@ -148,14 +130,7 @@ def write_top(top, filename, top_vars=None):
for idx, site in enumerate(unique_molecules[tag]["sites"]):
shifted_idx_map[top.get_index(site)] = idx
out_file.write(
"{0:8s}"
"{1:12s}"
"{2:8s}"
"{3:12s}"
"{4:8s}"
"{5:4s}"
"{6:12.5f}"
"{7:12.5f}\n".format(
"{0:8s}{1:12s}{2:8s}{3:12s}{4:8s}{5:4s}{6:12.5f}{7:12.5f}\n".format(
str(idx + 1),
site.atom_type.name,
str(site.molecule.number + 1 if site.molecule else 1),
Expand Down Expand Up @@ -302,9 +277,9 @@ def write_top(top, filename, top_vars=None):
)
)

out_file.write("\n[ system ]\n" "; name\n" "{0}\n\n".format(top.name))
out_file.write("\n[ system ]\n; name\n{0}\n\n".format(top.name))

out_file.write("[ molecules ]\n" "; molecule\tnmols\n")
out_file.write("[ molecules ]\n; molecule\tnmols\n")
for tag in unique_molecules:
out_file.write(
"{0}\t{1}\n".format(tag, len(unique_molecules[tag]["subtags"]))
Expand Down
Loading

0 comments on commit fb161b1

Please sign in to comment.