8#include "gsl/gsl_fft_real.h"
17 if (fieldFile.good()) {
66 std::vector<double> fieldComponents;
97 double& ,
double& ,
double& ,
double& ,
double& ,
126 std::vector<double> fieldComponents)
const {
127 double radiusSq = pow(R(0), 2.0) + pow(R(1), 2.0);
128 double transverseBFactor =
129 -fieldComponents.at(1) / 2.0 + radiusSq * fieldComponents.at(3) / 16.0;
131 B(0) += R(0) * transverseBFactor;
132 B(1) += R(1) * transverseBFactor;
133 B(2) += fieldComponents.at(0) - fieldComponents.at(2) * radiusSq / 4.0;
139 fieldComponents.push_back(0.0);
140 fieldComponents.push_back(0.0);
141 fieldComponents.push_back(0.0);
146 double coskzn = cos(kz * n);
147 double sinkzn = sin(kz * n);
149 fieldComponents.at(0) +=
152 fieldComponents.at(1) +=
156 double derivCoeff = pow(kn, 2.0);
157 fieldComponents.at(2) +=
161 fieldComponents.at(3) +=
171 gsl_fft_real_wavetable* waveTable = gsl_fft_real_wavetable_alloc(totalSize);
172 gsl_fft_real_workspace* workSpace = gsl_fft_real_workspace_alloc(totalSize);
174 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
182 for (
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; coefIndex++)
183 fourierCoefs_m.push_back(2.0 * fieldData[coefIndex] / (totalSize * maxBz));
185 gsl_fft_real_workspace_free(workSpace);
186 gsl_fft_real_wavetable_free(waveTable);
220 std::string tempString;
223 bool parsingPassed =
true;
228 fieldFile, tempString,
accuracy_m, tempString);
231 if (tempString !=
"TRUE" && tempString !=
"FALSE")
233 "FM1DMagnetoStatic::readFileHeader",
234 "The third string on the first line of 1D field "
235 "maps has to be either TRUE or FALSE");
250 return parsingPassed;
254 std::string tempString;
256 getLine(fieldFile, tempString);
257 getLine(fieldFile, tempString);
258 getLine(fieldFile, tempString);
ippl::Vector< T, Dim > Vector_t
constexpr double two_pi
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)
bool interpretLine(std::ifstream &in, S &value, const bool &file_length_known=true)
void getLine(std::ifstream &in, std::string &buffer)
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const
bool readFileHeader(std::ifstream &fieldFile)
std::vector< double > fourierCoefs_m
Number of Fourier coefficients to use reconstructing field.
virtual void setFrequency(double freq)
void computeFieldOffAxis(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, std::vector< double > fieldComponents) const
int numberOfGridPoints_m
Field length.
int accuracy_m
Number of grid points in field input file.
void stripFileHeader(std::ifstream &fieldFile)
friend class Fieldmap
Fourier coefficients derived from field map.
virtual double getFrequency() const
double length_m
Longitudinal end of field.
void computeFourierCoefficients(double maxEz, double fieldData[])
double rEnd_m
Minimum radius of field.
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
double zBegin_m
Maximum radius of field.
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 getFieldDimensions(double &zBegin, double &zEnd) const
double readFileData(std::ifstream &fieldFile, double fieldData[])
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
double zEnd_m
Longitudinal start of field.
virtual void getInfo(Inform *)
FM1DMagnetoStatic(std::string aFilename)