7 #include "gsl/gsl_interp.h"
8 #include "gsl/gsl_spline.h"
9 #include "gsl/gsl_fft_real.h"
19 int skippedValues = 0;
20 std::string tmpString;
28 bool parsing_passed =
true;
30 parsing_passed = interpretLine<std::string, int>(file, tmpString,
accuracy_m);
32 parsing_passed = interpretLine<std::string, int, std::string>(file,
38 if (tmpString !=
"TRUE" &&
41 "The third string on the first line of 1D field "
42 "maps has to be either TRUE or FALSE");
47 parsing_passed = parsing_passed &&
48 interpretLine<double, double>(file,
zbegin_m, tmpDouble);
51 while(!file.eof() && parsing_passed) {
52 parsing_passed = interpretLine<double, double>(file,
zend_m, tmpDouble,
false);
53 if (
zend_m - tmpDouble2 > 1
e-10) {
55 }
else if (parsing_passed) {
63 if (!parsing_passed && !file.eof()) {
67 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
88 bool parsing_passed =
true;
90 std::string tmpString;
99 gsl_spline *Ez_interpolant = gsl_spline_alloc(gsl_interp_cspline,
num_gridpz_m);
100 gsl_interp_accel *Ez_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 = interpretLine<double, double>(in, zvals[i], RealValues[i]);
115 if (zvals[i] - tmpDouble > 1
e-10) {
116 if (
std::abs(RealValues[i]) > Ez_max) {
119 tmpDouble = zvals[i];
125 gsl_spline_init(Ez_interpolant, zvals, RealValues,
num_gridpz_m);
132 RealValues[ii] = gsl_spline_eval(Ez_interpolant, z, Ez_accel);
138 RealValues[i] = RealValues[ii];
151 for (
int i = 1; i < 2 *
accuracy_m - 1; i++) {
155 gsl_fft_real_workspace_free(work);
156 gsl_fft_real_wavetable_free(
real);
158 gsl_spline_free(Ez_interpolant);
159 gsl_interp_accel_free(Ez_accel);
181 const double RR2 =
R(0) *
R(0) +
R(1) *
R(1);
193 double somefactor = 1.0;
194 double coskzl =
cos(kz * l);
195 double sinkzl =
sin(kz * l);
197 somefactor *= somefactor_base;
199 somefactor *= somefactor_base;
201 somefactor *= somefactor_base;
206 const double EfieldR = -ezp / 2. + ezppp / 16. * RR2;
208 E(0) += EfieldR *
R(0);
209 E(1) += EfieldR *
R(1);
210 E(2) += ez - ezpp * RR2 / 4.;
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
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)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
virtual double getFrequency() const
Astra1DElectroStatic(std::string aFilename)
virtual void setFrequency(double freq)
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
virtual void getInfo(Inform *)
void disableFieldmapWarning()
static std::string typeset_msg(const std::string &msg, const std::string &title)
void getLine(std::ifstream &in, std::string &buffer)