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

Always enable Newton3 within one cell #426

Closed
FG-TUM opened this issue Feb 19, 2020 · 0 comments · Fixed by #745
Closed

Always enable Newton3 within one cell #426

FG-TUM opened this issue Feb 19, 2020 · 0 comments · Fixed by #745
Labels
optimization not a bug, but can optimize speed

Comments

@FG-TUM
Copy link
Member

FG-TUM commented Feb 19, 2020

Is your feature request related to a problem? Please describe.
When calculating the forces within one cell (or any other quantity) should always be doable with Newton3.
However, when mixing functor calls with Newton3 == false in a Newton3 == true iteration the total energy is off by a factor of 0.5.
This is because of the following:
When calculating the global values, if Newton3 is activated, all values are divided by two:

if (newton3) {
upot *= 0.5;
virial = utils::ArrayMath::mulScalar(virial, (double)0.5);
}

and later if newton 3 is deactivated again:
if (not newton3) {
// if the newton3 optimization is disabled we have added every energy contribution twice, so we divide by 2
// here.
_upotSum *= 0.5;
_virialSum = utils::ArrayMath::mulScalar(_virialSum, 0.5);
}

Describe the solution you'd like
For deciding whether or not to divide everything by 0.5 do not (ab)use the Newton3 flag but introduce another.

Describe alternatives you've considered
🤷‍♂️

Additional context
At the moment we call the functor twice with Newton3 == false.

@FG-TUM FG-TUM added the optimization not a bug, but can optimize speed label Feb 19, 2020
@FG-TUM FG-TUM mentioned this issue Feb 19, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization not a bug, but can optimize speed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant