@@ -73,10 +73,12 @@ void pyne::_load_atomic_mass_map() { |
73 | 73 | H5Dclose(atomic_mass_set); |
74 | 74 | H5Fclose(nuc_data_h5); |
75 | 75 |
|
76 | | - // Ok now that we have the array of stucts, put it in the map |
| 76 | + // Ok now that we have the array of structs, put it in the map |
77 | 77 | for(int n = 0; n < atomic_mass_length; n++) { |
78 | | - atomic_mass_map[atomic_mass_array[n].nuc] = atomic_mass_array[n].mass; |
79 | | - natural_abund_map[atomic_mass_array[n].nuc] = atomic_mass_array[n].abund; |
| 78 | + atomic_mass_map.insert(std::pair<int, double>(atomic_mass_array[n].nuc, \ |
| 79 | + atomic_mass_array[n].mass)); |
| 80 | + natural_abund_map.insert(std::pair<int, double>(atomic_mass_array[n].nuc, \ |
| 81 | + atomic_mass_array[n].abund)); |
80 | 82 | } |
81 | 83 |
|
82 | 84 | delete[] atomic_mass_array; |
@@ -91,8 +93,9 @@ double pyne::atomic_mass(int nuc) { |
91 | 93 | nuc_end = atomic_mass_map.end(); |
92 | 94 |
|
93 | 95 | // First check if we already have the nuc mass in the map |
94 | | - if (nuc_iter != nuc_end) |
| 96 | + if (nuc_iter != nuc_end) { |
95 | 97 | return (*nuc_iter).second; |
| 98 | + } |
96 | 99 |
|
97 | 100 | // Next, fill up the map with values from the |
98 | 101 | // nuc_data.h5, if the map is empty. |
@@ -109,15 +112,19 @@ double pyne::atomic_mass(int nuc) { |
109 | 112 | // state mass...not strictly true, but good guess. |
110 | 113 | if (0 < nucid%10000) { |
111 | 114 | aw = atomic_mass((nucid/10000)*10000); |
112 | | - atomic_mass_map[nuc] = aw; |
| 115 | + if (atomic_mass_map.count(nuc) != 1) { |
| 116 | + atomic_mass_map.insert(std::pair<int, double>(nuc, aw)); |
| 117 | + } |
113 | 118 | return aw; |
114 | 119 | }; |
115 | 120 |
|
116 | 121 | // Finally, if none of these work, |
117 | 122 | // take a best guess based on the |
118 | 123 | // aaa number. |
119 | 124 | aw = (double) ((nucid/10000)%1000); |
120 | | - atomic_mass_map[nuc] = aw; |
| 125 | + if (atomic_mass_map.count(nuc) != 1) { |
| 126 | + atomic_mass_map.insert(std::pair<int, double>(nuc, aw)); |
| 127 | + } |
121 | 128 | return aw; |
122 | 129 | }; |
123 | 130 |
|
@@ -166,7 +173,7 @@ double pyne::natural_abund(int nuc) { |
166 | 173 | // state abundance...not strictly true, but good guess. |
167 | 174 | if (0 < nucid%10000) { |
168 | 175 | na = natural_abund((nucid/10000)*10000); |
169 | | - atomic_mass_map[nuc] = na; |
| 176 | + natural_abund_map[nuc] = na; |
170 | 177 | return na; |
171 | 178 | }; |
172 | 179 |
|
|