mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Using a separate dictionary for interpolation values
This commit is contained in:
parent
fd7683fe31
commit
fbce363784
4 changed files with 11 additions and 6 deletions
|
|
@ -61,6 +61,9 @@ inline double interpolate(const std::vector<double>& xs,
|
|||
{
|
||||
int idx = lower_bound_index(xs.begin(), xs.end(), x);
|
||||
|
||||
if (idx == xs.size())
|
||||
idx--;
|
||||
|
||||
switch (i) {
|
||||
case Interpolation::lin_lin:
|
||||
return interpolate_lin_lin(xs[idx], xs[idx + 1], ys[idx], ys[idx + 1], x);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from openmc.mixin import EqualityMixin
|
|||
from .data import EV_PER_MEV
|
||||
|
||||
INTERPOLATION_SCHEME = {1: 'histogram', 2: 'linear-linear', 3: 'linear-log',
|
||||
4: 'log-linear', 5: 'log-log', 6 : 'quadratic', 7 : 'cubic'}
|
||||
4: 'log-linear', 5: 'log-log'}
|
||||
|
||||
|
||||
def sum_functions(funcs):
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import pandas as pd
|
|||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
from .cell import Cell
|
||||
from .data.function import INTERPOLATION_SCHEME
|
||||
from .material import Material
|
||||
from .mixin import IDManagerMixin
|
||||
from .surface import Surface
|
||||
|
|
@ -1896,6 +1895,11 @@ class EnergyFunctionFilter(Filter):
|
|||
|
||||
"""
|
||||
|
||||
# keys selected to match those in function.py where possible
|
||||
INTERPOLATION_SCHEMES = {2: 'linear-linear', 3: 'linear-log',
|
||||
4: 'log-linear', 5: 'log-log',
|
||||
6 : 'quadratic', 7 : 'cubic'}
|
||||
|
||||
def __init__(self, energy, y, interpolation='linear-linear', filter_id=None):
|
||||
self.energy = energy
|
||||
self.y = y
|
||||
|
|
@ -1963,7 +1967,7 @@ class EnergyFunctionFilter(Filter):
|
|||
out = cls(energy, y, filter_id=filter_id)
|
||||
if 'interpolation' in group:
|
||||
out.interpolation = \
|
||||
openmc.data.INTERPOLATION_SCHEME[group['interpolation'][()]]
|
||||
cls.INTERPOLATION_SCHEMES[group['interpolation'][()]]
|
||||
|
||||
return out
|
||||
|
||||
|
|
@ -2053,7 +2057,7 @@ class EnergyFunctionFilter(Filter):
|
|||
@interpolation.setter
|
||||
def interpolation(self, val):
|
||||
cv.check_type('interpolation', val, str)
|
||||
cv.check_value('interpolation', val, INTERPOLATION_SCHEME.values())
|
||||
cv.check_value('interpolation', val, self.INTERPOLATION_SCHEMES.values())
|
||||
self._interpolation = val
|
||||
|
||||
def to_xml_element(self):
|
||||
|
|
|
|||
|
|
@ -73,9 +73,7 @@ class FilterEnergyFunHarness(PyAPITestHarness):
|
|||
br_tally = sp.tallies[2] / sp.tallies[1]
|
||||
dataframes_string += br_tally.get_pandas_dataframe().to_string() + '\n'
|
||||
|
||||
|
||||
for t_id in (3, 4, 5):
|
||||
# Write out the log-log interpolation as well
|
||||
ef_tally = sp.tallies[t_id]
|
||||
dataframes_string += ef_tally.get_pandas_dataframe().to_string() + '\n'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue