Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
06ae298
Implement get_pdf functionality
Aug 27, 2025
78d841e
Update include/openmc/distribution.h
itay-space Aug 28, 2025
33a27a9
Update include/openmc/particle_data.h
itay-space Aug 28, 2025
d968875
Update include/openmc/particle_data.h
itay-space Aug 28, 2025
3b896c0
Update src/physics.cpp
itay-space Aug 28, 2025
c034bff
Update src/physics.cpp
itay-space Aug 28, 2025
a5d2f4c
Update src/physics.cpp
itay-space Aug 28, 2025
ca5b44e
Cleaning some code
Aug 31, 2025
eed8b1c
Resolving conversations
Aug 31, 2025
f2ecdd4
cosmetic fixes
GuySten Aug 31, 2025
71d5fa2
Merge branch 'develop' into get_pdf
GuySten Aug 31, 2025
c3b4d82
simplified code significantly
GuySten Aug 31, 2025
78a33cc
Update src/distribution_angle.cpp
itay-space Aug 31, 2025
6d70d39
ran clang format
GuySten Aug 31, 2025
acfd402
fixes
GuySten Aug 31, 2025
98ca32e
cosmetics
GuySten Aug 31, 2025
26d2a56
using openmc's fatal_error
Sep 1, 2025
7abe69c
Use accessors in powerlaw
Sep 1, 2025
d183cce
clausing error for different distributions
Sep 1, 2025
37b41c4
fixing function signature
Sep 1, 2025
007dcf5
Update include/openmc/angle_energy.h
Eliezer214 Sep 2, 2025
ebebb7a
Update include/openmc/distribution_angle.h
Eliezer214 Sep 2, 2025
0239c1f
Update include/openmc/secondary_thermal.h
Eliezer214 Sep 2, 2025
225f837
Update include/openmc/angle_energy.h
Eliezer214 Sep 2, 2025
fa22e14
Update include/openmc/reaction_product.h
Eliezer214 Sep 2, 2025
a0678c9
Update src/reaction_product.cpp
itay-space Sep 2, 2025
e590d82
Update src/thermal.cpp
itay-space Sep 2, 2025
1b1134e
Update include/openmc/secondary_thermal.h
itay-space Sep 2, 2025
5c348f1
Update src/secondary_uncorrelated.cpp
itay-space Sep 2, 2025
203a191
Update src/secondary_thermal.cpp
itay-space Sep 2, 2025
c4d8aa6
Update include/openmc/secondary_thermal.h
itay-space Sep 2, 2025
e9b6860
Update src/reaction_product.cpp
itay-space Sep 2, 2025
ee1f2c5
Apply suggestion from @GuySten
itay-space Sep 2, 2025
e07e312
Apply suggestion from @GuySten
itay-space Sep 2, 2025
1ab0da1
Update src/thermal.cpp
itay-space Sep 2, 2025
c98566a
Update src/thermal.cpp
itay-space Sep 2, 2025
de3fc79
Update include/openmc/reaction_product.h
itay-space Sep 2, 2025
978bf74
remove gsl-lite
GuySten Sep 2, 2025
eb8389d
few fixes to signature
Sep 2, 2025
220f099
more signature fixes
Sep 2, 2025
d9a2b53
more signature fixes
Sep 2, 2025
8271e15
ran clang format
GuySten Sep 2, 2025
d0d8494
Restore PDF calculation block in secondary_kalbach.cpp after accident…
Sep 2, 2025
f2418d2
cleaning
Sep 2, 2025
9a5d701
remove gsl-lite
GuySten Sep 2, 2025
3f91b0d
clean
Sep 2, 2025
e1d069c
Update src/secondary_correlated.cpp
itay-space Sep 2, 2025
f9e4693
Update include/openmc/secondary_thermal.h
GuySten Sep 2, 2025
b45dcfd
ran clang format
GuySten Sep 2, 2025
a85365c
Update src/secondary_kalbach.cpp
GuySten Sep 2, 2025
d782013
returning pdf assuming data in lab
Sep 2, 2025
c72bb02
cleaning
Sep 2, 2025
3cb6821
remove gsl-lite
GuySten Sep 2, 2025
47e96a6
Apply suggestions from code review
GuySten Sep 2, 2025
f97f4ad
Update secondary_nbody.cpp
GuySten Sep 2, 2025
1e4b763
ran clang format
GuySten Sep 2, 2025
3bc4698
Update src/secondary_kalbach.cpp
itay-space Sep 3, 2025
4e85033
returning pdf
Sep 3, 2025
6727a03
Update src/secondary_nbody.cpp
itay-space Sep 3, 2025
c5a737b
isotropic and no lab yet
Sep 3, 2025
186ad34
Update src/distribution_angle.cpp
itay-space Sep 3, 2025
108fa52
remove gsl-lite
GuySten Sep 2, 2025
0f40022
ran clang format
GuySten Sep 3, 2025
4bf8f23
Update include/openmc/distribution_angle.h
GuySten Sep 3, 2025
ca7cd85
returning pdf in uncorrelated
Sep 3, 2025
d7b1621
fix access to get_pdf
GuySten Sep 3, 2025
7cb99e8
ran clang format
GuySten Sep 3, 2025
e2de1c4
cosmetics
GuySten Sep 3, 2025
d5ea1c0
WIP: trying new approach until reaction_product.cpp
GuySten Sep 4, 2025
dc87a7f
fix additional signatures
GuySten Sep 4, 2025
ad86823
wip
GuySten Sep 4, 2025
4500491
reverted most of the changes in the new approach
GuySten Sep 4, 2025
7a1b5cc
bugfix
GuySten Sep 4, 2025
ae2a0fb
bugfix
GuySten Sep 4, 2025
f3aa6dc
bugfix
GuySten Sep 4, 2025
52feef7
another fix for mixed elastic
GuySten Sep 4, 2025
12d5372
guarantee every AngleEnergy has sample_energy_and_pdf
GuySten Sep 4, 2025
ff83fc4
fix for decay photons
GuySten Sep 4, 2025
f859882
replace pdf->evaluate
GuySten Sep 6, 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
16 changes: 14 additions & 2 deletions include/openmc/distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Distribution {
public:
virtual ~Distribution() = default;
virtual double sample(uint64_t* seed) const = 0;

virtual double get_pdf(double x) const = 0;
//! Return integral of distribution
//! \return Integral of distribution
virtual double integral() const { return 1.0; };
Expand Down Expand Up @@ -84,6 +84,10 @@ class Discrete : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
//! Calculate the probability density function (PDF) at a given value
//! \param x The value at which to evaluate the PDF
//! \return The value of the PDF at the given point
double get_pdf(double x) const;

double integral() const override { return di_.integral(); };

Expand Down Expand Up @@ -111,6 +115,7 @@ class Uniform : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

double a() const { return a_; }
double b() const { return b_; }
Expand All @@ -135,6 +140,7 @@ class PowerLaw : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

double a() const { return std::pow(offset_, ninv_); }
double b() const { return std::pow(offset_ + span_, ninv_); }
Expand All @@ -160,6 +166,7 @@ class Maxwell : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

double theta() const { return theta_; }

Expand All @@ -180,6 +187,7 @@ class Watt : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

double a() const { return a_; }
double b() const { return b_; }
Expand All @@ -204,6 +212,7 @@ class Normal : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

double mean_value() const { return mean_value_; }
double std_dev() const { return std_dev_; }
Expand All @@ -227,8 +236,9 @@ class Tabular : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

// properties
// properties
vector<double>& x() { return x_; }
const vector<double>& x() const { return x_; }
const vector<double>& p() const { return p_; }
Expand Down Expand Up @@ -263,6 +273,7 @@ class Equiprobable : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

const vector<double>& x() const { return x_; }

Expand All @@ -282,6 +293,7 @@ class Mixture : public Distribution {
//! \param seed Pseudorandom number seed pointer
//! \return Sampled value
double sample(uint64_t* seed) const override;
double get_pdf(double x) const;

double integral() const override { return integral_; }

Expand Down
3 changes: 2 additions & 1 deletion include/openmc/distribution_angle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ class AngleDistribution {
//! \param[inout] seed pseudorandom number seed pointer
//! \return Cosine of the angle in the range [-1,1]
double sample(double E, uint64_t* seed) const;

double get_pdf(double E, double mu, uint64_t* seed) const;
//! Determine whether angle distribution is empty
//! \return Whether distribution is empty
bool empty() const { return energy_.empty(); }
double get_energy(int num) { return energy_[num]; }

private:
vector<double> energy_;
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ class ParticleData : public GeometryState {
int event_nuclide_;
int event_mt_;
int delayed_group_ {0};
int event_index_mt_;
int parent_nuclide_ {-1};

int n_bank_ {0};
Expand Down Expand Up @@ -622,6 +623,7 @@ class ParticleData : public GeometryState {
const int& event_nuclide() const { return event_nuclide_; }
int& event_mt() { return event_mt_; } // MT number of collision
const int& event_mt() const { return event_mt_; }
int& event_index_mt() { return event_index_mt_; }
int& delayed_group() { return delayed_group_; } // delayed group
const int& parent_nuclide() const { return parent_nuclide_; }
int& parent_nuclide() { return parent_nuclide_; } // Parent nuclide
Expand Down
8 changes: 6 additions & 2 deletions include/openmc/reaction_product.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include "openmc/endf.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/tallies/filter.h"
#include "openmc/tallies/tally.h"
#include "openmc/vector.h" // for vector

namespace openmc {

//==============================================================================
Expand Down Expand Up @@ -48,7 +49,10 @@ class ReactionProduct {
//! \param[out] mu Outgoing cosine with respect to current direction
//! \param[inout] seed Pseudorandom seed pointer
void sample(double E_in, double& E_out, double& mu, uint64_t* seed) const;

void get_pdf(int i_tally, double E_in, double& E_out, uint64_t* seed,
Particle& p, std::vector<double>& mu_cm, std::vector<double>& Js,
std::vector<Particle>& ghost_particles,
std::vector<double>& pdfs_lab) const;
ParticleType particle_; //!< Particle type
EmissionMode emission_mode_; //!< Emission mode
double decay_rate_; //!< Decay rate (for delayed neutron precursors) in [1/s]
Expand Down
5 changes: 5 additions & 0 deletions include/openmc/secondary_correlated.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "openmc/angle_energy.h"
#include "openmc/distribution.h"
#include "openmc/endf.h"
#include "openmc/particle.h"
#include "openmc/vector.h"

namespace openmc {
Expand Down Expand Up @@ -40,6 +41,10 @@ class CorrelatedAngleEnergy : public AngleEnergy {
//! \param[inout] seed Pseudorandom seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
void get_pdf(double det_pos[4], double E_in, double& E_out, uint64_t* seed,
Particle& p, std::vector<double>& mu_cm, std::vector<double>& Js,
std::vector<Particle>& ghost_particles,
std::vector<double>& pdfs_lab) const;

// energy property
vector<double>& energy() { return energy_; }
Expand Down
5 changes: 5 additions & 0 deletions include/openmc/secondary_kalbach.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "openmc/angle_energy.h"
#include "openmc/constants.h"
#include "openmc/endf.h"
#include "openmc/particle.h"
#include "openmc/vector.h"

namespace openmc {
Expand All @@ -31,6 +32,10 @@ class KalbachMann : public AngleEnergy {
//! \param[inout] seed Pseudorandom seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
void get_pdf(double det_pos[4], double E_in, double& E_out, uint64_t* seed,
Particle& p, std::vector<double>& mu_cm, std::vector<double>& Js,
std::vector<Particle>& ghost_particles,
std::vector<double>& pdfs_lab) const;

private:
//! Outgoing energy/angle at a single incoming energy
Expand Down
5 changes: 5 additions & 0 deletions include/openmc/secondary_nbody.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "hdf5.h"

#include "openmc/angle_energy.h"
#include "openmc/particle.h"

namespace openmc {

Expand All @@ -27,6 +28,10 @@ class NBodyPhaseSpace : public AngleEnergy {
//! \param[inout] seed Pseudorandom seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
void get_pdf(double det_pos[4], double E_in, double& E_out, uint64_t* seed,
Particle& p, std::vector<double>& mu_cm, std::vector<double>& Js,
std::vector<Particle>& ghost_particles,
std::vector<double>& pdfs_lab) const;

private:
int n_bodies_; //!< Number of particles distributed
Expand Down
6 changes: 6 additions & 0 deletions include/openmc/secondary_thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CoherentElasticAE : public AngleEnergy {
//! \param[inout] seed Pseudorandom seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
double get_pdf(double E_in, double& E_out, double& mu, uint64_t* seed) const;

private:
const CoherentElasticXS& xs_; //!< Coherent elastic scattering cross section
Expand All @@ -55,6 +56,7 @@ class IncoherentElasticAE : public AngleEnergy {
//! \param[inout] seed Pseudorandom number seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
double get_pdf(double E_in, double& E_out, double& mu, uint64_t* seed) const;

private:
double debye_waller_;
Expand All @@ -80,6 +82,7 @@ class IncoherentElasticAEDiscrete : public AngleEnergy {
//! \param[inout] seed Pseudorandom number seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
double get_pdf(double E_in, double& E_out, double& mu, uint64_t* seed) const;

private:
const vector<double>& energy_; //!< Energies at which cosines are tabulated
Expand All @@ -106,6 +109,8 @@ class IncoherentInelasticAEDiscrete : public AngleEnergy {
//! \param[inout] seed Pseudorandom number seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
double get_pdf(
double E_in, double& E_out, double& mu, uint64_t* seed, int l = -1) const;

private:
const vector<double>& energy_; //!< Incident energies
Expand Down Expand Up @@ -134,6 +139,7 @@ class IncoherentInelasticAE : public AngleEnergy {
//! \param[inout] seed Pseudorandom number seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
double get_pdf(double E_in, double& E_out, double& mu, uint64_t* seed) const;

private:
//! Secondary energy/angle distribution
Expand Down
5 changes: 5 additions & 0 deletions include/openmc/secondary_uncorrelated.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "openmc/distribution_angle.h"
#include "openmc/distribution_energy.h"
#include "openmc/memory.h"
#include "openmc/particle.h"
#include "openmc/vector.h"

namespace openmc {
Expand All @@ -31,6 +32,10 @@ class UncorrelatedAngleEnergy : public AngleEnergy {
//! \param[inout] seed Pseudorandom seed pointer
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
void get_pdf(double det_pos[4], double E_in, double& E_out, uint64_t* seed,
Particle& p, std::vector<double>& mu_cm, std::vector<double>& Js,
std::vector<Particle>& ghost_particles,
std::vector<double>& pdfs_lab) const;

// Accessors
AngleDistribution& angle() { return angle_; }
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ThermalData {
//! \param[inout] seed Pseudorandom seed pointer
void sample(const NuclideMicroXS& micro_xs, double E_in, double* E_out,
double* mu, uint64_t* seed);
double get_pdf(const NuclideMicroXS& micro_xs, double E, double& E_out,
double mu, uint64_t* seed);

private:
struct Reaction {
Expand Down
Loading
Loading