8 #include "gsl/gsl_fft_real.h" 
   22     if (fieldFile.good()) {
 
   70                                 onAxisFieldPP, onAxisFieldPPP);
 
   76         delete [] onAxisFieldP;
 
   77         delete [] onAxisFieldPP;
 
   78         delete [] onAxisFieldPPP;
 
  104     std::vector<double> fieldComponents;
 
  129                                           double &, 
double &)
 const {}
 
  136            << 
" (1D dynamic); zini= " 
  161                                      bool parsingPassed) {
 
  165         parsingPassed = parsingPassed
 
  166             && interpretLine<double>(fieldFile, tempDouble);
 
  173                                                double onAxisFieldP[],
 
  174                                                double onAxisFieldPP[],
 
  175                                                double onAxisFieldPPP[]) {
 
  181         onAxisFieldP[zStepIndex] = 0.0;
 
  182         onAxisFieldPP[zStepIndex] = 0.0;
 
  183         onAxisFieldPPP[zStepIndex] = 0.0;
 
  189             double coskzn = 
cos(kz * 
n);
 
  190             double sinkzn = 
sin(kz * n);
 
  192             onAxisFieldP[zStepIndex] += kn * (-fourierCoefs.at(coefIndex) * sinkzn
 
  193                                               - fourierCoefs.at(coefIndex + 1) * coskzn);
 
  195             double derivCoeff = 
pow(kn, 2.0);
 
  196             onAxisFieldPP[zStepIndex] += derivCoeff * (-fourierCoefs.at(coefIndex) * coskzn
 
  197                                                        + fourierCoefs.at(coefIndex + 1) * sinkzn);
 
  199             onAxisFieldPPP[zStepIndex] += derivCoeff * (fourierCoefs.at(coefIndex) * sinkzn
 
  200                                                         + fourierCoefs.at(coefIndex + 1) * coskzn);
 
  211                                            std::vector<double> fieldComponents)
 const {
 
  213     double radiusSq = 
pow(
R(0), 2.0) + 
pow(
R(1), 2.0);
 
  214     double transverseEFactor = (fieldComponents.at(1)
 
  216                                 - radiusSq * fieldComponents.at(3) / 16.0);
 
  217     double transverseBFactor = ((fieldComponents.at(0)
 
  219                                  - radiusSq * fieldComponents.at(2) / 16.0)
 
  222     E(0) += - 
R(0) * transverseEFactor;
 
  223     E(1) += - 
R(1) * transverseEFactor;
 
  225              - radiusSq * fieldComponents.at(2) / 4.0);
 
  227     B(0) += - 
R(1) * transverseBFactor;
 
  228     B(1) += 
R(0) * transverseBFactor;
 
  233                                           std::vector<double> &fieldComponents)
 
  248     gsl_fft_real_wavetable *waveTable = gsl_fft_real_wavetable_alloc(totalSize);
 
  249     gsl_fft_real_workspace *workSpace = gsl_fft_real_workspace_alloc(totalSize);
 
  252     double *fieldDataReflected = 
