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

Cassandra gmso #756

Merged
merged 52 commits into from
Sep 22, 2023
Merged

Cassandra gmso #756

merged 52 commits into from
Sep 22, 2023

Conversation

emarinri
Copy link
Contributor

The goal of this PR is to finish up the MCF writer of GMSO originally started by #560

rsdefever and others added 7 commits August 11, 2023 11:28
* Add fixed angle support
* Fix charge sign error (gmso-wide)
* Update ring identification to handle fused systems (mbuild mosdef-hub#744)
* Increase floating point accuracy
* Increase element type length and atom type length
* Correctly write atom indices for bonds/angles/dihedrals/impropers
* Modify dihedral constant indexing from k0 to k3
to k1 to k4 in the OPLSTorsionPotential template.
* Updated from old Mie Xenon test to OPLS ethane.
* Remove assertions related to n and m parameters of the Mie potential.
* Fix floating point format issues in MCF writer.
gmso/tests/test_mcf.py Fixed Show fixed Hide fixed
gmso/tests/test_mcf.py Fixed Show fixed Hide fixed
gmso/tests/test_mcf.py Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Patch coverage: 77.89% and project coverage change: +0.83% 🎉

Comparison is base (ff94811) 91.99% compared to head (f38cfb6) 92.82%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #756      +/-   ##
==========================================
+ Coverage   91.99%   92.82%   +0.83%     
==========================================
  Files          66       66              
  Lines        6806     6845      +39     
==========================================
+ Hits         6261     6354      +93     
+ Misses        545      491      -54     
Files Changed Coverage Δ
gmso/utils/io.py 94.36% <50.00%> (-2.65%) ⬇️
gmso/formats/mcf.py 82.86% <79.12%> (+28.70%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

emarinri and others added 4 commits August 13, 2023 14:06
This test is not complete yet. The 1/2 factor
in the angles and OPLS dihedral is not
accounted for.
Copy link
Contributor

@CalCraven CalCraven left a comment

Choose a reason for hiding this comment

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

Looking good, thanks for getting on this Eliseo. I think a few changes to use more of the GMSO functionality that's there will help speed this up a lot. Also need a few tests for things we expect to fail.

gmso/formats/mcf.py Outdated Show resolved Hide resolved
gmso/formats/mcf.py Outdated Show resolved Hide resolved
gmso/tests/test_mcf.py Show resolved Hide resolved
gmso/tests/test_mcf.py Fixed Show fixed Hide fixed
@CalCraven
Copy link
Contributor

In terms of just getting a single one of each molecule, here is something you can use. It could be a method just in the mcf writer, or something that's a method for the Topology class.

subtopsList = []
for molecule in top.unique_site_labels(name_only=True):
        subtopsList.append(top.create_subtop("molecule", (molecule, 1)))

@CalCraven
Copy link
Contributor

Is there any way to add a test that tests that the mcf files can actually be read into Cassandra. Something like the tests for the hoomd simulation in mBuild (https://github.com/mosdef-hub/mbuild/blob/1d744186e0c92c6fb5e704aef2c76eaa22cee802/mbuild/tests/test_hoomd.py#L197).

We probably also need to test MCF for an array of forcefields or molecules types.

@daico007
Copy link
Member

daico007 commented Sep 7, 2023

I think since canssandra is conda installable, we should be able to run a short sim (through mosdef_cassandra probably) to confirm the file written out is correctly formatted.

@daico007
Copy link
Member

I am pulling this PR for local testing. At first test, things seem to write out as expected (through inspection of the mcf file), however, there might some performance, as in it takes 8s to write out a system of one ethanol. I am doing some profiling right now and going through the code to see if there is something can be sped up. I might try to add some test, i.e., running a cassandra simulation, but since I can't install cassandra locally (there isn't a ARM distribution), it might or might not work.

@daico007
Copy link
Member

Hi @emarinri, can you check and confirm the conversion of k when writing out dihedrals and improper. Currently, our json has the OPLS dihedral with the form of:

{
  "name": "OPLSTorsionPotential",
  "expression": "0.5 * k1 * (1 + cos(phi)) + 0.5 * k2 * (1 - cos(2*phi)) + 0.5 * k3 * (1 + cos(3*phi)) + 0.5 * k4 * (1 - cos(4*phi))",
  "independent_variables": "phi",
  "expected_parameters_dimensions": {
    "k1": "energy",
    "k2": "energy",
    "k3": "energy",
    "k4": "energy"
  }
}

while the Cassandra forcefield is using 𝐸𝜙=𝑎0+𝑎1(1+cos(𝜙))+𝑎2(1−cos(2𝜙))+𝑎3(1+cos(3𝜙))
(https://cassandra-mc.readthedocs.io/en/latest/guides/forcefield.html), so without the 1/2.

However, the mcf.py currently scale down the number by another 1/2 (line 490-515), shouldn't these k be multiplied by 2 to match with the cassandra form?

gmso/tests/test_mcf.py Dismissed Show dismissed Hide dismissed
gmso/utils/io.py Dismissed Show dismissed Hide dismissed
gmso/tests/test_mcf.py Fixed Show resolved Hide resolved
gmso/tests/test_mcf.py Fixed Show fixed Hide fixed
Copy link
Contributor

@CalCraven CalCraven left a comment

Choose a reason for hiding this comment

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

Adding the tests to read it into cassandra itself look pretty good. I think there's probably more edge cases to add, but we may have to add them as they come. Some of these test are going to be covered more in the mosdef_cassandra package as well.

gmso/tests/test_mcf.py Fixed Show resolved Hide resolved
Copy link
Member

@daico007 daico007 left a comment

Choose a reason for hiding this comment

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

I think this is a good wrapping up point for this PR unless you want to add in more stuff @emarinri.

gmso/tests/test_mcf.py Show resolved Hide resolved
Comment on lines +427 to +432
# TODO: not sure why the cassandra MCF writer of mBuild
# outputs a different intramolecular exclusions relative
# to the GMSO writer. This is a temporary fix to make the
# test pass. We should investigate this further.
# Also, try to use the function top.set_lj_scale() and see how
# to update subtopologies.
Copy link
Member

Choose a reason for hiding this comment

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

Is this something we need to look into now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not think this is something we have to worry about for now.

@emarinri
Copy link
Contributor Author

@daico007 I agree this is a point where we can wrap this up for now. As you mentioned, there are a few more things to be tested for should be OK for the short term.

@daico007 daico007 merged commit 7537899 into mosdef-hub:main Sep 22, 2023
13 of 14 checks passed
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.

5 participants