mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Change how incoherent elastic data is written to HDF5
This commit is contained in:
parent
c851030511
commit
c48d5f07c4
5 changed files with 36 additions and 20 deletions
|
|
@ -43,8 +43,8 @@ class AngleEnergy(EqualityMixin, metaclass=ABCMeta):
|
|||
return openmc.data.IncoherentElasticAEDiscrete.from_hdf5(group)
|
||||
elif dist_type == 'incoherent_inelastic_discrete':
|
||||
return openmc.data.IncoherentInelasticAEDiscrete.from_hdf5(group)
|
||||
elif dist_type == 'incoherent_inelastic_continuous':
|
||||
return openmc.data.IncoherentInelasticAEContinuous.from_hdf5(group)
|
||||
elif dist_type == 'incoherent_inelastic':
|
||||
return openmc.data.IncoherentInelasticAE.from_hdf5(group)
|
||||
|
||||
@staticmethod
|
||||
def from_ace(ace, location_dist, location_start, rx=None):
|
||||
|
|
|
|||
|
|
@ -591,8 +591,8 @@ class Regions1D(EqualityMixin):
|
|||
Functions which are to be combined in a piecewise fashion
|
||||
breakpoints : Iterable of float
|
||||
The values of the dependent variable that define the domain of
|
||||
each function. The `i`th and `(i+1)`th values are the limits of the
|
||||
domain of the `i`th function. Values must be monotonically increasing.
|
||||
each function. The `i`\ th and `(i+1)`\ th values are the limits of the
|
||||
domain of the `i`\ th function. Values must be monotonically increasing.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from .njoy import make_ace_thermal
|
|||
from .thermal_angle_energy import (CoherentElasticAE, IncoherentElasticAE,
|
||||
IncoherentElasticAEDiscrete,
|
||||
IncoherentInelasticAEDiscrete,
|
||||
IncoherentInelasticAEContinuous)
|
||||
IncoherentInelasticAE)
|
||||
|
||||
|
||||
_THERMAL_NAMES = {
|
||||
|
|
@ -247,26 +247,26 @@ class IncoherentElastic(Function1D):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
xs : float
|
||||
bound_xs : float
|
||||
Characteristic bound cross section in [b]
|
||||
debye_waller : float
|
||||
Debye-Waller integral in [eV\ :math:`^{-1}`]
|
||||
|
||||
Attributes
|
||||
----------
|
||||
xs : float
|
||||
bound_xs : float
|
||||
Characteristic bound cross section in [b]
|
||||
debye_waller : float
|
||||
Debye-Waller integral in [eV\ :math:`^{-1}`]
|
||||
|
||||
"""
|
||||
def __init__(self, xs, debye_waller):
|
||||
self.xs = xs
|
||||
def __init__(self, bound_xs, debye_waller):
|
||||
self.bound_xs = bound_xs
|
||||
self.debye_waller = debye_waller
|
||||
|
||||
def __call__(self, E):
|
||||
W = self.debye_waller
|
||||
return self.xs / 2.0 * (1 - np.exp(-4*E*W)) / (2*E*W)
|
||||
return self.bound_xs / 2.0 * (1 - np.exp(-4*E*W)) / (2*E*W)
|
||||
|
||||
def to_hdf5(self, group, name):
|
||||
"""Write incoherent elastic scattering to an HDF5 group
|
||||
|
|
@ -279,14 +279,27 @@ class IncoherentElastic(Function1D):
|
|||
Name of the dataset to create
|
||||
|
||||
"""
|
||||
dataset = group.create_dataset(name)
|
||||
data = np.array([self.bound_xs, self.debye_waller])
|
||||
dataset = group.create_dataset(name, data=data)
|
||||
dataset.attrs['type'] = np.string_(type(self).__name__)
|
||||
dataset.attrs['debye_waller'] = self.debye_waller
|
||||
dataset.attrs['bound_xs'] = self.xs
|
||||
|
||||
@classmethod
|
||||
def from_hdf5(cls, dataset):
|
||||
return cls(dataset.attrs['xs'], dataset.attrs['debye_waller'])
|
||||
"""Read incoherent elastic scattering from an HDF5 dataset
|
||||
|
||||
Parameters
|
||||
----------
|
||||
dataset : h5py.Dataset
|
||||
HDF5 dataset to read from
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc.data.IncoherentElastic
|
||||
Incoherent elastic scattering cross section
|
||||
|
||||
"""
|
||||
bound_xs, debye_waller = dataset[()]
|
||||
return cls(bound_xs, debye_waller)
|
||||
|
||||
|
||||
class ThermalScatteringReaction(EqualityMixin):
|
||||
|
|
@ -676,7 +689,7 @@ class ThermalScattering(EqualityMixin):
|
|||
breakpoints = [n_energy]
|
||||
interpolation = [2]
|
||||
energy = inelastic_xs.x
|
||||
distribution = IncoherentInelasticAEContinuous(
|
||||
distribution = IncoherentInelasticAE(
|
||||
breakpoints, interpolation, energy, energy_out, mu_out)
|
||||
|
||||
table = cls(name, ace.atomic_weight_ratio, energy_max, kTs)
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class IncoherentInelasticAEDiscrete(AngleEnergy):
|
|||
mu_out : numpy.ndarray
|
||||
Discrete angles for each incoming/outgoing energy
|
||||
skewed : bool
|
||||
Whether distance angles are equi-probable or have a skewed distribution
|
||||
Whether discrete angles are equi-probable or have a skewed distribution
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -115,7 +115,7 @@ class IncoherentInelasticAEDiscrete(AngleEnergy):
|
|||
mu_out : numpy.ndarray
|
||||
Discrete angles for each incoming/outgoing energy
|
||||
skewed : bool
|
||||
Whether distance angles are equi-probable or have a skewed distribution
|
||||
Whether discrete angles are equi-probable or have a skewed distribution
|
||||
|
||||
"""
|
||||
def __init__(self, energy_out, mu_out, skewed=False):
|
||||
|
|
@ -137,5 +137,5 @@ class IncoherentInelasticAEDiscrete(AngleEnergy):
|
|||
return cls(energy_out, mu_out, skewed)
|
||||
|
||||
|
||||
class IncoherentInelasticAEContinuous(CorrelatedAngleEnergy):
|
||||
class IncoherentInelasticAE(CorrelatedAngleEnergy):
|
||||
_name = 'incoherent_inelastic'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "openmc/endf.h"
|
||||
|
||||
#include <algorithm> // for copy
|
||||
#include <array>
|
||||
#include <cmath> // for log, exp
|
||||
#include <iterator> // for back_inserter
|
||||
#include <stdexcept> // for runtime_error
|
||||
|
|
@ -244,8 +245,10 @@ double CoherentElasticXS::operator()(double E) const
|
|||
|
||||
IncoherentElasticXS::IncoherentElasticXS(hid_t dset)
|
||||
{
|
||||
read_attribute(dset, "bound_xs", bound_xs_);
|
||||
read_attribute(dset, "debye_waller", debye_waller_);
|
||||
std::array<double, 2> tmp;
|
||||
read_dataset(dset, nullptr, tmp);
|
||||
bound_xs_ = tmp[0];
|
||||
debye_waller_ = tmp[1];
|
||||
}
|
||||
|
||||
double IncoherentElasticXS::operator()(double E) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue