Address #690 comments

This commit is contained in:
Sterling Harper 2016-08-07 14:31:18 -05:00
parent 4ff005b439
commit 264cb33b36
5 changed files with 25 additions and 34 deletions

Binary file not shown.

View file

@ -22,10 +22,9 @@ created from ENDF files with the
prompt neutrons.
**/<nuclide name>/**
Nuclides are named by concatenating their Z and their A numbers. For
example, U235 is named 92235. Metastable nuclides are appended with an
'_m' and their metastable number. For example, the first excited isomer
of Am-242 is named 95242_m1.
Nuclides are named by concatenating their atomic symbol and mass number. For
example, 'U235' or 'Pu239'. Metastable nuclides are appended with an
'_m' and their metastable number. For example, 'Am242_m1'
:Datasets: - **data** (*double[][][]*) -- The energy release coefficients. The
first axis indexes the component type. The second axis specifies

View file

@ -12,9 +12,8 @@ import re
def read_float(float_string):
"""Parse ENDF 6E11.0 formatted string into a float."""
assert len(float_string) == 11
pattern = '([\s\\-]\d+\\.\d+)([\\+\\-]\d+)'
mantissa, exponent = re.match(pattern, float_string).groups()
return float(mantissa + 'e' + exponent)
pattern = r'([\s\-]\d+\.\d+)([\+\-]\d+)'
return float(re.sub(pattern, r'\1e\2', float_string))
def read_CONT_line(line):

View file

@ -6,8 +6,9 @@ import h5py
import numpy as np
from numpy.polynomial.polynomial import Polynomial
from .function import Tabulated1D, Sum
from .data import ATOMIC_SYMBOL
from .endf_utils import read_float, read_CONT_line, identify_nuclide
from .function import Tabulated1D, Sum
import openmc.checkvalue as cv
if sys.version_info[0] >= 3:
@ -70,11 +71,11 @@ def _extract_458_data(filename):
labels = ('EFR', 'ENP', 'END', 'EGP', 'EGD', 'EB', 'ENU', 'ER', 'ET')
# Associate each set of values and uncertainties with its label.
value = dict()
uncertainty = dict()
for i in range(len(labels)):
value[labels[i]] = data[2*i::18]
uncertainty[labels[i]] = data[2*i + 1::18]
value = {}
uncertainty = {}
for i, label in enumerate(labels):
value[label] = data[2*i::18]
uncertainty[label] = data[2*i + 1::18]
# In ENDF/B-7.1, data for 2nd-order coefficients were mistakenly not
# converted from MeV to eV. Check for this error and fix it if present.
@ -94,13 +95,6 @@ def _extract_458_data(filename):
for coeffs in value.values(): coeffs[2] *= 1e-6
for coeffs in uncertainty.values(): coeffs[2] *= 1e-6
# Perform the sanity check again... just in case.
for coeffs in value.values():
second_order = coeffs[2]
if abs(second_order) * 1e12 > 1e8:
raise ValueError("Encountered a ludicrously large second-"
"order polynomial coefficient.")
# Convert eV to MeV.
for coeffs in value.values():
for i in range(len(coeffs)):
@ -112,8 +106,8 @@ def _extract_458_data(filename):
return value, uncertainty
def write_compact_458_library(endf_files, output_name=None, comment=None,
verbose=False):
def write_compact_458_library(endf_files, output_name='fission_Q_data.h5',
comment=None, verbose=False):
"""Read ENDF files, strip the MF=1 MT=458 data and write to small HDF5.
Parameters
@ -130,7 +124,6 @@ def write_compact_458_library(endf_files, output_name=None, comment=None,
"""
# Open the output file.
if output_name is None: output_name = 'fission_Q_data.h5'
out = h5py.File(output_name, 'w', libver='latest')
# Write comments, if given. This commented out comment is the one used for
@ -179,7 +172,7 @@ def write_compact_458_library(endf_files, output_name=None, comment=None,
value, uncertainty = data
# Make a group for this isomer.
name = str(ident['Z']) + str(ident['A'])
name = ATOMIC_SYMBOL[ident['Z']] + str(ident['A'])
if ident['LISO'] != 0:
name += '_m' + str(ident['LISO'])
nuclide_group = out.create_group(name)
@ -447,7 +440,7 @@ class FissionEnergyRelease(object):
and p.emission_mode == 'prompt']
else:
raise ValueError('IncidentNeutron data has no fission '
'reaction.')
'reaction.')
if len(nu_prompt) == 0:
raise ValueError('Nu data is needed to compute fission energy '
'release with the Sher-Beck format.')
@ -533,7 +526,7 @@ class FissionEnergyRelease(object):
elif group.attrs['format'].decode() == 'Sher-Beck':
obj.form = 'Sher-Beck'
obj.prompt_neutrons = Tabulated1D.from_hdf5(
group['prompt_neutrons'])
group['prompt_neutrons'])
else:
raise ValueError('Unrecognized energy release format')
@ -565,14 +558,14 @@ class FissionEnergyRelease(object):
components = [s.decode() for s in fin.attrs['component order']]
nuclide_name = str(incident_neutron.atomic_number)
nuclide_name = ATOMIC_SYMBOL[incident_neutron.atomic_number]
nuclide_name += str(incident_neutron.mass_number)
if incident_neutron.metastable != 0:
nuclide_name += '_m' + str(incident_neutron.metastable)
if nuclide_name not in fin: return None
data = {c : fin[nuclide_name + '/data'][i, 0, :]
data = {c: fin[nuclide_name + '/data'][i, 0, :]
for i, c in enumerate(components)}
return cls._from_dictionary(data, incident_neutron)

View file

@ -710,7 +710,7 @@ contains
score = p % absorb_wgt * &
nuc % reactions(nuc % index_fission(1)) % Q_value * &
micro_xs(p % event_nuclide) % fission / &
micro_xs(p % event_nuclide) % absorption
micro_xs(p % event_nuclide) % absorption * flux
end if
end associate
else
@ -724,7 +724,7 @@ contains
score = p % last_wgt * &
nuc % reactions(nuc % index_fission(1)) % Q_value * &
micro_xs(p % event_nuclide) % fission / &
micro_xs(p % event_nuclide) % absorption
micro_xs(p % event_nuclide) % absorption * flux
end if
end associate
end if
@ -785,7 +785,7 @@ contains
score = p % absorb_wgt &
* nuc % fission_q_prompt % evaluate(p % last_E) &
* micro_xs(p % event_nuclide) % fission &
/ micro_xs(p % event_nuclide) % absorption
/ micro_xs(p % event_nuclide) % absorption * flux
end if
end associate
else
@ -799,7 +799,7 @@ contains
score = p % last_wgt &
* nuc % fission_q_prompt % evaluate(p % last_E) &
* micro_xs(p % event_nuclide) % fission &
/ micro_xs(p % event_nuclide) % absorption
/ micro_xs(p % event_nuclide) % absorption * flux
end if
end associate
end if
@ -844,7 +844,7 @@ contains
score = p % absorb_wgt &
* nuc % fission_q_recov % evaluate(p % last_E) &
* micro_xs(p % event_nuclide) % fission &
/ micro_xs(p % event_nuclide) % absorption
/ micro_xs(p % event_nuclide) % absorption * flux
end if
end associate
else
@ -858,7 +858,7 @@ contains
score = p % last_wgt &
* nuc % fission_q_recov % evaluate(p % last_E) &
* micro_xs(p % event_nuclide) % fission &
/ micro_xs(p % event_nuclide) % absorption
/ micro_xs(p % event_nuclide) % absorption * flux
end if
end associate
end if