71 endField_m = std::shared_ptr<endfieldmodel::EndFieldModel>();
95 double E_sin_t = E0*
sin(omega * t + phi);
96 double B_cos_t = E0*
cos(omega * t + phi);
100 for (
size_t i = 1; i < y_power.size(); ++i) {
101 y_power[i] = y_power[i-1]*
R[1];
105 std::vector<double> endField(
maxOrder_m/2+2, 0.);
106 for (
size_t i = 0; i < endField.size(); ++i) {
111 std::vector<double> omegaPower(
maxOrder_m+1, 1.);
112 for (
size_t i = 1; i < omegaPower.size(); ++i) {
113 omegaPower[i] = omegaPower[i-1]*omega;
125 for (
size_t i = 0; i <
f_m[index].size() && i < endField.size(); i += 2) {
126 fCoeff +=
f_m[index][i]*endField[i]*omegaPower[
n-i];
128 E[2] += E_sin_t*y_power[
n]*fCoeff;
135 size_t index = (
n-1)/2;
137 for (
size_t j = 0; j <
g_m[index].size() && j < endField.size(); ++j) {
141 gCoeff +=
g_m[index][j]*endField[j]*omegaPower[
n-j];
143 for (
size_t j = 0; j <
h_m[index].size() && j < endField.size(); ++j) {
144 hCoeff +=
h_m[index][j]*endField[j]*omegaPower[
n-j];
148 E[1] += E_sin_t*y_power[
n]*gCoeff;
149 B[0] += B_cos_t*y_power[
n]*hCoeff;
166 return apply(
R, P, t, E, B);
177 for (
size_t i = 0; i <
vec.size(); ++i) {
178 out << std::setw(3) << i;
179 for (
size_t j = 0; j <
vec[i].size(); ++j) {
180 out <<
" " << std::setw(14) <<
vec[i][j];
187 f_m = std::vector< std::vector<double> >();
188 g_m = std::vector< std::vector<double> >();
189 h_m = std::vector< std::vector<double> >();
190 f_m.push_back(std::vector<double>(1, 1.));
198 std::vector<double> f_n =
f_m.back();
199 std::vector<double> f_np2 = std::vector<double>(f_n.size()+2, 0.);
200 double n_const = 1./(
n+1.)/(
n+2.);
201 for (
size_t j = 0; j < f_n.size(); ++j) {
202 f_np2[j] -= f_n[j]*n_const/c_l/c_l;
204 for (
size_t j = 0; j < f_n.size(); ++j) {
205 f_np2[j+2] -= f_n[j]*n_const;
207 f_m.push_back(f_np2);
213 size_t f_index =
n/2;
214 std::vector<double> f_n =
f_m[f_index];
215 std::vector<double> g_np1 = std::vector<double>(f_n.size()+1, 0.);
216 std::vector<double> h_np1 = std::vector<double>(f_n.size(), 0.);
217 for (
size_t j = 0; j < f_n.size(); ++j) {
218 g_np1[j+1] = -1./(
n+1.)*f_n[j];
219 h_np1[j] = -1./c_l/c_l/(
n+1.)*f_n[j];
221 g_m.push_back(g_np1);
222 h_m.push_back(h_np1);
237 std::shared_ptr<endfieldmodel::EndFieldModel>
end) {
void printVector(std::ostream &out, std::vector< std::vector< double > > vec)
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
constexpr double two_pi
The value of.
constexpr double e
The value of.
constexpr double c
The velocity of light in m/s.
ParticleAttrib< Vector_t > P
virtual void visitVariableRFCavity(const VariableRFCavity &)=0
Apply the algorithm to a variable RF cavity.
PartBunchBase< double, 3 > * RefPartBunch_m
std::shared_ptr< AbstractTimeDependence > frequencyTD_m
std::shared_ptr< AbstractTimeDependence > amplitudeTD_m
std::shared_ptr< AbstractTimeDependence > phaseTD_m
VariableRFCavity & operator=(const VariableRFCavity &)
std::shared_ptr< endfieldmodel::EndFieldModel > endField_m
virtual ~VariableRFCavityFringeField()
std::vector< std::vector< double > > f_m
VariableRFCavityFringeField & operator=(const VariableRFCavityFringeField &)
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
VariableRFCavityFringeField()
std::vector< std::vector< double > > h_m
void initialiseCoefficients()
std::vector< std::vector< double > > g_m
void printCoefficients(std::ostream &out) const
virtual void accept(BeamlineVisitor &) const override
virtual ElementBase * clone() const override
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
virtual void setEndField(std::shared_ptr< endfieldmodel::EndFieldModel > endField)
Vektor< double, 3 > Vector_t