31 const Eigen::MatrixXd& profiles_,
32 double interpolation_points_fraction_)
33 : gridpoints(gridpoints_)
35 , splines(profiles_.cols())
37 if (interpolation_points_fraction_ <= 0. ||
38 interpolation_points_fraction_ > 1.) {
40 "fraction of points used in interpolation must be between 0 and 1");
47 double domain_end_,
int n_steps_,
48 double interpolation_points_fraction_)
50 n_steps_, domain_start_, domain_end_),
51 Eigen::MatrixXd::Zero(n_steps_, num_fields_),
52 interpolation_points_fraction_)
57 double domain_start_,
double domain_end_,
58 double interpolation_points_fraction_)
60 profiles_.rows(), domain_start_, domain_end_),
61 profiles_, interpolation_points_fraction_)
67 if (f <= 0. || f > 1.) {
69 "fraction of points used in interpolation must be between 0 and 1");
79 throw Setup_error(
"Field_profiles::set_field_profiles: " 80 "number of grid points does not match");
90 const int n_knots =
static_cast<int>(
93 if (n_knots > n_steps) {
94 throw Setup_error(
"Field_profiles::initialize_interpolation_grid_values: " 95 "number of knots cannot exceed number of grid points");
98 const int stride = (n_steps - 1) / (n_knots - 1);
105 for (
int i = 1; i < n_knots - 1; ++i) {
115 const int stride = (n_steps - 1) / (n_knots - 1);
118 for (
int i = 1; i < n_knots - 1; ++i) {
129 const int stride = (n_steps - 1) / (n_knots - 1);
137 for (
int i = 1; i < n_knots - 1; ++i) {
150 splines[field].construct_interpolant(
167 for (
int i = 0; i <
n_fields; ++i) {
176 if (field < 0 || field >=
profiles.cols()) {
179 "Field_profiles::evaluate_at: invalid field index " 180 + std::to_string(field));
183 return splines[field].evaluate_at(rho);
189 Eigen::VectorXd result(n_fields);
190 for (
int i = 0; i <
n_fields; ++i) {
191 result(i) =
splines[i].evaluate_at(rho);
199 if (order != 1 && order != 2) {
201 "Field_profiles::derivative_at: " 202 "only first or second derivatives may be computed");
205 if (field < 0 || field >=
profiles.cols()) {
208 "Field_profiles::evaluate_at: invalid field index " 209 + std::to_string(field));
212 return order == 1 ?
splines[field].evaluate_deriv_at(rho) :
213 splines[field].evaluate_second_deriv_at(rho);
contains the definition of the Field_profiles clas
double interpolation_points_fraction
double derivative_at(int field, int order, double rho) const
Take the radial derivative of a field at a given radius.
void set_interpolation_points_fraction(double f)
void set_field_profile(int i, const Eigen::VectorXd &p)
std::vector< GSL_interpolator > splines
void build_spline_for_field(int)
Eigen::MatrixXd interpolation_field_values
Eigen::VectorXd evaluate_at(double rho) const
Get all field values at a given radius.
void initialize_interpolation_field_values()
Eigen::VectorXd gridpoints
Exception indicating out of bounds access error.
Exception indicating general setup error.
Eigen::VectorXd interpolation_grid_values
void initialize_interpolation_grid_values()
Discretized set of field profiles.