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

lbboundaries reset after lbf.load_checkpoint() #4647

Closed
christophlohrmann opened this issue Jan 10, 2023 · 2 comments · Fixed by #4649
Closed

lbboundaries reset after lbf.load_checkpoint() #4647

christophlohrmann opened this issue Jan 10, 2023 · 2 comments · Fixed by #4649
Assignees

Comments

@christophlohrmann
Copy link
Contributor

After loading lb populations from checkpoint, boundary flags disappear and the fluid accelerates indefinitely

import numpy as np
import tempfile
import espressomd
import espressomd.lb
import espressomd.lbboundaries
import espressomd.shapes
import espressomd.checkpointing


def assert_has_boundaries(lbf):
    if np.sum(lbf[:,:,:].boundary) == 0:
        raise AssertionError("no boundary flags set in lb fluid")


system = espressomd.System(box_l = 3*[10])
system.time_step = 1
lbf = espressomd.lb.LBFluid(agrid = 1, tau=1, visc = 0.2, dens=1)
system.actors.add(lbf)
bound_shape = espressomd.shapes.Sphere(center = 3*[5], radius = 2)
lbbound = espressomd.lbboundaries.LBBoundary(shape = bound_shape)
system.lbboundaries.add(lbbound)
assert_has_boundaries(lbf)

checkpoint = espressomd.checkpointing.Checkpoint(
    checkpoint_id="test",
    checkpoint_path="./",
)
checkpoint.register("system")
checkpoint.save()
lbf.save_checkpoint('./test/lbf.cp', binary=True)
system.actors.clear()
system.lbboundaries.clear()

checkpoint.load()
assert_has_boundaries(lbf)

lbf.load_checkpoint('./test/lbf.cp', binary=True)
assert_has_boundaries(lbf)
@jngrad jngrad self-assigned this Jan 10, 2023
@jngrad
Copy link
Member

jngrad commented Jan 10, 2023

Thank you for this MWE!

When reloading LB populations, any LB boundary information is overwritten with zeros. There is functionality to regenerate the LB boundary information, but the callback call is missing. Here is the bugfix for 4.2.0 and 4.3-dev:

diff --git a/src/core/grid_based_algorithms/lb.cpp b/src/core/grid_based_algorithms/lb.cpp
index 504f3088f..a6e37cb58 100644
--- a/src/core/grid_based_algorithms/lb.cpp
+++ b/src/core/grid_based_algorithms/lb.cpp
@@ -33,4 +33,5 @@
 #include "communication.hpp"
 #include "errorhandling.hpp"
+#include "event.hpp"
 #include "grid.hpp"
 #include "grid_based_algorithms/lb_boundaries.hpp"
@@ -208,3 +209,4 @@ void lb_initialize_fields(std::vector<LB_FluidNode> &lb_fields,
 #endif // LB_BOUNDARIES
   }
+  on_lbboundary_change();
 }

Could you please confirm that your simulations are fixed with this change? From my side, both the testsuite and your MWE are successful.

This regression was introduced in 4.2.0, back when serialization of object lists was temporarily removed from ESPResSo. The checkpointing test worked around this issue by checking LB boundaries before the LB populations were reloaded. I'll rewrite the test to check LB boundary information both before and after the LB populations are reloaded.

@jngrad jngrad added this to the Espresso 4.2.1 milestone Jan 10, 2023
@christophlohrmann
Copy link
Contributor Author

works like a charm

jngrad added a commit that referenced this issue Jan 12, 2023
Fixes #4647

Description of changes:
- bugfix: reloading LB populations no longer clears LB boundary flags
jngrad added a commit to jngrad/espresso that referenced this issue Jan 19, 2023
Fixes espressomd#4647

Description of changes:
- bugfix: reloading LB populations no longer clears LB boundary flags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants