Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 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
b0613dc
Merge branch 'develop' into get_pdf
GuySten Nov 3, 2025
8bb4356
Merge branch 'develop' into get_pdf
GuySten Nov 3, 2025
cc7c3a5
added evaluate for SphericalUnitDistribution
GuySten Nov 3, 2025
758a01f
Merge branch 'develop' into get_pdf
GuySten Dec 3, 2025
481901e
simplify PR significantly
GuySten Dec 3, 2025
b067e7f
Merge branch 'develop' into get_pdf
GuySten Dec 23, 2025
43a6fbb
some fixes
GuySten Jan 12, 2026
c52ad4f
further simplification
GuySten Jan 16, 2026
f9d6d0f
further simplification
GuySten Jan 16, 2026
dc38dc5
further simplification
GuySten Jan 16, 2026
02aea31
reserve vector sizes
GuySten Jan 16, 2026
f14005a
Fix mu_vector reservation size in secondary_thermal.cpp
GuySten Jan 17, 2026
903af78
clang format
GuySten Jan 17, 2026
20ec56b
Merge branch 'develop' into get_pdf
GuySten Jan 29, 2026
64e23e3
fix for invalid energy distribution in elastic scattering case
GuySten Jan 29, 2026
1f36c89
Refactor probability sampling logic in reaction_product
GuySten Jan 29, 2026
8ee06a6
Merge branch 'develop' into get_pdf
GuySten Mar 2, 2026
d11f2e5
decrease dynamic allocations
GuySten Mar 2, 2026
321d188
decrease dynamic allocations further
GuySten Mar 2, 2026
7b9777e
decrease dynamic allocations further
GuySten Mar 2, 2026
1f5e24e
decrease
GuySten Mar 2, 2026
751202a
Merge branch 'develop' into pr/itay-space/3550
paulromano Mar 12, 2026
80413b0
Store copy of Bragg edges to avoid allocation
paulromano Mar 12, 2026
e3f2114
Add comments and docstrings
paulromano Mar 12, 2026
02ae3ac
Avoid falling off non-void function without returning
paulromano Mar 13, 2026
85f0fcd
Fix PolarAzimuthal::evaluate
paulromano Mar 13, 2026
722bdd4
list clamp
paulromano Mar 13, 2026
9825b96
Return non-zero value when E_in > bragg_edges_.back()
paulromano Mar 13, 2026
57da912
Fix incoherent elastic/inelastic PDF calculation
paulromano Mar 13, 2026
88ff94f
Single implementation for get_pdf_disrete
paulromano Mar 13, 2026
61563a6
Remove discrete_half_width
paulromano Mar 13, 2026
ff29e60
Move evaluate_bin into implementation
paulromano Mar 13, 2026
986acd1
Eliminate DoubleVector
paulromano Mar 13, 2026
696fb65
Fix up Doxygen comments
paulromano Mar 13, 2026
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
14 changes: 14 additions & 0 deletions include/openmc/angle_energy.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@ namespace openmc {

class AngleEnergy {
public:
//! Sample an outgoing energy and scattering cosine
//! \param[in] E_in Incoming energy in [eV]
//! \param[out] E_out Outgoing energy in [eV]
//! \param[out] mu Outgoing cosine with respect to current direction
//! \param[inout] seed Pseudorandom seed pointer
virtual void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const = 0;

//! Sample an outgoing energy and evaluate the angular PDF
//! \param[in] E_in Incoming energy in [eV]
//! \param[in] mu Scattering cosine with respect to current direction
//! \param[out] E_out Outgoing energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Probability density for the scattering cosine
virtual double sample_energy_and_pdf(
double E_in, double mu, double& E_out, uint64_t* seed) const = 0;
virtual ~AngleEnergy() = default;
};

Expand Down
9 changes: 9 additions & 0 deletions include/openmc/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class DecayPhotonAngleEnergy : public AngleEnergy {
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;

//! Sample an outgoing energy and evaluate the angular PDF
//! \param[in] E_in Incoming energy in [eV]
//! \param[in] mu Scattering cosine with respect to current direction
//! \param[out] E_out Outgoing energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Probability density for the scattering cosine
double sample_energy_and_pdf(
double E_in, double mu, double& E_out, uint64_t* seed) const override;

private:
const Distribution* photon_energy_;
};
Expand Down
6 changes: 6 additions & 0 deletions include/openmc/distribution_angle.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class AngleDistribution {
//! \return Cosine of the angle in the range [-1,1]
double sample(double E, uint64_t* seed) const;

//! Evaluate the angular PDF at a given energy and cosine
//! \param[in] E Particle energy in [eV]
//! \param[in] mu Cosine of the scattering angle
//! \return Probability density for the scattering cosine
double evaluate(double E, double mu) const;

//! Determine whether angle distribution is empty
//! \return Whether distribution is empty
bool empty() const { return energy_.empty(); }
Expand Down
19 changes: 19 additions & 0 deletions include/openmc/distribution_multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "pugixml.hpp"

#include "openmc/distribution.h"
#include "openmc/error.h"
#include "openmc/position.h"

namespace openmc {
Expand All @@ -29,6 +30,14 @@ class UnitSphereDistribution {
//! \return (sampled Direction, sample weight)
virtual std::pair<Direction, double> sample(uint64_t* seed) const = 0;

//! Evaluate the probability density for a given direction
//! \param[in] u Direction on the unit sphere
//! \return Probability density at the given direction
virtual double evaluate(Direction u) const
{
fatal_error("evaluate not available for this UnitSphereDistribution type");
}

Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
};

Expand All @@ -52,6 +61,11 @@ class PolarAzimuthal : public UnitSphereDistribution {
//! \return (sampled Direction, value of the PDF at this Direction)
std::pair<Direction, double> sample_as_bias(uint64_t* seed) const;

//! Evaluate the probability density for a given direction
//! \param[in] u Direction on the unit sphere
//! \return Probability density at the given direction
double evaluate(Direction u) const override;

// Observing pointers
Distribution* mu() const { return mu_.get(); }
Distribution* phi() const { return phi_.get(); }
Expand Down Expand Up @@ -87,6 +101,11 @@ class Isotropic : public UnitSphereDistribution {
//! \return (sampled direction, sample weight)
std::pair<Direction, double> sample(uint64_t* seed) const override;

//! Evaluate the probability density for a given direction
//! \param[in] u Direction on the unit sphere
//! \return Probability density at the given direction
double evaluate(Direction u) const override;

// Set or get bias distribution
void set_bias(std::unique_ptr<PolarAzimuthal> bias)
{
Expand Down
15 changes: 15 additions & 0 deletions include/openmc/reaction_product.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ class ReactionProduct {
//! \param[inout] seed Pseudorandom seed pointer
void sample(double E_in, double& E_out, double& mu, uint64_t* seed) const;

//! Select which angle-energy distribution to sample
//! \param[in] E_in Incoming energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Reference to the selected angle-energy distribution
AngleEnergy& sample_dist(double E_in, uint64_t* seed) const;

//! Sample an outgoing energy and evaluate the angular PDF
//! \param[in] E_in Incoming energy in [eV]
//! \param[in] mu Scattering cosine with respect to current direction
//! \param[out] E_out Outgoing energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Probability density for the scattering cosine
double sample_energy_and_pdf(
double E_in, double mu, double& E_out, uint64_t* seed) const;

ParticleType particle_; //!< Particle type
EmissionMode emission_mode_; //!< Emission mode
double decay_rate_; //!< Decay rate (for delayed neutron precursors) in [1/s]
Expand Down
16 changes: 16 additions & 0 deletions include/openmc/secondary_correlated.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ class CorrelatedAngleEnergy : public AngleEnergy {
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;

//! Sample the outgoing energy and return the angular distribution
//! \param[in] E_in Incoming energy in [eV]
//! \param[out] E_out Outgoing energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Reference to the angular distribution at the sampled energy bin
Distribution& sample_dist(double E_in, double& E_out, uint64_t* seed) const;

//! Sample an outgoing energy and evaluate the angular PDF
//! \param[in] E_in Incoming energy in [eV]
//! \param[in] mu Scattering cosine with respect to current direction
//! \param[out] E_out Outgoing energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Probability density for the scattering cosine
double sample_energy_and_pdf(
double E_in, double mu, double& E_out, uint64_t* seed) const override;

// energy property
vector<double>& energy() { return energy_; }
const vector<double>& energy() const { return energy_; }
Expand Down
18 changes: 18 additions & 0 deletions include/openmc/secondary_kalbach.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ class KalbachMann : public AngleEnergy {
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;

//! Sample outgoing energy and Kalbach-Mann parameters
//! \param[in] E_in Incoming energy in [eV]
//! \param[out] E_out Outgoing energy in [eV]
//! \param[out] km_a Kalbach-Mann 'a' parameter
//! \param[out] km_r Kalbach-Mann pre-compound fraction 'r'
//! \param[inout] seed Pseudorandom seed pointer
void sample_params(double E_in, double& E_out, double& km_a, double& km_r,
uint64_t* seed) const;

//! Sample an outgoing energy and evaluate the angular PDF
//! \param[in] E_in Incoming energy in [eV]
//! \param[in] mu Scattering cosine with respect to current direction
//! \param[out] E_out Outgoing energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Probability density for the scattering cosine
double sample_energy_and_pdf(
double E_in, double mu, double& E_out, uint64_t* seed) const override;

private:
//! Outgoing energy/angle at a single incoming energy
struct KMTable {
Expand Down
15 changes: 15 additions & 0 deletions include/openmc/secondary_nbody.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ class NBodyPhaseSpace : public AngleEnergy {
void sample(
double E_in, double& E_out, double& mu, uint64_t* seed) const override;

//! Sample an outgoing energy from the N-body phase space distribution
//! \param[in] E_in Incoming energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Sampled outgoing energy in [eV]
double sample_energy(double E_in, uint64_t* seed) const;

//! Sample an outgoing energy and evaluate the angular PDF
//! \param[in] E_in Incoming energy in [eV]
//! \param[in] mu Scattering cosine with respect to current direction
//! \param[out] E_out Outgoing energy in [eV]
//! \param[inout] seed Pseudorandom seed pointer
//! \return Probability density for the scattering cosine
double sample_energy_and_pdf(
double E_in, double mu, double& E_out, uint64_t* seed) const override;

private:
int n_bodies_; //!< Number of particles distributed
double mass_ratio_; //!< Total mass of particles [neutron mass]
Expand Down
Loading
Loading