1 #ifndef CLASSIC_RFCavity_HH
2 #define CLASSIC_RFCavity_HH
91 virtual void setFast(
bool fast);
99 virtual double getAutoPhaseEstimate(
const double & E0,
const double & t0,
const double & q,
const double & m);
107 std::ofstream *out = NULL);
109 virtual bool apply(
const size_t &i,
129 std::shared_ptr<AbstractTimeDependence> freq_atd,
130 std::shared_ptr<AbstractTimeDependence> ampl_atd,
131 std::shared_ptr<AbstractTimeDependence> phase_atd);
135 virtual bool bends()
const override;
137 virtual void goOnline(
const double &kineticEnergy)
override;
141 virtual void setDesignEnergy(
const double& ekin,
bool changeable =
true)
override;
156 virtual double getRmin()
const;
158 virtual double getRmax()
const;
170 virtual double getPhi0()
const;
178 void getMomentaKick(
const double normalRadius,
double momentum[],
const double t,
const double dtCorrt,
const int PID,
const double restMass,
const int chargenumber);
180 double spline(
double z,
double *za);
184 virtual void getDimensions(
double &zBegin,
double &zEnd)
const override;
192 void setPhaseModel(std::shared_ptr<AbstractTimeDependence> time_dep);
202 double &
end)
const override;
250 double getdE(
const int & i,
251 const std::vector<double> & t,
254 const double & frequency,
255 const std::vector<double> & F)
const;
257 double getdT(
const int & i,
258 const std::vector<double> & E,
260 const double mass)
const;
262 double getdA(
const int & i,
263 const std::vector<double> & t,
265 const double & frequency,
266 const std::vector<double> & F)
const;
268 double getdB(
const int & i,
269 const std::vector<double> & t,
271 const double & frequency,
272 const std::vector<double> & F)
const;
280 const std::vector<double> & t,
283 const double & frequency,
284 const std::vector<double> & F)
const {
285 return dz / (frequency * frequency * (t[i] - t[i-1]) * (t[i] - t[i-1])) *
286 (frequency * (t[i] - t[i-1]) * (F[i] *
std::sin(frequency * t[i] + phi) - F[i-1] *
std::sin(frequency * t[i-1] + phi)) +
287 (F[i] - F[i-1]) * (
std::cos(frequency * t[i] + phi) -
std::cos(frequency * t[i-1] + phi)));
292 const std::vector<double> & E,
294 const double mass)
const {
295 double gamma1 = 1. + (19. * E[i-1] + 1. * E[i]) / (20. * mass);
296 double gamma2 = 1. + (17. * E[i-1] + 3. * E[i]) / (20. * mass);
297 double gamma3 = 1. + (15. * E[i-1] + 5. * E[i]) / (20. * mass);
298 double gamma4 = 1. + (13. * E[i-1] + 7. * E[i]) / (20. * mass);
299 double gamma5 = 1. + (11. * E[i-1] + 9. * E[i]) / (20. * mass);
300 double gamma6 = 1. + (9. * E[i-1] + 11. * E[i]) / (20. * mass);
301 double gamma7 = 1. + (7. * E[i-1] + 13. * E[i]) / (20. * mass);
302 double gamma8 = 1. + (5. * E[i-1] + 15. * E[i]) / (20. * mass);
303 double gamma9 = 1. + (3. * E[i-1] + 17. * E[i]) / (20. * mass);
304 double gamma10 = 1. + (1. * E[i-1] + 19. * E[i]) / (20. * mass);
306 (1. /
std::sqrt(1. - 1. / (gamma1 * gamma1)) +
307 1. /
std::sqrt(1. - 1. / (gamma2 * gamma2)) +
308 1. /
std::sqrt(1. - 1. / (gamma3 * gamma3)) +
309 1. /
std::sqrt(1. - 1. / (gamma4 * gamma4)) +
310 1. /
std::sqrt(1. - 1. / (gamma5 * gamma5)) +
311 1. /
std::sqrt(1. - 1. / (gamma6 * gamma6)) +
312 1. /
std::sqrt(1. - 1. / (gamma7 * gamma7)) +
313 1. /
std::sqrt(1. - 1. / (gamma8 * gamma8)) +
314 1. /
std::sqrt(1. - 1. / (gamma9 * gamma9)) +
320 const std::vector<double> & t,
322 const double & frequency,
323 const std::vector<double> & F)
const {
324 double dt = t[i] - t[i-1];
325 return dz / (frequency * frequency * dt * dt) *
326 (frequency * dt * (F[i] *
std::cos(frequency * t[i]) - F[i-1] *
std::cos(frequency * t[i-1])) -
327 (F[i] - F[i-1]) * (
std::sin(frequency * t[i]) -
std::sin(frequency * t[i-1])));
332 const std::vector<double> & t,
334 const double & frequency,
335 const std::vector<double> & F)
const {
336 double dt = t[i] - t[i-1];
337 return dz / (frequency * frequency * dt * dt) *
338 (frequency * dt * (F[i] *
std::sin(frequency * t[i]) - F[i-1] *
std::sin(frequency * t[i-1])) +
339 (F[i] - F[i-1]) * (
std::cos(frequency * t[i]) -
std::cos(frequency * t[i-1])));
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
Tps< T > sqrt(const Tps< T > &x)
Square root.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
constexpr double c
The velocity of light in m/s.
boost::function< boost::tuple< double, bool >arguments_t)> type
Interface for a single beam element.
void setCavityType(std::string type)
std::string amplitude_name_m
virtual std::string getComponentType() const override
void setFrequencyModel(std::shared_ptr< AbstractTimeDependence > time_dep)
virtual bool isInside(const Vector_t &r) const override
virtual double getPhasem() const
virtual bool bends() const override
std::string getPhaseModelName()
virtual double getRmax() const
void setPerpenDistance(double pdis)
void getMomentaKick(const double normalRadius, double momentum[], const double t, const double dtCorrt, const int PID, const double restMass, const int chargenumber)
used in OPAL-cycl
virtual double getAzimuth() const
std::string getAmplitudeModelName()
virtual void setAmplitudeError(double vPeakError)
double getdE(const int &i, const std::vector< double > &t, const double &dz, const double &phi, const double &frequency, const std::vector< double > &F) const
virtual void accept(BeamlineVisitor &) const override
Apply visitor to RFCavity.
double getdB(const int &i, const std::vector< double > &t, const double &dz, const double &frequency, const std::vector< double > &F) const
std::unique_ptr< double[]> DvDr_m
void setPhaseModelName(std::string name)
virtual void finalise() override
void setRmin(double rmin)
void operator=(const RFCavity &)
void setPhaseModel(std::shared_ptr< AbstractTimeDependence > time_dep)
virtual std::pair< double, double > trackOnAxisParticle(const double &p0, const double &t0, const double &dt, const double &q, const double &mass, std::ofstream *out=NULL)
std::shared_ptr< AbstractTimeDependence > amplitude_td_m
virtual double getFrequency() const =0
Get RF frequencey.
void setFrequencyModelName(std::string name)
virtual double getPhase() const =0
Get RF phase.
virtual void getElementDimensions(double &begin, double &end) const override
virtual double getCosAzimuth() const
virtual double getAmplitudem() const
void setFrequency(double freq)
void setAmplitudeModelName(std::string name)
virtual bool getAutophaseVeto() const
virtual void setAmplitudem(double vPeak)
virtual bool getFast() const
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
std::shared_ptr< AbstractTimeDependence > frequency_td_m
virtual void setPhaseError(double phaseError)
virtual CoordinateSystemTrafo getEdgeToBegin() const override
std::unique_ptr< double[]> RNormal_m
virtual void setPhasem(double phase)
std::shared_ptr< AbstractTimeDependence > phase_td_m
virtual void setComponentType(std::string name) override
virtual double getSinAzimuth() const
void setPhi0(double phi0)
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
double spline(double z, double *za)
virtual std::string getFieldMapFN() const
virtual void setFrequencym(double freq)
virtual double getFrequencym() const
void setAzimuth(double angle)
std::unique_ptr< double[]> VrNormal_m
virtual void goOnline(const double &kineticEnergy) override
virtual CoordinateSystemTrafo getEdgeToEnd() const override
virtual void setAutophaseVeto(bool veto=true)
virtual double getCycFrequency() const
virtual double getAmplitudeError() const
double getdA(const int &i, const std::vector< double > &t, const double &dz, const double &frequency, const std::vector< double > &F) const
virtual double getAmplitude() const =0
Get RF amplitude.
virtual double getGapWidth() const
virtual double getAutoPhaseEstimate(const double &E0, const double &t0, const double &q, const double &m)
virtual void getDimensions(double &zBegin, double &zEnd) const override
virtual double getPhaseError() const
std::string getFrequencyModelName()
virtual double getPerpenDistance() const
virtual double getDesignEnergy() const override
virtual ElementBase::ElementType getType() const override
Get element type std::string.
virtual void setDesignEnergy(const double &ekin, bool changeable=true) override
void setGapWidth(double gapwidth)
virtual void setFast(bool fast)
virtual double getElementLength() const override
Get design length.
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
virtual void goOffline() override
virtual double getPhi0() const
virtual double getAutoPhaseEstimateFallback(double E0, double t0, double q, double m)
std::string frequency_name_m
void setRmax(double rmax)
void setAmplitudeModel(std::shared_ptr< AbstractTimeDependence > time_dep)
virtual double getRmin() const
std::string getCavityType() const
virtual void setFieldMapFN(std::string fmapfn)
Set the name of the field map.
double getdT(const int &i, const std::vector< double > &E, const double &dz, const double mass) const
Vektor< double, 3 > Vector_t