Skip to content

Commit

Permalink
Merge branch 'develop' into deplete-decay-only-nuclides
Browse files Browse the repository at this point in the history
  • Loading branch information
yardasol authored Aug 30, 2023
2 parents f3b822e + eea5223 commit a5ace74
Show file tree
Hide file tree
Showing 83 changed files with 2,077 additions and 731 deletions.
7 changes: 3 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,9 @@
# -- Options for HTML output ---------------------------------------------------

# The theme to use for HTML and HTML Help pages
if not on_rtd:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

html_logo = '_images/openmc_logo.png'

Expand Down
46 changes: 38 additions & 8 deletions docs/source/io_formats/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ fission.
``<cutoff>`` Element
--------------------

The ``<cutoff>`` element indicates two kinds of cutoffs. The first is the weight
cutoff used below which particles undergo Russian roulette. Surviving particles
are assigned a user-determined weight. Note that weight cutoffs and Russian
rouletting are not turned on by default. The second is the energy cutoff which
is used to kill particles under certain energy. The energy cutoff should not be
used unless you know particles under the energy are of no importance to results
you care. This element has the following attributes/sub-elements:
The ``<cutoff>`` element indicates three kinds of cutoffs. The first is the
weight cutoff used below which particles undergo Russian roulette. Surviving
particles are assigned a user-determined weight. Note that weight cutoffs and
Russian rouletting are not turned on by default. The second is the energy cutoff
which is used to kill particles under certain energy. The energy cutoff should
not be used unless you know particles under the energy are of no importance to
results you care. The third is the time cutoff used to kill particles whose time
exceeds a specific cutoff. Particles will be killed exactly at the specified
time.

:weight:
The weight below which particles undergo Russian roulette.
Expand Down Expand Up @@ -99,6 +101,26 @@ you care. This element has the following attributes/sub-elements:

*Default*: 0.0

:time_neutron
The time above which neutrons will be killed.

*Default*: Infinity

:time_photon
The time above which photons will be killed.

*Default*: Infinity

:time_electron
The time above which electrons will be killed.

*Default*: Infinity

:time_positron
The time above which positorns will be killed.

*Default*: Infinity

----------------------------
``<delayed_photon_scaling>``
----------------------------
Expand Down Expand Up @@ -345,6 +367,15 @@ either "false" or "true".

*Default*: false

-----------------------
``<plot_seed>`` Element
-----------------------

The ``<plot_seed>`` element is used to set the seed for the pseudorandom number
generator during generation of colors in plots.

*Default*: 1

---------------------
``<ptables>`` Element
---------------------
Expand Down Expand Up @@ -1175,4 +1206,3 @@ mesh-based weight windows.

The ``weight_windows_file`` element has no attributes and contains the path to
a weight windows HDF5 file to load during simulation initialization.

10 changes: 5 additions & 5 deletions docs/source/usersguide/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ distributed over a cube centered at the origin with an edge length of 10 cm, and
emitting a pulse of particles from 0 to 10 µs, one
would run::

source = openmc.Source()
source = openmc.IndependentSource()
source.space = openmc.stats.Box((-5, -5, -5), (5, 5, 5))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([10.0e6], [1.0])
Expand All @@ -237,11 +237,11 @@ that indicates the relative strength of a source distribution if multiple are
used. For example, to create two sources, one that should be sampled 70% of the
time and another that should be sampled 30% of the time::

src1 = openmc.Source()
src1 = openmc.IndependentSource()
src1.strength = 0.7
...

src2 = openmc.Source()
src2 = openmc.IndependentSource()
src2.strength = 0.3
...

Expand All @@ -251,7 +251,7 @@ Finally, the :attr:`Source.particle` attribute can be used to indicate the
source should be composed of particles other than neutrons. For example, the
following would generate a photon source::

source = openmc.Source()
source = openmc.IndependentSource()
source.particle = 'photon'
...

Expand All @@ -266,7 +266,7 @@ File-based Sources
OpenMC can use a pregenerated HDF5 source file by specifying the ``filename``
argument to :class:`openmc.Source`::

settings.source = openmc.Source(filename='source.h5')
settings.source = openmc.IndependentSource(filename='source.h5')

