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

Reference units different between hoomd_simulation.py, gsdwriter.py and hoomdxml.py #799

Closed
chrisjonesBSU opened this issue Oct 12, 2020 · 8 comments

Comments

@chrisjonesBSU
Copy link
Contributor

This is very similar to the changes made in #463

From what I understand, the idea in #463, is that for the sake of consistency, the units used by the reference value parameters in write_hoomdxml should be same units that are used in mbuild and foyer (nm, kJ/mol, amu).

Since parmed is actually being used behind the scenes, the reference values are converted from nm and kJ/mol into angstroms and kcal/mol. #463 added units to the reference value parameter doc strings and took care of the conversions required.

However, this is not how the reference values are being handled in create_hoomd_simulation and write_gsd (I'm not familiar with the lammps or par writers). These functions still require the user to enter their reference values in parmed units (kcal/mol, angstroms, Da) so that they are consistent with the parametrized parmed structure. There isn't any conversion being done, the values are used as entered by the user.

I agree with the method we're using in write_hoomdxml. To me, its a lot more intuitive to enter reference value as they appear in the forcefield files, and in the case of foyer that's nm and kJ/mol, so we should probably update the other relevant writers to handle to use the same process.

I can write up the PR for it, I just wanted to start some discussion since messing around with units can result in breaking changes to any existing workflows. Note that if auto_scale = True for any of these 3 writers, then this isn't an issue. Also, I just realized that write_gsd doesn't have an auto scale option, maybe that could be added with this PR as well.

This came up when talking with Mike earlier about the changes made in #798
#798

Also, if these changes are made, I assume they should also be made in #698 @mikemhenry

@jennyfothergill
Copy link
Contributor

@chrisjonesBSU was this issue fixed by #798 or #698?

@chrisjonesBSU
Copy link
Contributor Author

@chrisjonesBSU was this issue fixed by #798 or #698?

No it doesn't look like it was.

@slenka93
Copy link

Hi,

I wanted to clarify the units of mbuild gsdwriter.

I am using mbuild to build a coarse grain molecule and then mbuild fill box to pack molecules in a box. The position of atoms are defined such as the distance is in nm and my box length is in units of nm. After preparation of a box of the coarse grain molecule, i am using foyer and openmm to define the atom, bond, angle and dihedral types and charge of the coarse grain molecule. Distance is in nm, angles is in radian and energies are in kj/mol (I already have the values of equilibrium bond, angle...)

After this I want to save a gsd file to use it for hoomd runs. For this I am using mbuilds gsdwriter.
from mbuild.formats.gsdwriter import write_gsd
write_gsd(struc, 'box.gsd', ref_distance=1, ref_energy=1)

Using this set of commands changes the distance in angstroms and energy units I am not sure even though all the parameters in my files are nm and kj/mol.

@daico007
Copy link
Member

daico007 commented Jun 1, 2022

Hi @slenka93, I believe this is because when we perform the atomtyping using foyer, we actually have to convert our object to a parmed Structure to be able to store information related to potential parameters, which have a different set of default units than ours. The default unit of parmed is Angstrom and kcal/mol, so if you observed the unit discrepancy at the final gsd file, can adjust the ref_distance and ref_energy to revert back to the your original unit. We are working on a new backend that would have a better representation of units called GMSO, which will be used to replaced parmed in the near future.

@slenka93
Copy link

slenka93 commented Jun 1, 2022

Hi @daico007, thanks for the clarification.
Does the charge also converts to AKMA units (angstrom, kcal/mol) or is it the same as (nm, kj/mol)? Also is there any account of 4pipermittivity in the charges like gmso?

@daico007
Copy link
Member

daico007 commented Jun 1, 2022

Hi @slenka93, the charge will also be in electron charge (which i think is also the case in the in the original XML). The gsdwriter.py does account for the 4 * pi * permittivity (see https://github.com/mosdef-hub/mbuild/blob/main/mbuild/formats/gsdwriter.py#L135-L142)

@slenka93
Copy link

slenka93 commented Jun 2, 2022

Thanks @daico007!

@CalCraven
Copy link
Contributor

GSD writer has been transitioned to GMSO in PR 680.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants