ascot4fusion / ascot5

ASCOT5 is a high-performance orbit-following code for fusion plasma physics and engineering
https://ascot4fusion.github.io/ascot5/
GNU Lesser General Public License v3.0
31 stars 9 forks source link

Distributions not properly updated when using adaptive timestep #101

Open rui-coelho opened 8 months ago

rui-coelho commented 8 months ago

When testing ASCOT5 to benchmark against ASCOT4, i found that when using "SIM_MODE":2, "ENABLE_ADAPTIVE":1 as the grid resolution increases there is a notorious degradation/filamentation in the distribution function on slowing down. The following figure illustrates the several cases.

Screenshot 2024-03-27 at 15 54 28
miekkasarki commented 8 months ago

I pushed the fix on hotfix/101-distributions-not-properly-updated-when-using-adaptive-timestep if you want to try it out @rui-coelho .

The distributions are updated by depositing weight dt to the bin where marker is at the end of the time-step. The problem was that if dt varies (as it does in the adaptive time-step) this leads to bias. This was fixed by depositing weight dt / 2 to the final position/bin and weight * dt /2 to the initial position/bin.