mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Sampling and reconstructing working for large files
This commit is contained in:
parent
77b514950e
commit
0a1408def1
3 changed files with 20 additions and 9 deletions
|
|
@ -67,7 +67,13 @@ def float_endf(s):
|
|||
The number
|
||||
|
||||
"""
|
||||
return float(ENDF_FLOAT_RE.sub(r'\1e\2', s))
|
||||
try:
|
||||
return float(ENDF_FLOAT_RE.sub(r'\1e\2', s))
|
||||
except:
|
||||
if ENDF_FLOAT_RE.sub(r'\1e\2', s).isspace():
|
||||
return 0
|
||||
else:
|
||||
raise TypeError('Expected float value or blank entry')
|
||||
|
||||
|
||||
def int_endf(s):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import division, unicode_literals
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Iterable, Mapping, MutableMapping
|
||||
from collections import OrderedDict, Iterable, Mapping, MutableMapping
|
||||
from io import StringIO
|
||||
from itertools import chain
|
||||
from math import log10
|
||||
|
|
@ -10,6 +10,7 @@ import shutil
|
|||
import tempfile
|
||||
from warnings import warn
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
import h5py
|
||||
|
||||
|
|
@ -109,7 +110,6 @@ class IncidentNeutron(EqualityMixin):
|
|||
:meth:`IncidentNeutron.from_ace`.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name : str
|
||||
Name of the nuclide using the GND naming convention
|
||||
atomic_number : int
|
||||
|
|
@ -889,3 +889,10 @@ class IncidentNeutron(EqualityMixin):
|
|||
data[2].xs['0K'] = xs
|
||||
|
||||
return data
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Iterable, Mapping, MutableMapping
|
||||
from io import StringIO
|
||||
from itertools import chain
|
||||
from math import log10
|
||||
from numbers import Integral, Real
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import io
|
|||
|
||||
import numpy as np
|
||||
from numpy.polynomial import Polynomial
|
||||
from scipy import sparse
|
||||
import pandas as pd
|
||||
|
||||
from .data import NEUTRON_MASS
|
||||
|
|
@ -11,7 +12,6 @@ from .endf import get_head_record, get_cont_record, get_tab1_record, get_list_re
|
|||
import openmc.checkvalue as cv
|
||||
from .resonance import ResonanceRange
|
||||
|
||||
### Under Construction START
|
||||
def sample_resonance_parameters(nuclide, n_samples):
|
||||
"""Return a IncidentNeutron object with n_samples of xs
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ def sample_resonance_parameters(nuclide, n_samples):
|
|||
ev : openmc.data.endf.Evaluation
|
||||
|
||||
"""
|
||||
print('begin sampling')
|
||||
nparams,params = nuclide.res_covariance.ranges[0].parameters.shape
|
||||
cov = nuclide.res_covariance.ranges[0].covariance
|
||||
cov = cov + cov.T - np.diag(cov.diagonal()) #symmetrizing covariance matrix
|
||||
|
|
@ -128,6 +129,7 @@ def sample_resonance_parameters(nuclide, n_samples):
|
|||
spin = pd.DataFrame.as_matrix(nuclide.res_covariance.ranges[0].parameters['J'])
|
||||
mean = mean_array.flatten()
|
||||
for i in range(n_samples):
|
||||
print("On sample",i)
|
||||
sample = np.random.multivariate_normal(mean,cov)
|
||||
energy = sample[0::5]
|
||||
gn = sample[1::5]
|
||||
|
|
@ -144,7 +146,6 @@ def sample_resonance_parameters(nuclide, n_samples):
|
|||
samples.append(sample_params)
|
||||
|
||||
return samples
|
||||
### Under Construction END
|
||||
|
||||
class ResonanceCovariance(object):
|
||||
"""Resolved resonance covariance data
|
||||
|
|
@ -209,11 +210,9 @@ class ResonanceCovariance(object):
|
|||
abundance = items[1]
|
||||
fission_widths = (items[3] == 1) # Flag for fission widths
|
||||
n_ranges = items[4] # number of resonance energy ranges
|
||||
print('there are',n_ranges,'ranges')
|
||||
|
||||
for j in range(n_ranges):
|
||||
items = get_cont_record(file_obj)
|
||||
print("Line with unresovled flag:",items)
|
||||
resonance_flag = items[2] # flag for resolved (1)/unresolved (2)
|
||||
formalism = items[3] # resonance formalism
|
||||
|
||||
|
|
@ -582,7 +581,6 @@ class ReichMooreCovariance(ResonanceRange):
|
|||
# Build covariance matrix for General Resolved Resonance Formats
|
||||
if LCOMP == 1:
|
||||
items = get_cont_record(file_obj)
|
||||
print("in resonance_covariance.py", items)
|
||||
num_short_range = items[4] #Number of short range type resonance
|
||||
#covariances
|
||||
num_long_range = items[5] #Number of long range type resonance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue