Skip to content

Commit 7daebf8

Browse files
author
skywalker_cn
committed
Merge remote-tracking branch 'upstream/develop' into virtual_lattice_0.15.2
2 parents 21781e2 + 4011b7a commit 7daebf8

File tree

307 files changed

+11154
-9875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+11154
-9875
lines changed

cmake/OpenMCConfig.cmake.in

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
get_filename_component(OpenMC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
22

3-
find_package(fmt REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../fmt)
4-
find_package(pugixml REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../pugixml)
5-
find_package(xtl REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtl)
6-
find_package(xtensor REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtensor)
3+
# Compute the install prefix from this file's location
4+
get_filename_component(_OPENMC_PREFIX "${OpenMC_CMAKE_DIR}/../../.." ABSOLUTE)
5+
6+
find_package(fmt CONFIG REQUIRED HINTS ${_OPENMC_PREFIX})
7+
find_package(pugixml CONFIG REQUIRED HINTS ${_OPENMC_PREFIX})
8+
find_package(xtl CONFIG REQUIRED HINTS ${_OPENMC_PREFIX})
9+
find_package(xtensor CONFIG REQUIRED HINTS ${_OPENMC_PREFIX})
710
if(@OPENMC_USE_DAGMC@)
811
find_package(DAGMC REQUIRED HINTS @DAGMC_DIR@)
912
endif()

docs/source/capi/index.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ Functions
8484
:return: Return status (negative if an error occurred)
8585
:rtype: int
8686
87+
.. c:function:: int openmc_cell_get_density(int32_t index, const int32_t* instance, double* density)
88+
89+
Get the density of a cell
90+
91+
:param int32_t index: Index in the cells array
92+
:param int32_t* instance: Which instance of the cell. If a null pointer is passed, the density
93+
multiplier of the first instance is returned.
94+
:param double* density: Density of the cell in [g/cm3]
95+
:return: Return status (negative if an error occurred)
96+
:rtype: int
97+
8798
.. c:function:: int openmc_cell_set_fill(int32_t index, int type, int32_t n, const int32_t* indices)
8899
89100
Set the fill for a cell
@@ -113,8 +124,22 @@ Functions
113124
:param double T: Temperature in Kelvin
114125
:param instance: Which instance of the cell. To set the temperature for all
115126
instances, pass a null pointer.
116-
:param set_contained: If the cell is not filled by a material, whether to set the temperatures
117-
of all filled cells
127+
:param bool set_contained: If the cell is not filled by a material, whether
128+
to set the temperatures of all filled cells
129+
:type instance: const int32_t*
130+
:return: Return status (negative if an error occurred)
131+
:rtype: int
132+
133+
.. c:function:: int openmc_cell_set_density(index index, double density, const int32_t* instance, bool set_contained)
134+
135+
Set the density of a cell.
136+
137+
:param int32_t index: Index in the cells array
138+
:param double density: Density of the cell in [g/cm3]
139+
:param instance: Which instance of the cell. To set the density multiplier for all
140+
instances, pass a null pointer.
141+
:param bool set_contained: If the cell is not filled by a material, whether
142+
to set the density multiplier of all filled cells
118143
:type instance: const int32_t*
119144
:return: Return status (negative if an error occurred)
120145
:rtype: int

docs/source/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@
121121
# -- Options for HTML output ---------------------------------------------------
122122

123123
# The theme to use for HTML and HTML Help pages
124-
import sphinx_rtd_theme
125124
html_theme = 'sphinx_rtd_theme'
126-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
127125
html_baseurl = "https://docs.openmc.org/en/stable/"
128126

129127
html_logo = '_images/openmc_logo.png'

docs/source/io_formats/properties.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Properties File Format
55
======================
66

7-
The current version of the properties file format is 1.0.
7+
The current version of the properties file format is 1.1.
88

99
**/**
1010

@@ -25,6 +25,7 @@ The current version of the properties file format is 1.0.
2525
**/geometry/cells/cell <uid>/**
2626

2727
:Datasets: - **temperature** (*double[]*) -- Temperature of the cell in [K].
28+
- **density** (*double[]*) -- Density of the cell in [g/cm3].
2829

2930
**/materials/**
3031

docs/source/io_formats/summary.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary File Format
55
===================
66

7-
The current version of the summary file format is 6.0.
7+
The current version of the summary file format is 6.1.
88

99
**/**
1010

@@ -38,6 +38,7 @@ The current version of the summary file format is 6.0.
3838
is an array if the cell uses distributed materials, otherwise it is
3939
a scalar.
4040
- **temperature** (*double[]*) -- Temperature of the cell in Kelvin.
41+
- **density** (*double[]*) -- Density of the cell in [g/cm3].
4142
- **translation** (*double[3]*) -- Translation applied to the fill
4243
universe. This dataset is present only if fill_type is set to
4344
'universe'.

docs/source/methods/neutron_physics.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ create and store fission sites for the following generation. First, the average
290290
number of prompt and delayed neutrons must be determined to decide whether the
291291
secondary neutrons will be prompt or delayed. This is important because delayed
292292
neutrons have a markedly different spectrum from prompt neutrons, one that has a
293-
lower average energy of emission. The total number of neutrons emitted
293+
lower average energy of emission. Furthermore, in simulations where tracking
294+
time of neutrons is important, we need to consider the emission time delay of
295+
the secondary neutrons, which is dependent on the decay constant of the
296+
delayed neutron precursor. The total number of neutrons emitted
294297
:math:`\nu_t` is given as a function of incident energy in the ENDF format. Two
295298
representations exist for :math:`\nu_t`. The first is a polynomial of order
296299
:math:`N` with coefficients :math:`c_0,c_1,\dots,c_N`. If :math:`\nu_t` has this
@@ -306,8 +309,8 @@ interpolation law. The number of prompt neutrons released per fission event
306309
:math:`\nu_p` is also given as a function of incident energy and can be
307310
specified in a polynomial or tabular format. The number of delayed neutrons
308311
released per fission event :math:`\nu_d` can only be specified in a tabular
309-
format. In practice, we only need to determine :math:`nu_t` and
310-
:math:`nu_d`. Once these have been determined, we can calculated the delayed
312+
format. In practice, we only need to determine :math:`\nu_t` and
313+
:math:`\nu_d`. Once these have been determined, we can calculate the delayed
311314
neutron fraction
312315

313316
.. math::
@@ -335,8 +338,14 @@ neutrons. Otherwise, we produce :math:`\lfloor \nu \rfloor + 1` neutrons. Then,
335338
for each fission site produced, we sample the outgoing angle and energy
336339
according to the algorithms given in :ref:`sample-angle` and
337340
:ref:`sample-energy` respectively. If the neutron is to be born delayed, then
338-
there is an extra step of sampling a delayed neutron precursor group since they
339-
each have an associated secondary energy distribution.
341+
there is an extra step of sampling a delayed neutron precursor group to get the
342+
associated secondary energy distribution and the decay constant
343+
:math:`\lambda`, which is needed to sample the emission delay time :math:`t_d`:
344+
345+
.. math::
346+
:label: sample-delay-time
347+
348+
t_d = -\frac{\ln \xi}{\lambda}.
340349
341350
The sampled outgoing angle and energy of fission neutrons along with the
342351
position of the collision site are stored in an array called the fission

docs/source/usersguide/kinetics.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ are needed to compute kinetics parameters in OpenMC:
6767
Obtaining kinetics parameters
6868
-----------------------------
6969

70+
The ``Model`` class can be used to automatically generate all IFP tallies using
71+
the Python API with :attr:`openmc.Settings.ifp_n_generation` greater than 0 and
72+
the :meth:`openmc.Model.add_ifp_kinetics_tallies` method::
73+
74+
model = openmc.Model(geometry, settings=settings)
75+
model.add_kinetics_parameters_tallies(num_groups=6) # Add 6 precursor groups
76+
77+
Alternatively, each of the tallies can be manually defined using group-wise or
78+
total :math:`\beta_{\text{eff}}` specified by providing a 6-group
79+
:class:`openmc.DelayedGroupFilter`::
80+
81+
beta_tally = openmc.Tally(name="group-beta-score")
82+
beta_tally.scores = ["ifp-beta-numerator"]
83+
84+
# Add DelayedGroupFilter to enable group-wise tallies
85+
beta_tally.filters = [openmc.DelayedGroupFilter(list(range(1, 7)))]
86+
7087
Here is an example showing how to declare the three available IFP scores in a
7188
single tally::
7289

@@ -95,6 +112,12 @@ for ``ifp-denominator``:
95112
96113
\beta_{\text{eff}} = \frac{S_{\text{ifp-beta-numerator}}}{S_{\text{ifp-denominator}}}
97114
115+
The kinetics parameters can be retrieved directly from a statepoint file using
116+
the :meth:`openmc.StatePoint.ifp_results` method::
117+
118+
with openmc.StatePoint(output_path) as sp:
119+
generation_time, beta_eff = sp.get_kinetics_parameters()
120+
98121
.. only:: html
99122

100123
.. rubric:: References
@@ -107,4 +130,4 @@ for ``ifp-denominator``:
107130
of the Iterated Fission Probability Method in OpenMC to Compute Adjoint-Weighted
108131
Kinetics Parameters", International Conference on Mathematics and Computational
109132
Methods Applied to Nuclear Science and Engineering (M&C 2025), Denver, April 27-30,
110-
2025 (to be presented).
133+
2025.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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()

include/openmc/capi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ int openmc_cell_get_fill(
1717
int openmc_cell_get_id(int32_t index, int32_t* id);
1818
int openmc_cell_get_temperature(
1919
int32_t index, const int32_t* instance, double* T);
20+
int openmc_cell_get_density(
21+
int32_t index, const int32_t* instance, double* rho);
2022
int openmc_cell_get_translation(int32_t index, double xyz[]);
2123
int openmc_cell_get_rotation(int32_t index, double rot[], size_t* n);
2224
int openmc_cell_get_name(int32_t index, const char** name);
@@ -27,6 +29,8 @@ int openmc_cell_set_fill(
2729
int openmc_cell_set_id(int32_t index, int32_t id);
2830
int openmc_cell_set_temperature(
2931
int32_t index, double T, const int32_t* instance, bool set_contained = false);
32+
int openmc_cell_set_density(int32_t index, double rho, const int32_t* instance,
33+
bool set_contained = false);
3034
int openmc_cell_set_translation(int32_t index, const double xyz[]);
3135
int openmc_cell_set_rotation(int32_t index, const double rot[], size_t rot_len);
3236
int openmc_dagmc_universe_get_cell_ids(

include/openmc/cell.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ class Cell {
216216
//! \return Temperature in [K]
217217
double temperature(int32_t instance = -1) const;
218218

219+
//! Get the density multiplier of a cell instance
220+
//! \param[in] instance Instance index. If -1 is given, the density multiplier
221+
//! for the first instance is returned.
222+
//! \return Density multiplier
223+
double density_mult(int32_t instance = -1) const;
224+
225+
//! Get the density of a cell instance in g/cm3
226+
//! \param[in] instance Instance index. If -1 is given, the density
227+
//! for the first instance is returned.
228+
//! \return Density in [g/cm3]
229+
double density(int32_t instance = -1) const;
230+
219231
//! Set the temperature of a cell instance
220232
//! \param[in] T Temperature in [K]
221233
//! \param[in] instance Instance index. If -1 is given, the temperature for
@@ -226,6 +238,16 @@ class Cell {
226238
void set_temperature(
227239
double T, int32_t instance = -1, bool set_contained = false);
228240

241+
//! Set the density of a cell instance
242+
//! \param[in] density Density [g/cm3]
243+
//! \param[in] instance Instance index. If -1 is given, the density
244+
//! for all instances is set.
245+
//! \param[in] set_contained If this cell is not filled with a material,
246+
//! collect all contained cells with material fills and set their
247+
//! densities.
248+
void set_density(
249+
double density, int32_t instance = -1, bool set_contained = false);
250+
229251
int32_t n_instances() const;
230252

231253
//! Set the rotation matrix of a cell instance
@@ -341,6 +363,9 @@ class Cell {
341363
//! T. The units are sqrt(eV).
342364
vector<double> sqrtkT_;
343365

366+
//! \brief Unitless density multiplier(s) within this cell.
367+
vector<double> density_mult_;
368+
344369
//! \brief Neighboring cells in the same universe.
345370
NeighborList neighbors_;
346371

0 commit comments

Comments
 (0)