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

Rewrite LB/EK interface #4773

Merged
merged 5 commits into from
Aug 22, 2023
Merged

Conversation

jngrad
Copy link
Member

@jngrad jngrad commented Aug 11, 2023

Description of changes:

  • API changes:
    • the espressomd.System class now has a new member lb
    • the espressomd.System class member ekreactions is now the reaction attribute of system.ekcontainer
    • the espressomd.System class no longer has an actors member
    • further API changes will take place in an upcoming PR
  • remove Boost dependency from LB/EK sources
  • fix regressions in EK
    • EK now throws an error when the box_l or node_grid changes, when the MD time step and EK tau disagree, when the box size is not an integer multiple of agrid
  • rewrite the LB and EK code in the core from scratch to enforce SOLID principles
    • folder src/grid_based_algorithms was split into src/core/lb and src/core/ek
    • LB and EK global variables (lattice_switch, ek_container, ek_reactions, lb_walberla_instance,
      lb_walberla_params_instance) were removed; these objects are now members of the System class
      (partial fix for Remove global variables #2628)

jngrad added 3 commits August 8, 2023 16:17
Use lambda captures by reference. Use consistent function names.
Remove unused header includes. Reduce usage of the actors list.
The waLBerla module now only uses Boost in the unit tests.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

* remove the actor list
* enforce SOLID principles
* add fine-grained event hooks
@jngrad jngrad force-pushed the long_range_actors branch from e0c1f27 to 3c7a5d3 Compare August 15, 2023 16:34
@jngrad jngrad added Core Improvement ApiChange waLBerla Issues regarding waLBerla integration labels Aug 15, 2023
@jngrad jngrad requested a review from itischler August 15, 2023 17:24
@jngrad jngrad marked this pull request as ready for review August 15, 2023 17:24
@jngrad jngrad requested a review from reinaual August 17, 2023 18:32
Copy link
Contributor

@itischler itischler left a comment

Choose a reason for hiding this comment

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

Great work,
I only have a minor comment on the naming of steps_per_md_steps, which should probably be md_steps_per_lb/ek_steps

# note: several members can only be instantiated once
if has_features("WALBERLA"):
if self._lb is not None:
lb, self._lb = self._lb, None
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason why this is set in 2 lines and not just self.lb, self._lb = self._lb, None?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately yes, it has to be written in two lines because of Python's evaluation order.

In more detail: self.lb is a callback method that internally assigns a value to self._lb. We want to back up the self._lb object from the checkpoint file in a temporary variable lb, then assign None to self._lb. Then the expression self.lb = lb can safely initialize self._lb under the hood.

I couldn't find an better syntax due to how pickling works in Python. Once we're done moving all global variables to the core System class, all of this unsustainable Python code will disappear.

}
lb_lbcoupling_propagate();
} else if (lb_active) {
auto const lb_steps_per_md_step = LB::get_steps_per_md_step(time_step);
auto &lb = system.lb;
auto const lb_steps_per_md_step = lb.get_steps_per_md_step(time_step);
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this naming of the variables and functions misleading, because with tau >= dt (which is forced) there are multiple md steps in between 2 lb/ek steps. better would be md_steps_per_lb_step

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Not only that, but the assertion was also incorrect, because the EK propagation counter was not synchronized with the LB propagation counter. Let me fix that.

Copy link
Member Author

Choose a reason for hiding this comment

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

By the way, we should really think about writing a test for tau > dt with LB + EK active.

*/
double get_tau() const;

auto get_steps_per_md_step(double time_step) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

misleading naming see integrate.cpp

void add_force_density(Utils::Vector3d const &pos,
Utils::Vector3d const &force_density);

auto get_steps_per_md_step(double time_step) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

misleading naming see integrate.cpp

@jngrad jngrad requested a review from RudolfWeeber August 21, 2023 12:16
@jngrad jngrad added the automerge Merge with kodiak label Aug 22, 2023
@kodiakhq kodiakhq bot merged commit 08869c6 into espressomd:python Aug 22, 2023
@jngrad jngrad deleted the long_range_actors branch August 22, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ApiChange automerge Merge with kodiak Core Improvement waLBerla Issues regarding waLBerla integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants