OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 OPALX_OpalParticle_HH
19#define OPALX_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) { R_m[X] = val; }
122
123inline void OpalParticle::setY(double val) { R_m[Y] = val; }
124
125inline void OpalParticle::setZ(double val) { R_m[L] = val; }
126
127inline void OpalParticle::setPx(double val) { P_m[X] = val; }
128
129inline void OpalParticle::setPy(double val) { P_m[Y] = val; }
130
131inline void OpalParticle::setPz(double val) { P_m[L] = val; }
132
133inline void OpalParticle::setR(Vector_t<double, 3> const& R) { R_m = R; }
134
135inline void OpalParticle::setP(Vector_t<double, 3> const& P) { P_m = P; }
136
137inline void OpalParticle::setTime(double t) { time_m = t; }
138
139inline int64_t OpalParticle::getId() const { return id_m; }
140
141inline double OpalParticle::operator[](unsigned int i) const {
142 PAssert_LT(i, 6u);
143 return i % 2 == 0 ? R_m[i / 2] : P_m[i / 2];
144}
145
146inline double OpalParticle::getX() const { return R_m[X]; }
147
148inline double OpalParticle::getY() const { return R_m[Y]; }
149
150inline double OpalParticle::getZ() const { return R_m[L]; }
151
152inline double OpalParticle::getPx() const { return P_m[X]; }
153
154inline double OpalParticle::getPy() const { return P_m[Y]; }
155
156inline double OpalParticle::getPz() const { return P_m[L]; }
157
158inline const Vector_t<double, 3>& OpalParticle::getR() const { return R_m; }
159
160inline const Vector_t<double, 3>& OpalParticle::getP() const { return P_m; }
161
162inline double OpalParticle::getTime() const { return time_m; }
163
164inline double OpalParticle::getCharge() const { return charge_m; }
165
166inline double OpalParticle::getMass() const { return mass_m; }
167
168#endif // OPALX_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.
const Vector_t< double, 3 > & getR() const
Get position in m.