BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
field.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 "field.h"
20
21using namespace GMAD;
22
23Field::Field()
24{
25 clear();
27}
28
30{
31 name = "";
32 type = "";
33 eScaling = 1.0;
34 bScaling = 1.0;
35 integrator = "g4classicalrk4";
36 globalTransform = true;
37 magneticFile = "";
38 magneticInterpolator = "cubic";
39 electricFile = "";
40 electricInterpolator = "cubic";
41 x = 0;
42 y = 0;
43 z = 0;
44 t = 0;
45 phi = 0;
46 theta = 0;
47 psi = 0;
48 axisX = 0;
49 axisY = 0;
50 axisZ = 0;
51 angle = 0;
52 axisAngle = false;
53 autoScale = false;
55 magneticSubField = "";
56 electricSubField = "";
57 magneticReflection = "";
58 electricReflection = "";
59 fieldParameters = "";
60}
61
63{
64 publish("name", &Field::name);
65 publish("type", &Field::type);
66 publish("eScaling", &Field::eScaling);
67 publish("bScaling", &Field::bScaling);
68 publish("integrator", &Field::integrator);
69 publish("globalTransform", &Field::globalTransform);
70 publish("magneticFile", &Field::magneticFile);
71 publish("magneticInterpolator", &Field::magneticInterpolator);
72 publish("electricFile", &Field::electricFile);
73 publish("electricInterpolator", &Field::electricInterpolator);
74 publish("x", &Field::x);
75 publish("y", &Field::y);
76 publish("z", &Field::z);
77 publish("t", &Field::t);
78 publish("phi", &Field::phi);
79 publish("theta", &Field::theta);
80 publish("psi", &Field::psi);
81 publish("axisX", &Field::axisX);
82 publish("axisY", &Field::axisY);
83 publish("axisZ", &Field::axisZ);
84 publish("angle", &Field::angle);
85 publish("axisAngle", &Field::axisAngle);
86 publish("autoScale", &Field::autoScale);
87 publish("maximumStepLength", &Field::maximumStepLength);
88 publish("magneticSubField", &Field::magneticSubField);
89 publish("electricSubField", &Field::electricSubField);
90 publish("magneticReflection", &Field::magneticReflection);
91 publish("electricReflection", &Field::electricReflection);
92 publish("fieldParameters", &Field::fieldParameters);
93}
94
95void Field::print()const
96{
97 std::cout << "field: "
98 << "name " << name << std::endl
99 << "type " << type << std::endl
100 << "eScaling " << eScaling << std::endl
101 << "bScaling " << bScaling << std::endl
102 << "integrator " << integrator << std::endl
103 << "magneticFile " << magneticFile << std::endl
104 << "magneticInterpolator " << magneticInterpolator << std::endl
105 << "electricFile " << electricFile << std::endl
106 << "electricInterpolator " << electricInterpolator << std::endl
107 << "x, y, z,t " << x << " " << y << " " << z << " " << t << std::endl
108 << "phi, theta, psi " << phi << " " << theta << " " << psi << std::endl
109 << "axisX, Y, Z " << axisX << " " << axisY << " " << axisZ << std::endl
110 << "angle " << angle << std::endl
111 << "axisAngle " << axisAngle << std::endl
112 << "autoScale " << autoScale << std::endl
113 << "maximumStepLength " << maximumStepLength << std::endl
114 << "electricSubField " << electricSubField << std::endl
115 << "magneticSubField " << magneticSubField << std::endl
116 << "magneticReflection " << magneticReflection << std::endl
117 << "electricReflection " << electricReflection << std::endl
118 << "fieldParameters " << fieldParameters << std::endl;
119}
double theta
Euler angle for rotation.
Definition: field.h:56
bool autoScale
Scale the field to the magnet it's attached to.
Definition: field.h:67
void print() const
Print some properties.
Definition: field.cc:95
double z
Offset in z.
Definition: field.h:52
std::string type
Type.
Definition: field.h:40
std::string integrator
Which integrator to use.
Definition: field.h:43
std::string magneticInterpolator
Interpolator for the magnetic field.
Definition: field.h:46
std::string electricFile
File for the electric field map.
Definition: field.h:47
double axisX
Definition: field.h:60
void PublishMembers()
publish members
Definition: field.cc:62
double phi
Euler angle for rotation.
Definition: field.h:55
double t
Definition: field.h:53
double bScaling
B Field Scaling factor.
Definition: field.h:42
std::string name
Name.
Definition: field.h:39
double maximumStepLength
Maximum permitted step length in the volumes the field is attached to.
Definition: field.h:70
double y
Offset in y.
Definition: field.h:51
double angle
Definition: field.h:63
std::string magneticFile
File for magnetic field map.
Definition: field.h:45
std::string electricInterpolator
Interpolator for the electric field.
Definition: field.h:48
double x
Offset in x.
Definition: field.h:50
void clear()
Reset.
Definition: field.cc:29
bool axisAngle
Flag to use the axis angle construction of rotation.
Definition: field.h:65
double axisY
Definition: field.h:61
bool globalTransform
Provide global to curvilinear coordinate transform.
Definition: field.h:44
double eScaling
E Field Scaling factor.
Definition: field.h:41
double axisZ
Definition: field.h:62
double psi
Euler angle for rotation.
Definition: field.h:57
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:92
Parser namespace for GMAD language. Combination of Geant4 and MAD.