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

Possible bug in a5.markergen.generate method #78

Open
Antonjvv opened this issue Feb 5, 2024 · 8 comments
Open

Possible bug in a5.markergen.generate method #78

Antonjvv opened this issue Feb 5, 2024 · 8 comments
Assignees

Comments

@Antonjvv
Copy link

Antonjvv commented Feb 5, 2024

When generating markers for ascot (from a bbnbi results distribution) using a5.markergen.generate as follows:
nmrk = 4000
anum = 1
znum = 1
mass = 1.007unyt.amu
charge = 1.0
unyt.e
dist = a5_run_tcv.data.active.getdist("5d")
dist.integrate(charge=np.s_[:], time=np.s_[:])
mrk = a5_run_tcv.markergen.generate(nmrk, mass, charge, anum, znum
plt.scatter(mrk["pitch"], mrk["energy"])
image_480

The markers pitch and energy distribution appears to be changed from the bbnbi5 result markers:
mrk = a5_run_tcv.data.active.getstate_markers("gc")
plt.scatter(mrk["pitch"], mrk["energy"])
image_480

@Antonjvv Antonjvv added the bug Something isn't working label Feb 5, 2024
@miekkasarki miekkasarki self-assigned this Feb 5, 2024
@miekkasarki
Copy link
Contributor

In tutorials there is this plot which is obtained in the same way as the buggy plot you posted, but the one in the tutorials seem fine. https://ascot4fusion.github.io/ascot5/_images/tutorials_markergen_13_0.png

This makes me think that the bug is actually in the BBNBI distribution output. Did you plot the distribution you get from a5_run_tcv.data.active.getdist("5d") in momentum space and did it look ok?

@miekkasarki
Copy link
Contributor

Just to clarify: even if BBNBI distribution is broken, the result (i.e. marker output) seems fine, so it is likely that only the diagnostics is broken and nothing is wrong in the physics.

@miekkasarki
Copy link
Contributor

I managed to reproduce this. The BBNBI distribution is ok, so the bug is somewhere within the markergen.

@miekkasarki
Copy link
Contributor

Ok, it does not appear to be a bug, but an artefact produced by having a too coarse (ppar, pperp) grid. @Antonjvv what where your distribution settings in the options? I used 100 x 200 grid for (ppar,pperp) and that produced tolerable results. Eventually we will have implement (ekin,pitch) grid fro BBNBI and Ascot.

@Antonjvv
Copy link
Author

Antonjvv commented Mar 5, 2024

Thanks @miekkasarki !
It looks like I made a mistake setting up the (ppar, pperp) grid, which ended up being quite coarse and also I set the wrong mass (H instead of D) when I called markergen. Now the results look much better. Attached is the results, with blue markers from mrk = a5_run_tcv.data.active.getstate_markers("gc") and orange markers from mrk = a5_run_tcv.markergen.generate(nmrk, mass, charge, anum, znum, dist).
image

My (ppar, pperp) grid is 200x100, with ppar from negative to positive np.sqrt(2m_a const["elementary charge"][0]E); with E=100keV, and pperp is from 0 to np.sqrt(2m_a* const["elementary charge"][0]*E).
The beam main injection energy is around 28keV.

I notice the markers from markergen have a grid cell like structure, could this be due to the ppar, pperp grid?
image

@miekkasarki
Copy link
Contributor

Yeah, that's unfortunately from the grid. We will have to implement (energy,pitch) distributions directly in Ascot's C-kernel (so that BBNBI and AFSI output can be in these coordinates) to make better use of the marker generator tool.

@miekkasarki miekkasarki removed the bug Something isn't working label Mar 7, 2024
@lcarbajal-t1e
Copy link

@miekkasarki I'm having an issue with the function a5.markergen.rhoto5d(), after running an AFSI simulation for a 3-D stellarator case (via a5.afsi.thermal() function), I can generate well the markers (alpha-particles) only when running this on a Mac (Sonoma 14.5) but every time I try to run it on a linux machine it crashes with the error "Segmentation fault (core dumped)", I've tried three different linux systems all with the same result. Any chance this is related to this issue? is there any way to diagnose what could be going wrong?
I'm using ASCOT 5.5.4, and installing with conda (h5cc wrapper using gcc (conda-forge gcc 12.3.0-7) 12.3.0 ). Please, advice if I should file a new issue.
Thanks!

@miekkasarki
Copy link
Contributor

@miekkasarki I'm having an issue with the function a5.markergen.rhoto5d(), after running an AFSI simulation for a 3-D stellarator case (via a5.afsi.thermal() function), I can generate well the markers (alpha-particles) only when running this on a Mac (Sonoma 14.5) but every time I try to run it on a linux machine it crashes with the error "Segmentation fault (core dumped)", I've tried three different linux systems all with the same result. Any chance this is related to this issue? is there any way to diagnose what could be going wrong? I'm using ASCOT 5.5.4, and installing with conda (h5cc wrapper using gcc (conda-forge gcc 12.3.0-7) 12.3.0 ). Please, advice if I should file a new issue. Thanks!

@lcarbajal-t1e I'll make a new issue from this as it could be stellarator-specific.

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

No branches or pull requests

3 participants