Commit 92a0b366 authored by kraus's avatar kraus

- simplify classes for Astra fieldmaps;

    - fixing number of particles when the numbers don't add up to the total due to rounding errors;
    - clean up: rename files to comply with coding guide lines;
    - improve message when field of bend overlapps;
    - warning is emitted if too few fourier coefficients are used to filter the field map;
parent d6c1738e
......@@ -290,17 +290,17 @@ classic/5.0/src/Construction/Factory.cpp -text
classic/5.0/src/Construction/Factory.h -text
classic/5.0/src/Fields/AcceleratingField.h -text
classic/5.0/src/Fields/Astra1DDynamic.cpp -text
classic/5.0/src/Fields/Astra1DDynamic.hh -text
classic/5.0/src/Fields/Astra1DDynamic.h -text
classic/5.0/src/Fields/Astra1DDynamic_fast.cpp -text
classic/5.0/src/Fields/Astra1DDynamic_fast.hh -text
classic/5.0/src/Fields/Astra1DDynamic_fast.h -text
classic/5.0/src/Fields/Astra1DElectroStatic.cpp -text
classic/5.0/src/Fields/Astra1DElectroStatic.hh -text
classic/5.0/src/Fields/Astra1DElectroStatic.h -text
classic/5.0/src/Fields/Astra1DElectroStatic_fast.cpp -text
classic/5.0/src/Fields/Astra1DElectroStatic_fast.hh -text
classic/5.0/src/Fields/Astra1DElectroStatic_fast.h -text
classic/5.0/src/Fields/Astra1DMagnetoStatic.cpp -text
classic/5.0/src/Fields/Astra1DMagnetoStatic.hh -text
classic/5.0/src/Fields/Astra1DMagnetoStatic.h -text
classic/5.0/src/Fields/Astra1DMagnetoStatic_fast.cpp -text
classic/5.0/src/Fields/Astra1DMagnetoStatic_fast.hh -text
classic/5.0/src/Fields/Astra1DMagnetoStatic_fast.h -text
classic/5.0/src/Fields/BDipoleField.cpp -text
classic/5.0/src/Fields/BDipoleField.h -text
classic/5.0/src/Fields/BMultipoleField.cpp -text
......@@ -320,45 +320,39 @@ classic/5.0/src/Fields/EDipoleField.h -text
classic/5.0/src/Fields/EMField.cpp -text
classic/5.0/src/Fields/EMField.h -text
classic/5.0/src/Fields/FM1DDynamic.cpp -text
classic/5.0/src/Fields/FM1DDynamic.hh -text
classic/5.0/src/Fields/FM1DDynamic.h -text
classic/5.0/src/Fields/FM1DDynamic_fast.cpp -text
classic/5.0/src/Fields/FM1DDynamic_fast.hh -text
classic/5.0/src/Fields/FM1DDynamic_fast.h -text
classic/5.0/src/Fields/FM1DElectroStatic.cpp -text
classic/5.0/src/Fields/FM1DElectroStatic.hh -text
classic/5.0/src/Fields/FM1DElectroStatic.h -text
classic/5.0/src/Fields/FM1DElectroStatic_fast.cpp -text
classic/5.0/src/Fields/FM1DElectroStatic_fast.hh -text
classic/5.0/src/Fields/FM1DElectroStatic_fast.h -text
classic/5.0/src/Fields/FM1DMagnetoStatic.cpp -text
classic/5.0/src/Fields/FM1DMagnetoStatic.hh -text
classic/5.0/src/Fields/FM1DMagnetoStatic.h -text
classic/5.0/src/Fields/FM1DMagnetoStatic_fast.cpp -text
classic/5.0/src/Fields/FM1DMagnetoStatic_fast.hh -text
classic/5.0/src/Fields/FM1DMagnetoStatic_fast.h -text
classic/5.0/src/Fields/FM1DProfile1.cpp -text
classic/5.0/src/Fields/FM1DProfile1.hh -text
classic/5.0/src/Fields/FM1DProfile1.h -text
classic/5.0/src/Fields/FM1DProfile2.cpp -text
classic/5.0/src/Fields/FM1DProfile2.hh -text
classic/5.0/src/Fields/FM1DProfile2.h -text
classic/5.0/src/Fields/FM2DDynamic.cpp -text
classic/5.0/src/Fields/FM2DDynamic.hh -text
classic/5.0/src/Fields/FM2DDynamic_cspline.cpp -text
classic/5.0/src/Fields/FM2DDynamic_cspline.hh -text
classic/5.0/src/Fields/FM2DDynamic.h -text
classic/5.0/src/Fields/FM2DElectroStatic.cpp -text
classic/5.0/src/Fields/FM2DElectroStatic.hh -text
classic/5.0/src/Fields/FM2DElectroStatic_cspline.cpp -text
classic/5.0/src/Fields/FM2DElectroStatic_cspline.hh -text
classic/5.0/src/Fields/FM2DElectroStatic.h -text
classic/5.0/src/Fields/FM2DMagnetoStatic.cpp -text
classic/5.0/src/Fields/FM2DMagnetoStatic.hh -text
classic/5.0/src/Fields/FM2DMagnetoStatic_cspline.cpp -text
classic/5.0/src/Fields/FM2DMagnetoStatic_cspline.hh -text
classic/5.0/src/Fields/FM2DMagnetoStatic.h -text
classic/5.0/src/Fields/FM3DDynamic.cpp -text
classic/5.0/src/Fields/FM3DDynamic.hh -text
classic/5.0/src/Fields/FM3DDynamic.h -text
classic/5.0/src/Fields/FM3DH5Block.cpp -text
classic/5.0/src/Fields/FM3DH5Block.hh -text
classic/5.0/src/Fields/FM3DH5Block.h -text
classic/5.0/src/Fields/FM3DH5Block_nonscale.cpp -text
classic/5.0/src/Fields/FM3DH5Block_nonscale.hh -text
classic/5.0/src/Fields/FM3DH5Block_nonscale.h -text
classic/5.0/src/Fields/FM3DMagnetoStaticH5Block.cpp -text
classic/5.0/src/Fields/FM3DMagnetoStaticH5Block.hh -text
classic/5.0/src/Fields/FM3DMagnetoStaticH5Block.h -text
classic/5.0/src/Fields/FMDummy.cpp -text
classic/5.0/src/Fields/FMDummy.hh -text
classic/5.0/src/Fields/FMDummy.h -text
classic/5.0/src/Fields/Fieldmap.cpp -text
classic/5.0/src/Fields/Fieldmap.hh -text
classic/5.0/src/Fields/Fieldmap.h -text
classic/5.0/src/Fields/Fieldmap.icc -text
classic/5.0/src/Fields/NullField.cpp -text
classic/5.0/src/Fields/NullField.h -text
......@@ -1172,4 +1166,4 @@ tests/opal_src/Elements/OpalOffsetTest.cpp -text
tests/opal_src/Elements/OpalPolynomialTimeDependenceTest.cpp -text
tests/opal_src/Elements/OpalVariableRFCavityTest.cpp -text
tests/opal_src/Utilities/CMakeLists.txt -text
tests/opal_src/Utilities/MockComponent.h -text
tests/opal_src/Utilities/MockComponent.h -text
\ No newline at end of file
......@@ -22,7 +22,7 @@
#include "Physics/Physics.h"
#include "Algorithms/PartBunch.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Structure/LossDataSink.h"
#include "Utilities/Options.h"
#include "Solvers/SurfacePhysicsHandler.hh"
......
......@@ -24,7 +24,7 @@
#include "Physics/Physics.h"
#include "Structure/LossDataSink.h"
#include "Utilities/Options.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Utilities/GeneralClassicException.h"
#include <fstream>
......
......@@ -21,7 +21,7 @@
#include "AbsBeamline/CyclotronValley.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunch.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Physics/Physics.h"
#include <iostream>
......
......@@ -21,7 +21,7 @@
#include "AbsBeamline/Degrader.h"
#include "Algorithms/PartBunch.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Structure/LossDataSink.h"
#include "Utilities/Options.h"
#include "Physics/Physics.h"
......
......@@ -21,7 +21,7 @@
#include "Physics/Physics.h"
#include "Algorithms/PartBunch.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Structure/LossDataSink.h"
#include "Utilities/Options.h"
......
......@@ -21,7 +21,7 @@
#include "AbsBeamline/Multipole.h"
#include "Algorithms/PartBunch.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Physics/Physics.h"
extern Inform *gmsg;
......
......@@ -22,7 +22,7 @@
#include "AbsBeamline/ParallelPlate.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunch.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Physics/Physics.h"
#include <iostream>
......
......@@ -22,9 +22,7 @@
#include "Algorithms/PartBunch.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Utilities/Options.h"
#include "Fields/Fieldmap.hh"
#include "Fields/FM1DProfile1.hh"
#include "Fields/FM1DProfile2.hh"
#include "Fields/Fieldmap.h"
#include <iostream>
#include <fstream>
......@@ -1355,7 +1353,7 @@ void RBend::Print(Inform &msg, double bendAngleX, double bendAngleY) {
void RBend::ReadFieldMap(Inform &msg) {
*Ippl::Info << getName() << " using file ";
fieldmap_m->getInfo(Ippl::Info);
Fieldmap::readMap(fileName_m);
fieldmap_m->Get1DProfile1EntranceParam(entranceParameter1_m,
entranceParameter2_m,
......@@ -1658,4 +1656,4 @@ bool RBend::TreatAsDrift(Inform &msg) {
} else
return false;
}
}
\ No newline at end of file
......@@ -26,7 +26,7 @@
#include "Fields/BMultipoleField.h"
#include "Physics/Physics.h"
#include "Algorithms/PartPusher.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include <vector>
class Fieldmap;
......
......@@ -21,7 +21,7 @@
#include "AbsBeamline/RFCavity.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunch.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Utilities/GeneralClassicException.h"
#include "gsl/gsl_interp.h"
......
......@@ -23,7 +23,7 @@
#include "Algorithms/PartBunch.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Utilities/Options.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include <iostream>
#include <fstream>
......
......@@ -21,7 +21,7 @@
#include "AbsBeamline/Solenoid.h"
#include "Algorithms/PartBunch.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "Physics/Physics.h"
#include <iostream>
......
......@@ -21,7 +21,7 @@
#include "AbsBeamline/TravelingWave.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunch.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
#include "gsl/gsl_interp.h"
#include "gsl/gsl_spline.h"
......
#include "Fields/Astra1DDynamic.hh"
#include "Fields/Fieldmap.icc"
#include "Fields/Astra1DDynamic.h"
#include "Fields/Fieldmap.hpp"
#include "Physics/Physics.h"
#include "gsl/gsl_interp.h"
#include "gsl/gsl_spline.h"
......@@ -65,9 +65,7 @@ Astra1DDynamic::Astra1DDynamic(std::string aFilename):
}
Astra1DDynamic::~Astra1DDynamic() {
if(FourCoefs_m != NULL) {
delete[] FourCoefs_m;
}
freeMap();
}
void Astra1DDynamic::readMap() {
......@@ -156,11 +154,10 @@ void Astra1DDynamic::readMap() {
void Astra1DDynamic::freeMap() {
if(FourCoefs_m != NULL) {
Inform msg("*1DD ");
delete[] FourCoefs_m;
FourCoefs_m = NULL;
msg << typeset_msg("freed fieldmap '" + Filename_m + "'", "info") << endl;
INFOMSG(typeset_msg("freed fieldmap '" + Filename_m + "'", "info") << endl);
}
}
......@@ -265,4 +262,4 @@ void Astra1DDynamic::getOnaxisEz(vector<pair<double, double> > & F) {
for(int i = 0; i < num_gridpz_m; ++ i) {
F[i].second /= Ez_max;
}
}
}
\ No newline at end of file
#ifndef CLASSIC_AstraFIELDMAP1DDYNAMIC_HH
#define CLASSIC_AstraFIELDMAP1DDYNAMIC_HH
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
class Astra1DDynamic: public Fieldmap {
......
#ifndef CLASSIC_AstraFIELDMAP1DDYNAMICFAST_HH
#define CLASSIC_AstraFIELDMAP1DDYNAMICFAST_HH
#include "gsl/gsl_interp.h"
#include "gsl/gsl_spline.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Astra1D_fast.h"
class Astra1DDynamic_fast: public Fieldmap {
class Astra1DDynamic_fast: public Astra1D_fast {
public:
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const;
......@@ -20,28 +18,17 @@ public:
private:
Astra1DDynamic_fast(std::string aFilename);
~Astra1DDynamic_fast();
virtual ~Astra1DDynamic_fast();
virtual void readMap();
virtual void freeMap();
double* onAxisField_m;
double* zvals_m;
gsl_spline *onAxisInterpolants_m[4];
gsl_interp_accel *onAxisAccel_m[4];
double hz_m;
bool readFileHeader(std::ifstream &file);
int stripFileHeader(std::ifstream &file);
double frequency_m;
double xlrep_m;
double zbegin_m;
double zend_m;
double length_m;
int num_gridpz_m;
friend class Fieldmap;
};
#endif
#endif
\ No newline at end of file
#include "Fields/Astra1DElectroStatic.hh"
#include "Fields/Fieldmap.icc"
#include "Fields/Astra1DElectroStatic.h"
#include "Fields/Fieldmap.hpp"
#include "Physics/Physics.h"
#include "gsl/gsl_interp.h"
#include "gsl/gsl_spline.h"
......@@ -59,9 +59,7 @@ Astra1DElectroStatic::Astra1DElectroStatic(std::string aFilename)
}
Astra1DElectroStatic::~Astra1DElectroStatic() {
if(FourCoefs_m != NULL) {
delete[] FourCoefs_m;
}
freeMap();
}
void Astra1DElectroStatic::readMap() {
......@@ -152,6 +150,7 @@ void Astra1DElectroStatic::freeMap() {
if(FourCoefs_m != NULL) {
delete[] FourCoefs_m;
FourCoefs_m = NULL;
INFOMSG(typeset_msg("freed fieldmap '" + Filename_m + "'", "info") << endl);
}
......@@ -218,4 +217,4 @@ double Astra1DElectroStatic::getFrequency() const {
}
void Astra1DElectroStatic::setFrequency(double freq)
{ }
{ }
\ No newline at end of file
#ifndef CLASSIC_AstraFIELDMAP1DELECTROSTATIC_HH
#define CLASSIC_AstraFIELDMAP1DELECTROSTATIC_HH
#include "Fields/Fieldmap.hh"
#include "Fields/Fieldmap.h"
class Astra1DElectroStatic: public Fieldmap {
......
#include "Fields/Astra1DElectroStatic_fast.hh"
#include "Fields/Fieldmap.icc"
#include "Fields/Astra1DElectroStatic_fast.h"
#include "Physics/Physics.h"
#include "gsl/gsl_fft_real.h"
#include <fstream>
#include <ios>
using namespace std;
using Physics::mu_0;
using Physics::c;
using Physics::two_pi;
Astra1DElectroStatic_fast::Astra1DElectroStatic_fast(std::string aFilename):
Fieldmap(aFilename) {
ifstream file;
int tmpInt;
int skippedValues = 0;
std::string tmpString;
double tmpDouble;
double tmpDouble2;
Astra1D_fast(aFilename) {
numHeaderLines_m = 2;
onAxisField_m = NULL;
Type = TAstraElectroStatic;
// open field map, parse it and disable element on error
file.open(Filename_m.c_str());
if(file.good()) {
bool parsing_passed = interpreteLine<std::string, int>(file, tmpString, tmpInt);
parsing_passed = parsing_passed &&
interpreteLine<double, double>(file, zbegin_m, tmpDouble);
tmpDouble2 = zbegin_m;
while(!file.eof() && parsing_passed) {
parsing_passed = interpreteLine<double, double>(file, zend_m, tmpDouble, false);
if(zend_m - tmpDouble2 > 1e-10) {
tmpDouble2 = zend_m;
} else if(parsing_passed) {
++ skippedValues;
}
}
num_gridpz_m = lines_read_m - 2 - skippedValues;
lines_read_m = 0;
if(!parsing_passed && !file.eof()) {
disableFieldmapWarning();
zend_m = zbegin_m - 1e-3;
}
hz_m = (zend_m - zbegin_m) / (num_gridpz_m - 1);
length_m = 2.0 * num_gridpz_m * hz_m;
file.close();
} else {
std::ifstream file(Filename_m.c_str());
if(!file.good()) {
noFieldmapWarning();
zbegin_m = 0.0;
zend_m = -1e-3;
}
}
Astra1DElectroStatic_fast::~Astra1DElectroStatic_fast() {
if(onAxisField_m != NULL) {
for(int i = 0; i < 4; ++i) {
gsl_spline_free(onAxisInterpolants_m[i]);
gsl_interp_accel_free(onAxisAccel_m[i]);
}
bool parsing_passed = readFileHeader(file);
parsing_passed = parsing_passed && determineNumSamplingPoints(file);
file.close();
delete[] onAxisField_m;
if(!parsing_passed && !file.eof()) {
disableFieldmapWarning();
zend_m = zbegin_m - 1e-3;
}
hz_m = (zend_m - zbegin_m) / (num_gridpz_m - 1);
length_m = 2.0 * num_gridpz_m * hz_m;
}
Astra1DElectroStatic_fast::~Astra1DElectroStatic_fast() {
freeMap();
}
void Astra1DElectroStatic_fast::readMap() {
if(onAxisField_m == NULL) {
// declare variables and allocate memory
ifstream in;
onAxisField_m = new double[num_gridpz_m];
zvals_m = new double[num_gridpz_m];
bool parsing_passed = true;
std::ifstream file(Filename_m.c_str());
int accuracy = stripFileHeader(file);
double maxEz = readFieldData(file);
file.close();
std::string tmpString;
int accuracy;
int nsp;
int ii;
normalizeFieldData(maxEz * 1e-6);
double Ez_max = 0.0;
//double z = 0.0;
double tmpDouble = zbegin_m - hz_m;
double interior_derivative, base;
double coskzl, sinkzl;
double *higherDerivatives[3];
double *zvals[2];
std::vector<double> zvals = getEvenlyDistributedSamplingPoints();
std::vector<double> evenFieldSampling = interpolateFieldData(zvals);
std::vector<double> fourierCoefs = computeFourierCoefficients(accuracy, evenFieldSampling);
double *RealValues = new double[2 * num_gridpz_m];
onAxisField_m = new double[num_gridpz_m];
zvals[0] = new double[num_gridpz_m];
// read in and parse field map
in.open(Filename_m.c_str());
interpreteLine<std::string, int>(in, tmpString, accuracy);
for(nsp = 0; nsp < num_gridpz_m && parsing_passed; /* skip increment of nsp here */) {
parsing_passed = interpreteLine<double, double>(in, zvals[0][nsp], RealValues[nsp]);
// the sequence of z-position should be strictly increasing
// drop sampling points that don't comply to this
if(zvals[0][nsp] - tmpDouble > 1e-10) {
if(fabs(RealValues[nsp]) > Ez_max) {
Ez_max = fabs(RealValues[nsp]);
}
tmpDouble = zvals[0][nsp];
++ nsp; // increment nsp only if sampling point is accepted
}
}
in.close();
num_gridpz_m = nsp;
hz_m = (zend_m - zbegin_m) / (num_gridpz_m - 1);
higherDerivatives[0] = new double[num_gridpz_m];
higherDerivatives[1] = new double[num_gridpz_m];
higherDerivatives[2] = new double[num_gridpz_m];
zvals[1] = new double[num_gridpz_m];
for(int i = 0; i < 4; ++i) {
onAxisInterpolants_m[i] = gsl_spline_alloc(gsl_interp_cspline, num_gridpz_m);
onAxisAccel_m[i] = gsl_interp_accel_alloc();
}
gsl_fft_real_wavetable *real = gsl_fft_real_wavetable_alloc(2 * num_gridpz_m);
gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(2 * num_gridpz_m);
ii = num_gridpz_m - 1;
for(int i = 0; i < num_gridpz_m; ++ i, -- ii) {
onAxisField_m[i] = 1e6 * RealValues[i] / Ez_max;
zvals[0][ii] -= zvals[0][0];
}
gsl_spline_init(onAxisInterpolants_m[0], zvals[0], onAxisField_m, num_gridpz_m);
// get equidistant sampling from the, possibly, non-equidistant sampling
// using cubic spline for this
ii = num_gridpz_m;
double z = 0.0;
for(int i = 0; i < num_gridpz_m - 1; ++ i, ++ ii, z += hz_m) {
zvals[1][i] = z;
RealValues[ii] = gsl_spline_eval(onAxisInterpolants_m[0], z, onAxisAccel_m[0]);
}
zvals[1][num_gridpz_m - 1] = zvals[0][num_gridpz_m - 1];
RealValues[ii ++] = onAxisField_m[num_gridpz_m - 1];
// prepend mirror sampling points such that field values are periodic for sure
// ii == 2*num_gridpz_m at the moment
-- ii;
for(int i = 0; i < num_gridpz_m; ++ i, -- ii) {
RealValues[i] = RealValues[ii];
}
gsl_fft_real_transform(RealValues, 1, 2 * num_gridpz_m, real, work);
// normalize to Ez_max = 1 MV/m
RealValues[0] /= (2 * num_gridpz_m);
for(int i = 1; i < 2 * accuracy - 1; i++) {
RealValues[i] /= num_gridpz_m;
}
for(int i = 0; i < num_gridpz_m; ++ i) {
const double kz = two_pi * (zvals[1][i] / length_m + 0.5);
higherDerivatives[0][i] = 0.0;
higherDerivatives[1][i] = 0.0;
higherDerivatives[2][i] = 0.0;
int n = 1;
for(int l = 1; l < accuracy; ++l, n += 2) {
base = two_pi / length_m * l;
interior_derivative = base;
coskzl = cos(kz * l);
sinkzl = sin(kz * l);
higherDerivatives[0][i] += interior_derivative * (-RealValues[n] * sinkzl - RealValues[n + 1] * coskzl);
interior_derivative *= base;
higherDerivatives[1][i] += interior_derivative * (-RealValues[n] * coskzl + RealValues[n + 1] * sinkzl);
interior_derivative *= base;
higherDerivatives[2][i] += interior_derivative * (RealValues[n] * sinkzl + RealValues[n + 1] * coskzl);
}
}
gsl_fft_real_workspace_free(work);
gsl_fft_real_wavetable_free(real);
for(int i = 1; i < 4; ++i) {
gsl_spline_init(onAxisInterpolants_m[i], zvals[1], higherDerivatives[i - 1], num_gridpz_m);
}
delete[] RealValues;
delete[] higherDerivatives[0];
delete[] higherDerivatives[1];
delete[] higherDerivatives[2];
delete[] zvals[0];
delete[] zvals[1];
computeFieldDerivatives(fourierCoefs, accuracy);
INFOMSG(typeset_msg("read in fieldmap '" + Filename_m + "'", "info") << endl);
}
}
void Astra1DElectroStatic_fast::freeMap() {
if(onAxisField_m != NULL) {
for(int i = 0; i < 4; ++i) {
gsl_spline_free(onAxisInterpolants_m[i]);
gsl_interp_accel_free(onAxisAccel_m[i]);
}
checkMap(accuracy,
length_m,
zvals,
fourierCoefs,
onAxisInterpolants_m[0],
onAxisAccel_m[0]);
delete[] onAxisField_m;
INFOMSG(typeset_msg("freed fieldmap '" + Filename_m + "'", "info") << endl);
INFOMSG(typeset_msg("read in fieldmap '" + Filename_m + "'", "info") << endl);
}
}
......@@ -252,3 +109,21 @@ double Astra1DElectroStatic_fast::getFrequency() const {
void Astra1DElectroStatic_fast::setFrequency(double freq)
{ }
bool Astra1DElectroStatic_fast::readFileHeader(std::ifstream &file) {
std::string tmpString;
int tmpInt;
bool passed = interpreteLine<std::string, int>(file, tmpString, tmpInt);
return passed;
}
int Astra1DElectroStatic_fast::stripFileHeader(std::ifstream &file) {
std::string tmpString;
int accuracy;
interpreteLine<std::string, int>(file, tmpString, accuracy);
return accuracy;
}
\ No newline at end of file
#ifndef CLASSIC_AstraFIELDMAP1DELECTROSTATICFAST_HH
#define CLASSIC_AstraFIELDMAP1DELECTROSTATICFAST_HH
#include "gsl/gsl_interp.h"
#include "gsl/gsl_spline.h"
#include "Fields/Fieldmap.hh"
#include "Fields/Astra1D_fast.h"