@paulromano Here is my scipt.Thanks in advance.
import math
import os
from numpy.core.numeric import Infinity
from numpy.lib.utils import source
from openmc import cell, nuclide, region
from openmc.deplete import results
from openmc.deplete.results_list import ResultsList
import openmc.model
import openmc
import openmc.filter
from openmc import geometry
from openmc.model.funcs import subdivide
from openmc.model.model import Model
import openmc.stats
import openmc.statepoint
import openmc.deplete
import numpy as np
from xml.etree.ElementTree import ElementTree
dress_work = '/home/jason/study'
os.chdir(dress_work)
fuel_lat = 17
ctrl_rods_num_s = 24
axial_div = 11
fuel_dict = {"U235": 7.67425E+20, "U238": 2.3686E+22, 'O16': 4.89068E+22,
'I135': 0, 'Xe135': 0, 'Xe136': 0, 'Cs135': 0, 'Gd157': 0, 'Gd156': 0, 'U234': 0, }
rods_dict = {'Ag107': 2.3523E-02, 'Ag109': 2.1854e-02, 'In113': 3.4291E-04, 'In115': 7.6504E-03,
'Cd108': 2.4221E-05 + 3.4019E-05,
'Cd110': 3.3991E-04, 'Cd111': 3.4835E-04, 'Cd112': 6.5669E-04, 'Cd113': 3.3257E-04, 'Cd114': 7.8188E-04,
'Cd116': 2.0384E-04}
fuel_dict_list = []
for i in range((fuel_lat**2-ctrl_rods_num_s)*axial_div):
fuel_dict_list.append(fuel_dict)
fuel_density = 7.67425E+20 + 2.3686E+22+4.89068E+22
fuel_density_list = []
for i in range((fuel_lat**2-ctrl_rods_num_s)*axial_div):
fuel_density_list.append(fuel_density)
fuel_volume = math.pi*0.4096**2*10
def settings():
point = openmc.stats.Point((0, 0, 0))
source = openmc.Source(space=point)
settings = openmc.Settings()
settings.source = source
settings.particles = 20000
settings.inactive = 50
settings.batches = 150
return settings
def init_depletion_model(aim_rod_height):
point = openmc.stats.Point((0, 0, 0))
source = openmc.Source(space=point)
settings = openmc.Settings()
settings.source = source
settings.particles = 10000
settings.inactive = 50
settings.batches = 150
tallies = openmc.Tallies()
mesh = openmc.RectilinearMesh(name='3d_lattice tally')
x_grid = []
y_grid = []
z_grid = []
for i in range(18):
x_grid.append(-10.71 + 1.26 * i)
mesh.x_grid = x_grid
for j in range(18):
y_grid.append(-10.71 + 1.26 * j)
mesh.y_grid = y_grid
for k in range(11):
z_grid.append(-55 + 10 * k)
mesh.z_grid = z_grid
energy_filter = openmc.EnergyFilter([0, 0.625, 20.0e6])
mesh_filter = openmc.MeshFilter(mesh)
tally = openmc.Tally(name='mesh tally')
tally.filters = [mesh_filter, energy_filter]
tally.scores = ['flux', 'fission', 'nu-fission']
tallies.append(tally)
tallies.export_to_xml()
fuel_frg = []
for i in range((fuel_lat**2-ctrl_rods_num_s)*axial_div):
fuel_frg.append(openmc.Material(material_id=i+1,
name='uo2 fragmentation'))
for f_nu in fuel_dict_list[i].keys():
fuel_frg[i].add_nuclide(f_nu, fuel_dict_list[i][f_nu])
fuel_frg[i].set_density("atom/cm3", fuel_density_list[i])
fuel_frg[i].volume = fuel_volume
ctrl_rods = openmc.Material(material_id=(
fuel_lat**2-ctrl_rods_num_s)*axial_div+1, name='control rods')
for r_nu in rods_dict.keys():
ctrl_rods.add_nuclide(r_nu, rods_dict[r_nu])
ctrl_rods.set_density('g/cm3', 10.159)
water = openmc.Material(material_id=(
fuel_lat**2-ctrl_rods_num_s)*axial_div+2, name='water')
water.add_nuclide('H1', 2)
water.add_nuclide('O16', 1)
water.set_density('g/cm3', 1.0)
water.add_s_alpha_beta("c_H_in_H2O")
materials = openmc.Materials([ctrl_rods, water])
for i in range((fuel_lat**2-ctrl_rods_num_s)*axial_div):
materials.append(fuel_frg[i])
ctrl_rods_height_top = 55
rods_height = ctrl_rods_height_top - aim_rod_height
if rods_height % 10 == 0 and aim_rod_height == ctrl_rods_height_top:
mix_height = -5
position = 0
elif rods_height % 10 == 0:
mix_height = -5
position = 1
else:
mix_height = 5-(rods_height % 10)
position = 0
# fuel cell
fuel_radius = openmc.ZCylinder(r=0.4096)
pin_cell = openmc.Cell(name='pin_cell', fill=fuel_frg, region=-fuel_radius)
box_out = openmc.Cell(name='out cell', fill=water, region=+fuel_radius)
# control rods cell
ctrl_rods_radius = openmc.ZCylinder(r=0.5605)
ctrl_cell = openmc.Cell(name='control_rods', fill=ctrl_rods)
rods_region = -ctrl_rods_radius
ctrl_cell.region = rods_region
out_region = ~rods_region
ctrl_cell_outer = openmc.Cell(
name='outer cell', fill=water, region=out_region)
# fuel & rods cell
h = openmc.ZPlane(z0=mix_height)
water_part_region = -h
fuel_part = openmc.Cell(
name='water part', fill=water, region=water_part_region)
rods_part_region = +h & -ctrl_rods_radius
rods_part = openmc.Cell(
name='rods part', fill=ctrl_rods, region=rods_part_region)
out_rods_part_region = +h & + ctrl_rods_radius
out_rods_part = openmc.Cell(
name='out rods part', fill=water, region=out_rods_part_region)
# water cell
water_box = openmc.rectangular_prism(1.26, 1.26)
water_box_region = water_box
water_cell = openmc.Cell(
name='water box', fill=water, region=water_box_region)
u1 = openmc.Universe(name='fuel_universe',
cells=[pin_cell, box_out])
u2 = openmc.Universe(name='rod_universe', cells=[
ctrl_cell, ctrl_cell_outer])
u3 = openmc.Universe(name='mix_universe', cells=[
fuel_part, rods_part, out_rods_part])
u4 = openmc.Universe(name='water universe', cells=[water_cell])
u_fuel = [
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u4, u1, u1, u4,
u1, u1, u4, u1, u1, u1, u1, u1],
[u1, u1, u1, u4, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u4, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u4, u1, u1, u4, u1, u1, u4,
u1, u1, u4, u1, u1, u4, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u4, u1, u1, u4, u1, u1, u1,
u1, u1, u4, u1, u1, u4, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u4, u1, u1, u4, u1, u1, u4,
u1, u1, u4, u1, u1, u4, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u4, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u4, u1, u1, u1],
[u1, u1, u1, u1, u1, u4, u1, u1, u4,
u1, u1, u4, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1]]
u_rods = [
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u2, u1, u1, u2,
u1, u1, u2, u1, u1, u1, u1, u1],
[u1, u1, u1, u2, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u2, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u2, u1, u1, u2, u1, u1, u2,
u1, u1, u2, u1, u1, u2, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u2, u1, u1, u2, u1, u1, u1,
u1, u1, u2, u1, u1, u2, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u2, u1, u1, u2, u1, u1, u2,
u1, u1, u2, u1, u1, u2, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u2, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u2, u1, u1, u1],
[u1, u1, u1, u1, u1, u2, u1, u1, u2,
u1, u1, u2, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1]]
u_fuel_with_rods = [
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u3, u1, u1, u3,
u1, u1, u3, u1, u1, u1, u1, u1],
[u1, u1, u1, u3, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u3, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u3, u1, u1, u3, u1, u1, u3,
u1, u1, u3, u1, u1, u3, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u3, u1, u1, u3, u1, u1, u1,
u1, u1, u3, u1, u1, u3, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u3, u1, u1, u3, u1, u1, u3,
u1, u1, u3, u1, u1, u3, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u3, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u3, u1, u1, u1],
[u1, u1, u1, u1, u1, u3, u1, u1, u3,
u1, u1, u3, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1,
u1, u1, u1, u1, u1, u1, u1, u1],
[u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1]]
z_separation = 11
z_separation_unit = 10
position = int(z_separation - 1 -
(rods_height // z_separation_unit))+position
lattice = openmc.RectLattice(name='mix_fuel')
lattice.pitch = (1.26, 1.26, z_separation_unit)
lattice.lower_left = [-1.26 * 17. / 2.0] * \
2 + [-z_separation_unit * z_separation / 2.0]
lattice_list = [0] * z_separation
lattice_list[position] = u_fuel_with_rods
for i in range(0, position):
lattice_list[i] = u_fuel
for j in range(position + 1, z_separation):
lattice_list[j] = u_rods
lattice.universes = lattice_list
box1 = openmc.rectangular_prism(
width=21.42, height=21.42, boundary_type='reflective')
z_min = openmc.ZPlane(z0=-55)
z_min.boundary_type = 'reflective'
z_max = openmc.ZPlane(z0=55)
z_max.boundary_type = 'reflective'
z_region = +z_min & -z_max & box1
root_cell = openmc.Cell(
name='root cell', fill=lattice, region=z_region)
root_universe = openmc.Universe(
name='root universe', cells=[root_cell])
geometry_depletion = openmc.Geometry(root_universe)
return geometry_depletion
def depletion(settings):
restart_geometry = init_depletion_model(0)
operator = openmc.deplete.Operator(restart_geometry, settings,
energy_mode='energy-deposition',dilute_initial=0)
time_steps = [1*24*60*60]*5
integrator = openmc.deplete.PredictorIntegrator(
operator, time_steps, power_density=200)
integrator.integrate()
depletion(settings())