34 #include <boost/assign.hpp>
42 #define CHECK_VAC_FSCANF_EOF(arg) if (arg == EOF)\
43 throw GeneralClassicException("Vacuum::getPressureFromFile",\
44 "fscanf returned EOF at " #arg);
49 boost::assign::list_of<const boost::bimap<ResidualGas, std::string>::relation>
63 pressure_m(right.pressure_m),
64 pmapfn_m(right.pmapfn_m),
65 pscale_m(right.pscale_m),
66 temperature_m(right.temperature_m),
120 "Residual gas not set");
133 "Pressure must be positive");
154 "PScale must be positive");
167 "Temperature must be positive");
203 bool flagNeedUpdate =
false;
207 std::pair<Vector_t, double> boundingSphere;
208 boundingSphere.first = 0.5 * (rmax + rmin);
209 boundingSphere.second =
euclidean_norm(rmax - boundingSphere.first);
217 for (
unsigned int i = 0; i < tempnum; ++i) {
219 if ( (pflag != 0) && (bunch->
Bin[i] != -1) )
220 flagNeedUpdate =
true;
230 return flagNeedUpdate;
252 if (std::filesystem::exists(
pmapfn_m)) {
267 *gmsg <<
"* Finalize vacuum " <<
getName() <<
endl;
278 <<
": " <<
getName() <<
" -> Residual gas = "
281 <<
": " <<
getName() <<
" -> Pressure level = "
300 const double x =
R(0);
301 const double y =
R(1);
302 double pressure = 0.0;
311 const int ir = (
int)xir;
313 const double wr1 = xir - (double)ir;
315 const double wr2 = 1.0 - wr1;
319 if ((x < 0) && (y >= 0)) tet =
Physics::pi + tempv;
320 else if ((x < 0) && (y <= 0)) tet =
Physics::pi + tempv;
322 else if ((x == 0) && (y > 0)) tet =
Physics::pi / 2.0;
323 else if ((x == 0) && (y < 0)) tet = 1.5 *
Physics::pi;
332 const double wt1 = xit - (double)it;
333 const double wt2 = 1.0 - wt1;
337 double epsilon = 0.06;
338 if (tet > 360 - epsilon && tet < 360 + epsilon) it = 0;
340 int r1t1, r2t1, r1t2, r2t2;
345 r2t1 =
idx(ir + 1, it);
346 r1t2 =
idx(ir, it + 1);
347 r2t2 =
idx(ir + 1, it + 1);
354 if (pressure <= 0.0) {
356 *gmsg <<
level4 <<
getName() <<
": Take constant value through Vacuum::getPressure" <<
endl;
360 *gmsg <<
level4 <<
getName() <<
": Particle out of maximum radial position of pressure field map." <<
endl;
361 *gmsg <<
level4 <<
getName() <<
": Take constant value through Vacuum::getPressure" <<
endl;
365 "Pressure data not found");
374 for (
int i = 0; i < nrad_m; i++) {
383 *gmsg <<
"* " <<
endl;
384 *gmsg <<
"* Reading pressure field map " <<
endl;
388 if ((f = std::fopen(
pmapfn_m.c_str(),
"r")) ==
nullptr) {
390 "failed to open file '" +
pmapfn_m +
391 "', please check if it exists");
395 *gmsg <<
"* --- Minimal radius of measured pressure map: " <<
PP_m.
rmin_m <<
" [mm]" <<
endl;
400 *gmsg <<
"* --- Stepsize in radial direction: " <<
PP_m.
delr_m <<
" [mm]" <<
endl;
403 *gmsg <<
"* --- Minimal angle of measured pressure map: " <<
PP_m.
tetmin_m <<
" [deg]" <<
endl;
408 *gmsg <<
"* --- Stepsize in azimuthal direction: " <<
PP_m.
dtet_m <<
" [deg]" <<
endl;
420 *gmsg <<
"* --- Adding a guard cell along azimuth" << endl;
424 *gmsg <<
"* --- Total stored grid point number ((ntet_m+1) * nrad_m) : " <<
PField_m.
ntot_m <<
endl;
437 #undef CHECK_VAC_FSCANF_EOF
static OpalData * getInstance()
Tps< T > sqrt(const Tps< T > &x)
Square root.
virtual void goOffline() override
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
T rad(T x)
Convert degrees to radians.
constexpr double two_pi
The value of .
virtual bool checkVacuum(PartBunchBase< double, 3 > *bunch, Cyclotron *cycl)
virtual void visitVacuum(const Vacuum &)=0
Apply the algorithm to a vacuum space.
virtual void print(Inform &os)=0
void initR(double rmin, double dr, int nrad)
void updateParticleAttributes()
ParticleMatterInteractionHandler * parmatint_m
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
void getPressureFromFile()
ParticleAttrib< double > M
double minr_m
size limits took from cyclotron
PartBunchBase< double, 3 > * RefPartBunch_m
double getTemperature() const
std::string getTypeString() const
virtual const std::string & getName() const
Get element name.
int idx(int irad, int ktet)
double getQ() const
Access to reference data.
constexpr double pi
The value of .
Inform & endl(Inform &inf)
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
PETE_TUTree< FnArcTan, typename T::PETE_Expr_t > atan(const PETE_Expr< T > &l)
ResidualGas gas_m
parameters for Vacuum
void setPressure(double pressure)
ElementBase * getElement()
std::string getPressureMapFN() const
T euclidean_norm(const Vector< T > &)
Euclidean norm.
double pscale_m
stores the filename of the pressure map
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Vacuum.
double checkPressure(const Vector_t &R)
virtual double getMaxZ() const
Inform & level4(Inform &inf)
size_t getLocalNum() const
void setPressureMapFN(std::string pmapfn)
ParticleAttrib< double > Q
virtual double getElementLength() const
Get design length.
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
virtual ElementType getType() const override
Get element type std::string.
virtual void apply(PartBunchBase< double, 3 > *bunch, const std::pair< Vector_t, double > &boundingSphere)=0
void setTemperature(double temperature)
constexpr double q_e
The elementary charge in As.
bool checkPoint(const Vector_t &R)
double temperature_m
a scale factor for the P-field
virtual double getMaxR() const
void setPScale(double ps)
virtual void getDimensions(double &zBegin, double &zEnd) const override
virtual double getMinR() const
virtual ParticleMatterInteractionHandler * getParticleMatterInteraction() const
virtual void finalise() override
double pressure_m
Type of gas for residual vacuum.
static const boost::bimap< ResidualGas, std::string > bmResidualGasString_s
Inform & level2(Inform &inf)
ParticleAttrib< int > Bin
std::vector< double > rarr_m
std::vector< double > pfld_m
Interface for a single beam element.
ResidualGas getResidualGas() const
std::string getResidualGasName()
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
void setStop(bool stopflag)
void setResidualGas(std::string gas)
double getPressure() const
#define CHECK_VAC_FSCANF_EOF(arg)
bool reduce(Communicate &, InputIterator, InputIterator, OutputIterator, const ReduceOp &, bool *IncludeVal=0)
virtual double getMinZ() const
virtual void goOnline(const double &kineticEnergy) override