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 79 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 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
809769b
Had a bug in the formula for cond and insq. wasa using p1_cm instaed …
Jan 2, 2024
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
f0480c4
Fixed H1 2 soultions and not scoring while particle is outside of geo…
Nov 5, 2024
5a57f2e
Merge branch 'exclusion_sphere' into HEAD
Nov 10, 2024
132be34
applied clang-format-15
Nov 10, 2024
e5ac4d4
Applied PEP8
Nov 10, 2024
b0e4073
Merge branch 'develop' of https://github.com/itay-space/openmc into d…
Nov 14, 2024
77b53dc
Merge branch 'develop' into deploy
Nov 14, 2024
6975156
Implementd contribution from muitlpe sources, and verified al working…
Nov 26, 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
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
QualifierAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ FROM dependencies AS build

ENV HOME=/root

ARG openmc_branch=master
ENV OPENMC_REPO='https://github.com/openmc-dev/openmc'
ARG openmc_branch=deploy
ENV OPENMC_REPO='https://github.com/itay-space/openmc.git'

ARG compile_cores
ARG build_dagmc
Expand Down
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
14 changes: 12 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,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 @@ -111,6 +112,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 +137,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 +163,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 +184,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 +209,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 +233,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 +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 @@ -282,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
15 changes: 3 additions & 12 deletions include/openmc/ncrystal_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,10 @@ class NCrystalMat {

//----------------------------------------------------------------------------
// Trivial methods when compiling without NCRYSTAL
std::string cfg() const
{
return "";
}
double xs(const Particle& p) const
{
return -1.0;
}
std::string cfg() const { return ""; }
double xs(const Particle& p) const { return -1.0; }
void scatter(Particle& p) const {}
operator bool() const
{
return false;
}
operator bool() const { return false; }
#endif

private:
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,9 +34,6 @@ class Particle : public ParticleData {

Particle() = default;

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

double speed() const;

//! moves the particle by the distance length to its next location
Expand All @@ -45,6 +42,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 @@ -60,7 +61,9 @@ 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
96 changes: 69 additions & 27 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ 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;
int source_index;
};

//! State of a particle used for particle track files
Expand Down Expand Up @@ -391,41 +393,78 @@ class GeometryState {
class ParticleData : public GeometryState {
private:
//==========================================================================
// Data members -- see public: below for descriptions
// Data members (accessor methods are below)

vector<NuclideMicroXS> neutron_xs_;
vector<ElementMicroXS> photon_xs_;
MacroXS macro_xs_;
CacheDataMG mg_xs_cache_;
// Cross section caches
vector<NuclideMicroXS> neutron_xs_; //!< Microscopic neutron cross sections
vector<ElementMicroXS> photon_xs_; //!< Microscopic photon cross sections
MacroXS macro_xs_; //!< Macroscopic cross sections
CacheDataMG mg_xs_cache_; //!< Multigroup XS cache

ParticleType type_ {ParticleType::neutron};
int64_t id_; //!< Unique ID
ParticleType type_ {ParticleType::neutron}; //!< Particle type (n, p, e, etc.)

double E_;
double E_last_;
int g_ {0};
int g_last_;
int n_coord_ {1}; //!< number of current coordinate levels
int cell_instance_; //!< offset for distributed properties
vector<LocalCoord> coord_; //!< coordinates for all levels

double wgt_ {1.0};
double mu_;
double time_ {0.0};
double time_last_ {0.0};
double wgt_last_ {1.0};
// Particle coordinates before crossing a surface
int n_coord_last_ {1}; //!< number of current coordinates
vector<int> cell_last_; //!< coordinates for all levels

// Energy data
double E_; //!< post-collision energy in eV
double E_last_; //!< pre-collision energy in eV
int g_ {0}; //!< post-collision energy group (MG only)
int g_last_; //!< pre-collision energy group (MG only)

bool fission_ {false};
TallyEvent event_;
int event_nuclide_;
int event_mt_;
int delayed_group_ {0};
// Other physical data
double wgt_ {1.0}; //!< particle weight
double mu_; //!< angle of scatter
double time_ {0.0}; //!< time in [s]
double time_last_ {0.0}; //!< previous time in [s]

// Other physical data
Position r_last_current_; //!< coordinates of the last collision or
//!< reflective/periodic surface crossing for
//!< current tallies
Position r_last_; //!< previous coordinates
Direction u_last_; //!< previous direction coordinates
double wgt_last_ {1.0}; //!< pre-collision particle weight

// What event took place
bool fission_ {false}; //!< did particle cause implicit fission
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
int n_bank_second_ {0}; //!< number of secondary particles banked
double wgt_bank_ {0.0}; //!< weight of fission sites banked
int n_delayed_bank_[MAX_DELAYED_GROUPS]; //!< number of delayed fission
//!< sites banked

// Indices for various arrays
int surface_ {0}; //!< index for surface particle is on
int cell_born_ {-1}; //!< index for cell particle was born in
int material_ {-1}; //!< index for current material
int material_last_ {-1}; //!< index for last material

int n_bank_ {0};
int n_bank_second_ {0};
double wgt_bank_ {0.0};
int n_delayed_bank_[MAX_DELAYED_GROUPS];
// Boundary information
BoundaryInfo boundary_;

int cell_born_ {-1};
// Temperature of current cell
double sqrtkT_ {-1.0}; //!< sqrt(k_Boltzmann * temperature) in eV
double sqrtkT_last_ {0.0}; //!< last temperature

int n_collision_ {0};
// Statistical data
int n_collision_ {0}; //!< number of collisions

// Track output
bool write_track_ {false};

uint64_t seeds_[N_STREAMS];
Expand Down Expand Up @@ -528,8 +567,11 @@ class ParticleData : public GeometryState {
bool& fission() { return fission_; } // true if implicit fission
int& event_nuclide() { return event_nuclide_; } // index of collision nuclide
const int& event_nuclide() const { return event_nuclide_; }
int& event_mt() { return event_mt_; } // MT number of collision
int& event_mt() { return event_mt_; } // MT number of collision
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_; }

// Post-collision data
int& n_bank() { return n_bank_; } // number of banked fission sites
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 @@ -10,8 +10,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 @@ -43,7 +44,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
Loading