8 #include "gsl/gsl_fft_real.h"
19 if(fieldFile.good()) {
77 std::vector<double> fieldComponents;
113 double &,
double &)
const {
121 <<
" (1D magnetostatic); zini= "
134 bool parsingPassed) {
138 parsingPassed = parsingPassed
139 && interpretLine<double>(fieldFile, tempDouble);
148 std::vector<double> fieldComponents)
const {
150 double radiusSq =
pow(
R(0), 2.0) +
pow(
R(1), 2.0);
151 double transverseBFactor = -fieldComponents.at(1) / 2.0
152 + radiusSq * fieldComponents.at(3) / 16.0;
154 B(0) +=
R(0) * transverseBFactor;
155 B(1) +=
R(1) * transverseBFactor;
156 B(2) += fieldComponents.at(0) - fieldComponents.at(2) * radiusSq / 4.0;
161 std::vector<double> &fieldComponents)
const {
165 fieldComponents.push_back(0.0);
166 fieldComponents.push_back(0.0);
167 fieldComponents.push_back(0.0);
173 double coskzn =
cos(kz *
n);
174 double sinkzn =
sin(kz * n);
179 fieldComponents.at(1) += kn * (-
fourierCoefs_m.at(coefIndex) * sinkzn
182 double derivCoeff =
pow(kn, 2.0);
183 fieldComponents.at(2) += derivCoeff * (-
fourierCoefs_m.at(coefIndex) * coskzn
186 fieldComponents.at(3) += derivCoeff * (
fourierCoefs_m.at(coefIndex) * sinkzn
194 double fieldData[]) {
196 gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
197 gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
199 gsl_fft_real_transform(fieldData, 1, totalSize, waveTable, workSpace);
207 for(
int coefIndex = 1; coefIndex < 2 *
accuracy_m - 1; coefIndex++)
208 fourierCoefs_m.push_back(2.0 * fieldData[coefIndex] / (totalSize * maxBz));
210 gsl_fft_real_workspace_free(workSpace);
211 gsl_fft_real_wavetable_free(waveTable);
225 double fieldData[]) {
229 interpretLine<double>(fieldFile, fieldData[numberOfGridPoints_m
231 if(
std::abs(fieldData[numberOfGridPoints_m + dataIndex]) > maxBz)
232 maxBz =
std::abs(fieldData[numberOfGridPoints_m + dataIndex]);
239 fieldData[numberOfGridPoints_m - 1 - dataIndex]
240 = fieldData[numberOfGridPoints_m + dataIndex];
251 std::string tempString;
254 bool parsingPassed =
true;
256 parsingPassed = interpretLine<std::string, int>(fieldFile,
260 parsingPassed = interpretLine<std::string, int, std::string>(fieldFile,
266 if (tempString !=
"TRUE" &&
267 tempString !=
"FALSE")
269 "The third string on the first line of 1D field "
270 "maps has to be either TRUE or FALSE");
274 parsingPassed = parsingPassed &&
275 interpretLine<double, double, int>(fieldFile,
zBegin_m,
278 parsingPassed = parsingPassed &&
279 interpretLine<double, double, int>(fieldFile,
rBegin_m,
287 return parsingPassed;
292 std::string tempString;
294 getLine(fieldFile, tempString);
295 getLine(fieldFile, tempString);
296 getLine(fieldFile, tempString);
constexpr double two_pi
The value of .
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
std::vector< double > fourierCoefs_m
Number of Fourier coefficients to use reconstructing field.
void computeFourierCoefficients(double maxEz, double fieldData[])
static std::string typeset_msg(const std::string &msg, const std::string &title)
virtual ~_FM1DMagnetoStatic()
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
constexpr double pi
The value of .
std::string toUpper(const std::string &str)
Inform & endl(Inform &inf)
bool interpreteEOF(std::ifstream &in)
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
void stripFileHeader(std::ifstream &fieldFile)
virtual double getFrequency() const
std::shared_ptr< _FM1DMagnetoStatic > FM1DMagnetoStatic
virtual void setFrequency(double freq)
virtual void getInfo(Inform *)
void disableFieldmapWarning()
double rEnd_m
Minimum radius of field.
double readFileData(std::ifstream &fieldFile, double fieldData[])
Tps< T > cos(const Tps< T > &x)
Cosine.
_FM1DMagnetoStatic(const std::string &filename)
int accuracy_m
Number of grid points in field input file.
void getLine(std::ifstream &in, std::string &buffer)
double length_m
Longitudinal end of field.
Inform & level3(Inform &inf)
bool readFileHeader(std::ifstream &fieldFile)
constexpr double e
The value of .
double zEnd_m
Longitudinal start of field.
int numberOfGridPoints_m
Field length.
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Tps< T > sin(const Tps< T > &x)
Sine.
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
double zBegin_m
Maximum radius of field.
static FM1DMagnetoStatic create(const std::string &filename)