7 #include "gsl/gsl_fft_real.h"
18 if (fieldFile.good()) {
74 std::vector<double> fieldComponents;
105 double &rBegin,
double &rEnd)
const {
112 double &yIni,
double &yFinal,
113 double &zIni,
double &zFinal)
const {}
120 <<
" (1D electrostatic); zini= "
133 bool parsingPassed) {
137 parsingPassed = parsingPassed
138 && interpreteLine<double>(fieldFile, tempDouble);
147 std::vector<double> fieldComponents)
const {
149 double radiusSq =
pow(
R(0), 2.0) +
pow(
R(1), 2.0);
150 double transverseEFactor = -fieldComponents.at(1) / 2.0
151 + radiusSq * fieldComponents.at(3) / 16.0;
153 E(0) +=
R(0) * transverseEFactor;
154 E(1) +=
R(1) * transverseEFactor;
155 E(2) += fieldComponents.at(0) - fieldComponents.at(2) * radiusSq / 4.0;
160 std::vector<double> &fieldComponents)
const {
164 fieldComponents.push_back(0.0);
165 fieldComponents.push_back(0.0);
166 fieldComponents.push_back(0.0);
172 double coskzn =
cos(kz *
n);
173 double sinkzn =
sin(kz * n);
178 fieldComponents.at(1) += kn * (-
fourierCoefs_m.at(coefIndex) * sinkzn
181 double derivCoeff =
pow(kn, 2.0);
182 fieldComponents.at(2) += derivCoeff * (-
fourierCoefs_m.at(coefIndex) * coskzn
185 fieldComponents.at(3) += derivCoeff * (
fourierCoefs_m.at(coefIndex) * sinkzn
193 double fieldData[]) {
195 gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
196 gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
198 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
205 fourierCoefs_m.push_back(1.0e6 * fieldData[0] / (totalSize * maxEz));
206 for (
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; ++ coefIndex)
207 fourierCoefs_m.push_back(2.0 * 1.0e6 * fieldData[coefIndex] / (totalSize * maxEz));
209 gsl_fft_real_workspace_free(workSpace);
210 gsl_fft_real_wavetable_free(waveTable);
224 double fieldData[]) {
228 interpreteLine<double>(fieldFile,
229 fieldData[numberOfGridPoints_m - 1 + dataIndex]);
230 if (
std::abs(fieldData[numberOfGridPoints_m + dataIndex]) > maxEz)
231 maxEz =
std::abs(fieldData[numberOfGridPoints_m + dataIndex]);
238 fieldData[numberOfGridPoints_m - 1 - dataIndex]
239 = fieldData[numberOfGridPoints_m + dataIndex];
250 std::string tempString;
253 bool parsingPassed =
true;
255 parsingPassed = interpreteLine<std::string, int>(fieldFile,
259 parsingPassed = interpreteLine<std::string, int, std::string>(fieldFile,
265 if (tempString !=
"TRUE" &&
266 tempString !=
"FALSE")
268 "The third string on the first line of 1D field "
269 "maps has to be either TRUE or FALSE");
274 parsingPassed = parsingPassed &&
275 interpreteLine<double, double, int>(fieldFile,
279 parsingPassed = parsingPassed &&
280 interpreteLine<double, double, int>(fieldFile,
rBegin_m,
288 return parsingPassed;
293 std::string tempString;
295 getLine(fieldFile, tempString);
296 getLine(fieldFile, tempString);
297 getLine(fieldFile, tempString);
bool readFileHeader(std::ifstream &fieldFile)
void computeFourierCoefficients(double maxEz, double fieldData[])
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
constexpr double e
The value of .
Tps< T > sin(const Tps< T > &x)
Sine.
constexpr double two_pi
The value of .
double readFileData(std::ifstream &fieldFile, double fieldData[])
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
std::string toUpper(const std::string &str)
virtual void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
void disableFieldmapWarning()
static std::string typeset_msg(const std::string &msg, const std::string &title)
int accuracy_m
Number of grid points in field input file.
virtual double getFrequency() const
virtual void getInfo(Inform *)
constexpr double pi
The value of .
double length_m
Longitudinal end of field.
bool interpreteEOF(std::ifstream &in)
virtual void setFrequency(double freq)
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
double zEnd_m
Longitudinal start of field.
std::vector< double > fourierCoefs_m
Number of Fourier coefficients to use reconstructing field.
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
void stripFileHeader(std::ifstream &fieldFile)
double rEnd_m
Minimum radius of field.
FM1DElectroStatic(std::string aFilename)
Tps< T > cos(const Tps< T > &x)
Cosine.
void getLine(std::ifstream &in, std::string &buffer)
Inform & level3(Inform &inf)
double zBegin_m
Maximum radius of field.
int numberOfGridPoints_m
Field length.
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const
Inform & endl(Inform &inf)