12#ifndef __PENNING_TRAP__
13#define __PENNING_TRAP__
23#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
24 initializer(omp_priv = omp_orig)
34 std::function<double(
double)>
V_0;
53 vec_3d v_func(
unsigned int i,
unsigned int j,
double dt);
65 vec_3d r_func(
unsigned int i,
unsigned int j,
double dt);
77 std::function<
double(
double)>
V_0 =
78 [](
double t) {
return 25. *
V / 1000.; },
79 double d = 500.,
double t = 0.);
90 unsigned int i,
double B_0 =
T,
91 std::function<
double(
double)>
V_0 =
92 [](
double t) {
return 25. *
V / 1000.; },
93 double d = 500.,
double t = 0.);
105 std::function<
double(
double)>
V_0 =
106 [](
double t) {
return 25. *
V / 1000.; },
107 double d = 500.,
double t = 0.);
175 void evolve_RK4(
double dt,
bool particle_interaction =
true);
195 std::string method =
"rk4",
196 bool particle_interaction =
true);
207 unsigned int steps, std::string method =
"rk4",
208 bool particle_interaction =
true);
221 std::string method =
"rk4",
222 bool particle_interaction =
true);
A class that holds the properties of a particle.
A class that holds attributes of a particle.
A class that simulates a Penning trap.
std::vector< Particle > particles
The particles in the Penning trap.
double fraction_of_particles_left(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
double B_0
Magnetic field strength.
vec_3d external_E_field(vec_3d r)
Calculate E at point r.
vec_3d total_force(unsigned int i)
calculate the total force on a particle p_i.
void evolve_RK4(double dt, bool particle_interaction=true)
Go forward one timestep using the RK4 method.
vec_3d r_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
vec_3d total_force_particles(unsigned int i)
Calculate the total force on a particle p_i from other particles.
double d
Characteristic dimension.
void add_particle(Particle particle)
Add a particle to the system.
vec_3d force_on_particle(unsigned int i, unsigned int j)
Calculate the force between 2 particles.
std::function< double(double)> V_0
Applied potential.
void evolve_forward_euler(double dt, bool particle_interaction=true)
Go forward one timestep using the forward Euler method.
void write_simulation_to_dir(std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate and write the displacement of all particles to files.
vec_3d external_B_field(vec_3d r)
Calculate B at point r.
simulation_t simulate(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate the particle system inside the Penning trap over a certain amount of time.
vec_3d total_force_external(unsigned int i)
Calculate the total external force on a particle.
vec_3d v_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
Typedef for PenningTrap::simulation return value.
Useful typedefs for cleaner code.
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
std::vector< sim_cols > sim_arr
Typedef for the result of the simulate method.
Function prototypes and macros that are useful.