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 — updated to fix material.mcnp issue · walshjon/pyne@9bf0d3b

File tree

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

‎src/material.cpp‎

Copy file name to clipboardExpand all lines: src/material.cpp
+21-19Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -550,26 +550,28 @@ std::string pyne::Material::mcnp(std::string frac_type) {
550550
std::string nucmcnp;
551551
std::string table_item;
552552
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();
567574
}
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();
573575
}
574576

575577
return oss.str();
Collapse file

‎tests/test_material.py‎

Copy file name to clipboardExpand all lines: tests/test_material.py
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,29 @@ def test_mcnp():
10851085
' 92238.25c 9.5951e-01\n')
10861086
assert_equal(atom, atom_exp)
10871087

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+
10881111

10891112
def test_alara():
10901113

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.