-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrajectory.hpp
106 lines (81 loc) · 2.99 KB
/
Trajectory.hpp
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
99
100
101
102
103
104
105
106
/* Trajectory Classes
* It represents the trajectory of a single particle, which can be
* an Elegant/MadX trajectory or just a closed orbit
*
* Copyright (C) 2017 Jan Felix Schmidt <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __POLEMATRIX__TRAJECTORY_HPP_
#define __POLEMATRIX__TRAJECTORY_HPP_
#include <memory>
#include <libpalattice/FunctionOfPos.hpp>
#include "Configuration.hpp"
class Trajectory
{
public:
const unsigned int particleId;
std::shared_ptr<const pal::FunctionOfPos<pal::AccPair>> orbit;
protected:
const std::shared_ptr<Configuration> config;
bool initDone;
public:
Trajectory(unsigned int id, const std::shared_ptr<Configuration> c) : particleId(id), config(c), initDone(false) {}
virtual ~Trajectory() {}
void setOrbit(std::shared_ptr<const pal::FunctionOfPos<pal::AccPair>> o) {orbit = o;}
virtual pal::AccPair get(const double& pos) =0;
void init();
virtual void saveSimtoolData() {}
virtual void clear() {} // clear trajectory data
protected:
virtual void initImplementation() =0;
};
class Orbit : public Trajectory
{
public:
Orbit(unsigned int id, const std::shared_ptr<Configuration> c) : Trajectory(id,c) {}
virtual ~Orbit() {}
virtual pal::AccPair get(const double& pos) {return orbit->interp( orbit->posInTurn(pos) );}
protected:
virtual void initImplementation() {}
};
class SimtoolTrajectory : public Trajectory
{
private:
pal::FunctionOfPos<pal::AccPair> simtoolTrajectory;
public:
SimtoolTrajectory(unsigned int id, const std::shared_ptr<Configuration> c);
virtual ~SimtoolTrajectory() {}
virtual pal::AccPair get(const double& pos) {return simtoolTrajectory.interpPeriodic(pos-config->pos_start());}
virtual void clear() {simtoolTrajectory.clear();}
virtual void saveSimtoolData();
protected:
virtual void initImplementation();
};
class Oscillation : public Trajectory
{
private:
pal::FunctionOfPos<pal::AccPair> beta; // beta function (twiss)
AccPair emittance; // single particle emittance
AccPair phase0; // phase(0) start value
AccPair freq; // oscillation frequency / 1/m
public:
Oscillation(unsigned int id, const std::shared_ptr<Configuration> c);
virtual ~Oscillation() {}
virtual pal::AccPair get(const double& pos);
protected:
virtual void initImplementation();
};
#endif
// __POLEMATRIX__TRAJECTORY_HPP_