Use ufloat for k_combined in statepoint

This commit is contained in:
Paul Romano 2018-03-02 16:19:10 -06:00
parent 23324fe24b
commit 8487915f2a
7 changed files with 19 additions and 16 deletions

View file

@ -587,7 +587,7 @@ class Library(object):
self._nuclides = statepoint.summary.nuclides
if statepoint.run_mode == 'eigenvalue':
self._keff = statepoint.k_combined[0]
self._keff = statepoint.k_combined.n
# Load tallies for each MGXS for each domain and mgxs type
for domain in self.domains:

View file

@ -210,7 +210,7 @@ class Model(object):
Returns
-------
2-tuple of float
uncertainties.UFloat
Combined estimator of k-effective from the statepoint
"""

View file

@ -60,9 +60,9 @@ def _search_keff(guess, target, model_builder, model_args, print_iterations,
if print_iterations:
text = 'Iteration: {}; Guess of {:.2e} produced a keff of ' + \
'{:1.5f} +/- {:1.5f}'
print(text.format(len(guesses), guess, keff[0], keff[1]))
print(text.format(len(guesses), guess, keff.n, keff.s))
return (keff[0] - target)
return keff.n - target
def search_for_keff(model_builder, initial_guess=None, target=1.0,

View file

@ -1,3 +1,4 @@
from datetime import datetime
import re
import os
import warnings
@ -5,6 +6,7 @@ import glob
import numpy as np
import h5py
from uncertainties import ufloat
import openmc
import openmc.checkvalue as cv
@ -47,8 +49,8 @@ class StatePoint(object):
CMFD fission source distribution over all mesh cells and energy groups.
current_batch : int
Number of batches simulated
date_and_time : str
Date and time when simulation began
date_and_time : datetime.datetime
Date and time at which statepoint was written
entropy : numpy.ndarray
Shannon entropy of fission source at each batch
filters : dict
@ -59,8 +61,8 @@ class StatePoint(object):
global_tallies : numpy.ndarray of compound datatype
Global tallies for k-effective estimates and leakage. The compound
datatype has fields 'name', 'sum', 'sum_sq', 'mean', and 'std_dev'.
k_combined : list
Combined estimator for k-effective and its uncertainty
k_combined : uncertainties.UFloat
Combined estimator for k-effective
k_col_abs : float
Cross-product of collision and absorption estimates of k-effective
k_col_tra : float
@ -187,7 +189,8 @@ class StatePoint(object):
@property
def date_and_time(self):
return self._f.attrs['date_and_time'].decode()
s = self._f.attrs['date_and_time'].decode()
return datetime.strptime(s, '%Y-%m-%d %H:%M:%S')
@property
def entropy(self):
@ -255,7 +258,7 @@ class StatePoint(object):
@property
def k_combined(self):
if self.run_mode == 'eigenvalue':
return self._f['k_combined'].value
return ufloat(*self._f['k_combined'].value)
else:
return None
@ -457,7 +460,7 @@ class StatePoint(object):
@property
def version(self):
return tuple(self._f.attrs['version'])
return tuple(self._f.attrs['openmc_version'])
@property
def summary(self):

View file

@ -14,11 +14,11 @@ class EntropyTestHarness(TestHarness):
with StatePoint(statepoint) as sp:
# Write out k-combined.
outstr = 'k-combined:\n'
outstr += '{0:12.6E} {1:12.6E}\n'.format(*sp.k_combined)
outstr += '{:12.6E} {:12.6E}\n'.format(sp.k_combined.n, sp.k_combined.s)
# Write out entropy data.
outstr += 'entropy:\n'
results = ['{0:12.6E}'.format(x) for x in sp.entropy]
results = ['{:12.6E}'.format(x) for x in sp.entropy]
outstr += '\n'.join(results) + '\n'
return outstr

View file

@ -144,8 +144,8 @@ class MGXSTestHarness(PyAPITestHarness):
with openmc.StatePoint('statepoint.{}.h5'.format(batches)) as sp:
# Write out k-combined.
outstr += 'k-combined:\n'
form = '{0:12.6E} {1:12.6E}\n'
outstr += form.format(sp.k_combined[0], sp.k_combined[1])
form = '{:12.6E} {:12.6E}\n'
outstr += form.format(sp.k_combined.n, sp.k_combined.s)
return outstr

View file

@ -75,7 +75,7 @@ class TestHarness(object):
# Write out k-combined.
outstr = 'k-combined:\n'
form = '{0:12.6E} {1:12.6E}\n'
outstr += form.format(sp.k_combined[0], sp.k_combined[1])
outstr += form.format(sp.k_combined.n, sp.k_combined.s)
# Write out tally data.
for i, tally_ind in enumerate(sp.tallies):