2026-07-22 00:45:41 +09:00
|
|
|
#define _USE_MATH_DEFINES
|
2026-02-03 01:23:24 -06:00
|
|
|
#include <cmath> // for M_PI
|
2020-08-21 12:05:43 +01:00
|
|
|
#include <memory> // for unique_ptr
|
2020-03-13 16:13:53 -05:00
|
|
|
|
2026-02-03 01:23:24 -06:00
|
|
|
#include "openmc/particle.h"
|
2020-03-13 16:13:53 -05:00
|
|
|
#include "openmc/random_lcg.h"
|
|
|
|
|
#include "openmc/source.h"
|
|
|
|
|
|
2026-02-03 01:23:24 -06:00
|
|
|
class RingSource : public openmc::Source {
|
2021-05-03 17:52:20 -04:00
|
|
|
openmc::SourceSite sample(uint64_t* seed) const
|
2020-08-21 12:05:43 +01:00
|
|
|
{
|
2021-05-03 17:52:20 -04:00
|
|
|
openmc::SourceSite particle;
|
2022-01-19 18:30:11 -06:00
|
|
|
// particle type
|
2026-02-03 01:23:24 -06:00
|
|
|
particle.particle = openmc::ParticleType::neutron();
|
2020-08-21 12:05:43 +01:00
|
|
|
// position
|
|
|
|
|
double angle = 2.0 * M_PI * openmc::prn(seed);
|
|
|
|
|
double radius = 3.0;
|
|
|
|
|
particle.r.x = radius * std::cos(angle);
|
|
|
|
|
particle.r.y = radius * std::sin(angle);
|
|
|
|
|
particle.r.z = 0.0;
|
|
|
|
|
// angle
|
|
|
|
|
particle.u = {1.0, 0.0, 0.0};
|
|
|
|
|
particle.E = 14.08e6;
|
|
|
|
|
return particle;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-03 01:23:24 -06:00
|
|
|
// 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<RingSource> openmc_create_source(
|
|
|
|
|
std::string parameters)
|
2020-08-21 12:05:43 +01:00
|
|
|
{
|
2020-10-23 13:45:28 -05:00
|
|
|
return std::make_unique<RingSource>();
|
2020-03-13 16:13:53 -05:00
|
|
|
}
|