8 #include "gsl/gsl_interp.h"
9 #include "gsl/gsl_spline.h"
10 #include "gsl/gsl_fft_real.h"
17 FourCoefs_m(nullptr) {
20 int skippedValues = 0;
21 std::string tmpString;
29 bool parsing_passed =
true;
31 parsing_passed = interpretLine<std::string, int>(file, tmpString,
accuracy_m);
33 parsing_passed = interpretLine<std::string, int, std::string>(file,
39 if (tmpString !=
"TRUE" &&
42 "The third string on the first line of 1D field "
43 "maps has to be either TRUE or FALSE");
48 parsing_passed = parsing_passed &&
49 interpretLine<double, double>(file,
zbegin_m, tmpDouble);
52 while(!file.eof() && parsing_passed) {
53 parsing_passed = interpretLine<double, double>(file,
zend_m, tmpDouble,
false);
54 if (zend_m - tmpDouble2 > 1e-10) {
56 }
else if (parsing_passed) {
64 if (!parsing_passed && !file.eof()) {
68 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
94 bool parsing_passed =
true;
96 std::string tmpString;
105 gsl_spline *Ez_interpolant = gsl_spline_alloc(gsl_interp_cspline,
num_gridpz_m);
106 gsl_interp_accel *Ez_accel = gsl_interp_accel_alloc();
108 gsl_fft_real_wavetable *
real = gsl_fft_real_wavetable_alloc(2 *
num_gridpz_m);
109 gsl_fft_real_workspace *
work = gsl_fft_real_workspace_alloc(2 *
num_gridpz_m);
118 parsing_passed = interpretLine<double, double>(in, zvals[i], RealValues[i]);
121 if (zvals[i] - tmpDouble > 1
e-10) {
122 if (
std::abs(RealValues[i]) > Ez_max) {
125 tmpDouble = zvals[i];
131 gsl_spline_init(Ez_interpolant, zvals, RealValues,
num_gridpz_m);
138 RealValues[ii] = gsl_spline_eval(Ez_interpolant, z, Ez_accel);
140 RealValues[ii ++] = RealValues[num_gridpz_m - 1];
144 RealValues[i] = RealValues[ii];
150 gsl_fft_real_transform(RealValues, 1, num_gridpz_m, real, work);
157 for (
int i = 1; i < 2 *
accuracy_m - 1; i++) {
161 gsl_fft_real_workspace_free(work);
162 gsl_fft_real_wavetable_free(real);
164 gsl_spline_free(Ez_interpolant);
165 gsl_interp_accel_free(Ez_accel);
185 const double RR2 =
R(0) *
R(0) +
R(1) *
R(1);
195 for (
int l = 1; l <
accuracy_m ; l++, n += 2) {
197 double somefactor = 1.0;
198 double coskzl =
cos(kz * l);
199 double sinkzl =
sin(kz * l);
201 somefactor *= somefactor_base;
203 somefactor *= somefactor_base;
205 somefactor *= somefactor_base;
210 const double EfieldR = -ezp / 2. + ezppp / 16. * RR2;
212 E(0) += EfieldR *
R(0);
213 E(1) += EfieldR *
R(1);
214 E(2) += ez - ezpp * RR2 / 4.;
static Astra1DElectroStatic create(const std::string &filename)
virtual double getFrequency() const
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
constexpr double MVpm2Vpm
constexpr double two_pi
The value of .
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
static std::string typeset_msg(const std::string &msg, const std::string &title)
constexpr double pi
The value of .
std::string toUpper(const std::string &str)
Inform & endl(Inform &inf)
_Astra1DElectroStatic(const std::string &filename)
virtual void setFrequency(double freq)
virtual ~_Astra1DElectroStatic()
virtual void getInfo(Inform *)
void disableFieldmapWarning()
Tps< T > cos(const Tps< T > &x)
Cosine.
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or work
void getLine(std::ifstream &in, std::string &buffer)
std::shared_ptr< _Astra1DElectroStatic > Astra1DElectroStatic
Inform & level3(Inform &inf)
constexpr double e
The value of .
Tps< T > sin(const Tps< T > &x)
Sine.
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.