7 #include "gsl/gsl_fft_real.h"
18 if (fieldFile.good()) {
74 std::vector<double> fieldComponents;
110 double &,
double &)
const {}
117 <<
" (1D electrostatic); zini= "
130 bool parsingPassed) {
134 parsingPassed = parsingPassed
135 && interpretLine<double>(fieldFile, tempDouble);
144 std::vector<double> fieldComponents)
const {
146 double radiusSq =
pow(
R(0), 2.0) +
pow(
R(1), 2.0);
147 double transverseEFactor = -fieldComponents.at(1) / 2.0
148 + radiusSq * fieldComponents.at(3) / 16.0;
150 E(0) +=
R(0) * transverseEFactor;
151 E(1) +=
R(1) * transverseEFactor;
152 E(2) += fieldComponents.at(0) - fieldComponents.at(2) * radiusSq / 4.0;
157 std::vector<double> &fieldComponents)
const {
161 fieldComponents.push_back(0.0);
162 fieldComponents.push_back(0.0);
163 fieldComponents.push_back(0.0);
169 double coskzn =
cos(kz *
n);
170 double sinkzn =
sin(kz *
n);
175 fieldComponents.at(1) += kn * (-
fourierCoefs_m.at(coefIndex) * sinkzn
178 double derivCoeff =
pow(kn, 2.0);
179 fieldComponents.at(2) += derivCoeff * (-
fourierCoefs_m.at(coefIndex) * coskzn
182 fieldComponents.at(3) += derivCoeff * (
fourierCoefs_m.at(coefIndex) * sinkzn
190 double fieldData[]) {
192 gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
193 gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
195 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
202 fourierCoefs_m.push_back(1.0e6 * fieldData[0] / (totalSize * maxEz));
203 for (
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; ++ coefIndex)
204 fourierCoefs_m.push_back(2.0 * 1.0e6 * fieldData[coefIndex] / (totalSize * maxEz));
206 gsl_fft_real_workspace_free(workSpace);
207 gsl_fft_real_wavetable_free(waveTable);
221 double fieldData[]) {
225 interpretLine<double>(fieldFile,
247 std::string tempString;
250 bool parsingPassed =
true;
252 parsingPassed = interpretLine<std::string, int>(fieldFile,
256 parsingPassed = interpretLine<std::string, int, std::string>(fieldFile,
262 if (tempString !=
"TRUE" &&
263 tempString !=
"FALSE")
265 "The third string on the first line of 1D field "
266 "maps has to be either TRUE or FALSE");
271 parsingPassed = parsingPassed &&
272 interpretLine<double, double, int>(fieldFile,
276 parsingPassed = parsingPassed &&
277 interpretLine<double, double, int>(fieldFile,
rBegin_m,
285 return parsingPassed;
290 std::string tempString;
292 getLine(fieldFile, tempString);
293 getLine(fieldFile, tempString);
294 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)
Inform & level3(Inform &inf)
constexpr double two_pi
The value of.
constexpr double e
The value of.
constexpr double pi
The value of.
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)
double readFileData(std::ifstream &fieldFile, double fieldData[])
double zBegin_m
Maximum radius of field.
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
void stripFileHeader(std::ifstream &fieldFile)
double rEnd_m
Minimum radius of field.
virtual void setFrequency(double freq)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
int accuracy_m
Number of grid points in field input file.
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
double length_m
Longitudinal end of field.
virtual double getFrequency() const
std::vector< double > fourierCoefs_m
Number of Fourier coefficients to use reconstructing field.
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
int numberOfGridPoints_m
Field length.
bool readFileHeader(std::ifstream &fieldFile)
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const
virtual void getInfo(Inform *)
FM1DElectroStatic(std::string aFilename)
void computeFourierCoefficients(double maxEz, double fieldData[])
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
double zEnd_m
Longitudinal start of field.