OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
AbstractObjects/OpalParticle.h
Go to the documentation of this file.
1//
2// Class OpalParticle
3// This class represents the canonical coordinates of a particle.
4//
5// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#ifndef CLASSIC_OpalParticle_HH
19#define CLASSIC_OpalParticle_HH
20
21#include "Ippl.h"
22#include "OPALTypes.h"
23
24//
25#include <Kokkos_MathematicalConstants.hpp>
26#include <Kokkos_MathematicalFunctions.hpp>
27
29public:
30 // Particle coordinate numbers.
31 enum { X, Y, L, INVALID };
32
34 // Construct particle with the given coordinates.
36 int64_t id, double x, double px, double y, double py, double z, double pz, double time,
37 double q, double m);
38
40 int64_t id, Vector_t<double, 3> const& R, Vector_t<double, 3> const& P, double time,
41 double q, double m);
42
44
46 void setX(double);
47
49 void setPx(double);
50
52 void setY(double);
53
55 void setPy(double);
56
58 void setZ(double);
59
61 void setPz(double);
62
64 void setR(Vector_t<double, 3> const&);
65
67 void setP(Vector_t<double, 3> const&);
68
70 void setTime(double t);
71
73 int64_t getId() const;
74
76 // Access coordinate by index for constant particle.
77 double operator[](unsigned int) const;
78
80 double getX() const;
81
83 double getPx() const;
84
86 double getY() const;
87
89 double getPy() const;
90
92 double getZ() const;
93
95 double getPz() const;
96
98 const Vector_t<double, 3>& getR() const;
99
101 const Vector_t<double, 3>& getP() const;
102
104 double getTime() const;
105
107 double getCharge() const;
108
110 double getMass() const;
111
112private:
113 int64_t id_m;
116 double time_m;
117 double charge_m;
118 double mass_m;
119};
120
121inline void OpalParticle::setX(double val) {
122 R_m[X] = val;
123}
124
125inline void OpalParticle::setY(double val) {
126 R_m[Y] = val;
127}
128
129inline void OpalParticle::setZ(double val) {
130 R_m[L] = val;
131}
132
133inline void OpalParticle::setPx(double val) {
134 P_m[X] = val;
135}
136
137inline void OpalParticle::setPy(double val) {
138 P_m[Y] = val;
139}
140
141inline void OpalParticle::setPz(double val) {
142 P_m[L] = val;
143}
144
146 R_m = R;
147}
148
150 P_m = P;
151}
152
153inline void OpalParticle::setTime(double t) {
154 time_m = t;
155}
156
157inline int64_t OpalParticle::getId() const {
158 return id_m;
159}
160
161inline double OpalParticle::operator[](unsigned int i) const {
162 PAssert_LT(i, 6u);
163 return i % 2 == 0 ? R_m[i / 2] : P_m[i / 2];
164}
165
166inline double OpalParticle::getX() const {
167 return R_m[X];
168}
169
170inline double OpalParticle::getY() const {
171 return R_m[Y];
172}
173
174inline double OpalParticle::getZ() const {
175 return R_m[L];
176}
177
178inline double OpalParticle::getPx() const {
179 return P_m[X];
180}
181
182inline double OpalParticle::getPy() const {
183 return P_m[Y];
184}
185
186inline double OpalParticle::getPz() const {
187 return P_m[L];
188}
189
191 return R_m;
192}
193
195 return P_m;
196}
197
198inline double OpalParticle::getTime() const {
199 return time_m;
200}
201
202inline double OpalParticle::getCharge() const {
203 return charge_m;
204}
205
206inline double OpalParticle::getMass() const {
207 return mass_m;
208}
209
210#endif // CLASSIC_OpalParticle_HH
ippl::Vector< T, Dim > Vector_t
void setPy(double)
Set the vertical momentum.
double getPy() const
Get vertical momentum (no dimension).
Vector_t< double, 3 > R_m
double getPz() const
Get relative momentum error (no dimension).
Vector_t< double, 3 > P_m
const Vector_t< double, 3 > & getP() const
Get momentum.
void setPx(double)
Set the horizontal momentum.
void setPz(double)
Set the longitudinal momentum.
void setZ(double)
Set longitudinal position in m.
void setY(double)
Set the vertical displacement in m.
double getY() const
Get vertical displacement in m.
void setP(Vector_t< double, 3 > const &)
Set momentum.
double getCharge() const
Get charge in Coulomb.
double getZ() const
Get longitudinal displacement c*t in m.
double operator[](unsigned int) const
Get coordinate.
double getMass() const
Get mass in GeV/c^2.
double getTime() const
Get time.
void setTime(double t)
Set the time.
int64_t getId() const
Get the id of the particle.
double getPx() const
Get horizontal momentum (no dimension).
double getX() const
Get horizontal position in m.
void setR(Vector_t< double, 3 > const &)
Set position in m.
void setX(double)
Set the horizontal position in m.
OpalParticle(int64_t id, double x, double px, double y, double py, double z, double pz, double time, double q, double m)
Constructor.
const Vector_t< double, 3 > & getR() const
Get position in m.