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