8#include "gsl/gsl_fft_real.h"
17 if (fieldFile.good()) {
66 std::vector<double> fieldComponents;
99 double& ,
double& ,
double& ,
double& ,
double& ,
138 std::vector<double> fieldComponents)
const {
139 double radiusSq = pow(R(0), 2.0) + pow(R(1), 2.0);
140 double transverseEFactor =
142 - radiusSq * fieldComponents.at(3) / 16.0);
143 double transverseBFactor =
145 - radiusSq * fieldComponents.at(2) / 16.0)
148 E(0) += -R(0) * transverseEFactor;
149 E(1) += -R(1) * transverseEFactor;
152 - radiusSq * fieldComponents.at(2) / 4.0);
154 B(0) += -R(1) * transverseBFactor;
155 B(1) += R(0) * transverseBFactor;
161 fieldComponents.push_back(0.0);
162 fieldComponents.push_back(0.0);
163 fieldComponents.push_back(0.0);
168 double coskzn = cos(kz * n);
169 double sinkzn = sin(kz * n);
171 fieldComponents.at(0) +=
174 fieldComponents.at(1) +=
178 double derivCoeff = pow(kn, 2.0);
179 fieldComponents.at(2) +=
183 fieldComponents.at(3) +=
193 gsl_fft_real_wavetable* waveTable = gsl_fft_real_wavetable_alloc(totalSize);
194 gsl_fft_real_workspace* workSpace = gsl_fft_real_workspace_alloc(totalSize);
195 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
204 for (
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; ++coefIndex)
205 fourierCoefs_m.push_back(2.0 * fieldData[coefIndex] / (totalSize * maxEz));
207 gsl_fft_real_workspace_free(workSpace);
208 gsl_fft_real_wavetable_free(waveTable);
247 std::ifstream& fieldFile, std::vector<std::pair<double, double>>& eZ) {
251 eZ.at(dataIndex).first = deltaZ * dataIndex;
253 if (std::abs(eZ.at(dataIndex).second) > maxEz)
254 maxEz = std::abs(eZ.at(dataIndex).second);
264 std::string tempString;
267 bool parsingPassed =
true;
272 fieldFile, tempString,
accuracy_m, tempString);
275 if (tempString !=
"TRUE" && tempString !=
"FALSE")
277 "FM1DDynamic::FM1DDynamic",
278 "The third string on the first line of 1D field "
279 "maps has to be either TRUE or FALSE");
296 return parsingPassed;
301 eZ.at(dataIndex).second /= maxEz;
305 std::string tempString;
307 getLine(fieldFile, tempString);
308 getLine(fieldFile, tempString);
309 getLine(fieldFile, tempString);
310 getLine(fieldFile, tempString);
ippl::Vector< T, Dim > Vector_t
constexpr double two_pi
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)
bool interpretLine(std::ifstream &in, S &value, const bool &file_length_known=true)
void getLine(std::ifstream &in, std::string &buffer)
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 getOnaxisEz(std::vector< std::pair< double, double > > &eZ)
double zBegin_m
Maximum radius of field.
void computeFieldOffAxis(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, std::vector< double > fieldComponents) const
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.
friend class Fieldmap
Fourier coefficients derived from field map.
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 void getFieldDimensions(double &zBegin, double &zEnd) const
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) 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 *)
bool readFileHeader(std::ifstream &fieldFile)
virtual void setFrequency(double freq)