fusion-energy / openmc-plasma-source

Creates a plasma source as an openmc.source object from input parameters that describe the plasma
MIT License
25 stars 11 forks source link

Creating positive Z-only source #78

Closed emaartensson closed 1 year ago

emaartensson commented 1 year ago

Hello,

I'm trying to create an openmc model where I only model one half of the tokamak since my model is completely up/down symmetrical. Any ideas how I should accomplish this in TokamakSource()? I'm happy to create the entire source and then remove the source-points above or below the Z=0-plane but unsure how to remove points when I create the source like below. I can iterate over the my_source.sources and get the space-variable. Could I just delete the data points I don't want from the list?

Maybe it would be useful to have a Z-delimiter option in the input arguments, similar to the angles-argument.

my_source = TokamakSource(
    elongation=1.557,
    ion_density_centre=1.09e20,
    ion_density_peaking_factor=1,
    ion_density_pedestal=1.09e20,
    ion_density_separatrix=3e19,
    ion_temperature_centre=45.9,
    ion_temperature_peaking_factor=8.06,
    ion_temperature_pedestal=6.09,
    ion_temperature_separatrix=0.1,
    major_radius=9.06,
    minor_radius=2.92258,
    pedestal_radius=0.8 * 2.92258,
    mode="H",
    shafranov_factor=0.44789,
    triangularity=0.270,
    ion_temperature_beta=6
  )
emaartensson commented 1 year ago

If anyone want to create a positive Z plasma source, this is how I did it:

indexes = np.where(source.RZ[1] > 0)[0]
source.sources = list(np.array(source.sources)[indexes])
source.RZ = (list(np.array(source.RZ[0][indexes])), 
             list(np.array(source.RZ[1])[indexes]))
source.neutron_source_density =\
            list(np.array(source.neutron_source_density)[indexes])
RemDelaporteMathurin commented 1 year ago

Oops sorry I seem to have missed this! Yes deleting point afterwards should work!

shimwell commented 1 year ago

Is this functionality useful enough to others to merit a PR, I guess the source currently only works for models centered at z=0 which is a bit inconvenient

RemDelaporteMathurin commented 1 year ago

I'm not sure if this should have a PR. @emaartensson 's solution seems easy enough. Do you need to call list? Also the problem here is not that the source isn't centered on z=0 but rather that we want to remove all the z<0 points

shimwell commented 1 year ago

ok then I think we can close this issue, feel free to reopen if needed

emaartensson commented 1 year ago

Hi both, thanks for your message. I'm not sure how useful it is for other people, I only did it because my model is up-down symmetrical and I wanted to improve convergence.

@RemDelaporteMathurin, I tried to not create a list again but openmc didn't like source.sources not being a list for some reason.

I only did the RZ and neutron_source_density as well so I could plot it: source_plot_2d

If you want a PR then I could try and add to the class, but completely up to you.