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

Charmm parameters writer #848

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

CalCraven
Copy link
Contributor

@CalCraven CalCraven commented Sep 16, 2024

Port over the old CHARMM/NAMD .prm file writer from mBuild to GMSO. Adding to the savers and allowing for basic charmm style potentials to be written only.

TODOS:

  • Check for specified parameter types when writing file
  • Add support for urey bradley potential
  • Fix 1-4 scaling in charmm
  • Write out all units using unit system
  • Improve iteration over unique type info
  • Handle Array of charmm K dihedrals
  • Add test coverage
  • Fix failing tests


Parmed stores rmin/2 in "rmin"
"""
unit_system = LAMMPS_UnitSystems("real") # ang, kcal/mol, amu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to make sure we're using this everywhere we write out parameters? I see we use it for the atom mass, but not anywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, for in order to handle any input unyts this will do the filtering. I was just too lazy to do it every time at first. Was wondering if you think we should make a system that isn't specific to LAMMPS for this one. It is the exact same as the real units, but maybe a touch confusing to copy them across to other engines. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if unit_system should be a parameter of write_prm that defaults to None. If nothing is passed, then all units are used as-is from the toplogy? If we set unit_system = topology.unit_system as default behavior, would that work as well?

def write_prm(topology, filename, unit_system=None):
    if not unit_system:
        unit_system = topology.unit_system

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PRM file looks to me like it has default assumed units of kCal/mol, angstrom, amu, radians, etc for it's units. So it can only convert to one defined system.

@chrisjonesBSU chrisjonesBSU linked an issue Sep 17, 2024 that may be closed by this pull request
)

f.write("\nNONBONDED\n")
nonbonded14 = topology.scaling_factors[0][2]
Copy link
Contributor

@chrisjonesBSU chrisjonesBSU Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be fixed here, but I feel like this attribute should be more readable rather than just knowing that 0th index is LJ and 1st index is electrostatics. Maybe a dict? I can open a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was thinking the same thing myself. I think it should also be {"electrostatics":{"1-4":0.5}}, instead of a fixed list. Could potentially be some odd 1-5 interactions at some point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's sort of what I was thinking as well.

Copy link
Contributor

@chrisjonesBSU chrisjonesBSU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. It seems like we're just missing some type checks to ensure only supported potential formats are being used?

@CalCraven
Copy link
Contributor Author

Cool. Thanks @chrisjonesBSU, yeah I'll punch those in this week to get this writer off the ground. I'm not sure it gets a lot of use, but it'll be nice to have.

gmso/formats/prm_writer.py Fixed Show fixed Hide fixed
gmso/formats/prm_writer.py Fixed Show fixed Hide fixed
@chrisjonesBSU chrisjonesBSU self-requested a review October 18, 2024 22:02
Comment on lines +87 to +91
# if key not in uniqueTypesDict:
# sigma
# epsilon
# name
# mass

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Comment on lines +94 to +95
# else:
# vals = uniqueTypesDict[key]

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CHARMM par writer?
2 participants