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

Tiny numerical instabilities in the Energy and Momentum Computations #1109

Open
davschneller opened this issue May 13, 2024 · 2 comments
Open

Comments

@davschneller
Copy link
Contributor

davschneller commented May 13, 2024

Describe the bug
The energy and especially momentum computations inhibit slight numerical fluctuations between runs, since the summation order varies due to OpenMP threading. It's most visible for the momentum calculations in the end (due to the different signs and magnitudes of the components there). However, that may also point to the numerical momentum/energy results being slightly off (in some lesser significant digit), even without threading.
Maybe it would be useful to have a stable summation algorithm (e.g. Kahan summation or the likes) in the reduction?

Expected behavior
Reproducable values for energy and momentum, preferrably without numerical errors.

To Reproduce
Steps to reproduce the behavior:

  1. Which version do you use? Provide branch and commit id. Should happen on any commit with energy output. Take master: cdc14af
  2. Which build settings do you use? Which compiler version do you use? Default settings, ninja as build tool. GCC 13.2.1
  3. On which machine does your problem occur? If on a cluster: Which modules are loaded? Should happen everywhere. Tested it only on an own laptop and HomeOne (old software stack).
  4. Provide parameter/material files. Take e.g. Examples/tpv5 and preferrably scale down the mesh considerably.

Screenshots/Console output
Two runs on the same mesh:

Run 1

Mon May 13 09:33:11, Info:  Writing energy output at time 0.5 
Mon May 13 09:33:11, Info:   Elastic energy (total, % kinematic, % potential):  45828907986183.9  , 32.9355116010478  , 67.0644883989522 
Mon May 13 09:33:11, Info:   Total momentum (X, Y, Z): 0.821407467126846  , 9.94324527494609  , -6.11154559440911 
Mon May 13 09:33:11, Info:   Frictional work (total, % static, % radiated):  47221710417902.9  , 77.6918007508808  , 22.3081992491192 
Mon May 13 09:33:11, Info:   Seismic moment (without plasticity): 1.42187270151286e+17  Mw: 5.36524047752774 
Mon May 13 09:33:11, Info:  Writing energy output at time 0.5 Done.
Mon May 13 09:33:14, Info:  Writing energy output at time 1 
Mon May 13 09:33:14, Info:   Elastic energy (total, % kinematic, % potential):  166216128067038  , 17.1108673121962  , 82.8891326878038 
Mon May 13 09:33:14, Info:   Total momentum (X, Y, Z): 154.467472076416  , -3683.37903022766  , 437.808065414429 
Mon May 13 09:33:14, Info:   Frictional work (total, % static, % radiated):  161658240184471  , 72.3535972685184  , 27.6464027314816 
Mon May 13 09:33:14, Info:   Seismic moment (without plasticity): 5.37237046063348e+17  Mw: 5.75011063501262 
Mon May 13 09:33:14, Info:  Writing energy output at time 1 Done. 

Run 2

Mon May 13 09:05:19, Info:  Writing energy output at time 0.5 
Mon May 13 09:05:19, Info:   Elastic energy (total, % kinematic, % potential):  45828907986183.9  , 32.9355116010478  , 67.0644883989522 
Mon May 13 09:05:19, Info:   Total momentum (X, Y, Z): 0.838717415928841  , 9.94186248257756  , -6.11485366895795 
Mon May 13 09:05:19, Info:   Frictional work (total, % static, % radiated):  47221710417902.9  , 77.6918007508808  , 22.3081992491192 
Mon May 13 09:05:19, Info:   Seismic moment (without plasticity): 1.42187270151286e+17  Mw: 5.36524047752774 
Mon May 13 09:05:19, Info:  Writing energy output at time 0.5 Done. 
Mon May 13 09:05:22, Info:  Writing energy output at time 1 
Mon May 13 09:05:22, Info:   Elastic energy (total, % kinematic, % potential):  166216128067038  , 17.1108673121963  , 82.8891326878037 
Mon May 13 09:05:22, Info:   Total momentum (X, Y, Z): 154.488586425781  , -3683.39056396484  , 437.76358795166 
Mon May 13 09:05:22, Info:   Frictional work (total, % static, % radiated):  161658240184471  , 72.3535972685184  , 27.6464027314816 
Mon May 13 09:05:22, Info:   Seismic moment (without plasticity): 5.37237046063348e+17  Mw: 5.75011063501262 
Mon May 13 09:05:22, Info:  Writing energy output at time 1 Done. 

Here, only the momentum differs slightly; but it's also thinkable that there may be cases where the energy causes problems: though it is affected less by all of its values to sum up being non-negative, summing up values of largely different magnitude may distort the results as well.

Additional context
None.

@vikaskurapati
Copy link
Contributor

Is anyone else except me using the momentum calculations? I don't know if it is really worth it to do just for momentum calculations unless it is actually noticed in the energy calculations with some significance.

@davschneller
Copy link
Contributor Author

They indirectly helped me to spot a bug in #1103 —where an unusually high momentum was eventually caused by a bug which caused a too large timeskip (that's also when I noticed the value varying per run).

The terminal output is generally pretty useful for quick pseudo-verification if something broke IMO. But I haven't spotted such a behavior yet for the energy values—however I have only recently started to print them with so many significant digits. So—probably it's nice-to-have, but low priority to my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants