mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Update documentation regarding custom sources
This commit is contained in:
parent
0bb39005bc
commit
33b7dcfe22
2 changed files with 9 additions and 9 deletions
|
|
@ -465,7 +465,7 @@ attributes/sub-elements:
|
|||
as complex as is required to define the source for your problem. The library
|
||||
has a few basic requirements:
|
||||
|
||||
* It must contain a class that inherits from ``openmc::CustomSource``;
|
||||
* It must contain a class that inherits from ``openmc::Source``;
|
||||
* The class must implement a function called ``sample()``;
|
||||
* There must be an ``openmc_create_source()`` function that creates the source
|
||||
as a unique pointer. This function can be used to pass parameters through to
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ below.
|
|||
#include "openmc/source.h"
|
||||
#include "openmc/particle.h"
|
||||
|
||||
class Source : public openmc::CustomSource
|
||||
class CustomSource : public openmc::Source
|
||||
{
|
||||
openmc::Particle::Bank sample(uint64_t* seed)
|
||||
{
|
||||
|
|
@ -216,16 +216,16 @@ below.
|
|||
}
|
||||
};
|
||||
|
||||
extern "C" std::unique_ptr<Source> openmc_create_source(std::string parameters)
|
||||
extern "C" std::unique_ptr<CustomSource> openmc_create_source(std::string parameters)
|
||||
{
|
||||
return std::make_unique<Source>();
|
||||
return std::make_unique<CustomSource>();
|
||||
}
|
||||
|
||||
The above source creates monodirectional 14.08 MeV neutrons that are distributed
|
||||
in a ring with a 3 cm radius. This routine is not particularly complex, but
|
||||
should serve as an example upon which to build more complicated sources.
|
||||
|
||||
.. note:: The source class must inherit from ``openmc::CustomSource`` and
|
||||
.. note:: The source class must inherit from ``openmc::Source`` and
|
||||
implement a ``sample()`` function.
|
||||
|
||||
.. note:: The ``openmc_create_source()`` function signature must be declared
|
||||
|
|
@ -266,9 +266,9 @@ the source class when it is created:
|
|||
#include "openmc/source.h"
|
||||
#include "openmc/particle.h"
|
||||
|
||||
class Source : public openmc::CustomSource {
|
||||
class CustomSource : public openmc::Source {
|
||||
public:
|
||||
Source(double energy) : energy_{energy} { }
|
||||
CustomSource(double energy) : energy_{energy} { }
|
||||
|
||||
// Samples from an instance of this class.
|
||||
openmc::Particle::Bank sample(uint64_t* seed)
|
||||
|
|
@ -293,9 +293,9 @@ the source class when it is created:
|
|||
double energy_;
|
||||
};
|
||||
|
||||
extern "C" std::unique_ptr<Source> openmc_create_source(std::string parameter) {
|
||||
extern "C" std::unique_ptr<CustomSource> openmc_create_source(std::string parameter) {
|
||||
double energy = std::stod(parameter);
|
||||
return std::make_unique<Source>(energy);
|
||||
return std::make_unique<CustomSource>(energy);
|
||||
}
|
||||
|
||||
As with the basic custom source functionality, the custom source library
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue