OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
RFCavityRep.cpp
Go to the documentation of this file.
1//
2// Class RFCavityRep
3// Representation for a RF cavity.
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
20
22
23namespace {
24 struct Entry {
25 const char* name;
26 double (RFCavityRep::*get)() const;
27 void (RFCavityRep::*set)(double);
28 };
29
30 static const Entry entries[] = {
35 {0, 0, 0}};
36} // namespace
37
39
40RFCavityRep::RFCavityRep(const RFCavityRep& right) : RFCavity(right), geometry(right.geometry) {}
41
42RFCavityRep::RFCavityRep(const std::string& name) : RFCavity(name) {}
43
45
46ElementBase* RFCavityRep::clone() const { return new RFCavityRep(*this); }
47
48Channel* RFCavityRep::getChannel(const std::string& aKey, bool create) {
49 for (const Entry* entry = entries; entry->name != 0; ++entry) {
50 if (aKey == entry->name) {
51 return new IndirectChannel<RFCavityRep>(*this, entry->get, entry->set);
52 }
53 }
54
55 return ElementBase::getChannel(aKey, create);
56}
57
59
61
63
65
66double RFCavityRep::getAmplitude() const { return ignoreCavities ? 0.0 : field.getEz(); }
67
68double RFCavityRep::getFrequency() const { return field.getFrequency(); }
69
70double RFCavityRep::getPhase() const { return field.getPhase(); }
71
72void RFCavityRep::setAmplitude(double amplitude) { field.setEz(amplitude); }
73
74void RFCavityRep::setFrequency(double frequency) { field.setFrequency(frequency); }
75
76void RFCavityRep::setPhase(double phase) { field.setPhase(phase); }
77
78void RFCavityRep::setIgnore(bool ignore) { ignoreCavities = ignore; }
Abstract interface for read/write access to variable.
Definition Channel.h:30
virtual double getEz() const
Get component.
virtual void setEz(double)
Set component.
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
virtual void setElementLength(double length)
Set design length.
Access to a [b]double[/b] data member.
virtual void setFrequency(double f)
Assign the RF frequency in Hz.
virtual double getFrequency() const
Return the RF frequency in Hz.
virtual void setPhase(double phi)
Assign the RF phase in rad.
virtual double getPhase() const
Return the RF phase in rad.
virtual void setPhase(double phi)
Set phase.
virtual void setFrequency(double f)
Set frequency.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
virtual StraightGeometry & getGeometry()
Get geometry.
virtual double getPhase() const
Get phase.
virtual ElementBase * clone() const
Return clone.
virtual double getAmplitude() const
Get amplitude.
StraightGeometry geometry
The cavity's geometry.
Definition RFCavityRep.h:95
virtual void setAmplitude(double V)
Set amplitude.
static bool ignoreCavities
Cavities are ignored (amplitude = 0) when this switch is set.
static void setIgnore(bool ignore=false)
Set ignore switch.
virtual AcceleratingField & getField()
Get field.
AcceleratingField field
The cavity's field.
Definition RFCavityRep.h:98
virtual double getFrequency() const
Get frequency.
virtual ~RFCavityRep()
Interface for standing wave cavities.
Definition RFCavity.h:34
A geometry representing a straight line.