72 endField_m = std::shared_ptr<endfieldmodel::EndFieldModel>();
96 double E_sin_t = E0*
sin(omega * t + phi);
97 double B_cos_t = E0*
cos(omega * t + phi);
101 for (
size_t i = 1; i < y_power.size(); ++i) {
102 y_power[i] = y_power[i-1]*
R[1];
106 std::vector<double> endField(
maxOrder_m/2+2, 0.);
107 for (
size_t i = 0; i < endField.size(); ++i) {
112 std::vector<double> omegaPower(
maxOrder_m+1, 1.);
113 for (
size_t i = 1; i < omegaPower.size(); ++i) {
114 omegaPower[i] = omegaPower[i-1]*omega;
126 for (
size_t i = 0; i <
f_m[index].size() && i < endField.size(); i += 2) {
127 fCoeff +=
f_m[index][i]*endField[i]*omegaPower[
n-i];
129 E[2] += E_sin_t*y_power[
n]*fCoeff;
136 size_t index = (
n-1)/2;
138 for (
size_t j = 0; j <
g_m[index].size() && j < endField.size(); ++j) {
142 gCoeff +=
g_m[index][j]*endField[j]*omegaPower[
n-j];
144 for (
size_t j = 0; j <
h_m[index].size() && j < endField.size(); ++j) {
145 hCoeff +=
h_m[index][j]*endField[j]*omegaPower[
n-j];
149 E[1] += E_sin_t*y_power[
n]*gCoeff;
150 B[0] += B_cos_t*y_power[
n]*hCoeff;
167 return apply(
R, P, t, E, B);
178 for (
size_t i = 0; i <
vec.size(); ++i) {
179 out << std::setw(3) << i;
180 for (
size_t j = 0; j <
vec[i].size(); ++j) {
181 out <<
" " << std::setw(14) <<
vec[i][j];
188 f_m = std::vector< std::vector<double> >();
189 g_m = std::vector< std::vector<double> >();
190 h_m = std::vector< std::vector<double> >();
191 f_m.push_back(std::vector<double>(1, 1.));
199 std::vector<double> f_n =
f_m.back();
200 std::vector<double> f_np2 = std::vector<double>(f_n.size()+2, 0.);
201 double n_const = 1./(
n+1.)/(
n+2.);
202 for (
size_t j = 0; j < f_n.size(); ++j) {
203 f_np2[j] -= f_n[j]*n_const/c_l/c_l;
205 for (
size_t j = 0; j < f_n.size(); ++j) {
206 f_np2[j+2] -= f_n[j]*n_const;
208 f_m.push_back(f_np2);
214 size_t f_index =
n/2;
215 std::vector<double> f_n =
f_m[f_index];
216 std::vector<double> g_np1 = std::vector<double>(f_n.size()+1, 0.);
217 std::vector<double> h_np1 = std::vector<double>(f_n.size(), 0.);
218 for (
size_t j = 0; j < f_n.size(); ++j) {
219 g_np1[j+1] = -1./(
n+1.)*f_n[j];
220 h_np1[j] = -1./c_l/c_l/(
n+1.)*f_n[j];
222 g_m.push_back(g_np1);
223 h_m.push_back(h_np1);
238 std::shared_ptr<endfieldmodel::EndFieldModel>
end) {
void printVector(std::ostream &out, std::vector< std::vector< double > > vec)
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
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 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