7#include "gsl/gsl_fft_real.h"
8#include "gsl/gsl_interp.h"
9#include "gsl/gsl_spline.h"
15 :
Fieldmap(aFilename), FourCoefs_m(nullptr) {
17 int skippedValues = 0;
18 std::string tmpString;
26 bool parsing_passed =
true;
28 parsing_passed = interpretLine<std::string, int>(file, tmpString,
accuracy_m);
30 parsing_passed = interpretLine<std::string, int, std::string>(
34 if (tmpString !=
"TRUE" && tmpString !=
"FALSE")
36 "Astra1DMagnetoStatic::Astra1DMagnetoStatic",
37 "The third string on the first line of 1D field "
38 "maps has to be either TRUE or FALSE");
42 parsing_passed = parsing_passed && interpretLine<double, double>(file,
zbegin_m, tmpDouble);
45 while (!file.eof() && parsing_passed) {
46 parsing_passed = interpretLine<double, double>(file,
zend_m, tmpDouble,
false);
47 if (
zend_m - tmpDouble2 > 1
e-10) {
49 }
else if (parsing_passed) {
58 if (!parsing_passed && !file.eof()) {
62 "Astra1DMagnetoStatic::Astra1DMagnetoStatic",
63 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
82 bool parsing_passed =
true;
84 std::string tmpString;
93 gsl_spline* Bz_interpolant = gsl_spline_alloc(gsl_interp_cspline,
num_gridpz_m);
94 gsl_interp_accel* Bz_accel = gsl_interp_accel_alloc();
96 gsl_fft_real_wavetable* real = gsl_fft_real_wavetable_alloc(2 *
num_gridpz_m);
97 gsl_fft_real_workspace* work = gsl_fft_real_workspace_alloc(2 *
num_gridpz_m);
106 parsing_passed = interpretLine<double, double>(in, zvals[i], RealValues[i]);
109 if (zvals[i] - tmpDouble > 1
e-10) {
110 if (std::abs(RealValues[i]) > Bz_max) {
111 Bz_max = std::abs(RealValues[i]);
113 tmpDouble = zvals[i];
119 gsl_spline_init(Bz_interpolant, zvals, RealValues,
num_gridpz_m);
126 RealValues[ii] = gsl_spline_eval(Bz_interpolant, z, Bz_accel);
132 RealValues[i] = RealValues[ii];
135 gsl_fft_real_transform(RealValues, 1, 2 *
num_gridpz_m, real, work);
142 for (
int i = 1; i < 2 *
accuracy_m - 1; i++) {
146 gsl_spline_free(Bz_interpolant);
147 gsl_interp_accel_free(Bz_accel);
149 gsl_fft_real_workspace_free(work);
150 gsl_fft_real_wavetable_free(real);
172 const double RR2 = R(0) * R(0) + R(1) * R(1);
182 for (
int l = 1; l <
accuracy_m; l++, n += 2) {
184 double somefactor = 1.0;
185 double coskzl = cos(kz * l);
186 double sinkzl = sin(kz * l);
188 somefactor *= somefactor_base;
190 somefactor *= somefactor_base;
192 somefactor *= somefactor_base;
196 const double BfieldR = -ezp / 2. + ezppp / 16. * RR2;
198 B(0) += BfieldR * R(0);
199 B(1) += BfieldR * R(1);
200 B(2) += ez - ezpp * RR2 / 4.;
216 double& ,
double& ,
double& ,
double& ,
double& ,
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double two_pi
The value of.
constexpr double e
The value of.
constexpr double pi
The value of.
std::string toUpper(const std::string &str)
std::unique_ptr< Inform > Info
virtual void getInfo(Inform *)
virtual void setFrequency(double freq)
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const
Astra1DMagnetoStatic(std::string aFilename)
virtual bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const
virtual double getFrequency() const
void disableFieldmapWarning()
static std::string typeset_msg(const std::string &msg, const std::string &title)
void getLine(std::ifstream &in, std::string &buffer)