Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
869508a
Add sensitivity analysis for tallies
Ebiwonjumi Oct 23, 2024
1e3376d
Updates for post-processing
Ebiwonjumi Nov 2, 2024
d654be8
Fix total xs contribution to collision sens, update base & capi in do…
Ebiwonjumi Jan 10, 2025
1750bbe
Fix total xs contribution to collision sens, update base & capi in do…
Ebiwonjumi Jan 10, 2025
28098c8
Merge branch 'develop' into Sensitivity-Analysis
Ebiwonjumi Mar 7, 2025
88aafb0
d1s & SA
Ebiwonjumi Mar 10, 2025
c52ca39
Merge branch 'develop' into Sensitivity-Analysis
Ebiwonjumi May 5, 2025
5204829
Merge branch 'develop' into Sensitivity-Analysis
Ebiwonjumi May 6, 2025
3a07bed
Merge branch 'develop' into Sensitivity-Analysis
Ebiwonjumi Jun 7, 2025
953d626
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jun 17, 2025
ab4c484
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jun 18, 2025
cdceace
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jun 21, 2025
91691c8
Calc. Sens. Coeff. in one run
Ebiwonjumi Jul 1, 2025
1bf5e12
Merge remote-tracking branch 'origin/develop' into Sensitivity-Analysis
Ebiwonjumi Jul 1, 2025
c8497d2
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 3, 2025
be8f730
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 4, 2025
10bfdd8
Update
Ebiwonjumi Jul 9, 2025
63bfe63
Add adjoint-weighted source
Ebiwonjumi Jul 9, 2025
01afe1f
Update particle.cpp
Ebiwonjumi Jul 14, 2025
4f40874
adjoint-weighted source
Ebiwonjumi Jul 14, 2025
76ca98a
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 16, 2025
5821719
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 17, 2025
bc9487e
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 21, 2025
2b50b25
Merge branch 'develop' into Sensitivity-Analysis
Ebiwonjumi Jul 22, 2025
76aa09f
(n,xn) contribution to sensitivity
Ebiwonjumi Jul 24, 2025
1628787
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 27, 2025
1a5b6a2
fix (n,xn) contribution
Ebiwonjumi Jul 27, 2025
0bc76ae
Update (n,xn) contribution to sensitivity
Ebiwonjumi Jul 27, 2025
a92019e
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 29, 2025
112770d
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Jul 30, 2025
041a9f2
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Aug 8, 2025
125e2ef
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Aug 11, 2025
a0c5a56
Merge branch 'develop' into Sensitivity-Analysis
Ebiwonjumi Aug 29, 2025
55ad48c
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Sep 2, 2025
139332f
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Sep 4, 2025
9fb4fad
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Sep 6, 2025
400f572
Update reactions with multiplicities
Ebiwonjumi Sep 7, 2025
8826082
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Sep 11, 2025
326d4ef
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Sep 16, 2025
bb10cf3
Merge branch 'develop' into Sensitivity-Analysis
Ebiwonjumi Sep 22, 2025
0077da0
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Sep 24, 2025
030f151
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
Ebiwonjumi Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ list(APPEND libopenmc_SOURCES
src/tallies/filter_distribcell.cpp
src/tallies/filter_energy.cpp
src/tallies/filter_energyfunc.cpp
src/tallies/filter_importance.cpp
src/tallies/filter_legendre.cpp
src/tallies/filter_material.cpp
src/tallies/filter_materialfrom.cpp
Expand All @@ -434,6 +435,7 @@ list(APPEND libopenmc_SOURCES
src/tallies/filter_zernike.cpp
src/tallies/tally.cpp
src/tallies/tally_scoring.cpp
src/tallies/sensitivity.cpp
src/tallies/trigger.cpp
src/thermal.cpp
src/timer.cpp
Expand Down
3 changes: 3 additions & 0 deletions docs/source/pythonapi/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Constructing Tallies
openmc.SurfaceFilter
openmc.MeshFilter
openmc.MeshBornFilter
openmc.ImportanceFilter
openmc.MeshMaterialFilter
openmc.MeshSurfaceFilter
openmc.EnergyFilter
Expand All @@ -151,6 +152,8 @@ Constructing Tallies
openmc.MeshMaterialVolumes
openmc.Trigger
openmc.TallyDerivative
openmc.SensitivityTally
openmc.Sensitivity
openmc.Tally
openmc.Tallies

Expand Down
2 changes: 2 additions & 0 deletions docs/source/pythonapi/capi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Classes
Mesh
MeshFilter
MeshBornFilter
ImportanceFilter
MeshSurfaceFilter
MuFilter
Nuclide
Expand All @@ -89,6 +90,7 @@ Classes
SphericalMesh
SurfaceFilter
Tally
SensitivityTally
TemporarySession
UniverseFilter
UnstructuredMesh
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ enum class MgxsType {

enum class TallyResult { VALUE, SUM, SUM_SQ, SIZE };

enum class SensitivityTallyResult { VALUE, SUM, SUM_SQ, PREVIOUS_VALUE };

enum class TallyType { VOLUME, MESH_SURFACE, SURFACE, PULSE_HEIGHT };

enum class TallyEstimator { ANALOG, TRACKLENGTH, COLLISION };
Expand Down
58 changes: 58 additions & 0 deletions include/openmc/filter_importance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef OPENMC_TALLIES_FILTER_IMPORTANCE_H
#define OPENMC_TALLIES_FILTER_IMPORTANCE_H

#include <cstdint>

#include <gsl/gsl-lite.hpp>
#include "openmc/vector.h"
#include "openmc/tallies/filter.h"

namespace openmc {

//==============================================================================
//! Multiplies each tally by the importance corresponding to the mesh index
//==============================================================================

class ImportanceFilter : public Filter {
public:
//----------------------------------------------------------------------------
// Constructors, destructors

~ImportanceFilter() = default;

//----------------------------------------------------------------------------
// Methods

std::string type_str() const override {return "importance";}
FilterType type() const override { return FilterType::IMPORTANCE; }

void from_xml(pugi::xml_node node) override;

void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
const override;

void to_statepoint(hid_t filter_group) const override;

std::string text_label(int bin) const override;

//----------------------------------------------------------------------------
// Accessors

const std::vector<double>& importance() const { return importance_; }
void set_importance(gsl::span<const double> importance);

virtual int32_t mesh() const {return mesh_;}

virtual void set_mesh(int32_t mesh);

protected:
//----------------------------------------------------------------------------
// Data members

std::vector<double> importance_;

int32_t mesh_;
};

} // namespace openmc
#endif // OPENMC_TALLIES_FILTER_IMPORTANCE_H
51 changes: 51 additions & 0 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ struct SourceSite {
Position r;
Direction u;
double E;
double E_parent;
double time {0.0};
double wgt {1.0};
int delayed_group {0};
int fission_nuclide;
int surf_id {SURFACE_NONE};
ParticleType particle;

Expand Down Expand Up @@ -480,8 +482,13 @@ class ParticleData : public GeometryState {

double E_;
double E_last_;
double E_parent_; //!< energy of parent neutron in eV
int g_ {0};
int g_last_;

// Other birth data
int fission_nuclide_; //!< this particle was born as a result of this nuclide fissioning
// a double for fission cross section at birth? if so, I need to also add it to the bank...

double wgt_ {1.0};
double wgt_born_ {1.0};
Expand Down Expand Up @@ -520,6 +527,8 @@ class ParticleData : public GeometryState {
int64_t current_work_;

vector<double> flux_derivs_;

std::vector<std::vector<double>> cumulative_sensitivities_; // for sensitivities for this particle

vector<FilterMatch> filter_matches_;

Expand Down Expand Up @@ -582,6 +591,8 @@ class ParticleData : public GeometryState {
const double& E() const { return E_; }
double& E_last() { return E_last_; }
const double& E_last() const { return E_last_; }
double& E_parent() { return E_parent_; } // for sensitivity analysis
const double& E_parent() const { return E_parent_; } // for SA
int& g() { return g_; }
const int& g() const { return g_; }
int& g_last() { return g_last_; }
Expand Down Expand Up @@ -680,6 +691,12 @@ class ParticleData : public GeometryState {
// Used in tally derivatives
double& flux_derivs(int i) { return flux_derivs_[i]; }
const double& flux_derivs(int i) const { return flux_derivs_[i]; }

// Used in sensitivity analysis
std::vector<double>& cumulative_sensitivities(int i) { return cumulative_sensitivities_[i]; }
const std::vector<double>& cumulative_sensitivities(int i) const { return cumulative_sensitivities_[i]; }
int& fission_nuclide() { return fission_nuclide_; }
const int& fission_nuclide() const { return fission_nuclide_; }

// Matches of tallies
decltype(filter_matches_)& filter_matches() { return filter_matches_; }
Expand Down Expand Up @@ -748,6 +765,40 @@ class ParticleData : public GeometryState {
d = 0;
}
}

void resize_flux_derivs(int newSize)
{
flux_derivs_.resize(newSize, 0.0);
}

// Resize and initialize sensitivity vectors
void resize_init_cumulative_sensitivities(int newSize)
{
cumulative_sensitivities_.resize(newSize, {0.0});
}

void resize_init_cumulative_sensitivities_vec(int indx, int newSize)
{
cumulative_sensitivities_[indx].resize(newSize, 0.0);
}

void resize_alloc_filter_matches(int newSize)
{
filter_matches_.resize(newSize);
for (auto &match: filter_matches_){
match.bins_.resize(1, 0.0);
match.weights_.resize(1, 0.0);
match.i_bin_ = 0;
// bins_present_ default is false from header
}
}

void initialize_cumulative_sensitivities()
{
for (auto& it : cumulative_sensitivities_){
std::fill(it.begin(), it.end(), 0.0);
}
}
};

} // namespace openmc
Expand Down
3 changes: 3 additions & 0 deletions include/openmc/simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ void initialize_generation();
//! Full initialization of a particle history
void initialize_history(Particle& p, int64_t index_source);

//! Helper function for initialize_history() that is called independently elsewhere
void initialize_history_partial(Particle& p);

//! Finalize a batch
//!
//! Handles synchronization and accumulation of tallies, calculation of Shannon
Expand Down
1 change: 1 addition & 0 deletions include/openmc/tallies/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class FilterType {
MATERIALFROM,
MESH,
MESHBORN,
IMPORTANCE,
MESH_MATERIAL,
MESH_SURFACE,
MU,
Expand Down
58 changes: 58 additions & 0 deletions include/openmc/tallies/filter_importance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef OPENMC_TALLIES_FILTER_IMPORTANCE_H
#define OPENMC_TALLIES_FILTER_IMPORTANCE_H

#include <cstdint>

#include <gsl/gsl-lite.hpp>
#include "openmc/vector.h"
#include "openmc/tallies/filter.h"

namespace openmc {

//==============================================================================
//! Multiplies each tally by the importance corresponding to the mesh index
//==============================================================================

class ImportanceFilter : public Filter {
public:
//----------------------------------------------------------------------------
// Constructors, destructors

~ImportanceFilter() = default;

//----------------------------------------------------------------------------
// Methods

std::string type_str() const override {return "importance";}
FilterType type() const override { return FilterType::IMPORTANCE; }

void from_xml(pugi::xml_node node) override;

void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
const override;

void to_statepoint(hid_t filter_group) const override;

std::string text_label(int bin) const override;

//----------------------------------------------------------------------------
// Accessors

const std::vector<double>& importance() const { return importance_; }
void set_importance(gsl::span<const double> importance);

virtual int32_t mesh() const {return mesh_;}

virtual void set_mesh(int32_t mesh);

protected:
//----------------------------------------------------------------------------
// Data members

std::vector<double> importance_;

int32_t mesh_;
};

} // namespace openmc
#endif // OPENMC_TALLIES_FILTER_IMPORTANCE_H
Loading