From e715e5bd0589a5da0faaf3a752a184e8fe1e664a Mon Sep 17 00:00:00 2001 From: Martin Martinov Date: Fri, 12 Mar 2021 12:07:37 -0500 Subject: [PATCH] Modified the store/add/set/reset state functions Included proper sCount and baseSource() state setting, storing, and resetting. Modified addState so that sCount and count are added to, rather than set to the read in values. --- .../egs_radionuclide_source.cpp | 21 +++-- .../egs_radionuclide_source.h | 78 +++++++++++-------- 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.cpp b/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.cpp index 186b30309..1bc869ace 100755 --- a/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.cpp +++ b/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.cpp @@ -23,7 +23,7 @@ # # Author: Reid Townson, 2016 # -# Contributors: Martin Martinov, 2021 +# Contributors: # ############################################################################### */ @@ -41,16 +41,16 @@ EGS_RadionuclideSource::EGS_RadionuclideSource(EGS_Input *input, EGS_ObjectFactory *f) : EGS_BaseSource(input,f), - baseSource(0), q_allowed(0), decays(0), activity(1), sCount (0) { + baseSource(0), q_allowed(0), decays(0), activity(1) { int err; vector tmp_q; err = input->getInput("charge", tmp_q); if (!err) { if (std::find(q_allowed.begin(), q_allowed.end(), -1) != q_allowed.end() - && std::find(q_allowed.begin(), q_allowed.end(), 0) != q_allowed.end() - && std::find(q_allowed.begin(), q_allowed.end(), 1) != q_allowed.end() - && std::find(q_allowed.begin(), q_allowed.end(), 2) != q_allowed.end() + && std::find(q_allowed.begin(), q_allowed.end(), 0) != q_allowed.end() + && std::find(q_allowed.begin(), q_allowed.end(), 1) != q_allowed.end() + && std::find(q_allowed.begin(), q_allowed.end(), 2) != q_allowed.end() ) { q_allowAll = true; } @@ -69,6 +69,7 @@ EGS_RadionuclideSource::EGS_RadionuclideSource(EGS_Input *input, // Create the decay spectra count = 0; + sCount = 0; Emax = 0; unsigned int i = 0; EGS_Float spectrumWeightTotal = 0; @@ -159,7 +160,7 @@ EGS_RadionuclideSource::EGS_RadionuclideSource(EGS_Input *input, egsWarning("EGS_RadionuclideSource: no source named %s" " is defined\n",sName.c_str()); } - + // Initialize emission type to signify nothing has happened yet emissionType = 99; @@ -218,7 +219,6 @@ EGS_I64 EGS_RadionuclideSource::getNextParticle(EGS_RandomGenerator *rndm, int } q = decays[i]->getCharge(); - int qTemp (q), latchTemp (latch); EGS_Float ETemp (E); baseSource->getNextParticle(rndm, qTemp, latchTemp, ETemp, wt, x, u); @@ -297,6 +297,7 @@ bool EGS_RadionuclideSource::storeState(ostream &data_out) const { } } egsStoreI64(data_out,count); + egsStoreI64(data_out,sCount); baseSource->storeState(data_out); return true; @@ -311,7 +312,9 @@ bool EGS_RadionuclideSource::addState(istream &data) { } EGS_I64 tmp_val; egsGetI64(data,tmp_val); - count = tmp_val; + count += tmp_val; + egsGetI64(data,tmp_val); + sCount += tmp_val; baseSource->addState(data); return true; @@ -324,6 +327,7 @@ void EGS_RadionuclideSource::resetCounter() { ishower = 0; count = 0; sCount = 0; + baseSource->resetCounter(); } bool EGS_RadionuclideSource::setState(istream &data) { @@ -333,6 +337,7 @@ bool EGS_RadionuclideSource::setState(istream &data) { } } egsGetI64(data,count); + egsGetI64(data,sCount); baseSource->setState(data); return true; diff --git a/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.h b/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.h index fb88b4c3b..17d2dfaf2 100755 --- a/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.h +++ b/HEN_HOUSE/egs++/sources/egs_radionuclide_source/egs_radionuclide_source.h @@ -23,7 +23,7 @@ # # Author: Reid Townson, 2016 # -# Contributors: Martin Martinov, 2021 +# Contributors: # ############################################################################### */ @@ -137,19 +137,20 @@ on the number of disintegration events (tracked by \c ishower ). This is distinct from the \c ncase input parameter, which is the number of particles returned by the source (includes relaxations etc.). -A radionuclide source is defined using the following input. It imports a base -source and uses the base source getNextParticle() invocation to determine decay -location. This implementation leads to increased random number sampling than -that strictly required in the simulation, due to the information generated in -the base source beyond particle position that is not used in -egs_radionuclide_source. Thus, its probably best, though not required, that -the base source use a monoenergetic spectrum to avoid oversampling. - +A radionuclide source is defined using the following input. Notice that the +format is similar to \ref EGS_IsotropicSource or \ref EGS_CollimatedSource. +Be careful using a collimated source - it may neglect effects from the physical +source on the spectrum, and neglect potential contributions from surrounding +structures. Restricting the emission angles by collimation generally constitutes +a physical approximation of your geometry and is an approximate efficiency +enhancement technique. It is also important to note that the collimated source +determines the fluence with \f$N/d^2\f$, where \c N is the number of +disintegrations sampled and \c d is the user-defined minimum distance between the +source and target shapes. \verbatim :start source: name = my_mixture library = egs_radionuclide_source - base source = name of the source used to generate decay locations activity = [optional, default=1] total activity of mixture, assumed constant. The activity only affects the emission times assigned to particles. @@ -164,6 +165,26 @@ the base source use a monoenergetic spectrum to avoid oversampling. set to 0 for no time limit. Source particles generated after the experiment time are not transported. + # If source type = isotropic + geometry = [optional] my_geometry # see egs_isotropic_source + region selection = [optional] geometry confinement option + one of IncludeAll, ExcludeAll, + IncludeSelected, ExcludeSelected + selected regions = [required for IncludeSelected, ExcludeSelected] + regions to apply geometry confinement + :start shape: + definition of the isotropic source shape + :stop shape: + + # If source type = collimated (beware of its limitations) + :start source shape: + definition of the source shape + :stop source shape: + :start target shape: + definition of the target shape + :stop target shape: + distance = source-target shape min. distance + :start spectrum: definition of an EGS_RadionuclideSpectrum (see link below) :stop spectrum: @@ -234,8 +255,9 @@ results for non-disintegration emissions. :stop geometry definition: :start source definition: :start source: - name = source_location - library = egs_isotropic_source + name = my_source + library = egs_radionuclide_source + activity = 28e6 geometry = my_envelope region selection = IncludeSelected selected regions = 1 2 @@ -246,17 +268,6 @@ results for non-disintegration emissions. media = H2O521ICRU :stop media input: :stop shape: - :start spectrum: - type = monoenergetic # Input is ignored - energy = 1.0 # Input is ignored - :stop spectrum: - :stop source: - - :start source: - name = my_source - library = egs_radionuclide_source - base source = source_location - activity = 28e6 :start spectrum: type = radionuclide nuclide = Ir-192 @@ -272,30 +283,28 @@ class EGS_RADIONUCLIDE_SOURCE_EXPORT EGS_RadionuclideSource : public EGS_BaseSource { public: - /*! \brief Constructor from input file */ EGS_RadionuclideSource(EGS_Input *, EGS_ObjectFactory *f=0); /*! \brief Destructor */ ~EGS_RadionuclideSource() { - if (baseSource) + if (baseSource) if (!baseSource->deref()) { delete baseSource; } - for (vector::iterator it = - decays.begin(); - it!=decays.end(); it++) { - delete *it; - *it=0; - } - decays.clear(); + for (vector::iterator it = + decays.begin(); it!=decays.end(); it++) { + delete *it; + *it=0; + } + decays.clear(); }; /*! \brief Gets the next particle from the radionuclide spectra */ EGS_I64 getNextParticle(EGS_RandomGenerator *rndm, int &q, int &latch, EGS_Float &E, EGS_Float &wt, - EGS_Vector &x, EGS_Vector &u); + EGS_Vector &x, EGS_Vector &u); /*! \brief Returns the maximum energy out of all the spectra */ EGS_Float getEmax() const { @@ -304,7 +313,8 @@ class EGS_RADIONUCLIDE_SOURCE_EXPORT EGS_RadionuclideSource : /*! \brief Returns the current fluence (number of disintegrations) */ EGS_Float getFluence() const { - return (ishower+1)*(baseSource->getFluence()/sCount); //!< Scale ishower+1 return by fluence ratio returned by file + return (ishower+1)*(baseSource->getFluence()/sCount); + //!< Scale ishower+1 return by fluence ratio returned by file }; /*! \brief Returns the emission time of the most recent particle */