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

Add MD LJ validation tests #996

Merged
merged 25 commits into from
May 29, 2021
Merged

Add MD LJ validation tests #996

merged 25 commits into from
May 29, 2021

Conversation

joaander
Copy link
Member

Description

Add validation tests that check the energy and pressure or density with the NVT, Langevin, and NPT integration methods.

Motivation and context

Ensure that MD simulation compute correct results.

Related to #210 but does not completely solve it.

I also add a volume property to ComputeThermodyanmicQuantities. This is available elsewhere (i.e. the system box) but not as an easily loggable property.

How has this been tested?

I tested it locally on the serial CPU configuration. CI will check it on the GPU and MPI configurations.

Change log

Added:

- ``hoomd.md.compute.ThermodynamicQuantities.volume`` property.

Checklist:

@joaander joaander requested review from a team, b-butler and alacour and removed request for a team May 17, 2021 19:47
@joaander joaander added the validate Execute long running validation tests on pull requests label May 17, 2021
@joaander
Copy link
Member Author

This isn't quite working right yet. I'm currently working on some additional checks to see if I can get more reliable results from the test.

@joaander joaander marked this pull request as draft May 19, 2021 19:35
joaander added 3 commits May 19, 2021 20:18
I don't know why, but the block averaging method seems to underestimate
the error during short simulation runs.
@joaander joaander marked this pull request as ready for review May 20, 2021 12:47
@joaander
Copy link
Member Author

This is ready for review. I had to change a number of things from the initial design. I'm no longer using the NIST reference data. That system size was too small for MPI validation and most of the state points are in the two phase region so it is not suitable for NPT validation. The tests did pass with the NIST data in NVT.

Instead, I run the test in HOOMD for a longer time to obtain reference energies and pressures. This is still a good validation test, as it cross validates NVT, NPT, Langevin (and later, MC) methods. If they don't all agree on a state point, something is wrong with one or more of them.

The validation test runs for 65536 time steps sampling - this takes about 10 minutes on the CPU and is just long enough to get a decent measure of the mean quantities. However, 10 minutes is longer than I hoped for, so I also reduced the number of state points to 1 to keep the validation testing time low. We have many more validation tests to add and need to keep the time reasonable.

Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

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

I have a few comments and suggestions. Overall the code was fine (I liked your use of custom Actions in ListWriter). I don't know a way to speed this up more so 10 minutes will need to be okay (plus more time later).

@@ -121,15 +121,15 @@ env:
run: << invoke_pytest_serial >> << pytest_options >>
- name: Run pytest (mpi)
if: ${{ contains(matrix.config, 'mpi') }}
run: << invoke_pytest_mpi >> << pytest_options >> || cat pytest.out.1
run: << invoke_pytest_mpi >> << pytest_options >> || (( cat pytest.out.1 && exit 1 ))
Copy link
Member

Choose a reason for hiding this comment

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

Don't subshells only require a single set of parenthesis or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

pytest || cat pytest.out.1 executes cat when pytest fails and then assumes the exit code of cat. Thus GitHub Actions thinks the test passed when it actually failed. Adding the exit 1 raises the error code.

I don't know whether one ( would work here or not - but (( does work as tested on this PR.

hoomd/conftest.py Outdated Show resolved Hide resolved
hoomd/conftest.py Outdated Show resolved Hide resolved
hoomd/conftest.py Outdated Show resolved Hide resolved
hoomd/conftest.py Show resolved Hide resolved
hoomd/conftest.py Show resolved Hide resolved
hoomd/md/compute.py Outdated Show resolved Hide resolved
hoomd/md/pytest/test_lj_equation_of_state.py Outdated Show resolved Hide resolved
hoomd/md/pytest/test_lj_equation_of_state.py Outdated Show resolved Hide resolved
joaander and others added 3 commits May 21, 2021 14:22
Co-authored-by: Brandon Butler <[email protected]>
Co-authored-by: Brandon Butler <[email protected]>
Copy link
Contributor

@alacour alacour 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 it looks good. I do have a few suggestions for speeding it up, which may enable more or faster tests. To be complete, I am including some obvious suggestions:

  1. Lower density runs. Simulations at lower densities will probably run much faster for every thermostat. A much lower density run (<0.2) would probably see a speed up of > 5 times.

  2. Not initializing with an FCC lattices. It may take time to fall apart, while a simple cubic lattice would fall apart faster and may enable shorter simulations.

  3. Fewer particles. Maybe more tests could be added where the phase behavior could be tested with 1 CPU.

  4. Other Potentials. The WCA potential has a short cutoff of 2**(1/6) and probably runs multiple times faster. Instead of adding other tests for LJ, maybe other test could use WCA or other short-range potentials.

Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

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

Feel free to resolve comments that you don't think warrant addressing. I am only requesting changes to remove an errant comment (or what I think to be an errant comment).

hoomd/conftest.py Outdated Show resolved Hide resolved
hoomd/conftest.py Show resolved Hide resolved
hoomd/md/pytest/test_lj_equation_of_state.py Outdated Show resolved Hide resolved
@joaander
Copy link
Member Author

Thanks for reviewing @alacour!

I think it looks good. I do have a few suggestions for speeding it up, which may enable more or faster tests. To be complete, I am including some obvious suggestions:

  1. Lower density runs. Simulations at lower densities will probably run much faster for every thermostat. A much lower density run (<0.2) would probably see a speed up of > 5 times.

You get a speedup in terms of TPS, but the autocorrelation times of energies, pressures, etc increase because there are fewer collisions to randomize things. In practice, these statpoints needed to be run 5 times longer as well, negating the performance boost.

  1. Not initializing with an FCC lattices. It may take time to fall apart, while a simple cubic lattice would fall apart faster and may enable shorter simulations.

I tried this, it doesn't seem to make much of a difference. I implemented the FCC structure as it should help validate systems in the solid phase though I found the fluid gave quicker results for validation.

  1. Fewer particles. Maybe more tests could be added where the phase behavior could be tested with 1 CPU.

Unfortunately, the MPI simulations need quite a few particles in order to have a large enough box to communicate. I do reduce the size for the serial runs, but I'm concerned that if I reduce it much further finite size effects might make the validation reference point invalid.

  1. Other Potentials. The WCA potential has a short cutoff of 2**(1/6) and probably runs multiple times faster. Instead of adding other tests for LJ, maybe other test could use WCA or other short-range potentials.

This has the most promise. Ultimately, I didn't try it because I ran out of time to apply to this.

@joaander joaander requested a review from b-butler May 24, 2021 20:19
Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

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

LGTM

@joaander joaander enabled auto-merge May 28, 2021 23:59
@joaander joaander merged commit c96b0bf into master May 29, 2021
@joaander joaander deleted the validate-lj-eos branch May 29, 2021 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validate Execute long running validation tests on pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants