mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Compute interpolation value in loop. Correction to from_tab1D.
This commit is contained in:
parent
848c0f3e0b
commit
f33ea966b2
2 changed files with 6 additions and 9 deletions
|
|
@ -36,9 +36,7 @@ inline double interpolate_log_log(
|
|||
inline double interpolate_lagrangian(gsl::span<const double> xs,
|
||||
gsl::span<const double> ys, int idx, double x, int order)
|
||||
{
|
||||
Expects(order <= 3);
|
||||
std::array<double, 4> coeffs;
|
||||
coeffs.fill(0.0);
|
||||
double output {0.0};
|
||||
|
||||
for (int i = 0; i < order + 1; i++) {
|
||||
double numerator {1.0};
|
||||
|
|
@ -49,11 +47,10 @@ inline double interpolate_lagrangian(gsl::span<const double> xs,
|
|||
numerator *= (x - xs[idx + j]);
|
||||
denominator *= (xs[idx + i] - xs[idx + j]);
|
||||
}
|
||||
coeffs[i] = numerator / denominator;
|
||||
output += (numerator / denominator) * ys[i];
|
||||
}
|
||||
|
||||
return std::inner_product(
|
||||
coeffs.begin(), coeffs.end(), ys.begin() + idx, 0.0);
|
||||
return output;
|
||||
}
|
||||
|
||||
double interpolate(gsl::span<const double> xs, gsl::span<const double> ys,
|
||||
|
|
|
|||
|
|
@ -1995,11 +1995,11 @@ class EnergyFunctionFilter(Filter):
|
|||
if tab1d.n_regions > 1:
|
||||
raise ValueError('Only Tabulated1Ds with a single interpolation '
|
||||
'region are supported')
|
||||
interpolation = tab1d.interpolation[0]
|
||||
if interpolation not in cls.INTERPOLATION_SCHEMES.keys():
|
||||
interpolation_val = tab1d.interpolation[0]
|
||||
if interpolation_val not in cls.INTERPOLATION_SCHEMES.keys():
|
||||
raise ValueError('Only histogram, linear-linear, linear-log, log-linear, and '
|
||||
'log-log Tabulated1Ds are supported')
|
||||
return cls(tab1d.x, tab1d.y, interpolation)
|
||||
return cls(tab1d.x, tab1d.y, cls.INTERPOLATION_SCHEMES[interpolation_val])
|
||||
|
||||
@property
|
||||
def energy(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue