BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
coolingchannel.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "coolingchannel.h"
20
21using namespace GMAD;
22
28
30{
31 name = "";
32 surroundingMaterial = "vacuum";
33
34 nCells = 0;
35 cellLengthZ = 0;
36
37 nCoils = 0;
38 coilInnerRadius.clear();
39 coilRadialThickness.clear();
40 coilLengthZ.clear();
41 coilCurrent.clear();
42 coilOffsetZ.clear();
43 coilMaterial.clear();
44 mirrorCoils = false;
45 onAxisTolerance = 0;
46 nSheets = 0;
47
48 nDipoles = 0;
49 dipoleAperture.clear();
50 dipoleLengthZ.clear();
51 dipoleFieldStrength.clear();
52 dipoleEngeCoefficient.clear();
53 dipoleOffsetZ.clear();
54
55 nAbsorbers = 0;
56 absorberType.clear();
57 absorberMaterial.clear();
58 absorberOffsetZ.clear();
59 absorberCylinderLength.clear();
60 absorberCylinderRadius.clear();
61 absorberWedgeOpeningAngle.clear();
62 absorberWedgeHeight.clear();
63 absorberWedgeRotationAngle.clear();
64 absorberWedgeOffsetX.clear();
65 absorberWedgeOffsetY.clear();
66 absorberWedgeApexToBase.clear();
67
68 nRFCavities = 0;
69 rfOffsetZ.clear();
70 rfLength.clear();
71 rfVoltage.clear();
72 rfPhase.clear();
73 rfFrequency.clear();
74 rfWindowThickness.clear();
75 rfWindowMaterial.clear();
76 rfWindowRadius.clear();
77 rfCavityMaterial.clear();
78 rfCavityVacuumMaterial.clear();
79 rfCavityRadius.clear();
80 rfCavityThickness.clear();
81 rfTimeOffset.clear();
82
83 integrator = "g4classicalrk4";
84 magneticFieldModel = "solenoidblock";
85 electricFieldModel = "rfcavity";
86 dipoleFieldModel = "dipole";
87}
88
90{
92
93 publish("surroundingMaterial", &CoolingChannel::surroundingMaterial);
94 publish("nCells", &CoolingChannel::nCells);
95
96 publish("cellLengthZ", &CoolingChannel::cellLengthZ);
97 publish("nCoils", &CoolingChannel::nCoils);
98 publish("coilInnerRadius", &CoolingChannel::coilInnerRadius);
99 publish("coilRadialThickness", &CoolingChannel::coilRadialThickness);
100 publish("coilLengthZ", &CoolingChannel::coilLengthZ);
101 publish("coilCurrent", &CoolingChannel::coilCurrent);
102 publish("coilOffsetZ", &CoolingChannel::coilOffsetZ);
103 publish("coilMaterial", &CoolingChannel::coilMaterial);
104 publish("mirrorCoils", &CoolingChannel::mirrorCoils);
105 publish("onAxisTolerance", &CoolingChannel::onAxisTolerance);
106 publish("nSheets", &CoolingChannel::nSheets);
107
108 publish("nDipoles", &CoolingChannel::nDipoles);
109 publish("dipoleAperture", &CoolingChannel::dipoleAperture);
110 publish("dipoleLengthZ", &CoolingChannel::dipoleLengthZ);
111 publish("dipoleFieldStrength", &CoolingChannel::dipoleFieldStrength);
112 publish("dipoleEngeCoefficient",&CoolingChannel::dipoleEngeCoefficient);
113 publish("dipoleOffsetZ", &CoolingChannel::dipoleOffsetZ);
114
115 publish("nAbsorbers", &CoolingChannel::nAbsorbers);
116 publish("absorberType", &CoolingChannel::absorberType);
117 publish("absorberMaterial", &CoolingChannel::absorberMaterial);
118 publish("absorberOffsetZ", &CoolingChannel::absorberOffsetZ);
119 publish("absorberCylinderLength", &CoolingChannel::absorberCylinderLength);
120 publish("absorberCylinderRadius", &CoolingChannel::absorberCylinderRadius);
121 publish("absorberWedgeOpeningAngle", &CoolingChannel::absorberWedgeOpeningAngle);
122 publish("absorberWedgeHeight", &CoolingChannel::absorberWedgeHeight);
123 publish("absorberWedgeRotationAngle", &CoolingChannel::absorberWedgeRotationAngle);
124 publish("absorberWedgeOffsetX", &CoolingChannel::absorberWedgeOffsetX);
125 publish("absorberWedgeOffsetY", &CoolingChannel::absorberWedgeOffsetY);
126 publish("absorberWedgeApexToBase", &CoolingChannel::absorberWedgeApexToBase);
127
128 publish("nRFCavities", &CoolingChannel::nRFCavities);
129 publish("rfOffsetZ", &CoolingChannel::rfOffsetZ);
130 publish("rfLength", &CoolingChannel::rfLength);
131 publish("rfVoltage", &CoolingChannel::rfVoltage);
132 publish("rfPhase", &CoolingChannel::rfPhase);
133 publish("rfFrequency", &CoolingChannel::rfFrequency);
134 publish("rfWindowThickness", &CoolingChannel::rfWindowThickness);
135 publish("rfWindowMaterial", &CoolingChannel::rfWindowMaterial);
136 publish("rfWindowRadius", &CoolingChannel::rfWindowRadius);
137 publish("rfCavityMaterial", &CoolingChannel::rfCavityMaterial);
138 publish("rfCavityVacuumMaterial", &CoolingChannel::rfCavityVacuumMaterial);
139 publish("rfCavityRadius", &CoolingChannel::rfCavityRadius);
140 publish("rfCavityThickness", &CoolingChannel::rfCavityThickness);
141 publish("rfTimeOffset", &CoolingChannel::rfTimeOffset);
142
143 publish("integrator", &CoolingChannel::integrator);
144 publish("magneticFieldModel",&CoolingChannel::magneticFieldModel);
145 publish("electricFieldModel",&CoolingChannel::electricFieldModel);
146 publish("dipoleFieldModel", &CoolingChannel::dipoleFieldModel);
147
148 attribute_map_list_double["coilInnerRadius"] = &coilInnerRadius;
149 attribute_map_list_double["coilRadialThickness"] = &coilRadialThickness;
150 attribute_map_list_double["coilLengthZ"] = &coilLengthZ;
151 attribute_map_list_double["coilCurrent"] = &coilCurrent;
152 attribute_map_list_double["coilOffsetZ"] = &coilOffsetZ;
153 attribute_map_list_string["coilMaterial"] = &coilMaterial;
154 attribute_map_list_double["dipoleAperture"] = &dipoleAperture;
155 attribute_map_list_double["dipoleLengthZ"] = &dipoleLengthZ;
156 attribute_map_list_double["dipoleFieldStrength"] = &dipoleFieldStrength;
157 attribute_map_list_double["dipoleEngeCoefficient"] = &dipoleEngeCoefficient;
158 attribute_map_list_double["dipoleOffsetZ"] = &dipoleOffsetZ;
159 attribute_map_list_string["absorberType"] = &absorberType;
160 attribute_map_list_string["absorberMaterial"] = &absorberMaterial;
161 attribute_map_list_double["absorberOffsetZ"] = &absorberOffsetZ;
162 attribute_map_list_double["absorberCylinderLength"] = &absorberCylinderLength;
163 attribute_map_list_double["absorberCylinderRadius"] = &absorberCylinderRadius;
164 attribute_map_list_double["absorberWedgeOpeningAngle"] = &absorberWedgeOpeningAngle;
165 attribute_map_list_double["absorberWedgeHeight"] = &absorberWedgeHeight;
166 attribute_map_list_double["absorberWedgeRotationAngle"] = &absorberWedgeRotationAngle;
167 attribute_map_list_double["absorberWedgeOffsetX"] = &absorberWedgeOffsetX;
168 attribute_map_list_double["absorberWedgeOffsetY"] = &absorberWedgeOffsetY;
169 attribute_map_list_double["absorberWedgeApexToBase"] = &absorberWedgeApexToBase;
170 attribute_map_list_double["rfOffsetZ"] = &rfOffsetZ;
171 attribute_map_list_double["rfLength"] = &rfLength;
172 attribute_map_list_double["rfVoltage"] = &rfVoltage;
173 attribute_map_list_double["rfPhase"] = &rfPhase;
174 attribute_map_list_double["rfFrequency"] = &rfFrequency;
175 attribute_map_list_double["rfWindowThickness"] = &rfWindowThickness;
176 attribute_map_list_string["rfWindowMaterial"] = &rfWindowMaterial;
177 attribute_map_list_string["rfCavityVacuumMaterial"] = &rfCavityVacuumMaterial;
178 attribute_map_list_double["rfWindowRadius"] = &rfWindowRadius;
179 attribute_map_list_string["rfCavityMaterial"] = &rfCavityMaterial;
180 attribute_map_list_double["rfCavityRadius"] = &rfCavityRadius;
181 attribute_map_list_double["rfCavityThickness"] = &rfCavityThickness;
182 attribute_map_list_double["rfTimeOffset"] = &rfTimeOffset;
183 // integrator, magneticFieldModel and electricFieldModel can't be lists or arrays, so don't include here
184}
185
186template <class T>
187std::ostream& operator<<(std::ostream& out, const std::list<T>& l);
188
190
191{
192 std::cout << "coolingchannel: "
193 << "name " << name << std::endl
194 << "nCells " << nCells << std::endl
195 << "cellLengthZ " << cellLengthZ << std::endl
196 << "nCoils " << nCoils << std::endl
197 << "coilInnerRadius " << coilInnerRadius << std::endl
198 << "coilRadialThickness " << coilRadialThickness << std::endl
199 << "coilLengthZ " << coilLengthZ << std::endl
200 << "coilCurrent " << coilCurrent << std::endl
201 << "coilOffsetZ " << coilOffsetZ << std::endl
202 << "coilMaterial " << coilMaterial << std::endl
203 << "mirrorCoils " << mirrorCoils << std::endl
204 << "onAxisTolerance " << onAxisTolerance << std::endl
205 << "nSheets " << nSheets << std::endl
206 << "nDipoles " << nDipoles << std::endl
207 << "dipoleAperture " << dipoleAperture << std::endl
208 << "dipoleLengthZ " << dipoleLengthZ << std::endl
209 << "dipoleFieldStrength " << dipoleFieldStrength << std::endl
210 << "dipoleEngeCoefficient " << dipoleEngeCoefficient << std::endl
211 << "dipoleOffsetZ " << dipoleOffsetZ << std::endl
212 << "nAbsorbers " << nAbsorbers << std::endl
213 << "absorberType " << absorberType << std::endl
214 << "absorberMaterial " << absorberMaterial << std::endl
215 << "absorberOffsetZ " << absorberOffsetZ << std::endl
216 << "absorberCylinderLength " << absorberCylinderLength << std::endl
217 << "absorberCylinderRadius " << absorberCylinderRadius << std::endl
218 << "absorberWedgeOpeningAngle " << absorberWedgeOpeningAngle << std::endl
219 << "absorberWedgeHeight " << absorberWedgeHeight << std::endl
220 << "absorberWedgeRotationAngle " << absorberWedgeRotationAngle << std::endl
221 << "absorberWedgeOffsetX " << absorberWedgeOffsetX << std::endl
222 << "absorberWedgeOffsetY " << absorberWedgeOffsetY << std::endl
223 << "absorberWedgeApexToBase " << absorberWedgeApexToBase << std::endl
224 << "nRFCavities " << nRFCavities << std::endl
225 << "rfOffsetZ " << rfOffsetZ << std::endl
226 << "rfLength" << rfLength << std::endl
227 << "rfVoltage " << rfVoltage << std::endl
228 << "rfPhase " << rfPhase << std::endl
229 << "rfFrequency " << rfFrequency << std::endl
230 << "rfWindowThickness " << rfWindowThickness << std::endl
231 << "rfWindowMaterial " << rfWindowMaterial << std::endl
232 << "rfCavityVacuumMaterial " << rfCavityVacuumMaterial << std::endl
233 << "rfWindowRadius " << rfWindowRadius << std::endl
234 << "rfCavityMaterial " << rfCavityMaterial << std::endl
235 << "rfCavityRadius " << rfCavityRadius << std::endl
236 << "rfCavityThickness " << rfCavityThickness << std::endl
237 << "rfTimeOffset " << rfTimeOffset << std::endl
238 << "integrator " << integrator << std::endl
239 << "magneticFieldModel " << magneticFieldModel << std::endl
240 << "electricFieldModel " << electricFieldModel << std::endl
241 << "dipoleFieldModel " << dipoleFieldModel << std::endl;
242}
243
244template <class T>
245std::ostream& operator<<(std::ostream& out, const std::list<T>& l)
246{
247 out << "{";
248 for (const auto& v : l)
249 {out << v << ", ";}
250 out << "}";
251 return out;
252}
253
254void CoolingChannel::set_value(const std::string& property, Array* value)
255{
256 auto search = attribute_map_list_double.find(property);
257 if (search != attribute_map_list_double.end())
258 {value->set_vector(*search->second);}
259 else
260 {
261 auto search2 = attribute_map_list_string.find(property);
262 if (search2 != attribute_map_list_string.end())
263 {value->set_vector(*search2->second);}
264 else
265 {
266 std::cerr << "Error: parser> unknown coolingchannel option \"" << property << "\", or doesn't expect vector type" << std::endl;
267 exit(1);
268 }
269 }
270}
Representation of arrays used in tokens.
Definition array.h:40
void set_vector(Container< std::string, std::allocator< std::string > > &dst) const
Copy symbols into STL string containers.
Definition array.h:102
void print() const
Print some properties.
CoolingChannel()
Constructor.
std::string name
Object name.
void PublishMembers()
publish members
void set_value(const std::string &property, T value)
Set methods by property name and value.
void publish(const std::string &name, T C::*mp)
Make pointer to member from class C and type T with accessible with a name.
Definition published.h:94
Parser namespace for GMAD language. Combination of Geant4 and MAD.
std::ostream & operator<<(std::ostream &out, ElementType type)
output operator