mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-25 20:45:35 -04:00
Refactor ParticleType to use PDG Monte Carlo numbering scheme (#3756)
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com> Co-authored-by: Amanda Lund <alund1187@gmail.com>
This commit is contained in:
parent
fc0d9eec65
commit
b41e22f68b
62 changed files with 1401 additions and 558 deletions
|
|
@ -2,36 +2,37 @@
|
|||
#include "openmc/source.h"
|
||||
|
||||
class CustomSource : public openmc::Source {
|
||||
public:
|
||||
CustomSource(double energy) : energy_(energy) { }
|
||||
public:
|
||||
CustomSource(double energy) : energy_(energy) {}
|
||||
|
||||
// Samples from an instance of this class.
|
||||
openmc::SourceSite sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::SourceSite particle;
|
||||
// wgt
|
||||
particle.particle = openmc::ParticleType::neutron;
|
||||
particle.wgt = 1.0;
|
||||
// position
|
||||
particle.r.x = 0.0;
|
||||
particle.r.y = 0.0;
|
||||
particle.r.z = 0.0;
|
||||
// angle
|
||||
particle.u = {1.0, 0.0, 0.0};
|
||||
particle.E = this->energy_;
|
||||
particle.delayed_group = 0;
|
||||
// Samples from an instance of this class.
|
||||
openmc::SourceSite sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::SourceSite particle;
|
||||
// wgt
|
||||
particle.particle = openmc::ParticleType::neutron();
|
||||
particle.wgt = 1.0;
|
||||
// position
|
||||
particle.r.x = 0.0;
|
||||
particle.r.y = 0.0;
|
||||
particle.r.z = 0.0;
|
||||
// angle
|
||||
particle.u = {1.0, 0.0, 0.0};
|
||||
particle.E = this->energy_;
|
||||
particle.delayed_group = 0;
|
||||
|
||||
return particle;
|
||||
}
|
||||
return particle;
|
||||
}
|
||||
|
||||
private:
|
||||
double energy_;
|
||||
private:
|
||||
double energy_;
|
||||
};
|
||||
|
||||
// A function to create a unique pointer to an instance of this class when generated
|
||||
// via a plugin call using dlopen/dlsym.
|
||||
// You must have external C linkage here otherwise dlopen will not find the file
|
||||
extern "C" std::unique_ptr<CustomSource> openmc_create_source(std::string parameter)
|
||||
// A function to create a unique pointer to an instance of this class when
|
||||
// generated via a plugin call using dlopen/dlsym. You must have external C
|
||||
// linkage here otherwise dlopen will not find the file
|
||||
extern "C" std::unique_ptr<CustomSource> openmc_create_source(
|
||||
std::string parameter)
|
||||
{
|
||||
double energy = std::stod(parameter);
|
||||
return std::make_unique<CustomSource>(energy);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue