Commit 36591d00 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Added zaid_symbol function.

parent e2447af3
Pipeline #154914 passed with stages
in 17 minutes and 59 seconds
......@@ -14,6 +14,7 @@ SET(SOURCE
hcdump.cc
hysplitcdump.cc
spectrum.cc
zaid.hh
)
SET(HEADERS
......@@ -33,6 +34,7 @@ SET(HEADERS
spectrum.hh
spectrumpcfstream.i.hh
spectrumspestream.i.hh
zaid.cc
)
#
......
......@@ -8,6 +8,7 @@ ADD_GOOGLE_TEST(tstDecayDb.cc NP 1)
ADD_GOOGLE_TEST(tstHysplitCDump.cc NP 1)
ADD_GOOGLE_TEST(tstSpectrum.cc NP 1)
ADD_GOOGLE_TEST(tstArlDataStream.cc NP 1)
ADD_GOOGLE_TEST(tstZaid.cc NP 1)
SET(TEST_MET_FILE "RP195111.gbl")
......
This diff is collapsed.
#include "radixio/zaid.hh"
#include <sstream>
#include <string>
#include <vector>
std::string radix::zaid_symbol(int zzzaaai)
{
int isomeric_state;
int atomic_number;
int mass_number;
static const int ZZZAAAI_Z_OFFSET = 10000;
static const int ZZZAAAI_A_OFFSET = 10;
if (zzzaaai < 0 || zzzaaai > 1e7)
{
isomeric_state = 0;
atomic_number = 0;
mass_number = 0;
}
isomeric_state = zzzaaai % ZZZAAAI_A_OFFSET;
atomic_number = zzzaaai / ZZZAAAI_Z_OFFSET;
mass_number = (zzzaaai - atomic_number * ZZZAAAI_Z_OFFSET) / ZZZAAAI_A_OFFSET;
static const std::vector<std::string> elements = {
"h", "he", "li", "be", "b", "c", "n", "o", "f", "ne", "na", "mg",
"al", "si", "p", "s", "cl", "ar", "k", "ca", "sc", "ti", "v", "cr",
"mn", "fe", "co", "ni", "cu", "zn", "ga", "ge", "as", "se", "br", "kr",
"rb", "sr", "y", "zr", "nb", "mo", "tc", "ru", "rh", "pd", "ag", "cd",
"in", "sn", "sb", "te", "i", "xe", "cs", "ba", "la", "ce", "pr", "nd",
"pm", "sm", "eu", "gd", "tb", "dy", "ho", "er", "tm", "yb", "lu", "hf",
"ta", "w", "re", "os", "ir", "pt", "au", "hg", "tl", "pb", "bi", "po",
"at", "rn", "fr", "ra", "ac", "th", "pa", "u", "np", "pu", "am", "cm",
"bk", "cf", "es", "fm", "md", "no", "lr", "rf", "db", "sg", "bh", "hs",
"mt", "ds", "rg", "cn", "uut", "fl", "uup", "lv", "uus", "uuo"};
if (0 == atomic_number || size_t(atomic_number) > elements.size() - 1)
{
return std::string();
}
std::ostringstream os;
os << elements[size_t(atomic_number - 1)];
if (mass_number > 0)
{
os << mass_number;
if (isomeric_state == 1)
{
os << "m";
}
else if (isomeric_state > 1)
{
os << "m" << isomeric_state;
}
}
return os.str();
}
#ifndef RADIX_RADIXIO_ZAID_HH_
#define RADIX_RADIXIO_ZAID_HH_
#include <string>
#include "radixcore/visibility.hh"
namespace radix
{
/**
* @brief zaid_symbol Converts nuclide encoding to string symbol
* @param zzzaaai
* @return const char *
*/
RADIX_PUBLIC std::string zaid_symbol(int zzzaaai);
} // end namespace radix
#endif /* RADIX_RADIXIO_ZAID_HH_*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment