TDMS
Time Domain Maxwell Solver
|
Tests the performance of the interpolation functions, using 1D data mimicing a coordinate axes. More...
#include "interpolation_methods.h"
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <sstream>
#include <catch2/catch_approx.hpp>
#include <catch2/catch_test_macros.hpp>
#include <spdlog/spdlog.h>
#include "globals.h"
#include "input_flags.h"
#include "unit_test_utils.h"
Functions | |
TEST_CASE ("Cubic interpolation: exact for polynomials of degree <= 3") | |
In the case when cubic interpolation is to be used, check that all polynomial fields up to cubic order are interpolated exactly (to within machine error) | |
TEST_CASE ("BLi: interpolation-coefficient sums match") | |
The hard-coded numerical values for the interpolation constant should all sum to the same value. | |
double | constant_1 (double x) |
double | s2pi (double x) |
double | pulse (double x) |
Evaluates the smooth pulse/ mollifier Kernel function, supported between 0 and 1. | |
complex< double > | complex_fn (double x) |
TEST_CASE ("BLi: MATLAB benchmarking") | |
Variables | |
const double | ML_const_fn_max_pointwise_error = 2.82944733e-04 |
We will check that BLi interpolation data gives comparible error to the equivalent functions in MATLAB. | |
const double | ML_sin_max_pointwise_error = 2.63468327e-04 |
const double | ML_pulse_max_pointwise_error = 4.87599933e-04 |
const double | ML_complex_fn_max_pointwise_error = 5.35317432e-04 |
const double | ML_cont_fn_norm_error = 2.81526454e-03 |
const double | ML_sin_norm_error = 1.85845330e-03 |
const double | ML_pulse_norm_error = 9.65609916e-04 |
const double | ML_complex_fn_norm_error = 2.08892374e-03 |
Tests the performance of the interpolation functions, using 1D data mimicing a coordinate axes.
|
inline |
Evaluates the smooth pulse/ mollifier Kernel function, supported between 0 and 1.
The smooth mollifier \phi(x) is the function \phi(x) = \begin{cases} 0 & when |x| >= 1, e^{-1/(1-|x|^2)} & when |x| < 1 \end{cases} This function is compactly supported over the interval [-1,1]. By evaluating pulse(x) = \phi(3[2x-1]), we obtain a smooth function with support in [1/3,2/3] \subset [0,1]
x | Point of evaluation |
TEST_CASE | ( | "BLi: interpolation-coefficient sums match" | ) |
The hard-coded numerical values for the interpolation constant should all sum to the same value.
Note - the coefficients are not required to sum to unity!
TEST_CASE | ( | "Cubic interpolation: exact for polynomials of degree <= 3" | ) |
In the case when cubic interpolation is to be used, check that all polynomial fields up to cubic order are interpolated exactly (to within machine error)
Checks are run on both the old interp{1,2,3} functions and newer const Interp_scheme instances. Old cubic methods will be redundant upon integration of BLi into the codebase.
|
inline |
We will check that BLi interpolation data gives comparible error to the equivalent functions in MATLAB.
Interoplation will then be tested against over the range [0,1], the max element-wise error (by absolute value) will be determined. We will then check that this is of the same order of magnitude as the error produced by MATLAB, 5.35317432e-04.
For 100 sample points, we will use BLi to interpolate the following functions with 100 sample points:
MATLAB norm-errors: constant function norm error: 2.81526454e-03 sin function norm error: 1.85845330e-03 pulse function norm error: 9.65609916e-04 complex fn norm error: 2.08892374e-03
Error values produced from benchmark_test_interpolation_functions.m The complex function has real part sin(2\pi x) and its imaginary part is the pulse function.