fsciortino / Aurora

Modern toolbox for impurity transport, neutrals and radiation modeling in magnetically-confined plasmas
https://aurora-fusion.readthedocs.io
MIT License
41 stars 24 forks source link

Improve source handling in forward model #37

Closed fsciortino closed 2 years ago

fsciortino commented 3 years ago

This PR collects works to improve the way sources are handled in the Aurora forward model of particle transport.

Main objectives:

This is work in progress (WIP).

tomodstrcil commented 3 years ago

Now I can run the code, but when I do it, in a few timesteps the density diverges and it is infinite. It is working for you? I have use the default setting in IMPRAD, default analytical profiles, default source (constant in time).

odstrcilt commented 3 years ago

@fsciortino still, there is some bug in recycling when I set R = 0. Any value of R > 0 works. Do you know where could be this bug?

odstrcilt commented 3 years ago

Another issue, if I need to vary a source during the inference, I will have to call the function 'setup_kin_profs_depts' or at least 'get_radial_source' in every iteration.

fsciortino commented 3 years ago

@odstrcilt I see the issue. I'm working on it. I'm going to clean up the particle conservation routine first, eliminate redundant use of xarray, and then move on from there.

fsciortino commented 3 years ago

Another issue, if I need to vary a source during the inference, I will have to call the function 'setup_kin_profs_depts' or at least 'get_radial_source' in every iteration.

@odstrcilt regarding this, I don't think that we can do much to improve this. Depending how what kind of source option you're interested in, I would recommend calling get_radial_source at every iteration, or just changing self.src_core via direct creation/interpolation of whatever source profile you have.

odstrcilt commented 3 years ago

@fsciortino I have solved the issue with varying source in the IMPRAD GUI. If the source is 1D function, it will call source_utils.get_source_time_history in each iteration and multiply it with source_rad_prof in aurora class to get src_core. And for any source (including 2D), there is a new variable imp+'_source_scale', which will just scale asim.src_core by some number.

odstrcilt commented 3 years ago

@fsciortino new issue, if the kinetics profiles are changing in time, particle conservation is not working. The recycling source will have to vary in time as well.

fsciortino commented 3 years ago

@odstrcilt OK, I updated rcl_rad_prof to be time-dependent. I also merged some things from master into this branch -- I'm kind of worried that there may be something wrong in atomic.interp_atom_prof at this point... Let me know how it looks to you.

odstrcilt commented 3 years ago

@fsciortino I have found two issues with interpolation. If the grid was too fine, it has not detected the non-equal spacing and it was crashed during extrapolation. But else it works fine, I have compared it with RectBivariateSpline and the results are nearly exactly the same.

fsciortino commented 2 years ago

Merging since we seem to have resolved all the raised issues. Glad that we got this done, @odstrcilt !