forked from SixTrack/sixtracklib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.cpp
99 lines (87 loc) · 3.4 KB
/
interface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "lattice.h"
// required for vector of particles in Python
bool operator==(const Particle & p1, const Particle & p2) {
return (p1.x ==p2.x &&
p1.px==p2.px &&
p1.y ==p2.y &&
p1.py==p2.py &&
p1.sigma==p2.sigma &&
p1.delta==p2.delta );
}
BOOST_PYTHON_MODULE(tracker)
{
using namespace boost::python;
class_< std::vector<double> >("vec_double")
.def(vector_indexing_suite< std::vector<double> >())
;
class_< std::vector<Particle> >("vec_Particle")
.def(vector_indexing_suite< std::vector<Particle> >())
;
class_< std::vector<HostBunch> >("vec_HostBunch")
.def(vector_indexing_suite< std::vector<HostBunch> >())
.def("x", &get_x_from_bunches )
.def("px", &get_px_from_bunches)
.def("y", &get_y_from_bunches )
.def("py", &get_py_from_bunches)
.def("d", &get_d_from_bunches )
.def("z", &get_z_from_bunches )
;
void (Lattice::*lattice_track_H)(HostBunch&) = &Lattice::track;
void (Lattice::*lattice_track_D)(DeviceBunch&) = &Lattice::track;
class_<Lattice, boost::noncopyable>("Lattice")
.def(init<const std::string &>())
.def("read_twiss_table", &Lattice::read_twiss_table)
.def("optimise", &Lattice::optimise)
.def("add", &Lattice::add)
.def("n_elements", &Lattice::get_n_elements)
.def("compile", &Lattice::compile)
.def("write_ptx", &Lattice::write_ptx)
.def("read_ptx", &Lattice::read_ptx)
.def("make_matched_bunch", &Lattice::make_matched_bunch)
.def("track", lattice_track_H)
.def("track", lattice_track_D)
.def("sigma_x", &Lattice::sigma_x)
.def("sigma_y", &Lattice::sigma_y)
.def("rel_gamma", &Lattice::rel_gamma)
.def_readwrite("turns", &Lattice::turn_by_turn_data)
.def_readwrite("n_turns", &Lattice::n_turns)
.def_readwrite("collect_tbt_data", &Lattice::collect_tbt_data)
.def_readwrite("BETX", &Lattice::BETX)
.def_readwrite("BETY", &Lattice::BETY)
.def_readwrite("ALFX", &Lattice::ALFX)
.def_readwrite("ALFY", &Lattice::ALFY)
.def_readwrite("DX" , &Lattice::DX)
.def_readwrite("DY" , &Lattice::DY)
.def_readwrite("DPX" , &Lattice::DPX)
.def_readwrite("DPY" , &Lattice::DPY)
.def_readwrite("X" , &Lattice::X) //closed orbit
.def_readwrite("Y" , &Lattice::Y)
.def_readwrite("PX" , &Lattice::PX)
.def_readwrite("PY" , &Lattice::PY)
.def_readwrite("norm_emit_x", &Lattice::norm_emit_x)
.def_readwrite("norm_emit_y", &Lattice::norm_emit_y)
.def_readwrite("bunch_length", &Lattice::bunch_length)
.def_readwrite("bunch_energy_spread", &Lattice::bunch_energy_spread)
.def_readwrite("energy", &Lattice::energy)
.def_readwrite("mass", &Lattice::mass)
;
class_<Particle>("Particle")
.def_readwrite("x" , &Particle::x)
.def_readwrite("px", &Particle::px)
.def_readwrite("y" , &Particle::y)
.def_readwrite("py", &Particle::py)
.def_readwrite("z" , &Particle::sigma)
.def_readwrite("d" , &Particle::delta)
;
class_<HostBunch>("HostBunch", init<const size_t>())
.def("size", &HostBunch::size)
.def("fromDeviceBunch", &HostBunch::copyFromDeviceBunch)
.def("toDeviceBunch", &HostBunch::copyToDeviceBunch)
.def_readwrite("particle", &HostBunch::particles)
;
class_<DeviceBunch>("DeviceBunch",init<const HostBunch &>())
;
def("CUDA_info", CUDA_info);
}