-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_model.py
More file actions
160 lines (133 loc) · 4.47 KB
/
run_model.py
File metadata and controls
160 lines (133 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import argparse
import openmc
import openmc.model
import numpy as np
import single_wall_model
import openmc_data_downloader as odd
# Argument parser for command-line options
parser = argparse.ArgumentParser(
description="Run the OpenMC model with configurable parameters."
)
parser.add_argument(
"--particles",
type=float,
default=1e5,
help="Number of particles to simulate (default: 1e5)",
)
args, unknown = parser.parse_known_args()
reflector_thickness = 10
breeder_height = 80
breeder_thickness = 40
# Name: Portland concrete
# Density: 2.3 g/cm3
# Reference: PNNL Report 15870 (Rev. 1)
# Describes: facility foundation, floors, walls
Concrete = openmc.Material(name="Concrete")
Concrete.set_density("g/cm3", 2.3)
Concrete.add_nuclide("H1", 0.168759, "ao")
Concrete.add_element("C", 0.001416, "ao")
Concrete.add_nuclide("O16", 0.562524, "ao")
Concrete.add_nuclide("Na23", 0.011838, "ao")
Concrete.add_element("Mg", 0.0014, "ao")
Concrete.add_nuclide("Al27", 0.021354, "ao")
Concrete.add_element("Si", 0.204115, "ao")
Concrete.add_element("K", 0.005656, "ao")
Concrete.add_element("Ca", 0.018674, "ao")
Concrete.add_element("Fe", 0.004264, "ao")
air = openmc.Material(name="Air")
air.add_element("C", 0.00012399, "wo")
air.add_element("N", 0.75527, "wo")
air.add_element("O", 0.23178, "wo")
air.add_element("Ar", 0.012827, "wo")
air.set_density("g/cm3", 0.0012)
floor_rpp = openmc.model.RectangularParallelepiped(-300, 300, -300, 300, -150, -100)
floor_rpp.xmin.boundary_type = "vacuum"
floor_rpp.xmax.boundary_type = "vacuum"
floor_rpp.ymin.boundary_type = "vacuum"
floor_rpp.ymax.boundary_type = "vacuum"
floor_rpp.zmin.boundary_type = "vacuum"
boundary_top_plane = openmc.ZPlane(200, boundary_type="vacuum")
floor_cell = openmc.Cell(region=-floor_rpp, fill=Concrete, name="floor")
settings = openmc.Settings()
settings.run_mode = "fixed source"
settings.batches = 100
settings.inactive = 0
settings.particles = int(args.particles)
# settings.volume_calculations = [vol]
# settings.photon_transport = True
settings.photon_transport = False
libra_reg, libra_system_cell, materials, src, salt_cell, salt_material, salt_vol = (
single_wall_model.build_libra_xl(
salt_height=breeder_height,
salt_thickness=breeder_thickness,
reflector_thickness=reflector_thickness,
)
)
materials.append(Concrete)
materials.append(air)
outside_air_reg = (
+floor_rpp.xmin
& -floor_rpp.xmax
& +floor_rpp.ymin
& -floor_rpp.ymax
& +floor_rpp.zmax
& -boundary_top_plane
& ~libra_reg
)
outside_air_cell = openmc.Cell(region=outside_air_reg, fill=air, name="outside air")
universe = openmc.Universe(cells=[libra_system_cell, floor_cell, outside_air_cell])
geometry = openmc.Geometry(universe)
settings.source = src
t_tally = openmc.Tally(name="tritium tally")
salt_filter = openmc.MaterialFilter([salt_material])
salt_cell_filter = openmc.CellFilter([salt_cell])
t_tally.filters.append(salt_filter)
t_tally.filters.append(salt_cell_filter)
t_tally.scores = ["(n,Xt)"]
t_li_tally = openmc.Tally(name="tritium lithium tally")
t_li_tally.filters.append(salt_filter)
t_li_tally.nuclides = ["Li6", "Li7"]
t_li_tally.scores = ["(n,Xt)"]
t_tally_mesh = openmc.Tally(name="(n,Xt) tally mesh")
r_0 = 4.75 * 2.54
mesh = openmc.CylindricalMesh(
r_grid=np.linspace(r_0, r_0 + breeder_thickness, 100),
phi_grid=np.linspace(0, 2 * np.pi, 100),
z_grid=np.linspace(0, breeder_height, 100),
)
t_tally_mesh.filters.append(openmc.MeshFilter(mesh))
t_tally_mesh.scores = ["(n,Xt)"]
tallies = openmc.Tallies([t_tally, t_li_tally, t_tally_mesh])
plot1 = openmc.Plot.from_geometry(geometry)
plot1.pixels = (1000, 1500)
plot1.width = [200, 300]
plot1.basis = "xz"
plot1.origin = [0, 0, 25]
plot1.color_by = "material"
plots = openmc.Plots([plot1])
odd.download_cross_section_data(
materials,
libraries=["ENDFB-8.0-NNDC"],
set_OPENMC_CROSS_SECTIONS=True,
particles=["neutron"],
destination="cross_sections",
)
model = openmc.Model(
geometry=geometry,
materials=materials,
settings=settings,
tallies=tallies,
plots=plots,
)
model.export_to_model_xml()
model.plot_geometry()
if __name__ == "__main__":
# Run the model
model.run()
sp = openmc.StatePoint("statepoint.100.h5")
t_tally = sp.get_tally(name="tritium tally")
tbr = np.sum(t_tally.get_reshaped_data(value="mean").squeeze())
tbr_err = np.sqrt(
np.sum(np.square(t_tally.get_reshaped_data(value="std_dev").squeeze()))
)
print("TBR = {:.4f} +/- {:.4f}".format(tbr, tbr_err))