mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Use ufloat for k_combined in statepoint
This commit is contained in:
parent
23324fe24b
commit
8487915f2a
7 changed files with 19 additions and 16 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class Model(object):
|
|||
|
||||
Returns
|
||||
-------
|
||||
2-tuple of float
|
||||
uncertainties.UFloat
|
||||
Combined estimator of k-effective from the statepoint
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue