2020-07-31 17:32:50 +01:00
|
|
|
#include "openmc/source.h"
|
|
|
|
|
#include "openmc/particle.h"
|
|
|
|
|
|
2020-08-05 15:53:48 +01:00
|
|
|
class ParameterizedSource : public openmc::CustomSource {
|
2020-07-31 17:32:50 +01:00
|
|
|
public:
|
2020-08-05 16:10:04 +01:00
|
|
|
double energy;
|
2020-08-03 14:24:17 +01:00
|
|
|
|
2020-08-05 16:10:04 +01:00
|
|
|
ParameterizedSource(double energy) {
|
|
|
|
|
this->energy = energy;
|
2020-08-03 17:38:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Samples from an instance of this class.
|
|
|
|
|
openmc::Particle::Bank sample_source(uint64_t* seed) {
|
|
|
|
|
openmc::Particle::Bank particle;
|
|
|
|
|
// wgt
|
|
|
|
|
particle.particle = openmc::Particle::Type::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};
|
2020-08-05 16:10:04 +01:00
|
|
|
particle.E = this->energy;
|
2020-08-03 17:38:12 +01:00
|
|
|
particle.delayed_group = 0;
|
|
|
|
|
|
|
|
|
|
return particle;
|
2020-07-31 17:32:50 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// you must have external C linkage here otherwise
|
|
|
|
|
// dlopen will not find the file
|
2020-08-05 16:10:04 +01:00
|
|
|
extern "C" ParameterizedSource* openmc_create_source(const char* parameter) {
|
|
|
|
|
return new ParameterizedSource(atof(parameter));
|
2020-08-03 17:38:12 +01:00
|
|
|
}
|