7 #include "gsl/gsl_interp.h"
8 #include "gsl/gsl_spline.h"
9 #include "gsl/gsl_fft_real.h"
22 int skippedValues = 0;
23 std::string tmpString;
32 bool parsing_passed =
true;
34 parsing_passed = interpreteLine<std::string, int>(file, tmpString,
accuracy_m);
36 parsing_passed = interpreteLine<std::string, int, std::string>(file,
42 if (tmpString !=
"TRUE" &&
45 "The third string on the first line of 1D field "
46 "maps has to be either TRUE or FALSE");
51 parsing_passed = parsing_passed &&
52 interpreteLine<double, double>(file,
zbegin_m, tmpDouble);
55 while(!file.eof() && parsing_passed) {
56 parsing_passed = interpreteLine<double, double>(file,
zend_m, tmpDouble,
false);
57 if(zend_m - tmpDouble2 > 1e-10) {
59 }
else if(parsing_passed) {
67 if(!parsing_passed && !file.eof()) {
71 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
92 bool parsing_passed =
true;
94 std::string tmpString;
103 gsl_spline *Ez_interpolant = gsl_spline_alloc(gsl_interp_cspline,
num_gridpz_m);
104 gsl_interp_accel *Ez_accel = gsl_interp_accel_alloc();
106 gsl_fft_real_wavetable *
real = gsl_fft_real_wavetable_alloc(2 *
num_gridpz_m);
107 gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(2 *
num_gridpz_m);
116 parsing_passed = interpreteLine<double, double>(in, zvals[i], RealValues[i]);
119 if(zvals[i] - tmpDouble > 1
e-10) {
120 if(
std::abs(RealValues[i]) > Ez_max) {
123 tmpDouble = zvals[i];
129 gsl_spline_init(Ez_interpolant, zvals, RealValues,
num_gridpz_m);
136 RealValues[ii] = gsl_spline_eval(Ez_interpolant, z, Ez_accel);
138 RealValues[ii ++] = RealValues[num_gridpz_m - 1];
142 RealValues[i] = RealValues[ii];
148 gsl_fft_real_transform(RealValues, 1, num_gridpz_m, real, work);
159 gsl_fft_real_workspace_free(work);
160 gsl_fft_real_wavetable_free(real);
162 gsl_spline_free(Ez_interpolant);
163 gsl_interp_accel_free(Ez_accel);
185 const double RR2 =
R(0) *
R(0) +
R(1) *
R(1);
193 double somefactor_base, somefactor;
198 for(
int l = 1; l <
accuracy_m ; l++, n += 2) {
201 coskzl =
cos(kz * l);
202 sinkzl =
sin(kz * l);
204 somefactor *= somefactor_base;
206 somefactor *= somefactor_base;
208 somefactor *= somefactor_base;
213 const double EfieldR = -ezp / 2. + ezppp / 16. * RR2;
215 E(0) += EfieldR *
R(0);
216 E(1) += EfieldR *
R(1);
217 E(2) += ez - ezpp * RR2 / 4.;
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
constexpr double e
The value of .
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
virtual void setFrequency(double freq)
Tps< T > sin(const Tps< T > &x)
Sine.
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 double getFrequency() const
constexpr double mu_0
The permeability of vacuum in Vs/Am.
virtual void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
Astra1DElectroStatic(std::string aFilename)
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
virtual void getInfo(Inform *)
Tps< T > cos(const Tps< T > &x)
Cosine.
void getLine(std::ifstream &in, std::string &buffer)
Inform & level3(Inform &inf)
Inform & endl(Inform &inf)