7 #include "gsl/gsl_fft_real.h"
18 if(fieldFile.good()) {
74 std::vector<double> fieldComponents;
105 double &rBegin,
double &rEnd)
const {
113 double &yIni,
double &yFinal,
114 double &zIni,
double &zFinal)
const {
122 <<
" (1D dynamic); zini= "
150 parsingPassed = parsingPassed
151 && interpreteLine<double>(fieldFile, tempDouble);
160 std::vector<double> fieldComponents)
const {
162 double radiusSq =
pow(
R(0), 2.0) +
pow(
R(1), 2.0);
163 double transverseEFactor = (fieldComponents.at(1)
165 - radiusSq * fieldComponents.at(3) / 16.0);
166 double transverseBFactor = ((fieldComponents.at(0)
168 - radiusSq * fieldComponents.at(2) / 16.0)
171 E(0) += -
R(0) * transverseEFactor;
172 E(1) += -
R(1) * transverseEFactor;
173 E(2) += (fieldComponents.at(0)
175 - radiusSq * fieldComponents.at(2) / 4.0);
177 B(0) += -
R(1) * transverseBFactor;
178 B(1) +=
R(0) * transverseBFactor;
183 std::vector<double> &fieldComponents)
const {
187 fieldComponents.push_back(0.0);
188 fieldComponents.push_back(0.0);
189 fieldComponents.push_back(0.0);
195 double coskzn =
cos(kz *
n);
196 double sinkzn =
sin(kz * n);
201 fieldComponents.at(1) += kn * (-
fourierCoefs_m.at(coefIndex) * sinkzn
204 double derivCoeff =
pow(kn, 2.0);
205 fieldComponents.at(2) += derivCoeff * (-
fourierCoefs_m.at(coefIndex) * coskzn
208 fieldComponents.at(3) += derivCoeff * (
fourierCoefs_m.at(coefIndex) * sinkzn
217 gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
218 gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
219 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
228 for(
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; ++ coefIndex)
229 fourierCoefs_m.push_back(2.0 * fieldData[coefIndex] / (totalSize * maxEz));
231 gsl_fft_real_workspace_free(workSpace);
232 gsl_fft_real_wavetable_free(waveTable);
254 interpreteLine<double>(fieldFile, fieldData[numberOfGridPoints_m
256 if(
std::abs(fieldData[numberOfGridPoints_m + dataIndex]) > maxEz)
257 maxEz =
std::abs(fieldData[numberOfGridPoints_m + dataIndex]);
264 fieldData[numberOfGridPoints_m - 1 - dataIndex]
265 = fieldData[numberOfGridPoints_m + dataIndex];
275 std::vector<std::pair<double, double>> &eZ) {
280 eZ.at(dataIndex).first = deltaZ * dataIndex;
281 interpreteLine<double>(fieldFile, eZ.at(dataIndex).second);
282 if(
std::abs(eZ.at(dataIndex).second) > maxEz)
283 maxEz =
std::abs(eZ.at(dataIndex).second);
294 std::string tempString;
297 bool parsingPassed =
true;
299 parsingPassed = interpreteLine<std::string, int>(fieldFile,
303 parsingPassed = interpreteLine<std::string, int, std::string>(fieldFile,
309 if (tempString !=
"TRUE" &&
310 tempString !=
"FALSE")
312 "The third string on the first line of 1D field "
313 "maps has to be either TRUE or FALSE");
318 parsingPassed = parsingPassed &&
319 interpreteLine<double, double, int>(fieldFile,
323 parsingPassed = parsingPassed &&
325 parsingPassed = parsingPassed &&
326 interpreteLine<double, double, int>(fieldFile,
336 return parsingPassed;
341 eZ.at(dataIndex).second /= maxEz;
346 std::string tempString;
348 getLine(fieldFile, tempString);
349 getLine(fieldFile, tempString);
350 getLine(fieldFile, tempString);
351 getLine(fieldFile, tempString);
virtual void setFrequency(double freq)
int accuracy_m
Number of grid points in field input file.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
virtual void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
constexpr double e
The value of .
int numberOfGridPoints_m
Field length.
Tps< T > sin(const Tps< T > &x)
Sine.
double rBegin_m
2 Pi divided by the field RF wavelength squared.
constexpr double two_pi
The value of .
double rEnd_m
Minimum radius of field.
double readFileData(std::ifstream &fieldFile, double fieldData[])
std::string toUpper(const std::string &str)
void disableFieldmapWarning()
virtual void getOnaxisEz(std::vector< std::pair< double, double >> &eZ)
static std::string typeset_msg(const std::string &msg, const std::string &title)
FM1DDynamic(std::string aFilename)
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
bool readFileHeader(std::ifstream &fieldFile)
constexpr double pi
The value of .
constexpr double c
The velocity of light in m/s.
bool interpreteEOF(std::ifstream &in)
double length_m
Longitudinal end of field.
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
double zBegin_m
Maximum radius of field.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
std::vector< double > fourierCoefs_m
Number of Fourier coefficients to use reconstructing field.
void scaleField(double maxEz, std::vector< std::pair< double, double >> &eZ)
virtual double getFrequency() const
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
Tps< T > cos(const Tps< T > &x)
Cosine.
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const
void getLine(std::ifstream &in, std::string &buffer)
double twoPiOverLambdaSq_m
Field angular frequency (Hz).
double zEnd_m
Longitudinal start of field.
void stripFileHeader(std::ifstream &fieldFile)
void computeFourierCoefficients(double maxEz, double fieldData[])
virtual void getInfo(Inform *)
Inform & endl(Inform &inf)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const