new double[totalSize];
 
  254         fieldDataReflected[numberOfGridPoints_m - 1 + dataIndex]
 
  255             = fieldData[dataIndex];
 
  257             fieldDataReflected[numberOfGridPoints_m - 1 - dataIndex]
 
  258                 = fieldData[dataIndex];
 
  261     gsl_fft_real_transform(fieldDataReflected, 1,
 
  263                            waveTable, workSpace);
 
  265     std::vector<double> fourierCoefs;
 
  266     fourierCoefs.push_back(fieldDataReflected[0] / totalSize);
 
  267     for (
unsigned int coefIndex = 1; coefIndex < 2 * 
accuracy_m - 1; ++ coefIndex)
 
  268         fourierCoefs.push_back(2.0 * fieldDataReflected[coefIndex] / totalSize);
 
  270     delete [] fieldDataReflected;
 
  271     gsl_fft_real_workspace_free(workSpace);
 
  272     gsl_fft_real_wavetable_free(waveTable);
 
  279                                                    double onAxisFieldPP[],
 
  280                                                    double onAxisFieldPPP[]) {
 
  293         z[zStepIndex] = 
deltaZ_m * zStepIndex;
 
  297                     onAxisFieldP, numberOfGridPoints_m);
 
  299                     onAxisFieldPP, numberOfGridPoints_m);
 
  301                     onAxisFieldPPP, numberOfGridPoints_m);
 
  326                                       std::vector<double> &fourierCoefs) {
 
  332         fourierIterator < fourierCoefs.end(); ++ fourierIterator)
 
  333         *fourierIterator/= (maxEz * Units::Vpm2MVpm);
 
  338                                       double fieldData[]) {
 
  342         interpretLine<double>(fieldFile, fieldData[dataIndex]);
 
  343         if (
std::abs(fieldData[dataIndex]) > maxEz)
 
  344             maxEz = 
std::abs(fieldData[dataIndex]);
 
  354                                       std::vector<std::pair<double, double>> &eZ) {
 
  359         eZ.at(dataIndex).first = deltaZ * dataIndex;
 
  360         interpretLine<double>(fieldFile, eZ.at(dataIndex).second);
 
  361         if (
std::abs(eZ.at(dataIndex).second) > maxEz)
 
  362             maxEz = 
std::abs(eZ.at(dataIndex).second);
 
  373     std::string tempString;
 
  376     bool parsingPassed = 
true;
 
  378         parsingPassed = interpretLine<std::string, unsigned int>(fieldFile,
 
  382         parsingPassed = interpretLine<std::string, unsigned int, std::string>(fieldFile,
 
  388         if (tempString != 
"TRUE" &&
 
  389             tempString != 
"FALSE")
 
  391                                           "The third string on the first line of 1D field " 
  392                                           "maps has to be either TRUE or FALSE");
 
  396     parsingPassed = parsingPassed &&
 
  397         interpretLine<double, double, unsigned int>(fieldFile,
 
  401     parsingPassed = parsingPassed &&
 
  403     parsingPassed = parsingPassed &&
 
  404         interpretLine<double, double, int>(fieldFile,
 
  414     return parsingPassed;
 
  418                                   std::vector<std::pair<double, double>> &eZ) {
 
  422         eZ.at(dataIndex).second /= maxEz;
 
  427     std::string tempString;
 
  429     getLine(fieldFile, tempString);
 
  430     getLine(fieldFile, tempString);
 
  431     getLine(fieldFile, tempString);
 
  432     getLine(fieldFile, tempString);
 
  438         zSampling[zStepIndex] = 
deltaZ_m * zStepIndex;
 
virtual double getFrequency() const 
constexpr double c
The velocity of light in m/s. 
virtual void setFrequency(double freq)
gsl_interp_accel * onAxisFieldPAccel_m
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const 
constexpr double two_pi
The value of . 
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
gsl_spline * onAxisFieldPPInterpolants_m
On axis field first derivative interpolation structure. 
double deltaZ_m
Number of grid points in field input file. 
static FM1DDynamic_fast create(const std::string &filename)
gsl_spline * onAxisFieldPPPInterpolants_m
On axis field second derivative interpolation structure. 
static std::string typeset_msg(const std::string &msg, const std::string &title)
void stripFileHeader(std::ifstream &fieldFile)
virtual void getInfo(Inform *)
double rBegin_m
2 Pi divided by the field RF wavelength squared. 
constexpr double pi
The value of . 
std::string toUpper(const std::string &str)
constexpr double Vpm2MVpm
Inform & endl(Inform &inf)
void computeFieldOffAxis(const Vector_t &R, Vector_t &E, Vector_t &B, std::vector< double > fieldComponents) const 
bool interpreteEOF(std::ifstream &in)
void computeFieldDerivatives(std::vector< double > fourierCoefs, double onAxisFieldP[], double onAxisFieldPP[], double onAxisFieldPPP[])
bool readFileHeader(std::ifstream &fieldFile)
double readFileData(std::ifstream &fieldFile, double fieldData[])
std::string::iterator iterator
gsl_interp_accel * onAxisFieldPPPAccel_m
std::shared_ptr< _FM1DDynamic_fast > FM1DDynamic_fast
virtual ~_FM1DDynamic_fast()
double twoPiOverLambdaSq_m
Field angular frequency (Hz). 
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const 
void normalizeField(double maxEz, std::vector< double > &fourierCoefs)
_FM1DDynamic_fast(const std::string &filename)
double rEnd_m
Minimum radius of field. 
double zEnd_m
Longitudinal start of field. 
void disableFieldmapWarning()
unsigned int accuracy_m
Field grid point spacing. 
Tps< T > cos(const Tps< T > &x)
Cosine. 
void prepareForMapCheck(std::vector< double > &fourierCoefs)
gsl_interp_accel * onAxisFieldAccel_m
On axis field third derivative interpolation structure. 
gsl_interp_accel * onAxisFieldPPAccel_m
void getLine(std::ifstream &in, std::string &buffer)
virtual void getFieldDimensions(double &zBegin, double &zEnd) const 
constexpr double e
The value of . 
unsigned int numberOfGridPoints_m
Field length. 
Tps< T > pow(const Tps< T > &x, int y)
Integer power. 
Tps< T > sin(const Tps< T > &x)
Sine. 
void computeInterpolationVectors(double onAxisFieldP[], double onAxisFieldPP[], double onAxisFieldPPP[])
virtual void getOnaxisEz(std::vector< std::pair< double, double >> &eZ)
double length_m
Longitudinal end of field. 
std::vector< double > computeFourierCoefficients(double fieldData[])
gsl_spline * onAxisFieldPInterpolants_m
On axis field interpolation structure. 
void checkMap(unsigned int accuracy, std::pair< double, double > fieldDimensions, double deltaZ, const std::vector< double > &fourierCoefficients, gsl_spline *splineCoefficients, gsl_interp_accel *splineAccelerator)
double zBegin_m
Maximum radius of field. 
bool checkFileData(std::ifstream &fieldFile, bool parsingPassed)
void computeFieldOnAxis(double z, std::vector< double > &fieldComponents) const 
gsl_spline * onAxisFieldInterpolants_m
On axis field data. 
void scaleField(double maxEz, std::vector< std::pair< double, double >> &eZ)