8#include "gsl/gsl_fft_real.h"
19 if(fieldFile.good()) {
75 std::vector<double> fieldComponents;
112 double &,
double &)
const {
120 <<
" (1D dynamic); zini= "
148 parsingPassed = parsingPassed
149 && interpretLine<double>(fieldFile, tempDouble);
158 std::vector<double> fieldComponents)
const {
160 double radiusSq =
pow(
R(0), 2.0) +
pow(
R(1), 2.0);
161 double transverseEFactor = (fieldComponents.at(1)
163 - radiusSq * fieldComponents.at(3) / 16.0);
164 double transverseBFactor = ((fieldComponents.at(0)
166 - radiusSq * fieldComponents.at(2) / 16.0)
169 E(0) += -
R(0) * transverseEFactor;
170 E(1) += -
R(1) * transverseEFactor;
171 E(2) += (fieldComponents.at(0)
173 - radiusSq * fieldComponents.at(2) / 4.0);
175 B(0) += -
R(1) * transverseBFactor;
176 B(1) +=
R(0) * transverseBFactor;
181 std::vector<double> &fieldComponents)
const {
185 fieldComponents.push_back(0.0);
186 fieldComponents.push_back(0.0);
187 fieldComponents.push_back(0.0);
193 double coskzn =
cos(kz *
n);
194 double sinkzn =
sin(kz *
n);
199 fieldComponents.at(1) += kn * (-
fourierCoefs_m.at(coefIndex) * sinkzn
202 double derivCoeff =
pow(kn, 2.0);
203 fieldComponents.at(2) += derivCoeff * (-
fourierCoefs_m.at(coefIndex) * coskzn
206 fieldComponents.at(3) += derivCoeff * (
fourierCoefs_m.at(coefIndex) * sinkzn
215 gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
216 gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
217 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
226 for(
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; ++ coefIndex)
227 fourierCoefs_m.push_back(2.0 * fieldData[coefIndex] / (totalSize * maxEz));
229 gsl_fft_real_workspace_free(workSpace);
230 gsl_fft_real_wavetable_free(waveTable);
273 std::vector<std::pair<double, double>> &eZ) {
278 eZ.at(dataIndex).first = deltaZ * dataIndex;
279 interpretLine<double>(fieldFile, eZ.at(dataIndex).second);
280 if(
std::abs(eZ.at(dataIndex).second) > maxEz)
281 maxEz =
std::abs(eZ.at(dataIndex).second);
292 std::string tempString;
295 bool parsingPassed =
true;
297 parsingPassed = interpretLine<std::string, int>(fieldFile,
301 parsingPassed = interpretLine<std::string, int, std::string>(fieldFile,
307 if (tempString !=
"TRUE" &&
308 tempString !=
"FALSE")
310 "The third string on the first line of 1D field "
311 "maps has to be either TRUE or FALSE");
316 parsingPassed = parsingPassed &&
317 interpretLine<double, double, int>(fieldFile,
321 parsingPassed = parsingPassed &&
323 parsingPassed = parsingPassed &&
324 interpretLine<double, double, int>(fieldFile,
334 return parsingPassed;
339 eZ.at(dataIndex).second /= maxEz;
344 std::string tempString;
346 getLine(fieldFile, tempString);
347 getLine(fieldFile, tempString);
348 getLine(fieldFile, tempString);
349 getLine(fieldFile, tempString);
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Tps< T > sin(const Tps< T > &x)
Sine.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(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)
bool interpreteEOF(std::ifstream &in)
void disableFieldmapWarning()
static std::string typeset_msg(const std::string &msg, const std::string &title)
void getLine(std::ifstream &in, std::string &buffer)
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &eZ)
double zBegin_m
Maximum radius of field.
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
int numberOfGridPoints_m
Field length.
void stripFileHeader(std::ifstream &fieldFile)
FM1DDynamic(std::string aFilename)
double twoPiOverLambdaSq_m
Field angular frequency (Hz).
double readFileData(std::ifstream &fieldFile, double fieldData[])
std::vector< double > fourierCoefs_m
Number of Fourier coefficients to use reconstructing field.
double rEnd_m
Minimum radius of field.
double length_m
Longitudinal end of field.
void scaleField(double maxEz, std::vector< std::pair< double, double > > &eZ)
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
virtual double getFrequency() const
double zEnd_m
Longitudinal start of field.
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
int accuracy_m
Number of grid points in field input file.
void computeFourierCoefficients(double maxEz, double fieldData[])
double rBegin_m
2 Pi divided by the field RF wavelength squared.
virtual void getInfo(Inform *)
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
bool readFileHeader(std::ifstream &fieldFile)
virtual void setFrequency(double freq)