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
21 stars 6 forks source link

BBNBI5 resulting markers and distribution weights don't match #96

Closed Otsooni closed 3 months ago

Otsooni commented 4 months ago

The results from the bbnbi simulation do not agree with eachother. According to the source code: ` pdiag.weight[i] /= p.mileage[i] + hin[i]; }

    /* Update distributions for markers that finished */
    diag_update_fo(&sim->diag_data, &sim->B_data, &pdiag, &p);

    /* Update running particles */
    n_running = particle_cycle_fo(pq, &p, &sim->B_data, cycle);

`

pdiag is the marker at the end of the timestep, of which the distribution weights are calculated. Meanwhile p is the marker at the "beginning" of the time step and is used for defining the marker data.

To get them to match the first line can be changed to pdiag.weight[i] /=hin[i];. However, that should skew the distribution quite a bit.

Has somebody noticed anything weird with bbnbi5 distributions before?

miekkasarki commented 4 months ago

Yes it should be pdiag.weight[i] /=hin[i];. The reason why it is divided with hin is that within the routines that update the distribution, the marker's contribution is weight*hin. With BBNBI we want to have just weight since the output will be in [particles/s], not [particles] like in ASCOT simulation.

It's my mistake that there's also mileage since I didn't realize that only the last step is added to the distribution. You can go ahead and fix that.

(Things will get a bit more complicated once someone needs the neutral density from BBNBI as that will be again in units of [particles])