BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
field.h
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
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#ifndef FIELD_H
20#define FIELD_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
36 class Field : public Published<Field>
37 {
38 public:
39 std::string name;
40 std::string type;
41 double eScaling;
42 double bScaling;
43 std::string integrator;
45 std::string magneticFile;
47 std::string electricFile;
49 std::string fieldModulator;
50
51 double x;
52 double y;
53 double z;
54 double t;
56 double phi;
57 double theta;
58 double psi;
61 double axisX;
62 double axisY;
63 double axisZ;
64 double angle;
66 bool axisAngle;
67
68 bool autoScale;
69
72
73 std::string magneticSubField;
74 std::string electricSubField;
75
76 std::string magneticReflection;
77 std::string electricReflection;
78
79 std::string fieldParameters;
80
82 Field();
84 void clear();
86 void print()const;
88 template <typename T>
89 void set_value(std::string property, T value);
90
91
92 private:
94 void PublishMembers();
95 };
96
97 template <typename T>
98 void Field::set_value(std::string property, T value)
99 {
100#ifdef BDSDEBUG
101 std::cout << "field> Setting value " << std::setw(25) << std::left << property << value << std::endl;
102#endif
103 // member method can throw runtime_error, catch and exit gracefully
104 try
105 {set(this,property,value);}
106 catch (const std::runtime_error&)
107 {
108 std::cerr << "Error: field> unknown option \"" << property << "\" with value \"" << value << "\"" << std::endl;
109 exit(1);
110 }
111 }
112}
113
114#endif
Field class for parser.
Definition: field.h:37
void set_value(std::string property, T value)
Set methods by property name and value.
Definition: field.h:98
double theta
Euler angle for rotation.
Definition: field.h:57
bool autoScale
Scale the field to the magnet it's attached to.
Definition: field.h:68
void print() const
Print some properties.
Definition: field.cc:97
double z
Offset in z.
Definition: field.h:53
std::string type
Type.
Definition: field.h:40
std::string integrator
Which integrator to use.
Definition: field.h:43
Field()
Constructor.
Definition: field.cc:23
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:61
void PublishMembers()
publish members
Definition: field.cc:63
double phi
Euler angle for rotation.
Definition: field.h:56
double t
Definition: field.h:54
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:71
double y
Offset in y.
Definition: field.h:52
double angle
Definition: field.h:64
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:51
void clear()
Reset.
Definition: field.cc:29
std::string fieldModulator
Name of field modulator object.
Definition: field.h:49
bool axisAngle
Flag to use the axis angle construction of rotation.
Definition: field.h:66
double axisY
Definition: field.h:62
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:63
double psi
Euler angle for rotation.
Definition: field.h:58
Class that provides introspection to its members.
Definition: published.h:47
void set(Field *instance, const std::string &name, double value)
Definition: published.h:99
Parser namespace for GMAD language. Combination of Geant4 and MAD.