-
Notifications
You must be signed in to change notification settings - Fork 189
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
Fix regression in CPU LB thermalization. #3847
Conversation
9d45249
to
07f633e
Compare
07f633e
to
ad9a70f
Compare
This looks like a candidate for a 4.1.4 release... |
What are the physical consequences of this error? Are all our thermalized fluid simulations of the past 1.5 years wrong? |
the CPU version has probably not been used by many |
looking at this function the issue is the non trivial RNG code. There is a level of abstraction missing. |
@pkreissl, can you please check whether this also solves #3772. This definitely warrants a 4.1.4 release. |
f722423
to
11e2862
Compare
while I see that it might be tempting to think that a test with empirical or arbitrary tolerance is better than no test, we should invest some time in investigating if the tolerance limit can be deduced from some known facts abou the algorithm. A "false green" can harm when it comes to test driven development. Also with the upcoming change to Walberla we should be confident about the tolerance in our testsuite. |
For <sigma_ij> =0, that should be possible.
Since <sigma_ij>^2 can probably be found in Ulf’s thesis and one can assume that a Gaussian distribution is present.
For the ACF, the situation is too complicated, as a numerical integration and a least square fit is involved.
The semi-empirical tolerance was 10% deviation from prescribed viscosity. Based on the work that Patrick and I did on evaluating viscosity from stress acf, that’s probably as good as it gets.
More generally, we might have to introduce some long-running tests that run in a separate CI task.
Running some of them 10x as long as we do now is the only way to be absolutely sure that they converge to the correct value.
The need for that became apparent with the Walberla branch.
E.g., slight errors in ghost layer handling caused momentum changes that only became apparent in long simulations.
The error was of a nature I hadn’t considered when writing unit tests.
|
I thought @pkreissl already checked and was not sure if he found it or not |
The respective correlations for D3Q19 are given in eq. (4.51) of Ulfs dissertation -- however, they depend on the eigenvalues. I guess, those can be obtained via eqs. (4.29)/(4.30). But as I already mentioned, I have not yet had in-depth contact with the document (and its notation), so I am not yet overly confident, here. Comments from people with higher LB expertise are welcome (@mkuron , @KaiSzuttor ?). |
if I'd know what we are looking for I'd let you know 😃 |
The expected variance of the stress tensor element combinations in terms of LB input parameters... :) |
My knowledge about thermalization is contained in https://i10git.cs.fau.de/pycodegen/lbmpy/-/blob/master/lbmpy/fluctuatinglb.py, which was directly translated form Ulf's thesis. |
where are the unit tests. That's the interesting part... |
as far as I can see the unit tests in walberla also have "empirical" accuracy limits. So this does not help. @mkuron could you please have a look at the highly cited thesis and check if we can extract values for the accuracy limits? |
Correct me if I'm wrong: |
In LbmPy, stresss tensor fluctuagions can be matched against the expressions
The same should be possible in Espresso. There, the relaxation rates match |
|
with p_var_diag_expected == <R_{alpha,alpha},R_{beta,beta}>, fluctuations in the trace, this is actually exactly eq. (61) in the Phys. Rev. E you cited... |
ah I was not able to parse the tensor of rank 4 in my head and missed Eq. 61. You are probably right. |
so we should at least add this test to the walberla PR |
Looking into that right now... |
Turns out that the test in lbmpy only works for the relaxation rates I chose randomly. Lottery win... In fact, the stress tensor fluctuations <sigma_{ij}^2> do not depend on the relaxation rates at all. In fact, the expression in the paper is used in LbmPy when adding the fluctuations in fluctuation_amplitude_from_temperature() |
Correct, these are the equations for |
6627b24
to
0726a56
Compare
0726a56
to
bd25df9
Compare
In MD units, |
21b65f2
to
e42940b
Compare
e42940b
to
868818a
Compare
With re-enabled acf test for GPU the test takes ~27 s on the local machine. I excluded the test from the builds with coverage, still |
The |
So, I've added references to the relevant equations in scientific publications. For me, that would mean: In the test, however, the stress matches the above expression without the factor 2 in the -term (with factor it would be off)! |
@pkreissl should it be documented in the LB code? Doxygen supports LaTeX, see e.g. bonded_interactions.dox for the syntax. |
You mean the expected stress tensor value? Can do that, but I don't think that this directly occurs in the core. There just the thermalization fluctuations are added to the modes and the tensor evaluated. If you still find that useful, sure, I can add it as a comment to |
nevermind, I mixed up the python test we looked into this morning and the source code :) maybe it would be helpful to write a short comment about the kinetic energy formula and equipartition, so that future developers know why there is no factor 2 in there |
Fixes espressomd#3804 , fixes espressomd#3772 The issue was actually a regression that happened with the switch to philox in commit [f3cc4ba](espressomd@f3cc4ba). Random numbers formerly part of the interval (-0.5,0.5] were replaced by random numers in (0,1]. With this fix the `lb_pressure_tensor_acf.py` runs successfully for both CPU and GPU. However, as @KaiSzuttor correctly mentioned in PR espressomd#3831 the CPU part of the test takes a while to execute (on my machine, single core the whole test takes 136 s). I could try to make that faster which, however, would require tweaking the tolerance limits `tol_node` and `tol_global`. @RudolfWeeber , what was your reasoning behind the chosen limits? Or are they semi-arbitrary choices? Further, this PR corrects the comparison of the off-diagonal elements `avg_ij` vs. `avg_ji` in the test.
Fixes #3804 , fixes #3772
The issue was actually a regression that happened with the switch to philox in commit
f3cc4ba. Random numbers formerly part of the interval (-0.5,0.5] were replaced by random numers in (0,1].
With this fix the
lb_pressure_tensor_acf.py
runs successfully for both CPU and GPU. However, as @KaiSzuttor correctly mentioned in PR #3831 the CPU part of the test takes a while to execute (on my machine, single core the whole test takes 136 s). I could try to make that faster which, however, would require tweaking the tolerance limitstol_node
andtol_global
. @RudolfWeeber , what was your reasoning behind the chosen limits? Or are they semi-arbitrary choices?Further, this PR corrects the comparison of the off-diagonal elements
avg_ij
vs.avg_ji
in the test.