Statepoint and source files are generated automatically when a simulation is run
and can be used as the starting source in a new simulation. Alternatively, a
Expand Down
2 changes: 1 addition & 1 deletion docs/source/usersguide/troubleshoot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ commands:
.. code-block:: sh
mkdir build-debug && cd build-debug
cmake -Ddebug=on /path/to/openmc
cmake -DCMAKE_BUILD_TYPE=Debug /path/to/openmc
make
Now when you re-run your problem, it should report exactly where the program
Expand Down
10 changes: 10 additions & 0 deletions include/openmc/capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ int openmc_weight_windows_get_bounds(int32_t index, const double** lower_bounds,
const double** upper_bounds, size_t* size);
int openmc_weight_windows_set_bounds(int32_t index, const double* lower_bounds,
const double* upper_bounds, size_t size);
int openmc_weight_windows_get_survival_ratio(int32_t index, double* ratio);
int openmc_weight_windows_set_survival_ratio(int32_t index, double ratio);
int openmc_weight_windows_get_max_lower_bound_ratio(
int32_t index, double* lb_ratio);
int openmc_weight_windows_set_max_lower_bound_ratio(
int32_t index, double lb_ratio);
int openmc_weight_windows_get_weight_cutoff(int32_t index, double* cutoff);
int openmc_weight_windows_set_weight_cutoff(int32_t index, double cutoff);
int openmc_weight_windows_get_max_split(int32_t index, int* max_split);
int openmc_weight_windows_set_max_split(int32_t index, int max_split);
size_t openmc_weight_windows_size();
int openmc_weight_windows_export(const char* filename = nullptr);
int openmc_weight_windows_import(const char* filename = nullptr);
Expand Down
60 changes: 32 additions & 28 deletions include/openmc/mgxs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@

