BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
python.cc
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#include "python.h"
20
21#include "parser.h"
22
23#include <cstdio>
24#include <list>
25
27int GMAD::GmadParser_c(char *name)
28{
29 Parser::Instance(std::string(name));
30 return 0;
31}
32
34{
35 return Parser::Instance()->GetBeamline().size();
36}
37
38const char* GMAD::GetName(int i)
39{
40 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
41 std::advance(it, i);
42 return (it->name).c_str();
43}
44
45int GMAD::GetType(int i)
46{
47 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
48 std::advance(it, i);
49 return static_cast<int>(it->type);
50}
51
52double GMAD::GetLength(int i)
53{
54 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
55 std::advance(it, i);
56 return it->l;
57}
58
59double GMAD::GetAngle(int i)
60{
61 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
62 std::advance(it, i);
63 return it->angle;
64}
65
66double* GMAD::GetKs(int i)
67{
68 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
69 std::advance(it, i);
70 double* result = new double[5];
71 result[0] = it->ks;
72 result[1] = it->k1;
73 result[2] = it->k2;
74 result[3] = it->k3;
75 result[4] = it->k4;
76 return result;
77}
78
79double GMAD::GetAper1(int i)
80{
81 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
82 std::advance(it, i);
83 return it->aper1;
84}
85
86double GMAD::GetAper2(int i)
87{
88 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
89 std::advance(it, i);
90 return it->aper2;
91}
92
93double GMAD::GetAper3(int i)
94{
95 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
96 std::advance(it, i);
97 return it->aper3;
98}
99
100double GMAD::GetAper4(int i)
101{
102 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
103 std::advance(it, i);
104 return it->aper4;
105}
106
107const char* GMAD::GetApertureType(int i)
108{
109 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
110 std::advance(it, i);
111 return (it->apertureType).c_str();
112}
113
115{
116 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
117 std::advance(it, i);
118 return it->beampipeThickness;
119}
double GetBeampipeThickness(int)
Beam Pipe Thickness.
Definition: python.cc:114
const char * GetName(int)
Name of element.
Definition: python.cc:38
int GetType(int)
Type of element.
Definition: python.cc:45
double * GetKs(int)
All magnetic ks.
Definition: python.cc:66
double GetAper3(int)
Aperture 3.
Definition: python.cc:93
double GetAper1(int)
Aperture 1.
Definition: python.cc:79
double GetAper4(int)
Aperture 4.
Definition: python.cc:100
int GmadParser_c(char *name)
Definition: python.cc:27
int GetNElements()
Length of list.
Definition: python.cc:33
double GetLength(int)
Length of element.
Definition: python.cc:52
double GetAngle(int)
Angle of element.
Definition: python.cc:59
const char * GetApertureType(int)
Aperture Type.
Definition: python.cc:107
double GetAper2(int)
Aperture 2.
Definition: python.cc:86