16#define PoPI_Z_Chars "Z"
18static std::string emptyString(
"" );
19static std::map<int, std::string> ZtoChemicalElementSymbols{
20 {1,
"H"}, {2,
"He"}, {3,
"Li"}, {4,
"Be"}, {5,
"B"}, {6,
"C"}, {7,
"N"}, {8,
"O"}, {9,
"F"}, {10,
"Ne"},
21 {11,
"Na"}, {12,
"Mg"}, {13,
"Al"}, {14,
"Si"}, {15,
"P"}, {16,
"S"}, {17,
"Cl"}, {18,
"Ar"}, {19,
"K"}, {20,
"Ca"},
22 {21,
"Sc"}, {22,
"Ti"}, {23,
"V"}, {24,
"Cr"}, {25,
"Mn"}, {26,
"Fe"}, {27,
"Co"}, {28,
"Ni"}, {29,
"Cu"}, {30,
"Zn"},
23 {31,
"Ga"}, {32,
"Ge"}, {33,
"As"}, {34,
"Se"}, {35,
"Br"}, {36,
"Kr"}, {37,
"Rb"}, {38,
"Sr"}, {39,
"Y"}, {40,
"Zr"},
24 {41,
"Nb"}, {42,
"Mo"}, {43,
"Tc"}, {44,
"Ru"}, {45,
"Rh"}, {46,
"Pd"}, {47,
"Ag"}, {48,
"Cd"}, {49,
"In"}, {50,
"Sn"},
25 {51,
"Sb"}, {52,
"Te"}, {53,
"I"}, {54,
"Xe"}, {55,
"Cs"}, {56,
"Ba"}, {57,
"La"}, {58,
"Ce"}, {59,
"Pr"}, {60,
"Nd"},
26 {61,
"Pm"}, {62,
"Sm"}, {63,
"Eu"}, {64,
"Gd"}, {65,
"Tb"}, {66,
"Dy"}, {67,
"Ho"}, {68,
"Er"}, {69,
"Tm"}, {70,
"Yb"},
27 {71,
"Lu"}, {72,
"Hf"}, {73,
"Ta"}, {74,
"W"}, {75,
"Re"}, {76,
"Os"}, {77,
"Ir"}, {78,
"Pt"}, {79,
"Au"}, {80,
"Hg"},
28 {81,
"Tl"}, {82,
"Pb"}, {83,
"Bi"}, {84,
"Po"}, {85,
"At"}, {86,
"Rn"}, {87,
"Fr"}, {88,
"Ra"}, {89,
"Ac"}, {90,
"Th"},
29 {91,
"Pa"}, {92,
"U"}, {93,
"Np"}, {94,
"Pu"}, {95,
"Am"}, {96,
"Cm"}, {97,
"Bk"}, {98,
"Cf"}, {99,
"Es"}, {100,
"Fm"},
30 {101,
"Md"}, {102,
"No"}, {103,
"Lr"}, {104,
"Rf"}, {105,
"Db"}, {106,
"Sg"}, {107,
"Bh"}, {108,
"Hs"}, {109,
"Mt"}, {110,
"Ds"},
31 {111,
"Rg"}, {112,
"Cn"}, {113,
"Nh"}, {114,
"Fl"}, {115,
"Mc"}, {116,
"Lv"}, {117,
"Ts"}, {118,
"Og"} };
33static std::map<std::string, int> chemicalElementSymbolToZs;
35static std::string protonFakeAlias(
"h1" );
71 for( std::size_t i1 = 0; i1 < m_isotopes.size( ); ++i1 ) {
74 isotope.calculateNuclideGammaBranchStateInfos( a_pops, a_nuclideGammaBranchStateInfos );
87 std::string::size_type size = m_isotopes.size( );
90 if( size == 0 )
return;
92 std::string header = a_indent1 +
"<chemicalElement symbol=\"" +
symbol( ) +
"\" Z=\"" + ZStr +
"\" name=\"" + m_name +
"\">";
93 a_XMLList.push_back( std::move( header ) );
95 std::string indent2 = a_indent1 +
" ";
97 a_XMLList.push_back( std::move( isotopeSuite ) );
99 std::string indent3 = indent2 +
" ";
100 for( std::string::size_type i1 = 0; i1 < size; ++i1 ) m_isotopes[i1].
toXMLList( a_XMLList, indent3 );
114 return(
static_cast<int>( ZtoChemicalElementSymbols.size( ) ) );
545 info =
"Praseodymium";
769 info =
"Protactinium";
818 info =
"Californium";
825 info =
"Einsteinium";
839 info =
"Mendelevium";
860 info =
"Rutherfordium";
902 info =
"Darmstadtium";
909 info =
"Roentgenium";
916 info =
"Copernicium";
944 info =
"Livermorium";
965 if( a_wantSymbol && a_asNucleus ) {
967 c1[0] =
static_cast<char>( tolower( info.c_str( )[0] ) );
970 if( info.size( ) > 1 ) c1[1] = info.c_str( )[1];
988 if( ZtoChemicalElementSymbols.find( a_Z ) == ZtoChemicalElementSymbols.end( ) )
return( emptyString );
990 return( ZtoChemicalElementSymbols[a_Z ] );
1003 if( chemicalElementSymbolToZs.size( ) == 0 ) {
1004 for(
auto iter = ZtoChemicalElementSymbols.begin( ); iter != ZtoChemicalElementSymbols.end( ); ++iter ) {
1005 chemicalElementSymbolToZs[iter->second] = iter->first;
1009 if( chemicalElementSymbolToZs.find( a_symbol ) == chemicalElementSymbolToZs.end( ) )
return( 0 );
1011 return( chemicalElementSymbolToZs[a_symbol] );
1025 m_isSupported( false ),
1027 m_isNuclear( false ),
1028 m_isNucleus( false ),
1029 m_isChemicalElement( false ),
1031 m_isMetaStable( false ),
1046 baseId = protonFakeAlias;
1049 if( baseId ==
"n" ) {
1051 m_isSupported =
true;
1055 std::vector<std::string> parts;
1056 if( baseId.find(
"_m" ) != std::string::npos ) {
1057 m_isMetaStable =
true;
1065 std::string
isotope = parts[0];
1066 std::size_t digitIndex =
isotope.find_first_of(
"01233456789" );
1069 std::string symbolCap;
1070 if(
symbol.size( ) > 0 ) {
1072 firstChar[0] =
static_cast<char>( std::toupper(
symbol[0] ) );
1074 std::string firstStringChar( firstChar );
1075 symbolCap = firstStringChar +
symbol.substr( 1 );
1078 if( digitIndex != std::string::npos ) {
1079 std::string AStr(
isotope.substr( digitIndex ) );
1080 if(
symbol.size( ) > 0 ) {
1087 bool isValidNuclearId = parts.size( ) == 1;
1089 if( parts.size( ) > 1 ) {
1093 if( isValidNuclearId ) {
1094 m_symbol = symbolCap;
1096 m_isNucleus = symbolCap !=
symbol;
1100 m_isSupported =
true;
1103 else if(
symbol.size( ) > 0 ) {
1106 m_symbol = std::move( symbolCap );
1107 m_isChemicalElement =
true;
1108 m_isSupported =
true;
1123 std::cout << a_indent << m_id
1124 << boolToString( m_isSupported,
" " ).c_str( )
1125 << boolToString( m_isNuclear,
" " ).c_str( )
1126 << boolToString( m_isNucleus,
" " ).c_str( )
1127 << boolToString( m_isChemicalElement,
" " ).c_str( )
1128 << boolToString( m_isAnti,
" " ).c_str( )
1129 << boolToString( m_isMetaStable,
" " ).c_str( )
1137 std::cout << a_indent <<
"id = " << m_id << std::endl;
1141 std::cout << a_indent <<
LUPI::Misc::argumentsToString(
" isChemicalElement = %s", boolToString( m_isChemicalElement,
"" ).c_str( ) ) << std::endl;
1161std::string ParseIdInfo::boolToString(
bool a_value, std::string
const &a_prefix )
const {
1163 std::string boolString( a_prefix );
1166 boolString +=
"true"; }
1168 boolString +=
"false";
1171 return( boolString );
#define PoPI_isotopesChars
#define PoPI_chemicalElementChars
Node child(const char *name) const
void calculateNuclideGammaBranchStateInfos(PoPI::Database const &a_pops, NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos) const
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
ChemicalElement(HAPI::Node const &a_node, Database *a_DB, Database *a_parent)
virtual ~ChemicalElement()
void print(bool a_terse, std::string const &a_indent="") const
std::string const & symbol()
ParseIdInfo(std::string const &a_id)
std::string const & symbol() const
std::vector< std::string > splitString(std::string const &a_string, char a_delimiter, bool a_strip=false)
std::string argumentsToString(char const *a_format,...)
bool stringToInt(std::string const &a_string, int &a_value)
int maximumChemicalElementZ()
std::map< std::string, std::string > supportedNucleusAliases
std::string const & chemicalElementSymbolFromZ(int a_Z)
std::string chemicalElementInfoFromZ(int a_Z, bool a_wantSymbol, bool a_asNucleus=false)
void appendXMLEnd(std::vector< std::string > &a_XMLList, std::string const &a_label)
std::string baseAntiQualifierFromID(std::string const &a_id, std::string &a_anti, std::string *a_qualifier=nullptr)
int Z_FromChemicalElementSymbol(std::string const &a_symbol)
static std::string const anti
static std::string const proton