Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_nuclide.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 <stdlib.h>
11#include <stdexcept>
12
13#include "PoPI.hpp"
14
15namespace PoPI {
16
17// FIXME - Must be removed once unit conversion is supported.
18#define AMU2MeV 931.494028
19
20/*! \class Nuclide
21 * This class represents **PoPs** nuclide instance.
22 */
23
24/* *********************************************************************************************************//**
25 * Constructor that parses an **HAPI** instance to create a **PoPs** nuclide node.
26 *
27 * @param a_node [in] The **HAPI::Node** to be parsed.
28 * @param a_DB [in] The **PoPI::Database:: instance to add the constructed **Nuclide** to.
29 * @param a_isotope [in] This isotope instance that will contain *this*.
30 ***********************************************************************************************************/
31
32Nuclide::Nuclide( HAPI::Node const &a_node, Database *a_DB, Isotope *a_isotope ) :
34 m_isotope( a_isotope ),
35 m_nucleus( a_node.child( PoPI_nucleusChars ), a_DB, this ),
36 m_gammaDecayData( a_node.child( PoPI_gammaDecayDataChars ) ) {
37
38 int sign = ( isAnti( ) ? -1 : 1 );
39 setIntid( sign * ( 1000 * ( 1000 * levelIndex( ) + Z( ) ) + A( ) ) );
40
41 addToDatabase( a_DB );
42}
43
44/* *********************************************************************************************************//**
45 ***********************************************************************************************************/
46
50
51/* *********************************************************************************************************//**
52 * Returns of atomic number of the parent isotope.
53 *
54 * @return The atomic number of *this*.
55 ***********************************************************************************************************/
56
57int Nuclide::Z( void ) const {
58
59 return( m_isotope->Z( ) );
60}
61
62/* *********************************************************************************************************//**
63 * Returns of atomic mass number of the parent isotope.
64 *
65 * @return The atomic mass number of *this*.
66 ***********************************************************************************************************/
67
68int Nuclide::A( void ) const {
69
70 return( m_isotope->A( ) );
71}
72
73/* *********************************************************************************************************//**
74 * Returns of atomic symbol of the parent isotope.
75 *
76 * @return The atomic symbol of *this*.
77 ***********************************************************************************************************/
78
79std::string const &Nuclide::atomsID( void ) const {
80
81 return( m_isotope->symbol( ) );
82}
83
84/* *********************************************************************************************************//**
85 * Returns the mass suite for the first nuclide in the isotope containing *this*.
86 *
87 * @return A const reference to a PQ_suite.
88 ***********************************************************************************************************/
89
90PQ_suite const &Nuclide::baseMass( void ) const {
91
92 return( (*m_isotope).nuclides( )[0].mass( ) );
93}
94
95/* *********************************************************************************************************//**
96 * Returns the mass of the nuclide in units of *a_unit* including the nucleus excitation energy.
97 * Currently not fully implement and does not support *a_unit*.
98 *
99 * @param a_unit [in] The unit to return the mass in.
100 *
101 * @return The mass in unit of *a_unit*.
102 ***********************************************************************************************************/
103
104double Nuclide::massValue( char const *a_unit ) const {
105
106 std::string unit_c2( a_unit );
107 unit_c2 += " * c**2";
108 PQ_double const *pq_mass;
109
110 if( mass( ).size( ) > 0 ) {
111 pq_mass = static_cast<PQ_double const *>( mass( )[0] ); }
112 else {
113 if( baseMass( ).size( ) == 0 ) throw Exception( "nuclide::massValue: no mass in level 0 for particle '" + ID( ) + "'." );
114 pq_mass = static_cast<PQ_double const *>( baseMass( )[0] );
115 }
116 double _mass = pq_mass->value( a_unit );
117
118 double v_levelEnergy = levelEnergy( unit_c2 ) / AMU2MeV;
119
120 return( _mass + v_levelEnergy );
121}
122
123/* *********************************************************************************************************//**
124 ***********************************************************************************************************/
125
127 bool a_alwaysAdd ) const {
128
129 if( a_nuclideGammaBranchStateInfos.find( ID( ) ) != nullptr )
130 return;
131
132 NuclideGammaBranchStateInfo *nuclideGammaBranchStateInfo = new NuclideGammaBranchStateInfo( ID( ), intid( ), kind( ), m_nucleus.energy( "MeV" ) );
133
134 if( m_gammaDecayData.rows( ) > 0 ) {
135 m_gammaDecayData.calculateNuclideGammaBranchStateInfo( a_pops, *nuclideGammaBranchStateInfo ); }
136 else {
137 decayData( ).calculateNuclideGammaBranchStateInfo( a_pops, *nuclideGammaBranchStateInfo );
138 }
139
140 if( ( nuclideGammaBranchStateInfo->branches( ).size( ) > 0 ) || a_alwaysAdd ) {
141 a_nuclideGammaBranchStateInfos.add( nuclideGammaBranchStateInfo ); }
142 else {
143 delete nuclideGammaBranchStateInfo;
144 }
145}
146
147/* *********************************************************************************************************//**
148 * Added *m_nucleus* stuff to *a_XMLList*.
149 ***********************************************************************************************************/
150
151void Nuclide::toXMLListExtraElements( std::vector<std::string> &a_XMLList, std::string const &a_indent1 ) const {
152
153 m_nucleus.toXMLList( a_XMLList, a_indent1 );
154}
155
156}
#define PoPI_nucleusChars
Definition PoPI.hpp:50
#define PoPI_nuclideChars
Definition PoPI.hpp:49
#define PoPI_gammaDecayDataChars
Definition PoPI.hpp:85
#define AMU2MeV
friend Nuclide
Definition PoPI.hpp:679
int intid() const
Definition PoPI.hpp:655
std::string const & ID(void) const
Definition PoPI.hpp:652
void calculateNuclideGammaBranchStateInfo(PoPI::Database const &a_pops, NuclideGammaBranchStateInfo &a_nuclideGammaBranchStateInfo) const
std::size_t addToDatabase(Database *a_DB)
Definition PoPI_base.cc:95
std::vector< NuclideGammaBranchInfo > const & branches() const
Definition PoPI.hpp:600
NuclideGammaBranchStateInfo * find(std::string const &a_state)
void add(NuclideGammaBranchStateInfo *a_nuclideGammaBranchStateInfo)
virtual ~Nuclide()
void calculateNuclideGammaBranchStateInfos(PoPI::Database const &a_pops, NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos, bool a_alwaysAdd=false) const
int levelIndex(void) const
Definition PoPI.hpp:1009
PQ_suite const & baseMass(void) const
virtual void toXMLListExtraElements(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
double levelEnergy(std::string const &a_unit) const
Definition PoPI.hpp:1019
std::string const & kind() const
Definition PoPI.hpp:1011
std::string const & atomsID() const
int A(void) const
int Z(void) const
double massValue(char const *a_unit) const
double value(void) const
Definition PoPI.hpp:443
Particle(HAPI::Node const &a_node, Particle_class a_class, std::string const &a_family, int a_hasNucleus=0)
virtual PQ_suite const & mass(void) const
Definition PoPI.hpp:878
bool isAnti() const
Definition PoPI.hpp:875
DecayData const & decayData() const
Definition PoPI.hpp:887
Definition PoPI.hpp:28
Particle_class
Definition PoPI.hpp:58