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.

@hyschive
Copy link
Contributor

hyschive commented Jan 6, 2026

@BaronYou Just a reminder. Please check the suggestion above.

@hyschive hyschive added enhancement fdm Fuzzy dark matter labels Jan 8, 2026
@hyschive
Copy link
Contributor

hyschive commented Jan 8, 2026

@BaronYou Is PR ready for review? If so, please click the Ready for review button.

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

Labels

enhancement fdm Fuzzy dark matter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants