Dear all,
I recently encountered a problem when using a custom source. I want to define a spherical shell source with a radius of 400-730cm. The code is as follows:
However, when I run it, it prompts an error:
The model file I run is as follows, the location of the source is included in the geometry(the green area), the upper and lower surfaces are reflective surfaces:
geometry.xml (5.1 KB)
materials.xml (23.2 KB)
settings.xml (233 Bytes)
How should I resolve this error?
Thanks in advance for your help!
In addition, in order to find out the problem, I ran two groups of simulations. The first group used the point source (600,0,0).
The second group defined the same location in source.cpp.
However, the first group could run successfully, while the second group reported the same error.
In C++, the body of a class
is private by default. You need to explicitly have public:
before defining the sample method, i.e.:
class PlasmaSource : public openmc::Source {
public:
openmc::Particle::Bank sample(uint64_t* seed) const {
...
}
};
Also, just a forewarning – in the latest version of OpenMC (0.12.2), the interface for custom sources changed slightly. If you upgrade to 0.12.2, you’ll need to change openmc::Particle::Bank
to openmc::SourceSite
.
Hello paul,
I just tried your method, but after adding public:
, it’s still the same error.
Ah yes, on second thought public:
is actually not needed. Upon looking at your XML files, I see there is simply a typo in settings.xml:
<source libraray="./libsource.so" strength="1.0" />
In this line “libraray” should be “library”. Once you fix that, hopefully it should work (provided you have a compiled source libsource.so in that directory).
Thank you very much, paul. My carelessness caused a spelling error and caused a series of problems. Now the problem has been solved.