8 #include "gsl/gsl_fft_real.h"
19 if(fieldFile.good()) {
76 std::vector<double> fieldComponents;
113 double &,
double &)
const {
121 <<
" (1D dynamic); zini= "
149 parsingPassed = parsingPassed
150 && interpretLine<double>(fieldFile, tempDouble);
159 std::vector<double> fieldComponents)
const {
161 double radiusSq =
pow(
R(0), 2.0) +
pow(
R(1), 2.0);
162 double transverseEFactor = (fieldComponents.at(1)
164 - radiusSq * fieldComponents.at(3) / 16.0);
165 double transverseBFactor = ((fieldComponents.at(0)
167 - radiusSq * fieldComponents.at(2) / 16.0)
170 E(0) += -
R(0) * transverseEFactor;
171 E(1) += -
R(1) * transverseEFactor;
172 E(2) += (fieldComponents.at(0)
174 - radiusSq * fieldComponents.at(2) / 4.0);
176 B(0) += -
R(1) * transverseBFactor;
177 B(1) +=
R(0) * transverseBFactor;
182 std::vector<double> &fieldComponents)
const {
186 fieldComponents.push_back(0.0);
187 fieldComponents.push_back(0.0);
188 fieldComponents.push_back(0.0);
194 double coskzn =
cos(kz *
n);
195 double sinkzn =
sin(kz * n);
200 fieldComponents.at(1) += kn * (-
fourierCoefs_m.at(coefIndex) * sinkzn
203 double derivCoeff =
pow(kn, 2.0);
204 fieldComponents.at(2) += derivCoeff * (-
fourierCoefs_m.at(coefIndex) * coskzn
207 fieldComponents.at(3) += derivCoeff * (
fourierCoefs_m.at(coefIndex) * sinkzn
216 gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
217 gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
218 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
227 for(
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; ++ coefIndex)
228 fourierCoefs_m.push_back(2.0 * fieldData[coefIndex] / (totalSize * maxEz));
230 gsl_fft_real_workspace_free(workSpace);
231 gsl_fft_real_wavetable_free(waveTable);
253 interpretLine<double>(fieldFile, fieldData[numberOfGridPoints_m
255 if(
std::abs(fieldData[numberOfGridPoints_m + dataIndex]) > maxEz)
256 maxEz =
std::abs(fieldData[numberOfGridPoints_m + dataIndex]);
263 fieldData[numberOfGridPoints_m - 1 - dataIndex]
264 = fieldData[numberOfGridPoints_m + dataIndex];
274 std::vector<std::pair<double, double>> &eZ) {
279 eZ.at(dataIndex).first = deltaZ * dataIndex;
280 interpretLine<double>(fieldFile, eZ.at(dataIndex).second);
281 if(
std::abs(eZ.at(dataIndex).second) > maxEz)
282 maxEz =
std::abs(eZ.at(dataIndex).second);
293 std::string tempString;
296 bool parsingPassed =
true;
298 parsingPassed = interpretLine<std::string, int>(fieldFile,
302 parsingPassed = interpretLine<std::string, int, std::string>(fieldFile,
308 if (tempString !=
"TRUE" &&
309 tempString !=
"FALSE")
311 "The third string on the first line of 1D field "
312 "maps has to be either TRUE or FALSE");
317 parsingPassed = parsingPassed &&
318 interpretLine<double, double, int>(fieldFile,
322 parsingPassed = parsingPassed &&
324 parsingPassed = parsingPassed &&
325 interpretLine<double, double, int>(fieldFile,
335 return parsingPassed;
340 eZ.at(dataIndex).second /= maxEz;
345 std::string tempString;
347 getLine(fieldFile, tempString);
348 getLine(fieldFile, tempString);
349 getLine(fieldFile, tempString);
350 getLine(fieldFile, tempString);
constexpr double c
The velocity of light in m/s.
virtual void setFrequency(double freq)
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
constexpr double two_pi
The value of .
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
virtual double getFrequency() const
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
static FM1DDynamic create(const std::string &filename)
virtual void getOnaxisEz(std::vector< std::pair< double, double >> &eZ)
bool readFileHeader(std::ifstream &fieldFile)
static std::string typeset_msg(const std::string &msg, const std::string &title)
int numberOfGridPoints_m
Field length.
constexpr double pi
The value of .
std::string toUpper(const std::string &str)
constexpr double Vpm2MVpm
Inform & endl(Inform &inf)
double zEnd_m
Longitudinal start of field.
double zBegin_m
Maximum radius of field.
bool interpreteEOF(std::ifstream &in)
void stripFileHeader(std::ifstream &fieldFile)
virtual void getInfo(Inform *)
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const
double length_m
Longitudinal end of field.
double twoPiOverLambdaSq_m
Field angular frequency (Hz).
_FM1DDynamic(const std::string &filename)
void disableFieldmapWarning()
Tps< T > cos(const Tps< T > &x)
Cosine.
double rEnd_m
Minimum radius of field.
std::shared_ptr< _FM1DDynamic > FM1DDynamic
void scaleField(double maxEz, std::vector< std::pair< double, double >> &eZ)
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
void getLine(std::ifstream &in, std::string &buffer)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
void computeFourierCoefficients(double maxEz, double fieldData[])
double rBegin_m
2 Pi divided by the field RF wavelength squared.
constexpr double e
The value of .
int accuracy_m
Number of grid points in field input file.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Tps< T > sin(const Tps< T > &x)
Sine.
double readFileData(std::ifstream &fieldFile, double fieldData[])
std::vector< double > fourierCoefs_m
Number of Fourier coefficients to use reconstructing field.