Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to set additional ww attrs from openmc.lib #2609

Merged
merged 5 commits into from
Jul 22, 2023

Conversation

pshriwise
Copy link
Contributor

Description

This adds the ability to set additional attributes of WeightWindows objects:

  • survival_ratio
  • max_lower_bound_ratio
  • weight_cutoff
  • max_splits

Fixes # (issue)

#2607

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@shimwell shimwell self-assigned this Jul 18, 2023
@shimwell
Copy link
Member

I notice the CI is failing with ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects and I have seen this on other PRs so I think this error is unrelatead to the PR.

@shimwell
Copy link
Member

I've read through this PR and been making use of it locally. I used the script below to check that the attributes are set and change from their default values. Everything looks good to me.

import openmc
import openmc.lib
mat_water = openmc.Material()
mat_water.add_element("H", 1)
mat_water.add_element("O", 2)
mat_water.set_density("g/cm3", 1.0)
my_materials = openmc.Materials([mat_water])
outer_surface = openmc.model.RectangularParallelepiped(-300, 300, -300, 300, -300, 300, boundary_type="vacuum")
region_1 = -outer_surface
cell_1 = openmc.Cell(region=region_1)
cell_1.fill = mat_water
my_geometry = openmc.Geometry([cell_1])
space = openmc.stats.Point((0, 0, 0))
angle = openmc.stats.Isotropic()
energy = openmc.stats.Discrete([14e6], [1.0])
source = openmc.Source(space=space, angle=angle, energy=energy)
source.particle = "neutron"
mesh = openmc.RegularMesh().from_domain(domain=my_geometry)
mesh.dimension = (2,2,2)
mesh_filter = openmc.MeshFilter(mesh)
flux_tally = openmc.Tally(name="flux tally")
flux_tally.filters = [mesh_filter]
flux_tally.scores = ["flux"]
flux_tally.id = 55
my_tallies = openmc.Tallies()
my_tallies.append(flux_tally)
tallies = openmc.Tallies([flux_tally])
my_settings = openmc.Settings()
my_settings.run_mode = "fixed source"
my_settings.source = source
my_settings.particles = 120
my_settings.batches = 10
my_settings.output = {'tallies': False}
my_model = openmc.Model(my_geometry, my_materials, my_settings, my_tallies)
my_model.export_to_xml()
with openmc.lib.run_in_memory():
    tally = openmc.lib.tallies[55]
    wws = openmc.lib.WeightWindows.from_tally(tally)
    wws.max_split = 25
    wws.survival_ratio = 26
    wws.max_lower_bound_ratio = 27
    wws.weight_cutoff = 28
    for i in range(5):
        openmc.lib.run()
        wws.update_magic(tally)
        openmc.lib.settings.particles = int(openmc.lib.settings.particles * 1.5)
        openmc.lib.export_weight_windows(filename=f'weight_windows{str(i).zfill(2)}.h5')
        openmc.lib.statepoint_write(filename=f'statepoint_simulation_{str(i).zfill(2)}.h5')
        openmc.lib.settings.weight_windows_on = True
wws2 = openmc.hdf5_to_wws(f'weight_windows{str(i).zfill(2)}.h5')
print(wws2)

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks straightforward to me. Thanks @pshriwise!

@paulromano
Copy link
Contributor

@pshriwise Can you push an empty commit to this branch to restart CI from a fresh state?

@shimwell
Copy link
Member

🎉 CI is passing on this PR. Seeing as Paul has approved I'm going to go ahead and merge while I'm here

@shimwell shimwell merged commit afa6ceb into openmc-dev:develop Jul 22, 2023
16 checks passed
stchaker pushed a commit to stchaker/openmc that referenced this pull request Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants