Skip to content

Commit 5502f38

Browse files
committed
partially done with refactoring
1 parent 0ebfae4 commit 5502f38

31 files changed

Lines changed: 301 additions & 256 deletions

‎include/openmc/distribution.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Discrete : public Distribution {
3535

3636
//! Sample a value from the distribution
3737
//! \return Sampled value
38-
double sample() const;
38+
double sample(uint64_t * prn_seeds, int stream) const;
3939

4040
// Properties
4141
const std::vector<double>& x() const { return x_; }
@@ -59,7 +59,7 @@ class Uniform : public Distribution {
5959

6060
//! Sample a value from the distribution
6161
//! \return Sampled value
62-
double sample() const;
62+
double sample(uint64_t * prn_seeds, int stream) const;
6363
private:
6464
double a_; //!< Lower bound of distribution
6565
double b_; //!< Upper bound of distribution
@@ -76,7 +76,7 @@ class Maxwell : public Distribution {
7676

7777
//! Sample a value from the distribution
7878
//! \return Sampled value
79-
double sample() const;
79+
double sample(uint64_t * prn_seeds, int stream) const;
8080
private:
8181
double theta_; //!< Factor in exponential [eV]
8282
};
@@ -92,7 +92,7 @@ class Watt : public Distribution {
9292

9393
//! Sample a value from the distribution
9494
//! \return Sampled value
95-
double sample() const;
95+
double sample(uint64_t * prn_seeds, int stream) const;
9696
private:
9797
double a_; //!< Factor in exponential [eV]
9898
double b_; //!< Factor in square root [1/eV]
@@ -109,7 +109,7 @@ class Normal : public Distribution {
109109

110110
//! Sample a value from the distribution
111111
//! \return Sampled value
112-
double sample() const;
112+
double sample(uint64_t * prn_seeds, int stream) const;
113113
private:
114114
double mean_value_; //!< middle of distribution [eV]
115115
double std_dev_; //!< standard deviation [eV]
@@ -127,7 +127,7 @@ class Muir : public Distribution {
127127

128128
//! Sample a value from the distribution
129129
//! \return Sampled value
130-
double sample() const;
130+
double sample(uint64_t * prn_seeds, int stream) const;
131131
private:
132132
// example DT fusion m_rat = 5 (D = 2 + T = 3)
133133
// ion temp = 20000 eV
@@ -149,7 +149,7 @@ class Tabular : public Distribution {
149149

150150
//! Sample a value from the distribution
151151
//! \return Sampled value
152-
double sample() const;
152+
double sample(uint64_t * prn_seeds, int stream) const;
153153

154154
// x property
155155
std::vector<double>& x() { return x_; }
@@ -179,7 +179,7 @@ class Equiprobable : public Distribution {
179179

180180
//! Sample a value from the distribution
181181
//! \return Sampled value
182-
double sample() const;
182+
double sample(uint64_t * prn_seeds, int stream) const;
183183
private:
184184
std::vector<double> x_; //! Possible outcomes
185185
};

‎include/openmc/distribution_angle.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AngleDistribution {
2424
//! Sample an angle given an incident particle energy
2525
//! \param[in] E Particle energy in [eV]
2626
//! \return Cosine of the angle in the range [-1,1]
27-
double sample(double E) const;
27+
double sample(double E, uint64_t * prn_seeds, int stream) const;
2828

2929
//! Determine whether angle distribution is empty
3030
//! \return Whether distribution is empty

‎include/openmc/distribution_energy.h‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace openmc {
2222

2323
class EnergyDistribution {
2424
public:
25-
virtual double sample(double E) const = 0;
25+
virtual double sample(double E, uint64_t * prn_seeds, int stream) const = 0;
2626
virtual ~EnergyDistribution() = default;
2727
};
2828

@@ -37,7 +37,7 @@ class DiscretePhoton : public EnergyDistribution {
3737
//! Sample energy distribution
3838
//! \param[in] E Incident particle energy in [eV]
3939
//! \return Sampled energy in [eV]
40-
double sample(double E) const;
40+
double sample(double E, uint64_t * prn_seeds, int stream) const;
4141
private:
4242
int primary_flag_; //!< Indicator of whether the photon is a primary or
4343
//!< non-primary photon.
@@ -56,7 +56,7 @@ class LevelInelastic : public EnergyDistribution {
5656
//! Sample energy distribution
5757
//! \param[in] E Incident particle energy in [eV]
5858
//! \return Sampled energy in [eV]
59-
double sample(double E) const;
59+
double sample(double E, uint64_t * prn_seeds, int stream) const;
6060
private:
6161
double threshold_; //!< Energy threshold in lab, (A + 1)/A * |Q|
6262
double mass_ratio_; //!< (A/(A+1))^2
@@ -75,7 +75,7 @@ class ContinuousTabular : public EnergyDistribution {
7575
//! Sample energy distribution
7676
//! \param[in] E Incident particle energy in [eV]
7777
//! \return Sampled energy in [eV]
78-
double sample(double E) const;
78+
double sample(double E, uint64_t * prn_seeds, int stream) const;
7979
private:
8080
//! Outgoing energy for a single incoming energy
8181
struct CTTable {
@@ -104,7 +104,7 @@ class Evaporation : public EnergyDistribution {
104104
//! Sample energy distribution
105105
//! \param[in] E Incident particle energy in [eV]
106106
//! \return Sampled energy in [eV]
107-
double sample(double E) const;
107+
double sample(double E, uint64_t * prn_seeds, int stream) const;
108108
private:
109109
Tabulated1D theta_; //!< Incoming energy dependent parameter
110110
double u_; //!< Restriction energy
@@ -122,7 +122,7 @@ class MaxwellEnergy : public EnergyDistribution {
122122
//! Sample energy distribution
123123
//! \param[in] E Incident particle energy in [eV]
124124
//! \return Sampled energy in [eV]
125-
double sample(double E) const;
125+
double sample(double E, uint64_t * prn_seeds, int stream) const;
126126
private:
127127
Tabulated1D theta_; //!< Incoming energy dependent parameter
128128
double u_; //!< Restriction energy
@@ -140,7 +140,7 @@ class WattEnergy : public EnergyDistribution {
140140
//! Sample energy distribution
141141
//! \param[in] E Incident particle energy in [eV]
142142
//! \return Sampled energy in [eV]
143-
double sample(double E) const;
143+
double sample(double E, uint64_t * prn_seeds, int stream) const;
144144
private:
145145
Tabulated1D a_; //!< Energy-dependent 'a' parameter
146146
Tabulated1D b_; //!< Energy-dependent 'b' parameter

‎include/openmc/distribution_multi.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class UnitSphereDistribution {
2424

2525
//! Sample a direction from the distribution
2626
//! \return Direction sampled
27-
virtual Direction sample() const = 0;
27+
virtual Direction sample(uint64_t * prn_seeds, int stream) const = 0;
2828

2929
Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
3030
};
@@ -40,7 +40,7 @@ class PolarAzimuthal : public UnitSphereDistribution {
4040

4141
//! Sample a direction from the distribution
4242
//! \return Direction sampled
43-
Direction sample() const;
43+
Direction sample(uint64_t * prn_seeds, int stream) const;
4444
private:
4545
UPtrDist mu_; //!< Distribution of polar angle
4646
UPtrDist phi_; //!< Distribution of azimuthal angle
@@ -56,7 +56,7 @@ class Isotropic : public UnitSphereDistribution {
5656

5757
//! Sample a direction from the distribution
5858
//! \return Sampled direction
59-
Direction sample() const;
59+
Direction sample(uint64_t * prn_seeds, int stream) const;
6060
};
6161

6262
//==============================================================================
@@ -70,7 +70,7 @@ class Monodirectional : public UnitSphereDistribution {
7070

7171
//! Sample a direction from the distribution
7272
//! \return Sampled direction
73-
Direction sample() const;
73+
Direction sample(uint64_t * prn_seeds, int stream) const;
7474
};
7575

7676
using UPtrAngle = std::unique_ptr<UnitSphereDistribution>;

‎include/openmc/distribution_spatial.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SpatialDistribution {
1717
virtual ~SpatialDistribution() = default;
1818

1919
//! Sample a position from the distribution
20-
virtual Position sample() const = 0;
20+
virtual Position sample(uint64_t * prn_seeds, int stream) const = 0;
2121
};
2222

2323
//==============================================================================
@@ -30,7 +30,7 @@ class CartesianIndependent : public SpatialDistribution {
3030

3131
//! Sample a position from the distribution
3232
//! \return Sampled position
33-
Position sample() const;
33+
Position sample(uint64_t * prn_seeds, int stream) const;
3434
private:
3535
UPtrDist x_; //!< Distribution of x coordinates
3636
UPtrDist y_; //!< Distribution of y coordinates
@@ -47,7 +47,7 @@ class SphericalIndependent : public SpatialDistribution {
4747

4848
//! Sample a position from the distribution
4949
//! \return Sampled position
50-
Position sample() const;
50+
Position sample(uint64_t * prn_seeds, int stream) const;
5151
private:
5252
UPtrDist r_; //!< Distribution of r coordinates
5353
UPtrDist theta_; //!< Distribution of theta coordinates
@@ -65,7 +65,7 @@ class SpatialBox : public SpatialDistribution {
6565

6666
//! Sample a position from the distribution
6767
//! \return Sampled position
68-
Position sample() const;
68+
Position sample(uint64_t * prn_seeds, int stream) const;
6969

7070
// Properties
7171
bool only_fissionable() const { return only_fissionable_; }
@@ -87,7 +87,7 @@ class SpatialPoint : public SpatialDistribution {
8787

8888
//! Sample a position from the distribution
8989
//! \return Sampled position
90-
Position sample() const;
90+
Position sample(uint64_t * prn_seeds, int stream) const;
9191
private:
9292
Position r_; //!< Single position at which sites are generated
9393
};

‎include/openmc/math_functions.h‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,15 @@ extern "C" void calc_zn_rad(int n, double rho, double zn_rad[]);
129129
//! \param mu The cosine of angle in lab or CM
130130
//! \param phi The azimuthal angle; will randomly chosen angle if a nullptr
131131
//! is passed
132+
//! \param prn_seeds A pointer to the array of pseudorandom seeds
133+
//! \param stream The pseudorandom stream index with which to sample from
132134
//==============================================================================
133135

134-
extern "C" void rotate_angle_c(double uvw[3], double mu, const double* phi);
136+
extern "C" void rotate_angle_c(double uvw[3], double mu, const double* phi,
137+
uint64_t * prn_seeds, int stream);
135138

136-
Direction rotate_angle(Direction u, double mu, const double* phi);
139+
Direction rotate_angle(Direction u, double mu, const double* phi,
140+
uint64_t * prn_streams, int stream);
137141

138142
//==============================================================================
139143
//! Samples an energy from the Maxwell fission distribution based on a direct
@@ -144,10 +148,12 @@ Direction rotate_angle(Direction u, double mu, const double* phi);
144148
//! rule C64 in the Monte Carlo Sampler LA-9721-MS.
145149
//!
146150
//! \param T The tabulated function of the incoming energy
151+
//! \param prn_seeds A pointer to the array of pseudorandom seeds
152+
//! \param stream The pseudorandom stream index with which to sample from
147153
//! \return The sampled outgoing energy
148154
//==============================================================================
149155

150-
extern "C" double maxwell_spectrum(double T);
156+
extern "C" double maxwell_spectrum(double T, uint64_t * prn_seeds, int stream);
151157

152158
//==============================================================================
153159
//! Samples an energy from a Watt energy-dependent fission distribution.
@@ -159,10 +165,12 @@ extern "C" double maxwell_spectrum(double T);
159165
//!
160166
//! \param a Watt parameter a
161167
//! \param b Watt parameter b
168+
//! \param prn_seeds A pointer to the array of pseudorandom seeds
169+
//! \param stream The pseudorandom stream index with which to sample from
162170
//! \return The sampled outgoing energy
163171
//==============================================================================
164172

165-
extern "C" double watt_spectrum(double a, double b);
173+
extern "C" double watt_spectrum(double a, double b, uint64_t * prn_seeds, int stream);
166174

167175
//==============================================================================
168176
//! Samples an energy from the Gaussian energy-dependent fission distribution.
@@ -175,10 +183,13 @@ extern "C" double watt_spectrum(double a, double b);
175183
//!
176184
//! @param mean mean of the Gaussian distribution
177185
//! @param std_dev standard deviation of the Gaussian distribution
186+
//! @param prn_seeds A pointer to the array of pseudorandom seeds
187+
//! @param stream The pseudorandom stream index with which to sample from
178188
//! @result The sampled outgoing energy
179189
//==============================================================================
180190

181-
extern "C" double normal_variate(double mean, double std_dev);
191+
extern "C" double normal_variate(double mean, double std_dev, uint64_t * prn_seeds,
192+
int stream);
182193

183194
//==============================================================================
184195
//! Samples an energy from the Muir (Gaussian) energy-dependent distribution.
@@ -190,10 +201,13 @@ extern "C" double normal_variate(double mean, double std_dev);
190201
//! @param e0 peak neutron energy [eV]
191202
//! @param m_rat ratio of the fusion reactants to AMU
192203
//! @param kt the ion temperature of the reactants [eV]
204+
//! @param prn_seeds A pointer to the array of pseudorandom seeds
205+
//! @param stream The pseudorandom stream index with which to sample from
193206
//! @result The sampled outgoing energy
194207
//==============================================================================
195208

196-
extern "C" double muir_spectrum(double e0, double m_rat, double kt);
209+
extern "C" double muir_spectrum(double e0, double m_rat, double kt, uint64_t * prn_seeds,
210+
int stream);
197211

198212
//==============================================================================
199213
//! Doppler broadens the windowed multipole curvefit.

‎include/openmc/mgxs.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,22 @@ class Mgxs {
154154
//! @param gin Incoming energy group.
155155
//! @param dg Sampled delayed group index.
156156
//! @param gout Sampled outgoing energy group.
157+
//! @param prn_seeds Pseudorandom seed array.
158+
//! @param stream Pseudorandom stream index.
157159
void
158-
sample_fission_energy(int gin, int& dg, int& gout);
160+
sample_fission_energy(int gin, int& dg, int& gout, uint64_t * prn_seeds, int stream);
159161

160162
//! \brief Samples the outgoing energy and angle from a scatter event.
161163
//!
162164
//! @param gin Incoming energy group.
163165
//! @param gout Sampled outgoing energy group.
164166
//! @param mu Sampled cosine of the change-in-angle.
165167
//! @param wgt Weight of the particle to be adjusted.
168+
//! @param prn_seeds Array of pseudorandom stream seeds
169+
//! @param stream Pseudorandom stream index
166170
void
167-
sample_scatter(int gin, int& gout, double& mu, double& wgt);
171+
sample_scatter(int gin, int& gout, double& mu, double& wgt, uint64_t * prn_seeds,
172+
int stream);
168173

169174
//! \brief Calculates cross section quantities needed for tracking.
170175
//!

‎include/openmc/photon.h‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ class PhotonInteraction {
4545
void calculate_xs(Particle& p) const;
4646

4747
void compton_scatter(double alpha, bool doppler, double* alpha_out,
48-
double* mu, int* i_shell) const;
48+
double* mu, int* i_shell, uint64_t * prn_seeds, int stream) const;
4949

50-
double rayleigh_scatter(double alpha) const;
50+
double rayleigh_scatter(double alpha, uint64_t * prn_seeds, int stream) const;
5151

5252
void pair_production(double alpha, double* E_electron, double* E_positron,
53-
double* mu_electron, double* mu_positron) const;
53+
double* mu_electron, double* mu_positron, uint64_t * prn_seeds, int stream) const;
5454

5555
void atomic_relaxation(const ElectronSubshell& shell, Particle& p) const;
5656

@@ -96,14 +96,15 @@ class PhotonInteraction {
9696
xt::xtensor<double, 2> dcs_;
9797

9898
private:
99-
void compton_doppler(double alpha, double mu, double* E_out, int* i_shell) const;
99+
void compton_doppler(double alpha, double mu, double* E_out, int* i_shell,
100+
uint64_t * prn_seeds, int stream) const;
100101
};
101102

102103
//==============================================================================
103104
// Non-member functions
104105
//==============================================================================
105106

106-
std::pair<double, double> klein_nishina(double alpha);
107+
std::pair<double, double> klein_nishina(double alpha, uint64_t * prn_seeds, int stream);
107108

108109
void free_memory_photon();
109110

‎include/openmc/physics.h‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void sample_photon_product(int i_nuclide, const Particle* p, int* i_rx, int* i_p
5959

6060
void absorption(Particle* p, int i_nuclide);
6161

62-
void scatter(Particle*, int i_nuclide);
62+
void scatter(Particle* p, int i_nuclide);
6363

6464
//! Treats the elastic scattering of a neutron with a target.
6565
void elastic_scatter(int i_nuclide, const Reaction& rx, double kT,
@@ -72,15 +72,17 @@ void sab_scatter(int i_nuclide, int i_sab, Particle* p);
7272
//! dependence of cross sections in treating resonance elastic scattering such
7373
//! as the DBRC and a new, accelerated scheme are also implemented here.
7474
Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u,
75-
Direction v_neut, double xs_eff, double kT);
75+
Direction v_neut, double xs_eff, double kT, uint64_t * prn_seeds, int stream);
7676

7777
//! samples a target velocity based on the free gas scattering formulation, used
7878
//! by most Monte Carlo codes, in which cross section is assumed to be constant
7979
//! in energy. Excellent documentation for this method can be found in
8080
//! FRA-TM-123.
81-
Direction sample_cxs_target_velocity(double awr, double E, Direction u, double kT);
81+
Direction sample_cxs_target_velocity(double awr, double E, Direction u, double kT,
82+
uint64_t * prn_seeds, int stream);
8283

83-
void sample_fission_neutron(int i_nuclide, const Reaction* rx, double E_in, Particle::Bank* site);
84+
void sample_fission_neutron(int i_nuclide, const Reaction* rx, double E_in, Particle::Bank* site,
85+
uint64_t * prn_seeds, int stream);
8486

8587
//! handles all reactions with a single secondary neutron (other than fission),
8688
//! i.e. level scattering, (n,np), (n,na), etc.

‎include/openmc/plot.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void create_voxel(Plot pl);
285285

286286
//! Create a randomly generated RGB color
287287
//! \return RGBColor with random value
288-
RGBColor random_color();
288+
RGBColor random_color(uint64_t * prn_seeds, int stream);
289289

290290

291291
} // namespace openmc

0 commit comments

Comments
 (0)