namespace openmc {

//==============================================================================
// Cache contains the cached data for an MGXS object
//==============================================================================

struct CacheData {
double sqrtkT; // last temperature corresponding to t
int t; // temperature index
int a; // angle index
// last angle that corresponds to a
double u;
double v;
double w;
};

//==============================================================================
// MGXS contains the mgxs data for a nuclide/material
//==============================================================================
Expand Down Expand Up @@ -96,10 +82,9 @@ class Mgxs {
bool equiv(const Mgxs& that);

public:
std::string name; // name of dataset, e.g., UO2
double awr; // atomic weight ratio
bool fissionable; // Is this fissionable
vector<CacheData> cache; // index and data cache
std::string name; // name of dataset, e.g., UO2
double awr; // atomic weight ratio
bool fissionable; // Is this fissionable

Mgxs() = default;

Expand Down Expand Up @@ -135,13 +120,15 @@ class Mgxs {
//! @param mu Cosine of the change-in-angle, for scattering quantities;
//! use nullptr if irrelevant.
//! @param dg delayed group index; use nullptr if irrelevant.
//! @param t Temperature index.
//! @param a Angle index.
//! @return Requested cross section value.
double get_xs(
MgxsType xstype, int gin, const int* gout, const double* mu, const int* dg);
double get_xs(MgxsType xstype, int gin, const int* gout, const double* mu,
const int* dg, int t, int a);

inline double get_xs(MgxsType xstype, int gin)
inline double get_xs(MgxsType xstype, int gin, int t, int a)
{
return get_xs(xstype, gin, nullptr, nullptr, nullptr);
return get_xs(xstype, gin, nullptr, nullptr, nullptr, t, a);
}

//! \brief Samples the fission neutron energy and if prompt or delayed.
Expand All @@ -150,7 +137,10 @@ class Mgxs {
//! @param dg Sampled delayed group index.
//! @param gout Sampled outgoing energy group.
//! @param seed Pseudorandom seed pointer
void sample_fission_energy(int gin, int& dg, int& gout, uint64_t* seed);
//! @param t Temperature index.
//! @param a Angle index.
void sample_fission_energy(
int gin, int& dg, int& gout, uint64_t* seed, int t, int a);

//! \brief Samples the outgoing energy and angle from a scatter event.
//!
Expand All @@ -159,23 +149,37 @@ class Mgxs {
//! @param mu Sampled cosine of the change-in-angle.
//! @param wgt Weight of the particle to be adjusted.
//! @param seed Pseudorandom seed pointer.
//! @param t Temperature index.
//! @param a Angle index.
void sample_scatter(
int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
int gin, int& gout, double& mu, double& wgt, uint64_t* seed, int t, int a);

//! \brief Calculates cross section quantities needed for tracking.
//!
//! @param p The particle whose attributes set which MGXS to get.
void calculate_xs(Particle& p);

//! \brief Sets the temperature index in cache given a temperature
//! \brief Sets the temperature index in the particle's cache.
//!
//! @param p Particle.
void set_temperature_index(Particle& p);

//! \brief Gets the temperature index given a temperature.
//!
//! @param sqrtkT Temperature of the material.
void set_temperature_index(double sqrtkT);
//! @return The temperature index corresponding to sqrtkT.
int get_temperature_index(double sqrtkT) const;

//! \brief Sets the angle index in the particle's cache.
//!
//! @param p Particle.
void set_angle_index(Particle& p);

//! \brief Sets the angle index in cache given a direction
//! \brief Gets the angle index given a direction.
//!
//! @param u Incoming particle direction.
void set_angle_index(Direction u);
//! @return The angle index corresponding to u.
int get_angle_index(const Direction& u) const;

//! \brief Provide const access to list of XsData held by this
const vector<XsData>& get_xsdata() const { return xs; }
Expand Down
4 changes: 4 additions & 0 deletions include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class Particle : public ParticleData {

double speed() const;

//! moves the particle by the distance length to its next location
//! \param length the distance the particle is moved
void move_distance(double length);

//! create a secondary particle
//
//! stores the current phase space attributes of the particle in the
Expand Down
15 changes: 15 additions & 0 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ struct MacroXS {
double pair_production; //!< macroscopic pair production xs
};

//==============================================================================
// Cache contains the cached data for an MGXS object
//==============================================================================

struct CacheDataMG {
int material {-1}; //!< material index
double sqrtkT; //!< last temperature corresponding to t
int t {0}; //!< temperature index
int a {0}; //!< angle index
Direction u; //!< angle that corresponds to a
};

//==============================================================================
// Information about nearest boundary crossing
//==============================================================================
Expand Down Expand Up @@ -231,6 +243,7 @@ class ParticleData {
vector<NuclideMicroXS> neutron_xs_; //!< Microscopic neutron cross sections
vector<ElementMicroXS> photon_xs_; //!< Microscopic photon cross sections
MacroXS macro_xs_; //!< Macroscopic cross sections
CacheDataMG mg_xs_cache_; //!< Multigroup XS cache

int64_t id_; //!< Unique ID
ParticleType type_ {ParticleType::neutron}; //!< Particle type (n, p, e, etc.)
Expand Down Expand Up @@ -349,6 +362,8 @@ class ParticleData {
ElementMicroXS& photon_xs(int i) { return photon_xs_[i]; }
MacroXS& macro_xs() { return macro_xs_; }
const MacroXS& macro_xs() const { return macro_xs_; }
CacheDataMG& mg_xs_cache() { return mg_xs_cache_; }
const CacheDataMG& mg_xs_cache() const { return mg_xs_cache_; }

int64_t& id() { return id_; }
const int64_t& id() const { return id_; }
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ extern ElectronTreatment
electron_treatment; //!< how to treat secondary electrons
extern array<double, 4>
energy_cutoff; //!< Energy cutoff in [eV] for each particle type
extern array<double, 4>
time_cutoff; //!< Time cutoff in [s] for each particle type
extern int
legendre_to_tabular_points; //!< number of points to convert Legendres
extern int max_order; //!< Maximum Legendre order for multigroup data
Expand Down
16 changes: 16 additions & 0 deletions include/openmc/weight_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ class WeightWindows {

void set_particle_type(ParticleType p_type);

double survival_ratio() const { return survival_ratio_; }

double& survival_ratio() { return survival_ratio_; }

double max_lower_bound_ratio() const { return max_lb_ratio_; }

double& max_lower_bound_ratio() { return max_lb_ratio_; }

int max_split() const { return max_split_; }

int& max_split() { return max_split_; }

double weight_cutoff() const { return weight_cutoff_; }

double& weight_cutoff() { return weight_cutoff_; }

//----------------------------------------------------------------------------
// Accessors
int32_t id() const { return id_; }
Expand Down
Loading

0 comments on commit a5ace74

Please sign in to comment.