Skip to content

bug report: plot mesh with EnergyFunctionFilter shows zeros everywhere #106

Closed

Description

@shimwell

Really liking the plotting capabilities of this package

I think I stubbled across a small bug

When plotting regular mesh tallies that include a EnergyFunctionFilter the displayed result is all zeros.

This would be a useful feature as plotting dose maps could then be performed

Activity

  1. shimwell commented on Jan 12, 2023

    @shimwell
    MemberAuthor

    Screenshot from 2023-01-12 16-03-16

  2. shimwell commented on Jan 12, 2023

    @shimwell
    MemberAuthor

    minimal code to reproduce

    import openmc
    
    mat_1 = openmc.Material()
    mat_1.add_nuclide('Li6', 1)
    mat_1.set_density('g/cm3', 1)
    my_materials = openmc.Materials([mat_1])
    
    surface_1 = openmc.Sphere(r=100, boundary_type='vacuum')
    region_1 = -surface_1
    cell_1 = openmc.Cell(region=region_1)
    cell_1.fill = mat_1
    
    my_geometry = openmc.Geometry([cell_1])
    
    reg_mesh = openmc.RegularMesh().from_domain(
        my_geometry,
        dimension=[5, 5, 5]
    )
    reg_mesh_filter = openmc.MeshFilter(reg_mesh)
    
    energy_bins_n, dose_coeffs_n = openmc.data.dose_coefficients(
        particle="neutron", geometry="AP"
    )
    energy_function_filter_n = openmc.EnergyFunctionFilter(energy_bins_n, dose_coeffs_n)
    energy_function_filter_n.interpolation == "cubic"
    
    neutron_particle_filter = openmc.ParticleFilter("neutron")
    
    n_reg_mesh_tally = openmc.Tally(name="neutron_dose_on_cell")
    # note that the EnergyFunctionFilter is included as a filter
    n_reg_mesh_tally.filters = [
        neutron_particle_filter,
        energy_function_filter_n,
        reg_mesh_filter
    ]
    n_reg_mesh_tally.id = 1
    n_reg_mesh_tally.scores = ["flux"]
    my_tallies = openmc.Tallies([n_reg_mesh_tally])
    
    my_settings = openmc.Settings()
    
    my_settings.batches = 10
    my_settings.particles = 100000
    my_settings.run_mode = "fixed source"
    
    source = openmc.Source()
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Discrete([14e6], [1])
    source.space = openmc.stats.Point((0.0, 0.0, 0.0))
    
    my_settings.source = source
    
    my_model = openmc.Model(settings=my_settings, geometry=my_geometry, tallies=my_tallies, materials=my_materials)
    
    sp_filename = my_model.run()
    
    sp = openmc.StatePoint(sp_filename)
    
    # shows that the tally is not zero
    print(sp.tallies[1].mean)
  3. shimwell commented on Jan 12, 2023

    @shimwell
    MemberAuthor

    changing this line

    data = data[np.array(selected_bins)].sum(axis=0)

    to

     data = data[np.array(selected_bins)].sum(axis=0) [0]

    and this line

    if type(tally_filter) == openmc.MeshFilter:

    to

    if type(tally_filter) in [openmc.MeshFilter, openmc.EnergyFunctionFilter]:

    is a temporary fix

  4. letibdesneiges commented on Apr 6, 2023

    @letibdesneiges

    Hi,

    I have encountered the same problem when trying to plot doserate data from a flux mesh tally with an EnergyFunctionFilter converting flux to doserate.
    All values are displayed as zero. The above solution did not help unfortunately.

    Attached the statePoint file.
    statepoint.200.h5.zip

    openmc-plotter v. 0.3.1 installed via conda on Debian 11.

  5. letibdesneiges commented on Apr 7, 2023

    @letibdesneiges

    Implementing @shimwell changes to plotmodel.py and changing:

    # set image data, reverse y-axis
    image_data = data[::-1, ...]

    to

    # set image data, reverse y-axis
    data=data.squeeze()
    image_data = data[::-1, ...]
    

    solved it for my specific case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions