OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
VariableRFCavityFringeField.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef CLASSIC_ABSBEAMLINE_VariableRFCavityFringeField_HH
29#define CLASSIC_ABSBEAMLINE_VariableRFCavityFringeField_HH
30
31#include <iostream>
33
34class Fieldmap;
35namespace endfieldmodel {
36 class EndFieldModel;
37}
38
59 public:
61 explicit VariableRFCavityFringeField(const std::string &name);
73
79 virtual void accept(BeamlineVisitor &) const override;
80
82 virtual ElementBase* clone() const override;
83
93 virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override;
94
105 virtual bool apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override;
106
107
118 virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override;
119
125 virtual void setEndField
126 (std::shared_ptr<endfieldmodel::EndFieldModel> endField);
127
133 virtual inline std::shared_ptr<endfieldmodel::EndFieldModel>
134 getEndField() const;
135
140 virtual void initialise(PartBunchBase<double, 3> *bunch,
141 double &startField,
142 double &endField) override;
143
145 virtual inline void setCavityCentre(double zCentre);
147 virtual inline double getCavityCentre() const;
149 virtual inline void setMaxOrder(size_t maxOrder);
151 virtual inline size_t getMaxOrder() const;
155 void printCoefficients(std::ostream& out) const;
157 inline std::vector<std::vector<double> > getEzCoefficients() const;
159 inline std::vector<std::vector<double> > getEyCoefficients() const;
161 inline std::vector<std::vector<double> > getBxCoefficients() const;
162protected:
163 double zCentre_m; // offsets this element
165 std::shared_ptr<endfieldmodel::EndFieldModel> endField_m;
166 std::vector<std::vector<double> > f_m;
167 std::vector<std::vector<double> > g_m;
168 std::vector<std::vector<double> > h_m;
169private:
170 void initNull();
171};
172
174 zCentre_m = zCentre*1000.; // stored internally as mm
175}
176
178 return zCentre_m/1000.; // stored internally as mm
179}
180
182 maxOrder_m = maxOrder;
184}
185
187 return maxOrder_m;
188}
189
190std::shared_ptr<endfieldmodel::EndFieldModel>
192 return endField_m;
193}
194
195std::vector<std::vector<double> >
197 return f_m;
198}
199
200std::vector<std::vector<double> >
202 return g_m;
203}
204
205std::vector<std::vector<double> >
207 return h_m;
208}
209
210#endif // #ifdef CLASSIC_VirtualRFCavityFringeField_HH
const std::string name
void initialise() const
std::shared_ptr< endfieldmodel::EndFieldModel > endField_m
std::vector< std::vector< double > > getBxCoefficients() const
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
std::vector< std::vector< double > > getEzCoefficients() const
virtual void setMaxOrder(size_t maxOrder)
std::vector< std::vector< double > > getEyCoefficients() const
virtual std::shared_ptr< endfieldmodel::EndFieldModel > getEndField() const
std::vector< std::vector< double > > h_m
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 void setCavityCentre(double zCentre)
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)