7 #include "gsl/gsl_fft_real.h" 
   19     if(fieldFile.good()) {
 
   56         std::vector<double> fourierCoefs
 
   64                                 onAxisFieldPP, onAxisFieldPPP);
 
   70         delete [] onAxisFieldP;
 
   71         delete [] onAxisFieldPP;
 
   72         delete [] onAxisFieldPPP;
 
  101     std::vector<double> fieldComponents;
 
  128                                                 double &, 
double &)
 const {}
 
  135            << 
" (1D magnetostatic); zini= " 
  148                                            bool parsingPassed) {
 
  152         parsingPassed = parsingPassed
 
  153             && interpretLine<double>(fieldFile, tempDouble);
 
  160                                                      double onAxisFieldP[],
 
  161                                                      double onAxisFieldPP[],
 
  162                                                      double onAxisFieldPPP[]) {
 
  168         onAxisFieldP[zStepIndex] = 0.0;
 
  169         onAxisFieldPP[zStepIndex] = 0.0;
 
  170         onAxisFieldPPP[zStepIndex] = 0.0;
 
  176             double coskzn = 
cos(kz * 
n);
 
  177             double sinkzn = 
sin(kz * 
n);
 
  179             onAxisFieldP[zStepIndex] += kn * (-fourierCoefs.at(coefIndex) * sinkzn
 
  180                                               - fourierCoefs.at(coefIndex + 1) * coskzn);
 
  182             double derivCoeff = 
pow(kn, 2.0);
 
  183             onAxisFieldPP[zStepIndex] += derivCoeff * (-fourierCoefs.at(coefIndex) * coskzn
 
  184                                                        + fourierCoefs.at(coefIndex + 1) * sinkzn);
 
  186             onAxisFieldPPP[zStepIndex] += derivCoeff * (fourierCoefs.at(coefIndex) * sinkzn
 
  187                                                         + fourierCoefs.at(coefIndex + 1) * coskzn);
 
  197                                                  std::vector<double> fieldComponents)
 const {
 
  199     double radiusSq = 
pow(
R(0), 2.0) + 
pow(
R(1), 2.0);
 
  200     double transverseBFactor = -fieldComponents.at(1) / 2.0
 
  201         + radiusSq * fieldComponents.at(3) / 16.0;
 
  203     B(0) += 
R(0) * transverseBFactor;
 
  204     B(1) += 
R(1) * transverseBFactor;
 
  205     B(2) += fieldComponents.at(0) - fieldComponents.at(2) * radiusSq / 4.0;
 
  210                                                 std::vector<double> &fieldComponents)
 const {
 
  225     gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
 
  226     gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
 
  229     double *fieldDataReflected = 
new double[totalSize];
 
  232             = fieldData[dataIndex];
 
  235                 = fieldData[dataIndex];
 
  238     gsl_fft_real_transform(fieldDataReflected, 1, totalSize, waveTable, workSpace);
 
  240     std::vector<double> fourierCoefs;
 
  241     fourierCoefs.push_back(fieldDataReflected[0] / totalSize);
 
  242     for (
unsigned int coefIndex = 1; coefIndex + 1 < 2 * 
accuracy_m; ++ coefIndex)
 
  243         fourierCoefs.push_back(2.0 * fieldDataReflected[coefIndex] / totalSize);
 
  245     delete [] fieldDataReflected;
 
  246     gsl_fft_real_workspace_free(workSpace);
 
  247     gsl_fft_real_wavetable_free(waveTable);
 
  254                                                          double onAxisFieldPP[],
 
  255                                                          double onAxisFieldPPP[]) {
 
  268         z[zStepIndex] = 
deltaZ_m * zStepIndex;
 
  303         fourierIterator < fourierCoefs.end(); ++ fourierIterator)
 
  304         *fourierIterator /= maxBz;
 
  309                                             double fieldData[]) {
 
  313         interpretLine<double>(fieldFile, fieldData[dataIndex]);
 
  314         if(
std::abs(fieldData[dataIndex]) > maxBz)
 
  315             maxBz = 
std::abs(fieldData[dataIndex]);
 
  323     std::string tempString;
 
  326     bool parsingPassed = 
true;
 
  329         parsingPassed = interpretLine<std::string, unsigned int>(fieldFile,
 
  333         parsingPassed = interpretLine<std::string, unsigned int, std::string>(fieldFile,
 
  339         if (tempString != 
"TRUE" &&
 
  340             tempString != 
"FALSE")
 
  342                                           "The third string on the first line of 1D field " 
  343                                           "maps has to be either TRUE or FALSE");
 
  348     parsingPassed = parsingPassed &&
 
  349         interpretLine<double, double, unsigned int>(fieldFile,
 
  353     parsingPassed = parsingPassed &&
 
  354         interpretLine<double, double, int>(fieldFile,
 
  364     return parsingPassed;
 
  369     std::string tempString;
 
  371     getLine(fieldFile, tempString);
 
  372     getLine(fieldFile, tempString);
 
  373     getLine(fieldFile, tempString);
 
  379         zSampling[zStepIndex] = 
deltaZ_m * zStepIndex;
 
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::iterator iterator
 
std::string toUpper(const std::string &str)
 
bool interpreteEOF(std::ifstream &in)
 
void checkMap(unsigned int accuracy, std::pair< double, double > fieldDimensions, double deltaZ, const std::vector< double > &fourierCoefficients, gsl_spline *splineCoefficients, gsl_interp_accel *splineAccelerator)
 
void disableFieldmapWarning()
 
static std::string typeset_msg(const std::string &msg, const std::string &title)
 
void getLine(std::ifstream &in, std::string &buffer)
 
virtual double getFrequency() const
 
void computeFieldDerivatives(std::vector< double > fourierCoefs, double onAxisFieldP[], double onAxisFieldPP[], double onAxisFieldPPP[])
 
void computeInterpolationVectors(double onAxisFieldP[], double onAxisFieldPP[], double onAxisFieldPPP[])
 
gsl_interp_accel * onAxisFieldAccel_m
On axis field third derivative interpolation structure.
 
void stripFileHeader(std::ifstream &fieldFile)
 
std::vector< double > computeFourierCoefficients(double fieldData[])
 
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
 
bool readFileHeader(std::ifstream &fieldFile)
 
unsigned int accuracy_m
Field grid point spacing.
 
FM1DMagnetoStatic_fast(std::string aFilename)
 
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const
 
gsl_spline * onAxisFieldPPInterpolants_m
On axis field first derivative interpolation structure.
 
gsl_spline * onAxisFieldPInterpolants_m
On axis field interpolation structure.
 
gsl_spline * onAxisFieldPPPInterpolants_m
On axis field second derivative interpolation structure.
 
unsigned int numberOfGridPoints_m
Field length.
 
double rEnd_m
Minimum radius of field.
 
~FM1DMagnetoStatic_fast()
 
void prepareForMapCheck(std::vector< double > &fourierCoefs)
 
virtual void getInfo(Inform *)
 
double deltaZ_m
Number of grid points in field input file.
 
void normalizeField(double maxBz, std::vector< double > &fourierCoefs)
 
double readFileData(std::ifstream &fieldFile, double fieldData[])
 
double zEnd_m
Longitudinal start of field.
 
gsl_interp_accel * onAxisFieldPAccel_m
 
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const
 
double length_m
Longitudinal end of field.
 
virtual void setFrequency(double freq)
 
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
 
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
 
gsl_interp_accel * onAxisFieldPPAccel_m
 
gsl_spline * onAxisFieldInterpolants_m
On axis field data.
 
gsl_interp_accel * onAxisFieldPPPAccel_m
 
double zBegin_m
Maximum radius of field.
 
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const