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 fluka compound printing to emulated fluka scientific fixed wi… · walshjon/pyne@e7e2ad1

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
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,17 @@ std::string pyne::Material::fluka_compound_str(int id, std::string frac_type) {
757757
}
758758

759759
std::stringstream temp_s;
760+
temp_s << std::scientific;
761+
temp_s << std::setprecision(3);
762+
760763
int counter = comp.size();
761764
pyne::comp_iter nuc = comp.begin();
762765
// This will pick up multiples of 3 components
763766
while (counter >= 3) {
764767
ss << std::setw(10) << std::left << "COMPOUND";
765768

766769
temp_s << frac_sign << nuc->second;
770+
767771
ss << std::setw(10) << std::right << temp_s.str();
768772
ss << std::setw(10) << std::right << nucname::fluka(nuc->first);
769773
nuc++;
@@ -789,7 +793,6 @@ std::string pyne::Material::fluka_compound_str(int id, std::string frac_type) {
789793

790794
// Get the last (or only, as the case may be) one or two fractions
791795
if (nuc != comp.end()) {
792-
std::stringstream temp_s;
793796
ss << std::setw(10) << std::left << "COMPOUND";
794797
temp_s << frac_sign << nuc->second;
795798
ss << std::setw(10) << std::right << temp_s.str();
Collapse file

‎tests/test_material.py‎

Copy file name to clipboardExpand all lines: tests/test_material.py
+32-20Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,16 +1204,11 @@ def test_fluka():
12041204
matlines.append(compound)
12051205
written = ''.join(matlines)
12061206

1207-
exp = 'MATERIAL 92. 235.044 1. 25. 235-U'
1208-
exp += ' \n'
1209-
exp += 'MATERIAL 92. 238.051 1. 26. 238-U'
1210-
exp += ' \n'
1211-
exp += '* Fluka Compound'
1212-
exp += ' \n'
1213-
exp += 'MATERIAL 1. 1. 19.1 27. URANIUM'
1214-
exp += ' \n'
1215-
exp += 'COMPOUND 0.04 235-U 0.96 238-U URANIUM'
1216-
exp += ' \n'
1207+
exp = 'MATERIAL 92. 235.044 1. 25. 235-U \n'
1208+
exp += 'MATERIAL 92. 238.051 1. 26. 238-U \n'
1209+
exp += '* Fluka Compound \n'
1210+
exp += 'MATERIAL 1. 1. 19.1 27. URANIUM \n'
1211+
exp += 'COMPOUND 4.000e-02 235-U 9.600e-01 238-U URANIUM \n'
12171212

12181213
assert_equal(exp,written)
12191214

@@ -1243,19 +1238,36 @@ def test_fluka():
12431238
matlines.append(compound)
12441239
written = ''.join(matlines)
12451240

1246-
exp = 'MATERIAL 92. 235.044 1. 25. 235-U'
1247-
exp += ' \n'
1248-
exp += 'MATERIAL 92. 238.051 1. 26. 238-U'
1249-
exp += ' \n'
1250-
exp += '* Fluka Compound'
1251-
exp += ' \n'
1252-
exp += 'MATERIAL 1. 1. 19.1 27. URANIUM'
1253-
exp += ' \n'
1254-
exp += 'COMPOUND -0.04 235-U -0.96 238-U URANIUM'
1255-
exp += ' \n'
1241+
exp = 'MATERIAL 92. 235.044 1. 25. 235-U \n'
1242+
exp += 'MATERIAL 92. 238.051 1. 26. 238-U \n'
1243+
exp += '* Fluka Compound \n'
1244+
exp += 'MATERIAL 1. 1. 19.1 27. URANIUM \n'
1245+
exp += 'COMPOUND -4.000e-02 235-U-9.600e-01 238-U URANIUM \n'
1246+
assert_equal(exp,written)
1247+
1248+
def test_fluka_scientific():
1249+
# baseline test for scientific formatting
1250+
mat = Material({'H':0.1,'O':0.8,'C':0.1})
1251+
mat.density=1.0
1252+
mat.metadata['fluka_name'] = 'ORGPOLYM'
1253+
written = mat.fluka(25)
1254+
1255+
exp = 'MATERIAL 1. 1. 1. 25. ORGPOLYM \n'
1256+
exp += 'COMPOUND -1.000e-01 HYDROGEN-1.000e-01 CARBON-8.000e-01 OXYGENORGPOLYM \n'
1257+
assert_equal(exp,written)
12561258

1259+
mat = Material({'H':0.01,'O':0.8,'C':0.19})
1260+
mat.density=1.0
1261+
mat.metadata['fluka_name'] = 'ORGPOLYM'
1262+
written = mat.fluka(25)
1263+
1264+
exp = 'MATERIAL 1. 1. 1. 25. ORGPOLYM \n'
1265+
exp += 'COMPOUND -1.000e-02 HYDROGEN-1.900e-01 CARBON-8.000e-01 OXYGENORGPOLYM \n'
12571266
assert_equal(exp,written)
12581267

1268+
1269+
1270+
12591271
def test_write_alara():
12601272
if 'alara.txt' in os.listdir('.'):
12611273
os.remove('alara.txt')

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.