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 ability to use number density when calculating target box lenghts for shrinking and NVT. #112

Merged
merged 35 commits into from
Jan 22, 2024

Conversation

chrisjonesBSU
Copy link
Member

@chrisjonesBSU chrisjonesBSU commented Jan 11, 2024

Being able to easily and reliability get volumes that correspond to a desired density is very helpful, we currently do this for mass density, but that isn't very intuitive or helpful when running non-atomistic coarse-grain simulations such as the LJChain, 'KremerGrestBeadSpring' and ellipsoids (see #102).

Right now, the changes are in utils.calculate_box_length.

This PR also solves #64.

Still left to do:

  • Unit tests
  • Decide how to handle a Simulation property of N_beads
  • Decide if we need to change how Simulation.run_update_volume handles its density parameter.

@chrisjonesBSU chrisjonesBSU added the enhancement New feature or request label Jan 11, 2024
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (df50ced) 94.23% compared to head (a919fed) 94.28%.
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   94.23%   94.28%   +0.04%     
==========================================
  Files          23       25       +2     
  Lines        1770     1801      +31     
==========================================
+ Hits         1668     1698      +30     
- Misses        102      103       +1     
Files Coverage Δ
flowermd/base/molecule.py 96.77% <100.00%> (ø)
flowermd/base/simulation.py 91.48% <100.00%> (+0.06%) ⬆️
flowermd/base/system.py 92.00% <100.00%> (+0.01%) ⬆️
flowermd/internal/__init__.py 100.00% <100.00%> (ø)
flowermd/internal/exceptions.py 89.74% <ø> (ø)
flowermd/internal/ff_utils.py 89.58% <ø> (ø)
flowermd/internal/utils.py 100.00% <100.00%> (ø)
flowermd/library/surfaces.py 100.00% <ø> (ø)
...lowermd/modules/surface_wetting/surface_wetting.py 94.73% <100.00%> (+0.61%) ⬆️
flowermd/utils/__init__.py 100.00% <ø> (ø)
... and 2 more

@chrisjonesBSU
Copy link
Member Author

Ok, for now I took out the N_beads property from Simulation. We can make an issue and discuss how we want to handle that another time.

We can still figure out what to do in run_update_volume now that there are 2 types of density.

  1. Keep current behavior and have a final_density parameter that just assumes they are using mass density.
  2. Remove final_density and make it so that the utils funcs for calculating boxes that match a given density are more forward facing. People can just use it to get the final_box_lengths parameter they want to use in run_update_volume.

@marjanalbooyeh
Copy link
Collaborator

We can still figure out what to do in run_update_volume now that there are 2 types of density.

For the purpose of keeping function interfaces simple, I think option 2 is better.

@chrisjonesBSU chrisjonesBSU linked an issue Jan 17, 2024 that may be closed by this pull request
@chrisjonesBSU
Copy link
Member Author

Ok, I think everything is implemented correctly. I just need to update doc strings and run through the tutorials to make sure they are working correctly.

).value
final_box = hoomd.Box(Lx=L, Ly=L, Lz=L)

# TODO: Do we need to do anything here?
Copy link
Member Author

Choose a reason for hiding this comment

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

Forgot about this TODO that is remaining.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't think of anything to do for cases where final_box_lengths does not have units. I guess we can remove this else for now?

@@ -95,21 +95,27 @@ def run_droplet(

"""
# Shrink down to high density
target_box = get_target_box_mass_density(
density=shrink_density * (u.g / (u.cm**3)), mass=self.mass.to("g")
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we need an if statement here. Maybe someone passes in other density units for final_density and shrink_density and we don't always want to use g/cm^3

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess the behavior here should basically be the same as what we do in Pack now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree. same as in Pack we could first check if the units exists and if not assume the default is g/cm^3

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Collaborator

@marjanalbooyeh marjanalbooyeh left a comment

Choose a reason for hiding this comment

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

LGTM overall! I added a few comments/questions.

Thank you Chris

flowermd/base/simulation.py Show resolved Hide resolved
).value
final_box = hoomd.Box(Lx=L, Ly=L, Lz=L)

# TODO: Do we need to do anything here?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't think of anything to do for cases where final_box_lengths does not have units. I guess we can remove this else for now?

flowermd/base/system.py Show resolved Hide resolved
@@ -95,21 +95,27 @@ def run_droplet(

"""
# Shrink down to high density
target_box = get_target_box_mass_density(
density=shrink_density * (u.g / (u.cm**3)), mass=self.mass.to("g")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree. same as in Pack we could first check if the units exists and if not assume the default is g/cm^3

flowermd/base/simulation.py Outdated Show resolved Hide resolved
flowermd/tests/base/test_simulation.py Show resolved Hide resolved
Copy link
Collaborator

@marjanalbooyeh marjanalbooyeh left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you

@chrisjonesBSU chrisjonesBSU merged commit c06e8c3 into cmelab:main Jan 22, 2024
4 checks passed
@chrisjonesBSU chrisjonesBSU deleted the number-density branch January 22, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move the density parameter out of System
2 participants