fusion-energy / openmc_regular_mesh_plotter

A Python package for plotting OpenMC regular mesh tally results with underlying geometry from neutronics simulations.
MIT License
9 stars 1 forks source link

Tally cannot be scaled #25

Closed RemDelaporteMathurin closed 10 months ago

RemDelaporteMathurin commented 2 years ago

Currently the only tallies that can be scaled are current, flux, heating, damage-energy. I would like to scale (n,Xt) with the strenght of my source, but I can't.

the openmc unit is particle/neutron/m3 (i think) and the desired unit is particle/m3/s

The conversion is desired_units = openmc_units * source_strength [n/s]

RemDelaporteMathurin commented 2 years ago

I think this stands for all reaction rates, is that right @shimwell ?

shimwell commented 2 years ago

plot_regular_mesh_tally takes a source_strength argument.

When combined with required units this should scale the results.

I'm not sure if this works for specific reaction rates, it would depend on the openmc_tally_unit_convertor being able to handle reaction rates.

I think most of the testing is done with flux scaling

I don't have any examples for this but should add one for this

RemDelaporteMathurin commented 2 years ago

When running

plot = plot_regular_mesh_tally_with_geometry(
    tally=my_tally_xz,
    dagmc_file_or_trimesh_object="dagmc_not_merged.h5m",
    plane_origin=(0, 0, 0),
    plane_normal=[0, 1, 0],
    rotate_geometry=90,
    source_strength=1e10,
    required_units="particle/m^3/s",
    scale=LogNorm(),
    vmin=None,
    label="Tritium generation (T/m3/s)",
    filename="my_tally_xz.png",
)

I get

  File "convert_results.py", line 25, in <module>
    plot = plot_regular_mesh_tally_with_geometry(
  File "/home/regular_mesh_plotter/regular_mesh_plotter/core.py", line 123, in plot_regular_mesh_tally_with_geometry
    values = otuc.process_tally(
  File "/opt/conda/lib/python3.8/site-packages/openmc_tally_unit_converter/utils.py", line 313, in process_tally
    base_units = get_score_units(tally)
  File "/opt/conda/lib/python3.8/site-packages/openmc_tally_unit_converter/utils.py", line 607, in get_score_units
    raise ValueError(msg)
ValueError: units for tally can't be found. Tallies that are supported by get_score_units function are those with scores of current, flux, heating, damage-energy

So I think it's just that the score is not supported yet

shimwell commented 2 years ago

Yep it looks like openmc_tally_unit_converter doesn't know about all the reactions possible. It could do with a generic reactions per particle adding to this function

we could perhaps import REACTION_NAME from opemc.data and compare the score with this list to see if it should be assigned units of reactions per particle

RemDelaporteMathurin commented 2 years ago

Yep sounds like the way to go.

In the meantime, is there a simple way to scale the tally by an abitrary float?

Like I just want to do my_tally *= source_strength

shimwell commented 10 months ago

there is now an arg called scaling_factor