|
6 | 6 | #ifndef PYNE_IS_AMALGAMATED |
7 | 7 | #include "nucname.h" |
8 | 8 | #include "state_map.cpp" |
| 9 | +#include <cctype> |
| 10 | +#include <algorithm> |
9 | 11 | #endif |
10 | 12 |
|
| 13 | +/***String used to check for metastable states***/ |
| 14 | +std::string pyne::nucname::metastable_states = "mnopqrstuvxyz"; |
| 15 | +//Capitalize all letters in the metastable states string |
| 16 | +std::string upper_metastable = metastable_states; |
| 17 | +std::transform(upper_metastable.begin(), upper_metastable.end(), upper_metastable.begin(), |
| 18 | + [](char c){ return std::toupper(c); }); |
11 | 19 |
|
12 | 20 | /*** Constructs the LL to zz Dictionary ***/ |
13 | 21 | pyne::nucname::name_zz_t pyne::nucname::get_name_zz() { |
@@ -586,8 +594,7 @@ int pyne::nucname::id(std::string nuc) { |
586 | 594 |
|
587 | 595 | // Figure out if we are meta-stable or not |
588 | 596 | std::string end_char = pyne::last_char(nucstr); |
589 | | - std::string metastable_states = "MNOPQRSTUVWXYZ"; |
590 | | - size_t pos = metastable_states.find(end_char); |
| 597 | + size_t pos = upper_metastable.find(end_char); |
591 | 598 |
|
592 | 599 | if (pos != std::string::npos) { |
593 | 600 | newnuc = (10000 * anum) + static_cast<int>(pos) + 1; |
@@ -675,9 +682,8 @@ std::string pyne::nucname::name(int nuc) { |
675 | 682 | newnuc += pyne::to_str(aaa); |
676 | 683 |
|
677 | 684 | // Add meta-stable flag |
678 | | - std::string metastable_states = "MNOPQRSTUVWXYZ"; |
679 | 685 | if (0 < ssss) |
680 | | - newnuc += metastable_states[ssss - 1]; |
| 686 | + newnuc += upper_metastable[ssss - 1]; |
681 | 687 |
|
682 | 688 | return newnuc; |
683 | 689 | } |
@@ -840,9 +846,8 @@ std::string pyne::nucname::zzllaaam(int nuc) { |
840 | 846 | if (0 < aaassss) |
841 | 847 | newnuc += pyne::to_str(aaa); |
842 | 848 | // Add meta-stable flag |
843 | | - std::string metastable_states = "mnopqrstuvwxyz"; |
844 | 849 | if (0 < ssss) |
845 | | - newnuc += metastable_states[ssss - 1]; |
| 850 | + newnuc += pyne::nucname::metastable_states[ssss - 1]; |
846 | 851 | return newnuc; |
847 | 852 | } |
848 | 853 |
|
@@ -893,8 +898,7 @@ int pyne::nucname::zzllaaam_to_id(std::string nuc) { |
893 | 898 |
|
894 | 899 | // Figure out if we are meta-stable or not |
895 | 900 | std::string end_char = pyne::last_char(nucstr); |
896 | | - std::string metastable_states = "MNOPQRSTUVWXYZ"; |
897 | | - size_t pos = metastable_states.find(end_char); |
| 901 | + size_t pos = upper_metastable.find(end_char); |
898 | 902 | if (pos != std::string::npos) { |
899 | 903 | nucid = (10000 * anum) + static_cast<int>(pos) + 1; |
900 | 904 | } |
@@ -1119,9 +1123,8 @@ std::string pyne::nucname::serpent(int nuc) { |
1119 | 1123 | newnuc += "nat"; |
1120 | 1124 |
|
1121 | 1125 | // Add meta-stable flag |
1122 | | - std::string metastable_states = "mnopqrstuvwxyz"; |
1123 | 1126 | if (0 < ssss) |
1124 | | - char meta_char = metastable_states[ssss - 1]; |
| 1127 | + char meta_char = pyne::nucname::metastable_states[ssss - 1]; |
1125 | 1128 | newnuc += meta_char; |
1126 | 1129 | return newnuc; |
1127 | 1130 | } |
@@ -1175,8 +1178,7 @@ int pyne::nucname::serpent_to_id(std::string nuc) { |
1175 | 1178 |
|
1176 | 1179 | // Figure out if we are meta-stable or not |
1177 | 1180 | std::string end_char = pyne::last_char(nucstr); |
1178 | | - std::string metastable_states = "MNOPQRSTUVWXYZ"; |
1179 | | - size_t pos = metastable_states.find(end_char); |
| 1181 | + size_t pos = upper_metastable.find(end_char); |
1180 | 1182 | if (pos != std::string::npos) |
1181 | 1183 | nucid = (10000 * anum) + static_cast<int>(pos) + 1; |
1182 | 1184 | else if (pyne::contains_substring(pyne::digits, end_char)) |
|
0 commit comments