Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_isotope.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include <PoPI.hpp>
11
12namespace PoPI {
13
14#define PoPI_A_Chars "A"
15
16/*! \class Isotope
17 * This class represents **PoPs** isotope instance.
18 */
19
20/* *********************************************************************************************************//**
21 * Constructor that parses an **HAPI** instance to create a **PoPs** isotope node.
22 *
23 * @param a_node [in] The **HAPI::Node** to be parsed.
24 * @param a_DB [in] The **PoPI::Database:: instance to add the constructed **Isotope** to.
25 * @param a_chemicalElement [in] The parent chemical element suite that will contain *this*.
26 ***********************************************************************************************************/
27
28Isotope::Isotope( HAPI::Node const &a_node, Database *a_DB, ChemicalElement *a_chemicalElement ) :
30 m_chemicalElement( a_chemicalElement ),
31 m_Z( a_chemicalElement->Z( ) ),
32 m_A( a_node.attribute( PoPI_A_Chars ).as_int( ) ),
33 m_nuclides( PoPI_nuclidesChars ) {
34
35 m_nuclides.appendFromParentNode( a_node.child( PoPI_nuclidesChars ), a_DB, this );
36}
37
38/* *********************************************************************************************************//**
39 ***********************************************************************************************************/
40
44
45/* *********************************************************************************************************//**
46 ***********************************************************************************************************/
47
48void Isotope::calculateNuclideGammaBranchStateInfos( PoPI::Database const &a_pops, NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos ) const {
49
50 NuclideGammaBranchStateInfo *info = nullptr, *priorInfo = nullptr;
51 std::string energyUnit = "MeV"; // FIXME, MeV needs to be a variable.
52 double width = 0.0;
53
54 for( std::size_t i1 = 0; i1 < m_nuclides.size( ); ++i1 ) {
55 std::size_t initialSize = a_nuclideGammaBranchStateInfos.size( );
56 Nuclide const &nuclide = m_nuclides[i1];
57 double levelEnergy = nuclide.levelEnergy( energyUnit );
58
59 nuclide.calculateNuclideGammaBranchStateInfos( a_pops, a_nuclideGammaBranchStateInfos );
60 if( a_nuclideGammaBranchStateInfos.size( ) > initialSize ) {
61 info = a_nuclideGammaBranchStateInfos[initialSize];
62 if( priorInfo != nullptr ) {
63 if( priorInfo->kind( ) == PoPI_continuumChars ) {
64 for( std::size_t i2 = i1 + 1; i2 < m_nuclides.size( ); ++i2 ) {
65 Nuclide const &nuclide2 = m_nuclides[i2];
66 if( nuclide2.levelEnergy( energyUnit ) > levelEnergy ) {
67 width = nuclide2.levelEnergy( energyUnit ) - levelEnergy;
68 break;
69 }
70 }
71 priorInfo->setNuclearLevelEnergyWidth( width );
72 }
73 }
74 }
75
76 priorInfo = info;
77 }
78}
79
80/* *********************************************************************************************************//**
81 * Adds the contents of *this* to *a_XMLList* where each item in *a_XMLList* is one line (without linefeeds) to output as an XML representation of *this*.
82 *
83 * @param a_XMLList [in] The list to add an XML output representation of *this* to.
84 * @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
85 ***********************************************************************************************************/
86
87void Isotope::toXMLList( std::vector<std::string> &a_XMLList, std::string const &a_indent1 ) const {
88
89 std::string::size_type size = m_nuclides.size( );
90 std::string AStr = LUPI::Misc::argumentsToString( "%d", m_A );
91
92 std::string header = a_indent1 + "<isotope symbol=\"" + symbol( ) + "\" A=\"" + AStr + "\">";
93 a_XMLList.push_back( std::move( header ) );
94
95 std::string indent2 = a_indent1 + " ";
96 std::string nuclideSuite = indent2 + "<" + PoPI_nuclidesChars + ">";
97 a_XMLList.push_back( std::move( nuclideSuite ) );
98
99 std::string indent3 = indent2 + " ";
100 for( std::string::size_type i1 = 0; i1 < size; ++i1 ) m_nuclides[i1].toXMLList( a_XMLList, indent3 );
101
102 appendXMLEnd( a_XMLList, PoPI_nuclidesChars );
103 appendXMLEnd( a_XMLList, PoPI_isotopeChars );
104}
105
106}
#define PoPI_nuclidesChars
Definition PoPI.hpp:48
#define PoPI_continuumChars
Definition PoPI.hpp:99
#define PoPI_isotopeChars
Definition PoPI.hpp:44
#define PoPI_A_Chars
Node child(const char *name) const
Definition HAPI_Node.cc:72
virtual ~Isotope()
void calculateNuclideGammaBranchStateInfos(PoPI::Database const &a_pops, NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos) const
int Z(void) const
Definition PoPI.hpp:1046
Isotope(HAPI::Node const &a_node, Database *a_DB, ChemicalElement *a_parent)
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
std::size_t size() const
Definition PoPI.hpp:622
double levelEnergy(std::string const &a_unit) const
Definition PoPI.hpp:1019
SymbolBase(HAPI::Node const &a_node, Particle_class a_class)
Definition PoPI_base.cc:110
std::string const & symbol() const
Definition PoPI.hpp:712
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305
Definition PoPI.hpp:28
void appendXMLEnd(std::vector< std::string > &a_XMLList, std::string const &a_label)
Definition PoPI_misc.cc:53
Particle_class
Definition PoPI.hpp:58