42 #define CHECK_VAC_FSCANF_EOF(arg) if (arg == EOF)\
43 throw GeneralClassicException("Vacuum::getPressureFromFile",\
44 "fscanf returned EOF at " #arg);
56 pressure_m(right.pressure_m),
57 pmapfn_m(right.pmapfn_m),
58 pscale_m(right.pscale_m),
59 temperature_m(right.temperature_m),
102 "Pressure must not be zero");
115 "Temperature must not be zero");
136 "PScale must be positive");
143 }
else if (gas ==
"H2") {
162 "Residual gas not set");
178 bool flagNeedUpdate =
false;
182 std::pair<Vector_t, double> boundingSphere;
183 boundingSphere.first = 0.5 * (rmax + rmin);
184 boundingSphere.second =
euclidean_norm(rmax - boundingSphere.first);
192 for (
unsigned int i = 0; i < tempnum; ++i) {
193 int pflag =
checkPoint(bunch->
R[i](0), bunch->
R[i](1), bunch->
R[i](2));
194 if ( (pflag != 0) && (bunch->
Bin[i] != -1) )
195 flagNeedUpdate =
true;
202 return flagNeedUpdate;
226 for (
size_t i = 0; i < bunch->
getLocalNum(); ++i) {
227 bunch->
M[i] = bunch->
getM()*1E-9;
237 *
gmsg <<
"* Finalize vacuum" <<
endl;
274 double pressure = 0.0;
281 const int ir = (
int)xir;
283 const double wr1 = xir - (double)ir;
285 const double wr2 = 1.0 - wr1;
289 if ((x < 0) && (y >= 0)) tet =
Physics::pi + tempv;
290 else if ((x < 0) && (y <= 0)) tet =
Physics::pi + tempv;
292 else if ((x == 0) && (y > 0)) tet =
Physics::pi / 2.0;
293 else if ((x == 0) && (y < 0)) tet = 1.5 *
Physics::pi;
300 double xit = tet /
PP.
dtet;
302 const double wt1 = xit - (double)it;
303 const double wt2 = 1.0 - wt1;
307 double epsilon = 0.06;
308 if (tet > 360 - epsilon && tet < 360 + epsilon) it = 0;
310 int r1t1, r2t1, r1t2, r2t2;
315 r2t1 =
idx(ir + 1, it);
316 r1t2 =
idx(ir, it + 1);
317 r2t2 =
idx(ir + 1, it + 1);
324 if (pressure <= 0.0) {
330 *
gmsg <<
level4 <<
getName() <<
": Particle out of maximum radial position of pressure field map." <<
endl;
335 "Pressure data not found");
347 for (
int i = 0; i < nrad; i++)
348 PP.
rarr[i] = rmin + i * dr;
359 *
gmsg <<
"* Reading pressure field map " <<
endl;
363 if ((f = std::fopen(
pmapfn_m.c_str(),
"r")) == NULL) {
365 "failed to open file '" +
pmapfn_m +
366 "', please check if it exists");
370 *
gmsg <<
"* --- Minimal radius of measured pressure map: " <<
PP.
rmin <<
" [mm]" <<
endl;
375 *
gmsg <<
"* --- Stepsize in radial direction: " <<
PP.
delr <<
" [mm]" <<
endl;
378 *
gmsg <<
"* --- Minimal angle of measured pressure map: " <<
PP.
tetmin <<
" [deg]" <<
endl;
383 *
gmsg <<
"* --- Stepsize in azimuthal direction: " <<
PP.
dtet <<
" [deg]" <<
endl;
395 *
gmsg <<
"* --- Adding a guard cell along azimuth" <<
endl;
399 *
gmsg <<
"* --- Total stored grid point number ((ntet+1) * nrad) : " <<
PField.
ntot <<
endl;
412 #undef CHECK_VAC_FSCANF_EOF
#define CHECK_VAC_FSCANF_EOF(arg)
Tps< T > sqrt(const Tps< T > &x)
Square root.
T euclidean_norm(const Vector< T > &)
Euclidean norm.
bool reduce(Communicate &, InputIterator, InputIterator, OutputIterator, const ReduceOp &, bool *IncludeVal=0)
PETE_TUTree< FnArcTan, typename T::PETE_Expr_t > atan(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
Inform & level4(Inform &inf)
constexpr double two_pi
The value of.
constexpr double q_e
The elementary charge in As.
constexpr double pi
The value of.
constexpr double rad2deg
The conversion factor from radians to degrees.
T rad(T x)
Convert degrees to radians.
ParticleAttrib< int > Bin
double getQ() const
Access to reference data.
size_t getLocalNum() const
ParticleAttrib< double > M
ParticleAttrib< double > Q
void get_bounds(Vector_t &rmin, Vector_t &rmax)
virtual void visitVacuum(const Vacuum &)=0
Apply the algorithm to a vacuum space.
Interface for a single beam element.
PartBunchBase< double, 3 > * RefPartBunch_m
virtual double getMaxR() const
virtual double getMaxZ() const
virtual double getMinZ() const
virtual double getMinR() const
virtual const std::string & getName() const
Get element name.
virtual ParticleMatterInteractionHandler * getParticleMatterInteraction() const
virtual double getElementLength() const
Get design length.
std::vector< double > pfld
std::vector< double > rarr
double minr_m
Flag if particles should be stripped or stopped.
virtual ElementBase::ElementType getType() const
Get element type std::string.
void setPScale(double ps)
double pscale_m
stores the filename of the pressure map
double getPressure() const
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
virtual std::string getPressureMapFN() const
void initR(double rmin, double dr, int nrad)
void setTemperature(double temperature)
int idx(int irad, int ktet)
double temperature_m
a scale factor for the P-field
ResidualGas getResidualGas() const
virtual double getPScale() const
virtual void getDimensions(double &zBegin, double &zEnd) const
double checkPressure(const double &x, const double &y)
void setPressureMapFN(std::string pmapfn)
std::string getVacuumShape()
virtual void accept(BeamlineVisitor &) const
Apply visitor to Vacuum.
virtual void goOnline(const double &kineticEnergy)
void setPressure(double pressure)
virtual bool checkVacuum(PartBunchBase< double, 3 > *bunch, Cyclotron *cycl)
ParticleMatterInteractionHandler * parmatint_m
mm
double getTemperature() const
void setResidualGas(std::string gas)
void getPressureFromFile(const double &scaleFactor)
std::string getResidualGasName()
int checkPoint(const double &x, const double &y, const double &z)
virtual bool getStop() const
virtual bool bends() const
ResidualGas gas_m
parameters for Vacuum
void setStop(bool stopflag)
virtual void apply(PartBunchBase< double, 3 > *bunch, const std::pair< Vector_t, double > &boundingSphere)=0