7 #include "gsl/gsl_interp.h"
8 #include "gsl/gsl_spline.h"
9 #include "gsl/gsl_fft_real.h"
24 int skippedValues = 0;
25 std::string tmpString;
34 bool parsing_passed =
true;
36 parsing_passed = interpreteLine<std::string, int>(file,
40 parsing_passed = interpreteLine<std::string, int, std::string>(file,
46 if (tmpString !=
"TRUE" &&
49 "The third string on the first line of 1D field "
50 "maps has to be either TRUE or FALSE");
55 parsing_passed = parsing_passed &&
57 parsing_passed = parsing_passed &&
58 interpreteLine<double, double>(file,
zbegin_m, tmpDouble);
61 while(!file.eof() && parsing_passed) {
62 parsing_passed = interpreteLine<double, double>(file,
zend_m, tmpDouble,
false);
63 if (zend_m - tmpDouble2 > 1e-10) {
65 }
else if (parsing_passed) {
73 if (!parsing_passed && !file.eof()) {
77 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
101 bool parsing_passed =
true;
103 std::string tmpString;
112 gsl_spline *Ez_interpolant = gsl_spline_alloc(gsl_interp_cspline,
num_gridpz_m);
113 gsl_interp_accel *Ez_accel = gsl_interp_accel_alloc();
115 gsl_fft_real_wavetable *
real = gsl_fft_real_wavetable_alloc(2 *
num_gridpz_m);
116 gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(2 *
num_gridpz_m);
127 parsing_passed = interpreteLine<double, double>(in, zvals[i], RealValues[i]);
130 if (zvals[i] - tmpDouble > 1
e-10) {
131 if (
std::abs(RealValues[i]) > Ez_max) {
134 tmpDouble = zvals[i];
140 gsl_spline_init(Ez_interpolant, zvals, RealValues,
num_gridpz_m);
147 RealValues[ii] = gsl_spline_eval(Ez_interpolant, z, Ez_accel);
149 RealValues[ii ++] = RealValues[num_gridpz_m - 1];
153 RealValues[i] = RealValues[ii];
156 gsl_fft_real_transform(RealValues, 1, 2 * num_gridpz_m, real, work);
164 for (
int i = 1; i < 2 *
accuracy_m - 1; ++ i) {
168 gsl_spline_free(Ez_interpolant);
169 gsl_interp_accel_free(Ez_accel);
171 gsl_fft_real_workspace_free(work);
172 gsl_fft_real_wavetable_free(real);
192 const double RR2 =
R(0) *
R(0) +
R(1) *
R(1);
200 double somefactor_base, somefactor;
205 for (
int l = 1; l <
accuracy_m ; ++ l, n += 2) {
208 coskzl =
cos(kz * l);
209 sinkzl =
sin(kz * l);
211 somefactor *= somefactor_base;
213 somefactor *= somefactor_base;
215 somefactor *= somefactor_base;
222 const double EfieldR = -(ezp / 2. + fp * RR2);
223 const double BfieldT = (ez / 2. + f * RR2) *
xlrep_m /
c;
225 E(0) += EfieldR *
R(0);
226 E(1) += EfieldR *
R(1);
227 E(2) += ez + 4. * f * RR2;
228 B(0) += -BfieldT *
R(1);
229 B(1) += BfieldT *
R(0);
273 std::string tmpString;
277 interpreteLine<std::string, int>(in, tmpString, tmpInt);
278 interpreteLine<double>(in, tmpDouble);
281 interpreteLine<double, double>(in, F[i].first, F[i].second);
282 if (
std::abs(F[i].second) > Ez_max) {
289 F[i].second /= Ez_max;
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &F)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
constexpr double e
The value of .
Tps< T > sin(const Tps< T > &x)
Sine.
constexpr double two_pi
The value of .
std::string toUpper(const std::string &str)
void disableFieldmapWarning()
double *__restrict__ FourCoefs_m
virtual void getInfo(Inform *)
static std::string typeset_msg(const std::string &msg, const std::string &title)
virtual void setFrequency(double freq)
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
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.
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
virtual void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
virtual double getFrequency() const
Tps< T > cos(const Tps< T > &x)
Cosine.
void getLine(std::ifstream &in, std::string &buffer)
Astra1DDynamic(std::string aFilename)
Inform & level3(Inform &inf)
Inform & endl(Inform &inf)