Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "vendor/Catch2"]
path = vendor/Catch2
url = https://github.com/catchorg/Catch2.git
[submodule "vendor/gsl-lite"]
path = vendor/gsl-lite
url = https://github.com/gsl-lite/gsl-lite.git
2 changes: 1 addition & 1 deletion include/openmc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ enum class TallyResult { VALUE, SUM, SUM_SQ, SIZE };

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

enum class TallyEstimator { ANALOG, TRACKLENGTH, COLLISION };
enum class TallyEstimator { ANALOG, TRACKLENGTH, COLLISION, POINT };

enum class TallyEvent { SURFACE, LATTICE, KILL, SCATTER, ABSORB };

Expand Down
17 changes: 15 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,10 @@ 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
// double get_pdf_value(double x,uint64_t* seed) const;
// 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 +274,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 +294,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: 1 addition & 1 deletion include/openmc/hdf5_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void write_int(hid_t group_id, int ndim, const hsize_t* dims, const char* name,
void write_llong(hid_t group_id, int ndim, const hsize_t* dims,
const char* name, const long long* buffer, bool indep);
void write_string(hid_t group_id, int ndim, const hsize_t* dims, size_t slen,
const char* name, char const* buffer, bool indep);
const char* name, const char* buffer, bool indep);
void write_tally_results(
hid_t group_id, hsize_t n_filter, hsize_t n_score, const double* results);
} // extern "C"
Expand Down
11 changes: 7 additions & 4 deletions include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ class Particle : public ParticleData {

Particle() = default;

//==========================================================================
// Methods

double speed() const;

//! create a secondary particle
//
//
double getMass() const;
//
//
//! stores the current phase space attributes of the particle in the
//! secondary bank and increments the number of sites in the secondary bank.
//! \param wgt Weight of the secondary particle
Expand All @@ -63,7 +64,9 @@ class Particle : public ParticleData {
//! simply as a secondary particle.
//! \param src Source site data
void from_source(const SourceSite* src);

void initialize_ghost_particle(Particle& p, Direction u, double E);
void initialize_ghost_particle_from_source(
const SourceSite* src, Direction u_new);
// Coarse-grained particle events
void event_calculate_xs();
void event_advance();
Expand Down
7 changes: 7 additions & 0 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct SourceSite {
int parent_nuclide {-1};
int64_t parent_id;
int64_t progeny_id;
int source_index;
bool ext {true}; //!< Is this source site external?
};

//! State of a particle used for particle track files
Expand Down Expand Up @@ -488,7 +490,9 @@ class ParticleData : public GeometryState {
int event_nuclide_;
int event_mt_;
int delayed_group_ {0};
int event_index_mt_;
int parent_nuclide_ {-1};
Direction v_t_;

int n_bank_ {0};
double bank_second_E_ {0.0};
Expand Down Expand Up @@ -622,7 +626,10 @@ 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
Position& v_t() { return v_t_; }
const Position& v_t() const { return v_t_; }
const int& parent_nuclide() const { return parent_nuclide_; }
int& parent_nuclide() { return parent_nuclide_; } // Parent nuclide

Expand Down
5 changes: 5 additions & 0 deletions include/openmc/physics.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ Direction sample_cxs_target_velocity(
void sample_fission_neutron(
int i_nuclide, const Reaction& rx, SourceSite* site, Particle& p);

void score_fission_neutron(int i_tally, int i_nuclide, const Reaction& rx,
SourceSite* site, Particle& p, std::vector<double>& mu_cm,
std::vector<double>& Js, std::vector<Particle>& ghost_particles,
std::vector<double>& pdfs_lab);

//! handles all reactions with a single secondary neutron (other than fission),
//! i.e. level scattering, (n,np), (n,na), etc.
void inelastic_scatter(const Nuclide& nuc, const Reaction& rx, Particle& p);
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
8 changes: 8 additions & 0 deletions include/openmc/tallies/tally.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class Tally {

void set_nuclides(const vector<std::string>& nuclides);

void set_positions(pugi::xml_node node);

void set_positions(const vector<std::string>& positions);

const xt::xtensor<double, 3>& results() const { return results_; }

//! returns vector of indices corresponding to the tally this is called on
Expand Down Expand Up @@ -151,6 +155,9 @@ class Tally {

vector<int> scores_; //!< Filter integrands (e.g. flux, fission)

//! Index of each pos to be tallied.
vector<std::string> positions_;

//! Index of each nuclide to be tallied. -1 indicates total material.
vector<int> nuclides_ {-1};

Expand Down Expand Up @@ -206,6 +213,7 @@ extern vector<int> active_tallies;
extern vector<int> active_analog_tallies;
extern vector<int> active_tracklength_tallies;
extern vector<int> active_collision_tallies;
extern vector<int> active_point_tallies;
extern vector<int> active_meshsurf_tallies;
extern vector<int> active_surface_tallies;
extern vector<int> active_pulse_height_tallies;
Expand Down
Loading
Loading