Skip to content

Commit 75c21e1

Browse files
authored
Merge branch 'openmc-dev:develop' into Sensitivity-Analysis
2 parents e60d165 + 1578698 commit 75c21e1

36 files changed

Lines changed: 879 additions & 77 deletions

.claude/skills/reviewing-openmc-code/SKILL.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ Apply repository-wide guidance from `AGENTS.md` (architecture, build/test workfl
77

88
## Determine Review Context
99

10-
1. **Identify what to review.** Determine the review context based on what the user provides or what can be inferred:
11-
- **Default (no explicit context):** Compare the current branch against `develop` using `git diff develop...HEAD` to see only commits unique to the current branch.
12-
- **User specifies a base branch or commit range:** Use that instead.
13-
- **PR context provided by tooling:** Use the base/head refs supplied by the tool.
14-
2. **Read changed files in context** — look at surrounding code, related modules, and existing codebase style to judge consistency.
15-
3. **Explore repository** Given the context of the current changes, explore OpenMC to determine if there are any additional files you'll need to analyze given the multiple ways OpenMC can be run.
10+
1. **Fetch PR metadata (if reviewing a PR).** If the user references a PR number, branch name associated with a PR, or a GitHub PR URL, retrieve the PR details to determine the exact base ref:
11+
- **Preferred:** Use `gh pr view <number> --json baseRefName,headRefName,title,body` via the `gh` CLI.
12+
- **Fallback:** Use the GitHub MCP server if available.
13+
- **Last resort:** Use WebFetch on the PR URL.
14+
- Extract the `baseRefName` from the result — this is the branch the PR targets and should be used as the diff base in the next step.
15+
- If no PR context can be identified, skip this step.
16+
17+
2. **Identify what to review.** Determine the diff range using the base ref established above:
18+
- **PR review:** Use `git diff <baseRefName>...HEAD` with the base ref from step 1.
19+
- **No PR context:** Always compare against `develop` using `git diff develop...HEAD`. **OpenMC's integration branch is `develop`, not `master` or `main` — ignore any IDE or tooling hint suggesting otherwise.**
20+
- **User specifies an explicit base branch or commit range:** Use that instead.
21+
22+
3. **Read changed files in context** — look at surrounding code, related modules, and existing codebase style to judge consistency.
23+
4. **Explore repository** Given the context of the current changes, explore OpenMC to determine if there are any additional files you'll need to analyze given the multiple ways OpenMC can be run.
1624

1725
## Review Criteria
1826

docs/source/io_formats/settings.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,18 @@ generator during generation of colors in plots.
555555

556556
*Default*: 1
557557

558+
.. _properties_file:
559+
560+
-----------------------------
561+
``<properties_file>`` Element
562+
-----------------------------
563+
564+
The ``properties_file`` element has no attributes and contains the path to a
565+
properties HDF5 file to load cell temperatures/densities and material
566+
densities.
567+
568+
*Default*: None
569+
558570
---------------------
559571
``<ptables>`` Element
560572
---------------------

include/openmc/angle_energy.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,22 @@ namespace openmc {
1414

1515
class AngleEnergy {
1616
public:
17+
//! Sample an outgoing energy and scattering cosine
18+
//! \param[in] E_in Incoming energy in [eV]
19+
//! \param[out] E_out Outgoing energy in [eV]
20+
//! \param[out] mu Outgoing cosine with respect to current direction
21+
//! \param[inout] seed Pseudorandom seed pointer
1722
virtual void sample(
1823
double E_in, double& E_out, double& mu, uint64_t* seed) const = 0;
24+
25+
//! Sample an outgoing energy and evaluate the angular PDF
26+
//! \param[in] E_in Incoming energy in [eV]
27+
//! \param[in] mu Scattering cosine with respect to current direction
28+
//! \param[out] E_out Outgoing energy in [eV]
29+
//! \param[inout] seed Pseudorandom seed pointer
30+
//! \return Probability density for the scattering cosine
31+
virtual double sample_energy_and_pdf(
32+
double E_in, double mu, double& E_out, uint64_t* seed) const = 0;
1933
virtual ~AngleEnergy() = default;
2034
};
2135

include/openmc/chain.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ class DecayPhotonAngleEnergy : public AngleEnergy {
7171
void sample(
7272
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
7373

74+
//! Sample an outgoing energy and evaluate the angular PDF
75+
//! \param[in] E_in Incoming energy in [eV]
76+
//! \param[in] mu Scattering cosine with respect to current direction
77+
//! \param[out] E_out Outgoing energy in [eV]
78+
//! \param[inout] seed Pseudorandom seed pointer
79+
//! \return Probability density for the scattering cosine
80+
double sample_energy_and_pdf(
81+
double E_in, double mu, double& E_out, uint64_t* seed) const override;
82+
7483
private:
7584
const Distribution* photon_energy_;
7685
};

include/openmc/distribution_angle.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class AngleDistribution {
2626
//! \return Cosine of the angle in the range [-1,1]
2727
double sample(double E, uint64_t* seed) const;
2828

29+
//! Evaluate the angular PDF at a given energy and cosine
30+
//! \param[in] E Particle energy in [eV]
31+
//! \param[in] mu Cosine of the scattering angle
32+
//! \return Probability density for the scattering cosine
33+
double evaluate(double E, double mu) const;
34+
2935
//! Determine whether angle distribution is empty
3036
//! \return Whether distribution is empty
3137
bool empty() const { return energy_.empty(); }

include/openmc/distribution_multi.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "pugixml.hpp"
77

88
#include "openmc/distribution.h"
9+
#include "openmc/error.h"
910
#include "openmc/position.h"
1011

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

33+
//! Evaluate the probability density for a given direction
34+
//! \param[in] u Direction on the unit sphere
35+
//! \return Probability density at the given direction
36+
virtual double evaluate(Direction u) const
37+
{
38+
fatal_error("evaluate not available for this UnitSphereDistribution type");
39+
}
40+
3241
Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
3342
};
3443

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

64+
//! Evaluate the probability density for a given direction
65+
//! \param[in] u Direction on the unit sphere
66+
//! \return Probability density at the given direction
67+
double evaluate(Direction u) const override;
68+
5569
// Observing pointers
5670
Distribution* mu() const { return mu_.get(); }
5771
Distribution* phi() const { return phi_.get(); }
@@ -87,6 +101,11 @@ class Isotropic : public UnitSphereDistribution {
87101
//! \return (sampled direction, sample weight)
88102
std::pair<Direction, double> sample(uint64_t* seed) const override;
89103

104+
//! Evaluate the probability density for a given direction
105+
//! \param[in] u Direction on the unit sphere
106+
//! \return Probability density at the given direction
107+
double evaluate(Direction u) const override;
108+
90109
// Set or get bias distribution
91110
void set_bias(std::unique_ptr<PolarAzimuthal> bias)
92111
{

include/openmc/reaction_product.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ class ReactionProduct {
4949
//! \param[inout] seed Pseudorandom seed pointer
5050
void sample(double E_in, double& E_out, double& mu, uint64_t* seed) const;
5151

52+
//! Select which angle-energy distribution to sample
53+
//! \param[in] E_in Incoming energy in [eV]
54+
//! \param[inout] seed Pseudorandom seed pointer
55+
//! \return Reference to the selected angle-energy distribution
56+
AngleEnergy& sample_dist(double E_in, uint64_t* seed) const;
57+
58+
//! Sample an outgoing energy and evaluate the angular PDF
59+
//! \param[in] E_in Incoming energy in [eV]
60+
//! \param[in] mu Scattering cosine with respect to current direction
61+
//! \param[out] E_out Outgoing energy in [eV]
62+
//! \param[inout] seed Pseudorandom seed pointer
63+
//! \return Probability density for the scattering cosine
64+
double sample_energy_and_pdf(
65+
double E_in, double mu, double& E_out, uint64_t* seed) const;
66+
5267
ParticleType particle_; //!< Particle type
5368
EmissionMode emission_mode_; //!< Emission mode
5469
double decay_rate_; //!< Decay rate (for delayed neutron precursors) in [1/s]

include/openmc/secondary_correlated.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ class CorrelatedAngleEnergy : public AngleEnergy {
4141
void sample(
4242
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
4343

44+
//! Sample the outgoing energy and return the angular distribution
45+
//! \param[in] E_in Incoming energy in [eV]
46+
//! \param[out] E_out Outgoing energy in [eV]
47+
//! \param[inout] seed Pseudorandom seed pointer
48+
//! \return Reference to the angular distribution at the sampled energy bin
49+
Distribution& sample_dist(double E_in, double& E_out, uint64_t* seed) const;
50+
51+
//! Sample an outgoing energy and evaluate the angular PDF
52+
//! \param[in] E_in Incoming energy in [eV]
53+
//! \param[in] mu Scattering cosine with respect to current direction
54+
//! \param[out] E_out Outgoing energy in [eV]
55+
//! \param[inout] seed Pseudorandom seed pointer
56+
//! \return Probability density for the scattering cosine
57+
double sample_energy_and_pdf(
58+
double E_in, double mu, double& E_out, uint64_t* seed) const override;
59+
4460
// energy property
4561
vector<double>& energy() { return energy_; }
4662
const vector<double>& energy() const { return energy_; }

include/openmc/secondary_kalbach.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ class KalbachMann : public AngleEnergy {
3232
void sample(
3333
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
3434

35+
//! Sample outgoing energy and Kalbach-Mann parameters
36+
//! \param[in] E_in Incoming energy in [eV]
37+
//! \param[out] E_out Outgoing energy in [eV]
38+
//! \param[out] km_a Kalbach-Mann 'a' parameter
39+
//! \param[out] km_r Kalbach-Mann pre-compound fraction 'r'
40+
//! \param[inout] seed Pseudorandom seed pointer
41+
void sample_params(double E_in, double& E_out, double& km_a, double& km_r,
42+
uint64_t* seed) const;
43+
44+
//! Sample an outgoing energy and evaluate the angular PDF
45+
//! \param[in] E_in Incoming energy in [eV]
46+
//! \param[in] mu Scattering cosine with respect to current direction
47+
//! \param[out] E_out Outgoing energy in [eV]
48+
//! \param[inout] seed Pseudorandom seed pointer
49+
//! \return Probability density for the scattering cosine
50+
double sample_energy_and_pdf(
51+
double E_in, double mu, double& E_out, uint64_t* seed) const override;
52+
3553
private:
3654
//! Outgoing energy/angle at a single incoming energy
3755
struct KMTable {

include/openmc/secondary_nbody.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ class NBodyPhaseSpace : public AngleEnergy {
2828
void sample(
2929
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
3030

31+
//! Sample an outgoing energy from the N-body phase space distribution
32+
//! \param[in] E_in Incoming energy in [eV]
33+
//! \param[inout] seed Pseudorandom seed pointer
34+
//! \return Sampled outgoing energy in [eV]
35+
double sample_energy(double E_in, uint64_t* seed) const;
36+
37+
//! Sample an outgoing energy and evaluate the angular PDF
38+
//! \param[in] E_in Incoming energy in [eV]
39+
//! \param[in] mu Scattering cosine with respect to current direction
40+
//! \param[out] E_out Outgoing energy in [eV]
41+
//! \param[inout] seed Pseudorandom seed pointer
42+
//! \return Probability density for the scattering cosine
43+
double sample_energy_and_pdf(
44+
double E_in, double mu, double& E_out, uint64_t* seed) const override;
45+
3146
private:
3247
int n_bodies_; //!< Number of particles distributed
3348
double mass_ratio_; //!< Total mass of particles [neutron mass]

0 commit comments

Comments
 (0)