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