GeezerVison is showing github.com — updated to fix material.mcnp issue · walshjon/pyne@9bf0d3b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/material.cpp +21-19Lines changed: 21 additions & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -550,26 +550,28 @@ std::string pyne::Material::mcnp(std::string frac_type) { |
550 | 550 | std::string nucmcnp; |
551 | 551 | std::string table_item; |
552 | 552 | for(pyne::comp_iter i = fracs.begin(); i != fracs.end(); ++i) { |
553 | | - // Clear first |
554 | | - ss.str(std::string() ); |
555 | | - ss.str(""); |
556 | | - ss << pyne::nucname::mcnp(i->first ); |
557 | | - nucmcnp = ss.str(); |
558 | | - |
559 | | - int mcnp_id; |
560 | | - mcnp_id = pyne::nucname::mcnp(i->first ); |
561 | | - // Spaces are important for tests |
562 | | - table_item = metadata["table_ids"][nucmcnp].asString(); |
563 | | - if ( !table_item.empty() ) { |
564 | | - oss << " " << mcnp_id << "." << table_item << " "; |
565 | | - } else { |
566 | | - oss << " " << mcnp_id << " "; |
| 553 | + if ( i->second > 0.0 ) { |
| 554 | + // Clear first |
| 555 | + ss.str(std::string() ); |
| 556 | + ss.str(""); |
| 557 | + ss << pyne::nucname::mcnp(i->first ); |
| 558 | + nucmcnp = ss.str(); |
| 559 | + |
| 560 | + int mcnp_id; |
| 561 | + mcnp_id = pyne::nucname::mcnp(i->first ); |
| 562 | + // Spaces are important for tests |
| 563 | + table_item = metadata["table_ids"][nucmcnp].asString(); |
| 564 | + if ( !table_item.empty() ) { |
| 565 | + oss << " " << mcnp_id << "." << table_item << " "; |
| 566 | + } else { |
| 567 | + oss << " " << mcnp_id << " "; |
| 568 | + } |
| 569 | + // The int needs a little formatting |
| 570 | + std::stringstream fs; |
| 571 | + fs << std::setprecision(4) << std::scientific << frac_sign << i->second \ |
| 572 | + << std::endl; |
| 573 | + oss << fs.str(); |
567 | 574 | } |
568 | | - // The int needs a little formatting |
569 | | - std::stringstream fs; |
570 | | - fs << std::setprecision(4) << std::scientific << frac_sign << i->second \ |
571 | | - << std::endl; |
572 | | - oss << fs.str(); |
573 | 575 | } |
574 | 576 |
|
575 | 577 | return oss.str(); |
|
Collapse file
Copy file name to clipboardExpand all lines: tests/test_material.py +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1085,6 +1085,29 @@ def test_mcnp(): |
1085 | 1085 | ' 92238.25c 9.5951e-01\n') |
1086 | 1086 | assert_equal(atom, atom_exp) |
1087 | 1087 |
|
| 1088 | +def test_mcnp_mat0(): |
| 1089 | + |
| 1090 | + leu = Material(nucvec={'U235': 0.04, 'U236': 0.0, 'U238': 0.96}, |
| 1091 | + metadata={'mat_number': 2, |
| 1092 | + 'table_ids': {'92235':'15c', '92236':'15c', '92238':'25c'}, |
| 1093 | + 'mat_name':'LEU', |
| 1094 | + 'source':'Some URL', |
| 1095 | + 'comments': ('this is a long comment that will definitly ' |
| 1096 | + 'go over the 80 character limit, for science'), |
| 1097 | + 'name':'leu'}, |
| 1098 | + density=19.1) |
| 1099 | + |
| 1100 | + mass = leu.mcnp() |
| 1101 | + mass_exp = ('C name: leu\n' |
| 1102 | + 'C density = 19.1\n' |
| 1103 | + 'C source: Some URL\n' |
| 1104 | + 'C comments: this is a long comment that will definitly go over the 80 character\n' |
| 1105 | + 'C limit, for science\n' |
| 1106 | + 'm2\n' |
| 1107 | + ' 92235.15c -4.0000e-02\n' |
| 1108 | + ' 92238.25c -9.6000e-01\n') |
| 1109 | + assert_equal(mass, mass_exp) |
| 1110 | + |
1088 | 1111 |
|
1089 | 1112 | def test_alara(): |
1090 | 1113 |
|
|