|
Penning Trap Simulation
Simulate particle behavior inside a Penning Trap
|
A class that simulates a Penning trap. More...
#include <PenningTrap.hpp>
Public Member Functions | |
| PenningTrap (double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.) | |
| Constructor for the PenningTrap class. | |
| PenningTrap (uint i, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.) | |
| Constructor for the PenningTrap class. | |
| PenningTrap (std::vector< Particle > particles, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.) | |
| Constructor for the PenningTrap class. | |
| void | set_pertubation (double f, double omega_V) |
| Time dependent perturbation to V_0. | |
| void | reinitialize (double f, double omega_V, double t=0.) |
| Give all particles new positions and velocities, and change t and V_0. | |
| void | add_particle (Particle particle) |
| Add a particle to the system. | |
| void | evolve_RK4 (double dt, bool particle_interaction=true) |
| Go forward one timestep using the RK4 method. | |
| void | evolve_forward_euler (double dt, bool particle_interaction=true) |
| Go forward one timestep using the forward Euler method. | |
| simulation_t | simulate (double time, uint steps, std::string method="rk4", bool particle_interaction=true) |
| Simulate the particle system inside the Penning trap over a certain amount of time. | |
| void | write_simulation_to_dir (std::string path, double time, uint steps, std::string method="rk4", bool particle_interaction=true) |
| Simulate and write the displacement of all particles to files. | |
| double | fraction_of_particles_left (double time, uint 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 simulation. | |
Private Member Functions | |
| vec3 | v_func (uint i, uint j, double dt) |
| Helper for evolve_RK4 when calculating \(k_{v,i,j}\) values. | |
| vec3 | r_func (uint i, uint j, double dt) |
| Helper for evolve_RK4 when calculating \(k_{r,i,j}\) values. | |
| vec3 | external_E_field (vec3 r) |
| Calculate E at point r. | |
| vec3 | external_B_field (vec3 r) |
| Calculate B at point r. | |
| vec3 | force_on_particle (uint i, uint j) |
| Calculate the force between 2 particles. | |
| vec3 | total_force_external (uint i) |
| Calculate the total external force on a particle. | |
| vec3 | total_force_particles (uint i) |
| Calculate the total force on a particle p_i from other particles. | |
| vec3 | total_force (uint i) |
| calculate the total force on a particle p_i. | |
| vec3 | total_force_no_interaction (uint i) |
| calculate the total force on a particle p_i without interaction | |
Private Attributes | |
| double | B_0 |
| Magnetic field strength. | |
| double | V_0 |
| Applied potential. | |
| std::function< double(double)> | perturbation |
| Time-dependent perturbation. | |
| double | d |
| Characteristic dimension. | |
| double | t |
| Current time. | |
| std::vector< Particle > | particles |
| The particles in the Penning trap. | |
| sim_arr | k_v |
| A 2D vector containing all \(k_{v,i,j}\) where \(j\) is the index of a particle. | |
| sim_arr | k_r |
| A 2D vector containing all \(k_{r,i,j}\) where \(j\) is the index of a particle. | |
Friends | |
| class | PenningTrapTest |
| Make PenningTrapTest a friend of PenningTrap. | |
A class that simulates a Penning trap.
This class simulates a Penning trap. It can take in a number of particles and simulate how they would behave inside a Penning trap.
Definition at line 31 of file PenningTrap.hpp.
| PenningTrap::PenningTrap | ( | double | B_0 = T, |
| double | V_0 = (25. * V) / 1000., |
||
| double | d = 500., |
||
| double | t = 0. |
||
| ) |
Constructor for the PenningTrap class.
| B_0 | The magnetic field strength |
| V_0 | The time dependent applied potential |
| d | The characteristic dimension |
| t | The starting time |
Definition at line 120 of file PenningTrap.cpp.
| PenningTrap::PenningTrap | ( | uint | i, |
| double | B_0 = T, |
||
| double | V_0 = (25. * V) / 1000., |
||
| double | d = 500., |
||
| double | t = 0. |
||
| ) |
Constructor for the PenningTrap class.
| i | The number of particles to generate |
| B_0 | The magnetic field strength |
| V_0 | The time dependent applied potential |
| d | The characteristic dimension |
| t | The starting time |
Definition at line 129 of file PenningTrap.cpp.
| PenningTrap::PenningTrap | ( | std::vector< Particle > | particles, |
| double | B_0 = T, |
||
| double | V_0 = (25. * V) / 1000., |
||
| double | d = 500., |
||
| double | t = 0. |
||
| ) |
Constructor for the PenningTrap class.
| particles | The starting particles |
| B_0 | The magnetic field strength |
| V_0 | The time dependent applied potential |
| d | The characteristic dimension |
| t | The starting time |
Definition at line 139 of file PenningTrap.cpp.
| void PenningTrap::add_particle | ( | Particle | particle | ) |
Add a particle to the system.
| particle | The particle to add to the Penning trap |
Definition at line 166 of file PenningTrap.cpp.
| void PenningTrap::evolve_forward_euler | ( | double | dt, |
| bool | particle_interaction = true |
||
| ) |
Go forward one timestep using the forward Euler method.
| dt | The step length |
| particle_interaction | Turn particle interactions on/off |
Definition at line 211 of file PenningTrap.cpp.
| void PenningTrap::evolve_RK4 | ( | double | dt, |
| bool | particle_interaction = true |
||
| ) |
Go forward one timestep using the RK4 method.
| dt | The step length |
| particle_interaction | Turn particle interactions on/off |
Definition at line 171 of file PenningTrap.cpp.
Calculate B at point r.
| r | The position where we want to calculate the B field |
Definition at line 67 of file PenningTrap.cpp.
Calculate E at point r.
| r | The position where we want to calculate the E field |
Definition at line 59 of file PenningTrap.cpp.
|
private |
Calculate the force between 2 particles.
Calculate the force exhibited on particle p_i from particle p_j.
| i | The index of particle p_i |
| j | The index of particle p_j |
Definition at line 72 of file PenningTrap.cpp.
| double PenningTrap::fraction_of_particles_left | ( | double | time, |
| uint | 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 simulation.
| time | The time to simulate in microseconds |
| steps | The amount of steps for the whole simulation |
| method | The method to use when moving forward a timestep |
| particle_interaction | Turn particle interactions on/off |
Definition at line 311 of file PenningTrap.cpp.
|
private |
Helper for evolve_RK4 when calculating \(k_{r,i,j}\) values.
Something
| i | Index i for \(k_{r,i,j}\) |
| j | Index j for \(k_{r,i,j}\) |
| dt | The step length (delta time) |
Definition at line 40 of file PenningTrap.cpp.
| void PenningTrap::reinitialize | ( | double | f, |
| double | omega_V, | ||
| double | t = 0. |
||
| ) |
Give all particles new positions and velocities, and change t and V_0.
| V_0 | The tiome dependent applied potential |
| t | The starting time |
Definition at line 153 of file PenningTrap.cpp.
| void PenningTrap::set_pertubation | ( | double | f, |
| double | omega_V | ||
| ) |
Time dependent perturbation to V_0.
| f | The amplitude of the perturbation @parma omega_V the angular frequency of the perturbation |
Definition at line 146 of file PenningTrap.cpp.
| simulation_t PenningTrap::simulate | ( | double | time, |
| uint | steps, | ||
| std::string | method = "rk4", |
||
| bool | particle_interaction = true |
||
| ) |
Simulate the particle system inside the Penning trap over a certain amount of time.
| time | The time to simulate in microseconds |
| steps | The amount of steps for the whole simulation |
| method | The method to use when moving forward a timestep |
| particle_interaction | Turn particle interactions on/off |
Definition at line 240 of file PenningTrap.cpp.
|
private |
calculate the total force on a particle p_i.
| i | The index of particle p_i |
Definition at line 104 of file PenningTrap.cpp.
|
private |
Calculate the total external force on a particle.
Calculate the total amount of force that E and B exhibits on particle p_i.
| i | The index of particle p_i |
Definition at line 83 of file PenningTrap.cpp.
|
private |
calculate the total force on a particle p_i without interaction
| i | The index of particle p_i |
Definition at line 112 of file PenningTrap.cpp.
|
private |
Calculate the total force on a particle p_i from other particles.
| i | The index of particle p_i |
Definition at line 92 of file PenningTrap.cpp.
|
private |
Helper for evolve_RK4 when calculating \(k_{v,i,j}\) values.
Something
| i | Index i for \(k_{v,i,j}\) |
| j | Index j for \(k_{v,i,j}\) |
| dt | the step length (delta time) |
Definition at line 21 of file PenningTrap.cpp.
| void PenningTrap::write_simulation_to_dir | ( | std::string | path, |
| double | time, | ||
| uint | steps, | ||
| std::string | method = "rk4", |
||
| bool | particle_interaction = true |
||
| ) |
Simulate and write the displacement of all particles to files.
| path | The directory to save the data |
| time | The time to simulate in microseconds |
| steps | The amount of steps for the whole simulation |
| method | The method to use when moving forward a timestep |
| particle_interaction | Turn particle interactions on/off |
Definition at line 273 of file PenningTrap.cpp.
|
friend |
Make PenningTrapTest a friend of PenningTrap.
Definition at line 35 of file PenningTrap.hpp.
|
private |
Magnetic field strength.
Definition at line 37 of file PenningTrap.hpp.
|
private |
Characteristic dimension.
Definition at line 40 of file PenningTrap.hpp.
|
private |
A 2D vector containing all \(k_{r,i,j}\) where \(j\) is the index of a particle.
Definition at line 52 of file PenningTrap.hpp.
|
private |
A 2D vector containing all \(k_{v,i,j}\) where \(j\) is the index of a particle.
Definition at line 47 of file PenningTrap.hpp.
|
private |
The particles in the Penning trap.
Definition at line 42 of file PenningTrap.hpp.
|
private |
Time-dependent perturbation.
Definition at line 39 of file PenningTrap.hpp.
|
private |
Current time.
Definition at line 41 of file PenningTrap.hpp.
|
private |
Applied potential.
Definition at line 38 of file PenningTrap.hpp.