Skip to content

Commit

Permalink
Use openmc model for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
DanShort12 committed Sep 9, 2020
1 parent c0b0148 commit 0e34dc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions examples/build_xml.py → examples/build_and_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
iron.set_density("g/cm3", 5.0)
iron.add_element("Fe", 1.0)
mats = openmc.Materials([iron])
mats.export_to_xml()

# Create a 5 cm x 5 cm box filled with iron
cells = []
Expand All @@ -46,7 +45,6 @@
cells += [openmc.Cell(fill=None, region=+inner_box1 & -inner_box2)]
cells += [openmc.Cell(fill=iron, region=+inner_box2 & outer_box)]
geometry = openmc.Geometry(cells)
geometry.export_to_xml()

# Tell OpenMC we're going to use our custom source
settings = openmc.Settings()
Expand All @@ -57,7 +55,6 @@
source.library = SOURCE_SAMPLING_PATH
source.parameters = str(plasma)
settings.source = source
settings.export_to_xml()

# Finally, define a mesh tally so that we can see the resulting flux
mesh = openmc.RegularMesh()
Expand All @@ -69,4 +66,9 @@
tally.filters = [openmc.MeshFilter(mesh)]
tally.scores = ["flux"]
tallies = openmc.Tallies([tally])
tallies.export_to_xml()

model = openmc.model.Model(
materials=mats, geometry=geometry, settings=settings, tallies=tallies
)

model.run()
2 changes: 1 addition & 1 deletion examples/plot_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Get the flux from the statepoint
with openmc.StatePoint("statepoint.10.h5") as sp:
flux = np.log(sp.tallies[1].mean)
flux = np.log(sp.get_tally(scores=["flux"]).mean)
flux.shape = (50, 50)

# Plot the flux
Expand Down

0 comments on commit 0e34dc6

Please sign in to comment.