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

Feature/new box resize #618

Merged
merged 99 commits into from
May 26, 2020
Merged

Conversation

b-butler
Copy link
Member

@b-butler b-butler commented Mar 30, 2020

Description

An updated Python Box class and an updated C++ and Python BoxResize{Updater} class. Introduces a new module folder hoomd/update and the min, max, and range methods for Variants as well.

The new Box class's interface is modeled in part from freud, and makes extensive use of properties. Unlike the previous Python boxdim class, this class always has an up to date C++ BoxDim object.

The new BoxResize interface uses ParameterDict like previously converted updaters. In addition, the interface uses an initial and final box along with a single variant used for interpolation between the boxes.

How Has This Been Tested?

Tested locally in a jupyter notebook.

b-butler and others added 13 commits March 20, 2020 17:12
Just wraps a _hoomd.BoxDim class
min and max must be overloaded for all Python and C++ derived Variants
range is automatically implemented. These are necessary for some
updaters to properly interpolate values.
Technically this removes the balance (MPI domain decomposition) class;
however, this is not working with the current development branch for v3
and a replacement is instituted in a different branch.
Also adds a hoomd.update module folder with __init__.py file
@b-butler b-butler requested review from a team and joaander and removed request for a team March 30, 2020 21:24
if the C++ side is used they are set to None
the setters for the C++ side also check if the variables are set to None
before attempting to use the new C++ object for the python variables
Copy link
Member

@joaander joaander left a comment

Choose a reason for hiding this comment

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

This looks great. I have a few comments and suggestions.

hoomd/BoxResizeUpdater.cc Outdated Show resolved Hide resolved
hoomd/BoxResizeUpdater.cc Outdated Show resolved Hide resolved
hoomd/BoxResizeUpdater.cc Outdated Show resolved Hide resolved
hoomd/Variant.cc Outdated Show resolved Hide resolved
hoomd/update/box_resize.py Outdated Show resolved Hide resolved
hoomd/box.py Outdated Show resolved Hide resolved
hoomd/box.py Outdated Show resolved Hide resolved
hoomd/box.py Outdated Show resolved Hide resolved
hoomd/box.py Outdated Show resolved Hide resolved
hoomd/state.py Outdated Show resolved Hide resolved
@joaander joaander requested review from a team and bdice and removed request for a team April 1, 2020 18:15
@b-butler
Copy link
Member Author

@Joander that is my fault, I noticed some unintuitive behavior with the logger and just went to fix it without checking tests. I should have just created a PR.

Copy link
Member

@joaander joaander left a comment

Choose a reason for hiding this comment

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

Thanks! I think all that is left is to fix the power figure and resolve the merge conflict.
Do the other reviewers have any suggestions before we merge this?

Copy link
Contributor

@vyasr vyasr 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 more change requests, but these should be faster and I'll review quickly once they're done so that we can finalize and move forward.

hoomd/BoxResizeUpdater.cc Show resolved Hide resolved
}

auto initial_box = getBoxDimFromPyObject(m_initial_box);
auto final_box = getBoxDimFromPyObject(m_final_box);
Copy link
Contributor

Choose a reason for hiding this comment

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

In practice, I expect getCurrentBox to be called much more frequently than users requesting the current box in Python, so I would suggest storing BoxDim objects as the members so that you don't have to do this every time and instead making Python boxes if/when the user requests it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem come in when the user does something like box_resize.box1.L = 10. This should change the internal box. Currently we export the BoxDim class wrapped in a std::unique_ptr. This prevents having multiple full pointers, so we have to copy to store the BoxDim object directly in C++. We could change this to a std::shared_ptr like we do elsewhere, I just don't know if this would break existing code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, so right now the Python box object is the single source of truth. I'm not sure where you're referring to the unique_ptr, but since the getBoxDimFromPyObject is just pulling the pointer to the _cpp_obj from the Python box, what exactly is the type of _cpp_obj? I don't know the pybind API very well, is it a pointer to the BoxDim object, a copy of the object, or is it wrapped in some intermediate layer? Is it feasible to just return a const BoxDim [*|&] from getBoxDimFromPyObject so that you don't make new objects each time this is called?

hoomd/BoxResizeUpdater.cc Outdated Show resolved Hide resolved
hoomd/Variant.cc Show resolved Hide resolved
hoomd/Variant.h Outdated Show resolved Hide resolved
hoomd/Variant.h Outdated Show resolved Hide resolved
hoomd/Variant.h Outdated Show resolved Hide resolved
hoomd/snapshot.py Outdated Show resolved Hide resolved
hoomd/update/box_resize.py Outdated Show resolved Hide resolved
hoomd/box.py Outdated Show resolved Hide resolved
@vyasr
Copy link
Contributor

vyasr commented May 24, 2020

I see two unresolved comments, one regarding the getBoxDimfromPyObject usage and one regarding whether 3D->2D conversion should be allowed. Once those two are resolved, I think this PR is done and ready for merging.

@vyasr vyasr self-requested a review May 25, 2020 19:51
@vyasr
Copy link
Contributor

vyasr commented May 25, 2020

I've discussed my final questions with @b-butler and I'm happy with this PR. @joaander if you wish to discuss whether or not we should allow changing dimensionality in simulations further I'm open to doing that. I don't think it's critical to decide that in this pull request, so I'm going to approve it as is.

@bdice bdice removed their request for review May 26, 2020 17:46
@bdice
Copy link
Member

bdice commented May 26, 2020

I’m removing myself as a reviewer on this PR to cut down on my notifications, it seems well covered by past and current reviews. Thanks!

@b-butler b-butler merged commit 0d1d783 into feature/new-object-API May 26, 2020
@b-butler b-butler deleted the feature/new-box-resize branch May 26, 2020 20:38
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