fusion-energy / openmc-plasma-source

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

Units of Major and minor radii in Tokamak sources #75

Closed Adambar24 closed 1 year ago

Adambar24 commented 1 year ago

Hi when creating and setting my source to a Tokamak source I followed the examples as shown. This states that the major and minor radii are in metres (also stated in the source code). Though when I actually fit this to a EU demo model the source appears near the origin. I changed the units to cm (i.e major _radius *100) and it fitted within my demo reactor. This was confirmed with a paraview image of the traces shown below (Images showing CM compared to M as an input). I don't know if it was a typo or something fundamentally different in the code.

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=906,
    minor_radius=292.2,
    pedestal_radius=0.8 * 292.2,
    mode="H",
    shafranov_factor= 0.44789,
    triangularity=0.270,
    ion_temperature_beta=6,
    angles = (0, math.pi/2),
    sample_size= 10
)

Other consideration are how this affects other properties. I believe the Shafranov factor is a ratio of these radii multiplied by the ratio of direction field strength so the cm to m conversion shouldn't affect this. I don't believe any other value needs changing in the parameters.

DEMO_Radii_cm DEMO_Radii_M

RemDelaporteMathurin commented 1 year ago

Hi @Adambar24 thanks for your report

Just to clarify: the top image was created with:

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=906,
    minor_radius=292.2,
    pedestal_radius=0.8 * 292.2,
    mode="H",
    shafranov_factor= 0.44789,
    triangularity=0.270,
    ion_temperature_beta=6,
    angles = (0, math.pi/2),
    sample_size= 10
)

and the bottom one with:

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.922,
    pedestal_radius=0.8 * 292.2,
    mode="H",
    shafranov_factor= 0.44789,
    triangularity=0.270,
    ion_temperature_beta=6,
    angles = (0, math.pi/2),
    sample_size= 10
)
RemDelaporteMathurin commented 1 year ago

You may be onto something here! OpenMC uses cm as units and I don't think we make any kind of conversion so it's likely a docstrings mistake.

Regarding the shafranov factor, I believe it is completely decoupled from the radii and down to the user so this shouldn't affect anything else.

Feel free to open a PR to fix the docstrings! 😃

shimwell commented 1 year ago

Yep I think the input numbers are just taken as they are and passed to openmc. So they end up in cm as this is the native unit in openmc

Nice model you have there @Adambar24

Adambar24 commented 1 year ago

Hi yes @RemDelaporteMathurin the top image was created using the top set of input (the one in cm). I will open a request and sort it today.

Thanks @shimwell