8#include "gsl/gsl_fft_real.h"
9#include "gsl/gsl_interp.h"
10#include "gsl/gsl_spline.h"
17 int skippedValues = 0;
18 std::string tmpString;
26 bool parsing_passed =
true;
28 parsing_passed = interpretLine<std::string, int>(file, tmpString,
accuracy_m);
30 parsing_passed = interpretLine<std::string, int, std::string>(
34 if (tmpString !=
"TRUE" && tmpString !=
"FALSE")
36 "Astra1DDynamic::Astra1DDynamic",
37 "The third string on the first line of 1D field "
38 "maps has to be either TRUE or FALSE");
43 parsing_passed = parsing_passed && interpretLine<double>(file,
frequency_m);
44 parsing_passed = parsing_passed && interpretLine<double, double>(file,
zbegin_m, tmpDouble);
47 while (!file.eof() && parsing_passed) {
48 parsing_passed = interpretLine<double, double>(file,
zend_m, tmpDouble,
false);
49 if (
zend_m - tmpDouble2 > 1
e-10) {
51 }
else if (parsing_passed) {
59 if (!parsing_passed && !file.eof()) {
63 "Astra1DDynamic::Astra1DDynamic",
64 "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);
114 parsing_passed = interpretLine<double, double>(in, zvals[i], RealValues[i]);
117 if (zvals[i] - tmpDouble > 1
e-10) {
118 if (std::abs(RealValues[i]) > Ez_max) {
119 Ez_max = std::abs(RealValues[i]);
121 tmpDouble = zvals[i];
127 gsl_spline_init(Ez_interpolant, zvals, RealValues,
num_gridpz_m);
134 RealValues[ii] = gsl_spline_eval(Ez_interpolant, z, Ez_accel);
140 RealValues[i] = RealValues[ii];
143 gsl_fft_real_transform(RealValues, 1, 2 *
num_gridpz_m, real, work);
150 for (
int i = 1; i < 2 *
accuracy_m - 1; ++i) {
154 gsl_spline_free(Ez_interpolant);
155 gsl_interp_accel_free(Ez_accel);
157 gsl_fft_real_workspace_free(work);
158 gsl_fft_real_wavetable_free(real);
180 const double RR2 = R(0) * R(0) + R(1) * R(1);
190 for (
int l = 1; l <
accuracy_m; ++l, n += 2) {
192 double somefactor = 1.0;
193 double coskzl = cos(kz * l);
194 double sinkzl = sin(kz * l);
196 somefactor *= somefactor_base;
198 somefactor *= somefactor_base;
200 somefactor *= somefactor_base;
207 const double EfieldR = -(ezp / 2. + fp * RR2);
210 E(0) += EfieldR * R(0);
211 E(1) += EfieldR * R(1);
212 E(2) += ez + 4. * f * RR2;
213 B(0) += -BfieldT * R(1);
214 B(1) += BfieldT * R(0);
241 double& ,
double& ,
double& ,
double& ,
double& ,
265 std::string tmpString;
269 interpretLine<std::string, int>(in, tmpString, tmpInt);
270 interpretLine<double>(in, tmpDouble);
273 interpretLine<double, double>(in, F[i].
first, F[i].
second);
274 if (std::abs(F[i].
second) > Ez_max) {
275 Ez_max = std::abs(F[i].
second);
281 F[i].second /= Ez_max;
constexpr KOKKOS_INLINE_FUNCTION auto second()
constexpr KOKKOS_INLINE_FUNCTION auto first()
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double two_pi
The value of.
constexpr double e
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)
std::unique_ptr< Inform > Info
virtual void setFrequency(double freq)
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const
virtual double getFrequency() const
virtual bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &F)
double *__restrict__ FourCoefs_m
virtual void getInfo(Inform *)
Astra1DDynamic(std::string aFilename)
void disableFieldmapWarning()
static std::string typeset_msg(const std::string &msg, const std::string &title)
void getLine(std::ifstream &in, std::string &buffer)