|
| 1 | +import matplotlib.pyplot as plt |
| 2 | +import numpy as np |
| 3 | +import openmc |
| 4 | + |
| 5 | +############################################################################### |
| 6 | +# Create materials for the problem |
| 7 | + |
| 8 | +uo2 = openmc.Material(name="UO2 fuel at 2.4% wt enrichment") |
| 9 | +uo2.set_density("g/cm3", 10.29769) |
| 10 | +uo2.add_element("U", 1.0, enrichment=2.4) |
| 11 | +uo2.add_element("O", 2.0) |
| 12 | + |
| 13 | +helium = openmc.Material(name="Helium for gap") |
| 14 | +helium.set_density("g/cm3", 0.001598) |
| 15 | +helium.add_element("He", 2.4044e-4) |
| 16 | + |
| 17 | +zircaloy = openmc.Material(name="Zircaloy 4") |
| 18 | +zircaloy.set_density("g/cm3", 6.55) |
| 19 | +zircaloy.add_element("Sn", 0.014, "wo") |
| 20 | +zircaloy.add_element("Fe", 0.00165, "wo") |
| 21 | +zircaloy.add_element("Cr", 0.001, "wo") |
| 22 | +zircaloy.add_element("Zr", 0.98335, "wo") |
| 23 | + |
| 24 | +borated_water = openmc.Material(name="Borated water") |
| 25 | +borated_water.set_density("g/cm3", 0.740582) |
| 26 | +borated_water.add_element("B", 2.0e-4) # 3x the original pincell |
| 27 | +borated_water.add_element("H", 5.0e-2) |
| 28 | +borated_water.add_element("O", 2.4e-2) |
| 29 | +borated_water.add_s_alpha_beta("c_H_in_H2O") |
| 30 | + |
| 31 | +############################################################################### |
| 32 | +# Define problem geometry |
| 33 | + |
| 34 | +# Create cylindrical surfaces |
| 35 | +fuel_or = openmc.ZCylinder(r=0.39218, name="Fuel OR") |
| 36 | +clad_ir = openmc.ZCylinder(r=0.40005, name="Clad IR") |
| 37 | +clad_or = openmc.ZCylinder(r=0.45720, name="Clad OR") |
| 38 | + |
| 39 | +# Create a region represented as the inside of a rectangular prism |
| 40 | +pitch = 1.25984 |
| 41 | +box = openmc.model.RectangularPrism(pitch, pitch, boundary_type="reflective") |
| 42 | + |
| 43 | +# Create cells, mapping materials to regions |
| 44 | +fuel = openmc.Cell(fill=uo2, region=-fuel_or) |
| 45 | +gap = openmc.Cell(fill=helium, region=+fuel_or & -clad_ir) |
| 46 | +clad = openmc.Cell(fill=zircaloy, region=+clad_ir & -clad_or) |
| 47 | +water = openmc.Cell(fill=borated_water, region=+clad_or & -box) |
| 48 | + |
| 49 | +# Create a model and assign geometry |
| 50 | +model = openmc.Model() |
| 51 | +model.geometry = openmc.Geometry([fuel, gap, clad, water]) |
| 52 | + |
| 53 | +############################################################################### |
| 54 | +# Define problem settings |
| 55 | + |
| 56 | +# Set the mode |
| 57 | +model.settings.run_mode = "fixed source" |
| 58 | + |
| 59 | +# Indicate how many batches and particles to run |
| 60 | +model.settings.batches = 10 |
| 61 | +model.settings.particles = 10000 |
| 62 | + |
| 63 | +# Set time cutoff (we only care about t < 100 seconds, see tally below) |
| 64 | +model.settings.cutoff = {"time_neutron": 100} |
| 65 | + |
| 66 | +# Create the neutron pulse source (by default, isotropic direction, t=0) |
| 67 | +space = openmc.stats.Point() # At the origin (0, 0, 0) |
| 68 | +energy = openmc.stats.delta_function(14.1e6) # At 14.1 MeV |
| 69 | +model.settings.source = openmc.IndependentSource(space=space, energy=energy) |
| 70 | + |
| 71 | +############################################################################### |
| 72 | +# Define tallies |
| 73 | + |
| 74 | +# Create time filter |
| 75 | +t_grid = np.insert(np.logspace(-6, 2, 100), 0, 0.0) |
| 76 | +time_filter = openmc.TimeFilter(t_grid) |
| 77 | + |
| 78 | +# Tally for total neutron density in time |
| 79 | +density_tally = openmc.Tally(name="Density") |
| 80 | +density_tally.filters = [time_filter] |
| 81 | +density_tally.scores = ["inverse-velocity"] |
| 82 | + |
| 83 | +# Add tallies to model |
| 84 | +model.tallies = openmc.Tallies([density_tally]) |
| 85 | + |
| 86 | + |
| 87 | +# Run the model |
| 88 | +model.run(apply_tally_results=True) |
| 89 | + |
| 90 | +# Bin-averaged result |
| 91 | +density_mean = density_tally.mean.ravel() / np.diff(t_grid) |
| 92 | + |
| 93 | +# Plot particle density versus time |
| 94 | +fig, ax = plt.subplots() |
| 95 | +ax.stairs(density_mean, t_grid) |
| 96 | +ax.set_xscale("log") |
| 97 | +ax.set_yscale("log") |
| 98 | +ax.set_xlabel("Time [s]") |
| 99 | +ax.set_ylabel("Total density") |
| 100 | +ax.grid() |
| 101 | +plt.show() |
0 commit comments