Skip to content

Commit

Permalink
started conderc examlpe
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Jun 5, 2023
1 parent 481fe37 commit 9f239ba
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions examples/decay_heat_vs_time/decay_heat_vs_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import openmc
import openmc_depletion_plotter
import openmc.deplete
import math



# makes a simple material from Silver
my_material = openmc.Material()
my_material.add_element('Fe', 1, percent_type='ao')
my_material.set_density('g/cm3', 10.49)

sphere_radius = 100
volume_of_sphere = (4/3) * math.pi * math.pow(sphere_radius, 3)
my_material.volume = volume_of_sphere # a volume is needed so openmc can find the number of atoms in the cell/material
my_material.depletable = True # depletable = True is needed to tell openmc to update the material with each time step

materials = openmc.Materials([my_material])
materials.export_to_xml()

# GEOMETRY

# surfaces
sph1 = openmc.Sphere(r=sphere_radius, boundary_type='vacuum')

# cells, makes a simple sphere cell
shield_cell = openmc.Cell(region=-sph1)
shield_cell.fill = my_material

# sets the geometry to the universe that contains just the one cell
universe = openmc.Universe(cells=[shield_cell])
geometry = openmc.Geometry(universe)

# creates a 14MeV neutron point source
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14e6], [1])
source.particles = 'neutron'

# SETTINGS

# Instantiate a Settings object
settings = openmc.Settings()
settings.batches = 2
settings.inactive = 0
settings.particles = 10000
settings.source = source
settings.run_mode = 'fixed source'

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

operator = openmc.deplete.CoupledOperator(
model=model,
normalization_mode="source-rate", # set for fixed source simulation, otherwise defaults to fission simulation
dilute_initial=0, # set to zero to avoid adding small amounts of isotopes, defaults to adding small amounts of fissionable isotopes
reduce_chain=True, # reduced to only the isotopes present in depletable materials and their possible progeny
reduce_chain_level=5,
)

# We define timesteps together with the source rate to make it clearer
timesteps_and_source_rates = [
(5*60, 1e20),
(35, 0),
(15, 0),
(15, 0),
(16, 0),
(15, 0),
(26, 0),
(36, 0),
(36, 0),
(52, 0),
(66, 0),
(67, 0),
(97, 0),
(123, 0),
(123, 0),
(184, 0),
(246, 0),
(247, 0),
(246, 0),
(427, 0),
(607, 0),
(606, 0),
]

# Uses list Python comprehension to get the timesteps and source_rates separately
timesteps = [item[0] for item in timesteps_and_source_rates]
source_rates = [item[1] for item in timesteps_and_source_rates]

integrator = openmc.deplete.PredictorIntegrator(
operator=operator,
timesteps=timesteps,
source_rates=source_rates,
timestep_units = 's'
)

integrator.integrate()

results = openmc.deplete.ResultsList.from_hdf5("depletion_results.h5")

plot = results.plot_decay_heat_vs_time(
x_scale='log',
y_scale='log',
excluded_material=my_material
)
plot.show()

0 comments on commit 9f239ba

Please sign in to comment.