23#pragma omp declare reduction( + : arma::vec : omp_out += omp_in ) \
24 initializer( omp_priv = omp_orig )
40 arma::vec::fixed<3> res;
41 double f = this->
V_0/(this->
d*this->
d);
51 arma::vec::fixed<3> res;
62 arma::vec::fixed<3> res = this->
particles.at(i).r_vec
66 double norm = arma::norm(res);
69 res *= this->
particles.at(j).q/(norm*norm*norm);
78 arma::vec::fixed<3> v_cross_B;
82 v_cross_B(0) = p.
v_vec(1)*B(2) - p.
v_vec(2)*B(1);
83 v_cross_B(1) = p.
v_vec(2)*B(0) - p.
v_vec(0)*B(2);
84 v_cross_B(2) = p.
v_vec(0)*B(1) - p.
v_vec(1)*B(0);
98 for (
int j=0; j < this->
particles.size(); j++) {
106 res *=
K_E*(p.
q/p.
m);
123 std::vector<Particle> new_state = this->
particles;
127 #pragma omp parallel for private(p)
128 for (
int i=0; i < this->
particles.size(); i++) {
129 p = &new_state.at(i);
137arma::vec PenningTrap::get_particle(
int i)
142double PenningTrap::get_d()
A class for simulating a Penning trap.
A class that holds attributes of a particle.
arma::vec::fixed< 3 > v_vec
velocity
arma::vec::fixed< 3 > r_vec
position
std::vector< Particle > particles
The particles in the Penning trap.
arma::vec total_force_external(int i)
Calculate the total external force on a particle.
double B_0
Magnetic field strength.
arma::vec total_force_particles(int i)
Calculate the total force on a particle from other particles.
arma::vec external_B_field(arma::vec r)
Calculate B at point r.
arma::vec force_on_particle(int i, int j)
Calculate the force between 2 particles.
void evolve_forward_euler(double dt)
Go forward one timestep using the forward Euler method.
double d
Characteristic dimension.
void add_particle(Particle particle)
Add a particle to the system.
double V_0
Applied potential.
PenningTrap(double B_0=T, double V_0=25.*V/1000., double d=500.)
Set B_0, V_0 and d.
arma::vec total_force(int i)
calculate the total force on a particle.
arma::vec external_E_field(arma::vec r)
Calculate E at point r.
void evolve_RK4(double dt)
Go forward one timestep using the RK4 method.
#define K_E
Coulomb constant. unit: .
Function prototypes and macros that are useful.