BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
coolingchannel.h
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#ifndef COOLINGCHANNEL_H
19#define COOLINGCHANNEL_H
20
21#include <iomanip>
22#include <iostream>
23#include <list>
24#include <map>
25#include <string>
26#if __cplusplus >= 201703L
27#include <variant>
28#include <algorithm>
29#endif
30
31#include "published.h"
32
33namespace GMAD
34{
41 class CoolingChannel: public Published<CoolingChannel>
42 {
43 public:
44 std::string name;
45
46 std::string surroundingMaterial;
47
48 int nCells;
49 double cellLengthZ;
50
51 int nCoils;
52 std::list<double> coilInnerRadius;
53 std::list<double> coilRadialThickness;
54 std::list<double> coilLengthZ;
55 std::list<double> coilCurrent;
56 std::list<double> coilOffsetZ;
57 std::list<std::string> coilMaterial;
58 bool mirrorCoils;
59 double onAxisTolerance;
60 int nSheets;
61
62 int nDipoles;
63 std::list<double> dipoleAperture;
64 std::list<double> dipoleLengthZ;
65 std::list<double> dipoleFieldStrength;
66 std::list<double> dipoleEngeCoefficient;
67 std::list<double> dipoleOffsetZ;
68
69 int nAbsorbers;
70 std::list<std::string> absorberType;
71 std::list<std::string> absorberMaterial;
72 std::list<double> absorberOffsetZ;
73 std::list<double> absorberCylinderLength;
74 std::list<double> absorberCylinderRadius;
75 std::list<double> absorberWedgeOpeningAngle;
76 std::list<double> absorberWedgeHeight;
77 std::list<double> absorberWedgeRotationAngle;
78 std::list<double> absorberWedgeOffsetX;
79 std::list<double> absorberWedgeOffsetY;
80 std::list<double> absorberWedgeApexToBase;
81
82 int nRFCavities;
83 std::list<double> rfOffsetZ;
84 std::list<double> rfLength;
85 std::list<double> rfVoltage;
86 std::list<double> rfPhase;
87 std::list<double> rfFrequency;
88 std::list<double> rfWindowThickness;
89 std::list<std::string> rfWindowMaterial;
90 std::list<double> rfWindowRadius;
91 std::list<std::string> rfCavityMaterial;
92 std::list<std::string> rfCavityVacuumMaterial;
93 std::list<double> rfCavityRadius;
94 std::list<double> rfCavityThickness;
95 std::list<double> rfTimeOffset;
96
97 std::string integrator;
98 std::string magneticFieldModel;
99 std::string electricFieldModel;
100 std::string dipoleFieldModel;
101
105 void clear();
107 void print()const;
109 template <typename T>
110 void set_value(const std::string& property, T value, bool bExit = true);
111 // Template overloading for Array pointers
113 void set_value(const std::string& property, Array* value, bool bExit = true);
115#if __cplusplus >= 201703L
116 std::list<std::variant<bool, int, double, std::string>> get_value_array(const std::string &);
117#endif
118
119 private:
121 void PublishMembers();
122
123 std::map<std::string, std::list<double>*> attribute_map_list_double;
124 std::map<std::string, std::list<std::string>*> attribute_map_list_string;
125 };
126
127 template <typename T>
128 void CoolingChannel::set_value(const std::string& property, T value, bool bExit)
129 {
130#ifdef BDSDEBUG
131 std::cout << "coolingchannel> Setting value " << std::setw(25) << std::left << property << value << std::endl;
132#endif
133 // member method can throw runtime_error, catch and exit gracefully
134 try
135 {set(this,property,value);}
136 catch(const std::runtime_error&)
137 {
138 std::cerr << "Error: coolingchannel> unknown option \"" << property << "\" with value " << value << std::endl;
139 if(bExit)
140 {exit(1);}
141 else
142 {std::rethrow_exception(std::current_exception());}
143 }
144 }
145}
146
147#endif
Representation of arrays used in tokens.
Definition array.h:39
Cooling channel parameters.
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
Class that provides introspection to its members.
Definition published.h:48
void set(CoolingChannel *instance, const std::string &name, double value)
Definition published.h:100
Parser namespace for GMAD language. Combination of Geant4 and MAD.