GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge branch 'molmassnan' of https://github.com/jdangerx/pyne into jd… · walshjon/pyne@e4f57e5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • data.cpp
    • material.cpp
  • tests
    • test_data.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/data.cpp‎

Copy file name to clipboardExpand all lines: src/data.cpp
+14-7Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ void pyne::_load_atomic_mass_map() {
7373
H5Dclose(atomic_mass_set);
7474
H5Fclose(nuc_data_h5);
7575

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
7777
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));
8082
}
8183

8284
delete[] atomic_mass_array;
@@ -91,8 +93,9 @@ double pyne::atomic_mass(int nuc) {
9193
nuc_end = atomic_mass_map.end();
9294

9395
// First check if we already have the nuc mass in the map
94-
if (nuc_iter != nuc_end)
96+
if (nuc_iter != nuc_end) {
9597
return (*nuc_iter).second;
98+
}
9699

97100
// Next, fill up the map with values from the
98101
// nuc_data.h5, if the map is empty.
@@ -109,15 +112,19 @@ double pyne::atomic_mass(int nuc) {
109112
// state mass...not strictly true, but good guess.
110113
if (0 < nucid%10000) {
111114
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+
}
113118
return aw;
114119
};
115120

116121
// Finally, if none of these work,
117122
// take a best guess based on the
118123
// aaa number.
119124
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+
}
121128
return aw;
122129
};
123130

@@ -166,7 +173,7 @@ double pyne::natural_abund(int nuc) {
166173
// state abundance...not strictly true, but good guess.
167174
if (0 < nucid%10000) {
168175
na = natural_abund((nucid/10000)*10000);
169-
atomic_mass_map[nuc] = na;
176+
natural_abund_map[nuc] = na;
170177
return na;
171178
};
172179

Collapse file

‎src/material.cpp‎

Copy file name to clipboardExpand all lines: src/material.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ pyne::Material pyne::Material::expand_elements() {
11511151
nabund = (*abund_itr).first;
11521152
if (zabund == znuc && 0 != nucname::anum(nabund) && 0.0 != (*abund_itr).second)
11531153
newcomp[nabund] = (*abund_itr).second * (*nuc).second * \
1154-
atomic_mass_map[nabund] / atomic_mass_map[n];
1154+
atomic_mass(nabund) / atomic_mass(n);
11551155
else if (n == nabund && 0.0 == (*abund_itr).second)
11561156
newcomp.insert(*nuc);
11571157
abund_itr++;
Collapse file

‎tests/test_data.py‎

Copy file name to clipboardExpand all lines: tests/test_data.py
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import warnings
55

66
import nose
7-
from nose.tools import assert_equal, assert_not_equal, assert_raises, raises, \
8-
assert_in, assert_true
7+
from nose.tools import assert_equal, assert_in, assert_true
98
import numpy as np
109
import numpy.testing as npt
1110

@@ -37,6 +36,17 @@ def test_atomic_mass():
3736
assert_in(data.atomic_mass(952421), am242m)
3837

3938

39+
def test_natural_abund_excited_state():
40+
# initialize natural_abund_map
41+
gnd = 902320000
42+
excited = gnd + 1
43+
data.natural_abund(gnd)
44+
# excited state should not be in the map yet
45+
assert_equal(data.natural_abund_map.get(excited), None)
46+
nabund = data.natural_abund(excited)
47+
assert_equal(nabund, data.natural_abund_map.get(excited))
48+
49+
4050
def test_q_val():
4151
assert_equal(data.q_val(110240001), 0.473)
4252
assert_equal(data.q_val('H1'), 0.0)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.