Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@BaronYou
Copy link

@BaronYou BaronYou commented Dec 4, 2025

Summary

This PR adds new runtime parameters ELBDM_RESCALE_MASS_ERROR, which enables GAMER to rescale total mass to its initial total mass every certain number of steps.

Purpose

In base level only simulation, the algorithm ensures total mass conservation. Which means the total mass error only comes from numerical error. Every step accumulates an error of $\sim10^{-7}$ relative to its initial mass. If a simulation is required to run $\sim10^6$ steps, this error will have a significant influence on the result. Run the simulation with double precision is an easy way to resolve this problem, as it accumulates a much smaller error of $\sim10^{-13}$ each step. However, this will cause the run to be very expensive. Therefore, we try to fix the mass error caused by numerical error in single precision run, which allow us to keep both efficiency and accuracy.

New

In Input_Parameter, added ELBDM_RESCALE_MASS_ERROR and ELBDM_RESCALE_MASS_STEPS
Turn this feature on by setting
ELBDM_RESCALE_MASS_ERROR == 1
and specify how many steps you want to rescale total mass to its initial value, by setting
ELBDM_RESCALE_MASS_STEPS == 100
In default, GAMER will rescale total mass every 100 steps if ELBDM_RESCALE_MASS_ERROR is turned on.

Effect

As shown in the figure below, compare the rescale method with single and double precision run, resolves the problem described in above.
image

Method

@technic960183
Copy link
Member

@hyschive I noticed that large binary files appear in the history of this PR.
@BaronYou Could you please use rebase and squash to clean up the commit history?
This would help improve GAMER's repository health.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants