Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point Detector Tally #3109

Open
wants to merge 71 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
21efc8d
changed output, now printing xs in every collision
Itay-max Oct 25, 2022
8269657
created get pdf value and didnt use it
Itay-max Oct 25, 2022
9d1f196
implemented u_com and tried making a ghost particle for each collisio…
Itay-max Oct 25, 2022
64f1d40
succefuly calculated mean free path using a ghost parrticle. memory p…
Itay-max Oct 25, 2022
22a54ca
cant kill particles
Itay-max Oct 25, 2022
4e3ab1d
finally fixed the problem of generating the gost particle and trackin…
Itay-max Oct 25, 2022
f48ef19
added a new estimtor named point - works
Itay-max Oct 25, 2022
c2dfc90
tried adding Mu lab calcs but coulndt compile
Itay-max Oct 25, 2022
23a7d14
added arik function but only took one solution for mu com
Itay-max Oct 25, 2022
6ac128f
implementd two solution for comCM
Itay-max Oct 25, 2022
913273d
getting similar results to mcnp but assuming target is in rest
Itay-max Oct 25, 2022
65f3033
added v_t = velcity of target particle as a property of particle data
Itay-max Oct 25, 2022
52d337e
using v_t for calcualtion of p2 , no longer assuming target in rest
Itay-max Oct 25, 2022
bff894c
changed p2 calc and verified it by maxwell boltzman distirbution
Itay-max Oct 25, 2022
eb3fcb8
printing temprature
Itay-max Oct 25, 2022
bcae8f7
Merge branch 'Ecalc' of https://github.com/itayhorin/openmc into Ecalc
Itay-max Oct 25, 2022
d860ce7
Merge pull request #1 from itayhorin/Ecalc
Itay-max Oct 25, 2022
8b70afb
Merge branch 'develop' of https://github.com/Itay-max/openmc into dev…
Jul 27, 2023
be52bad
working point tally for elastic scattering
Nov 13, 2023
ab940cf
Merge branch 'develop' of https://github.com/itay-space/openmc into d…
Nov 13, 2023
ad47f6b
trying to add contribution from source
Nov 16, 2023
bf1f515
flux from source is calcualted in tally scoring
Nov 18, 2023
bcab472
added get_MFP function and trying to read inelastic angle energy dist…
Nov 19, 2023
4b0b402
energy filter works for point det
Nov 23, 2023
60df643
trying to get pdf from inelastic disrtibutions
Nov 28, 2023
ca6f94c
calculating pdfs in a diffenent function
Nov 28, 2023
cf30f45
doing kinemtics and calcuating pdf for elastic scattering in a new fu…
Nov 28, 2023
f96377e
get the positin of the detector in a new function
Nov 28, 2023
6c90155
detector position in a new function
Nov 28, 2023
e44d140
working on detector positin function
Nov 28, 2023
666bf5e
looping on the ghost particles and calcuting their flux contibution a…
Nov 28, 2023
f8de667
Made sure the target veloity is initialzied to zero in inelastic scat…
Nov 28, 2023
a969cd4
Added mu_cm calcuation for KalbachMann distrubition.
Nov 29, 2023
310e660
calculating pdf_lab using derivative and chagning function to void so…
Nov 29, 2023
42b87c6
Now filling ghost particles and getting pdfs from Uncorrelated angle …
Nov 29, 2023
a6c51f9
Now creating also ghost particle from nbodyphase space distribution
Nov 30, 2023
1439772
fixed all calcualtions in inelastic, accidently took mu_cm from sampling
Nov 30, 2023
e7aae35
only taking solutions that conserve energy.
Nov 30, 2023
db48c1c
multiply the weight with yield for example n,2n is 2
Dec 3, 2023
8a3e48e
calculating pdf and generating ghost particles in Correlated distribu…
Dec 3, 2023
1c519fc
trying to creat ghost particles from fission
Dec 5, 2023
77ffc54
scoring ghost particles from fission is working now
Dec 5, 2023
690c705
added tools to make discrete mu distrubtion to pdf values
Dec 6, 2023
7b8135d
added pdfs calculations for IncoherentElastic and CoherentElasticAE +…
Dec 6, 2023
023baab
added pdf calculations for Discrete Incohernet both for elastic and i…
Dec 6, 2023
daf65f3
added pdf for incohernet inelastic
Dec 6, 2023
c33df5a
printing the thermal distribution used.
Dec 6, 2023
e86efdd
distinguish from non s(a,b) elastic scattering to prevent double scoring
Dec 6, 2023
bd53fb7
creating the ghost particle from s(a,b) and getting pdf in physics.cpp
Dec 6, 2023
f5fde24
scoring the ghost particle in a designated function
Dec 10, 2023
cb09cb7
scoring the ghost paritcles in S(a,b)
Dec 10, 2023
56698e6
added pdf contribution from coherentleastic. and can print to file pd…
Dec 13, 2023
16db49e
initialized p.event._index_mt every collision to distinguish between …
Dec 23, 2023
93dfd87
fixed coherentElastic
Dec 26, 2023
2a37ce7
trying arik's function
Dec 28, 2023
a8124ef
added inelastic function
Dec 28, 2023
13801e1
also included fission to be in the new scoring method
Dec 29, 2023
090a111
merged elastic and inelatic by repalcing m4
Jan 2, 2024
5f21e9f
added option to add point detector via python api
Jan 2, 2024
549c66e
same q for both sols and also using approx more often
Jan 2, 2024
4848fb7
modified tolernace param to use approx
Jan 7, 2024
e14851b
implemented multiple detectors
Jan 7, 2024
4e58b2c
trying to add exclusion sphere and also no need for score fission net…
Jan 16, 2024
612ff60
fixed the MFP function so now the exculsion sphere works
Jan 18, 2024
f05488f
contibution is now only from external source
Jan 30, 2024
41221f6
User now have to specify R0 (dor the exclusion sphere radius) and als…
May 13, 2024
075b87c
We Fixed cohernetElastic!
Jun 6, 2024
b3cb01a
discrete distribution was not implemented
Aug 4, 2024
9881ab0
Point tally detector development
Aug 6, 2024
26f4fd1
fixed: Expected function implmention (virtual)
Aug 13, 2024
aa1e4e6
Merge branch 'deploy' of https://github.com/itay-space/openmc into de…
Aug 13, 2024
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
2 changes: 1 addition & 1 deletion include/openmc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,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
13 changes: 12 additions & 1 deletion include/openmc/distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 @@ -83,6 +83,7 @@ class Discrete : 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 di_.integral(); };

Expand Down Expand Up @@ -110,6 +111,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 @@ -134,6 +136,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 @@ -159,6 +162,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 @@ -179,6 +183,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 @@ -203,6 +208,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 @@ -226,7 +232,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;


//double get_pdf_value(double x,uint64_t* seed) const;
// properties
vector<double>& x() { return x_; }
const vector<double>& x() const { return x_; }
Expand Down Expand Up @@ -262,6 +271,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 @@ -281,6 +291,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
11 changes: 7 additions & 4 deletions include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace openmc {


// Forward declare the Surface class for use in Particle::cross_vacuum_bc, etc.
class Surface;

Expand All @@ -35,9 +36,6 @@ class Particle : public ParticleData {

Particle() = default;

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

double speed() const;

//! moves the particle by the distance length to its next location
Expand All @@ -46,6 +44,10 @@ class Particle : public ParticleData {

//! 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 @@ -61,7 +63,8 @@ class Particle : public ParticleData {
//! simply as a secondary particle.
//! \param src Source site data
void from_source(const SourceSite* src);

void initilze_ghost_particle(Particle& p,Direction u, double E);
void initilze_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 @@ -51,6 +51,7 @@ struct SourceSite {
double wgt {1.0};
int delayed_group {0};
int surf_id {0};
bool ext {false};
ParticleType particle;
int64_t parent_id;
int64_t progeny_id;
Expand Down Expand Up @@ -234,6 +235,7 @@ class ParticleData {
//----------------------------------------------------------------------------
// Constructors
ParticleData();
void reset_cords();

private:
//==========================================================================
Expand Down Expand Up @@ -281,7 +283,9 @@ class ParticleData {
TallyEvent event_; //!< scatter, absorption
int event_nuclide_; //!< index in nuclides array
int event_mt_; //!< reaction MT
int event_index_mt_;
int delayed_group_ {0}; //!< delayed group
Direction v_t_;

// Post-collision physical data
int n_bank_ {0}; //!< number of fission sites banked
Expand Down Expand Up @@ -420,7 +424,10 @@ class ParticleData {
int& event_nuclide() { return event_nuclide_; }
const int& event_nuclide() const { return event_nuclide_; }
int& event_mt() { return event_mt_; }
int& event_index_mt() { return event_index_mt_; }
int& delayed_group() { return delayed_group_; }
Position& v_t() { return v_t_; }
const Position& v_t() const { return v_t_; }

int& n_bank() { return n_bank_; }
int& n_bank_second() { return n_bank_second_; }
Expand Down
4 changes: 4 additions & 0 deletions include/openmc/physics.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ 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
5 changes: 3 additions & 2 deletions include/openmc/reaction_product.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/vector.h" // for vector

#include "openmc/tallies/filter.h"
#include "openmc/tallies/tally.h"
namespace openmc {

//==============================================================================
Expand Down Expand Up @@ -43,7 +44,7 @@ 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
3 changes: 3 additions & 0 deletions include/openmc/secondary_correlated.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "openmc/distribution.h"
#include "openmc/endf.h"
#include "openmc/vector.h"
#include "openmc/particle.h"

namespace openmc {

Expand Down Expand Up @@ -40,6 +41,8 @@ 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
2 changes: 2 additions & 0 deletions include/openmc/secondary_kalbach.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "openmc/constants.h"
#include "openmc/endf.h"
#include "openmc/vector.h"
#include "openmc/particle.h"

namespace openmc {

Expand All @@ -31,6 +32,7 @@ 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
4 changes: 4 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,9 @@ 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
13 changes: 12 additions & 1 deletion include/openmc/secondary_thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ 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,8 @@ 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 +83,8 @@ 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 +111,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 +141,8 @@ 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 Expand Up @@ -178,6 +187,8 @@ class MixedElasticAE : public AngleEnergy {
const Function1D& incoherent_xs_; //!< Polymorphic ref. to incoherent XS
};



} // namespace openmc

#endif // OPENMC_SECONDARY_THERMAL_H
3 changes: 3 additions & 0 deletions include/openmc/secondary_uncorrelated.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "openmc/distribution_energy.h"
#include "openmc/memory.h"
#include "openmc/vector.h"
#include "openmc/particle.h"

namespace openmc {

Expand All @@ -31,6 +32,8 @@ 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