7 #include "gsl/gsl_interp.h"
8 #include "gsl/gsl_spline.h"
9 #include "gsl/gsl_fft_real.h"
23 int skippedValues = 0;
24 std::string tmpString;
33 bool parsing_passed =
true;
35 parsing_passed = interpreteLine<std::string, int>(file, tmpString,
accuracy_m);
37 parsing_passed = interpreteLine<std::string, int, std::string>(file, tmpString,
accuracy_m, tmpString);
40 if (tmpString !=
"TRUE" &&
43 "The third string on the first line of 1D field "
44 "maps has to be either TRUE or FALSE");
48 parsing_passed = parsing_passed &&
49 interpreteLine<double, double>(file,
zbegin_m, tmpDouble);
52 while(!file.eof() && parsing_passed) {
53 parsing_passed = interpreteLine<double, double>(file,
zend_m, tmpDouble,
false);
54 if(zend_m - tmpDouble2 > 1e-10) {
56 }
else if(parsing_passed) {
65 if(!parsing_passed && !file.eof()) {
69 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
88 bool parsing_passed =
true;
90 std::string tmpString;
99 gsl_spline *Bz_interpolant = gsl_spline_alloc(gsl_interp_cspline,
num_gridpz_m);
100 gsl_interp_accel *Bz_accel = gsl_interp_accel_alloc();
102 gsl_fft_real_wavetable *
real = gsl_fft_real_wavetable_alloc(2 *
num_gridpz_m);
103 gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(2 *
num_gridpz_m);
112 parsing_passed = interpreteLine<double, double>(in, zvals[i], RealValues[i]);
115 if(zvals[i] - tmpDouble > 1
e-10) {
116 if(
fabs(RealValues[i]) > Bz_max) {
117 Bz_max =
fabs(RealValues[i]);
119 tmpDouble = zvals[i];
125 gsl_spline_init(Bz_interpolant, zvals, RealValues,
num_gridpz_m);
132 RealValues[ii] = gsl_spline_eval(Bz_interpolant, z, Bz_accel);
134 RealValues[ii ++] = RealValues[num_gridpz_m - 1];
138 RealValues[i] = RealValues[ii];
141 gsl_fft_real_transform(RealValues, 1, 2 * num_gridpz_m, real, work);
152 gsl_spline_free(Bz_interpolant);
153 gsl_interp_accel_free(Bz_accel);
155 gsl_fft_real_workspace_free(work);
156 gsl_fft_real_wavetable_free(real);
177 const double RR2 =
R(0) *
R(0) +
R(1) *
R(1);
185 double somefactor_base, somefactor;
190 for(
int l = 1; l <
accuracy_m ; l++, n += 2) {
193 coskzl =
cos(kz * l);
194 sinkzl =
sin(kz * l);
196 somefactor *= somefactor_base;
198 somefactor *= somefactor_base;
200 somefactor *= somefactor_base;
204 const double BfieldR = -ezp / 2. + ezppp / 16. * RR2;
206 B(0) += BfieldR *
R(0);
207 B(1) += BfieldR *
R(1);
208 B(2) += ez - ezpp * RR2 / 4.;
Astra1DMagnetoStatic(std::string aFilename)
constexpr double e
The value of .
virtual void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
virtual double getFrequency() const
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
PETE_TUTree< FnFabs, typename T::PETE_Expr_t > fabs(const PETE_Expr< T > &l)
Tps< T > sin(const Tps< T > &x)
Sine.
virtual void getInfo(Inform *)
constexpr double two_pi
The value of .
std::string toUpper(const std::string &str)
void disableFieldmapWarning()
static std::string typeset_msg(const std::string &msg, const std::string &title)
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
virtual void setFrequency(double freq)
constexpr double pi
The value of .
constexpr double mu_0
The permeability of vacuum in Vs/Am.
constexpr double c
The velocity of light in m/s.
Tps< T > cos(const Tps< T > &x)
Cosine.
void getLine(std::ifstream &in, std::string &buffer)
Inform & level3(Inform &inf)
Inform & endl(Inform &inf)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const