8#include "gsl/gsl_interp.h"
9#include "gsl/gsl_spline.h"
10#include "gsl/gsl_fft_real.h"
21 int skippedValues = 0;
22 std::string tmpString;
30 bool parsing_passed = true;
32 parsing_passed = interpretLine<std::string, int>(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 &&
53 parsing_passed = parsing_passed &&
57 while(!file.eof() && parsing_passed) {
59 if (
zend_m - tmpDouble2 > 1e-10) {
61 }
else if (parsing_passed) {
69 if (!parsing_passed && !file.eof()) {
73 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
102 bool parsing_passed =
true;
104 std::string tmpString;
113 gsl_spline *Ez_interpolant = gsl_spline_alloc(gsl_interp_cspline,
num_gridpz_m);
114 gsl_interp_accel *Ez_accel = gsl_interp_accel_alloc();
116 gsl_fft_real_wavetable *
real = gsl_fft_real_wavetable_alloc(2 *
num_gridpz_m);
117 gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(2 *
num_gridpz_m);
131 if (zvals[i] - tmpDouble > 1e-10) {
132 if (std::abs(RealValues[i]) > Ez_max) {
133 Ez_max = std::abs(RealValues[i]);
135 tmpDouble = zvals[i];
141 gsl_spline_init(Ez_interpolant, zvals, RealValues,
num_gridpz_m);
148 RealValues[ii] = gsl_spline_eval(Ez_interpolant, z, Ez_accel);
154 RealValues[i] = RealValues[ii];
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);
190 const double RR2 = R(0) * R(0) + R(1) * R(1);
200 for (
int l = 1; l <
accuracy_m ; ++ l, n += 2) {
202 double somefactor = 1.0;
203 double coskzl =
cos(kz * l);
204 double sinkzl =
sin(kz * l);
206 somefactor *= somefactor_base;
208 somefactor *= somefactor_base;
210 somefactor *= somefactor_base;
217 const double EfieldR = -(ezp / 2. + fp * RR2);
220 E(0) += EfieldR * R(0);
221 E(1) += EfieldR * R(1);
222 E(2) += ez + 4. * f * RR2;
223 B(0) += -BfieldT * R(1);
224 B(1) += BfieldT * R(0);
268 std::string tmpString;
277 if (std::abs(F[i].second) > Ez_max) {
278 Ez_max = std::abs(F[i].second);
284 F[i].second /= Ez_max;
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
std::shared_ptr< _Astra1DDynamic > Astra1DDynamic
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double two_pi
The value of.
constexpr double c
The velocity of light in m/s.
constexpr double pi
The value of.
constexpr double Vpm2MVpm
std::string toUpper(const std::string &str)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &F)
virtual double getFrequency() const
double *__restrict__ FourCoefs_m
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
static Astra1DDynamic create(const std::string &filename)
_Astra1DDynamic(const std::string &filename)
virtual void getInfo(Inform *)
virtual void setFrequency(double freq)
virtual ~_Astra1DDynamic()
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
static std::string typeset_msg(const std::string &msg, const std::string &title)
void disableFieldmapWarning()
void getLine(std::ifstream &in, std::string &buffer)
bool interpretLine(std::ifstream &in, S &value, const bool &file_length_known=true)
Vektor< double, 3 > Vector_t