Penning Trap Simulation
Simulate particle behavior inside a Penning Trap
Loading...
Searching...
No Matches
PenningTrap Class Reference

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.
 

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< Particleparticles
 The particles in the Penning trap.
 
sim_arr k_v
 
sim_arr k_r
 

Friends

class PenningTrapTest
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PenningTrap() [1/3]

PenningTrap::PenningTrap ( double  B_0 = T,
double  V_0 = (25. * V) / 1000.,
double  d = 500.,
double  t = 0. 
)

Constructor for the PenningTrap class.

Parameters
B_0The magnetic field strength
V_0The time dependent applied potential
dThe characteristic dimension
tThe starting time

Definition at line 20 of file PenningTrap.cpp.

◆ PenningTrap() [2/3]

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.

Parameters
iThe number of particles to generate
B_0The magnetic field strength
V_0The time dependent applied potential
dThe characteristic dimension
tThe starting time

Definition at line 29 of file PenningTrap.cpp.

◆ PenningTrap() [3/3]

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.

Parameters
particlesThe starting particles
B_0The magnetic field strength
V_0The time dependent applied potential
dThe characteristic dimension
tThe starting time

Definition at line 39 of file PenningTrap.cpp.

Member Function Documentation

◆ add_particle()

void PenningTrap::add_particle ( Particle  particle)

Add a particle to the system.

Parameters
particleThe particle to add to the Penning trap

Definition at line 101 of file PenningTrap.cpp.

◆ evolve_forward_euler()

void PenningTrap::evolve_forward_euler ( double  dt,
bool  particle_interaction = true 
)

Go forward one timestep using the forward Euler method.

Parameters
dtThe step length
particle_interactionTurn particle interactions on/off

Definition at line 201 of file PenningTrap.cpp.

◆ evolve_RK4()

void PenningTrap::evolve_RK4 ( double  dt,
bool  particle_interaction = true 
)

Go forward one timestep using the RK4 method.

Parameters
dtThe step length
particle_interactionTurn particle interactions on/off

Definition at line 163 of file PenningTrap.cpp.

◆ external_B_field()

vec3 PenningTrap::external_B_field ( vec3  r)
private

Calculate B at point r.

Parameters
rThe position where we want to calculate the B field
Returns
vec3

Definition at line 114 of file PenningTrap.cpp.

◆ external_E_field()

vec3 PenningTrap::external_E_field ( vec3  r)
private

Calculate E at point r.

Parameters
rThe position where we want to calculate the E field
Returns
vec3

Definition at line 106 of file PenningTrap.cpp.

◆ force_on_particle()

vec3 PenningTrap::force_on_particle ( uint  i,
uint  j 
)
private

Calculate the force between 2 particles.

Calculate the force exhibited on particle p_i from particle p_j.

Parameters
iThe index of particle p_i
jThe index of particle p_j
Returns
vec3

Definition at line 119 of file PenningTrap.cpp.

◆ fraction_of_particles_left()

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.

Parameters
timeThe time to simulate in microseconds
stepsThe amount of steps for the whole simulation
methodThe method to use when moving forward a timestep
particle_interactionTurn particle interactions on/off
Returns
double

Definition at line 297 of file PenningTrap.cpp.

◆ r_func()

vec3 PenningTrap::r_func ( uint  i,
uint  j,
double  dt 
)
private

Helper for evolve_RK4 when calculating \(k_{r,i,j}\) values.

Something

Parameters
iIndex i for \(k_{r,i,j}\)
jIndex j for \(k_{r,i,j}\)
dtThe step length (delta time)
Returns
vec3

Definition at line 82 of file PenningTrap.cpp.

◆ reinitialize()

void PenningTrap::reinitialize ( double  f,
double  omega_V,
double  t = 0. 
)

Give all particles new positions and velocities, and change t and V_0.

Parameters
V_0The tiome dependent applied potential
tThe starting time

Definition at line 53 of file PenningTrap.cpp.

◆ set_pertubation()

void PenningTrap::set_pertubation ( double  f,
double  omega_V 
)

Time dependent perturbation to V_0.

Parameters
fThe amplitude of the perturbation @parma omega_V the angular frequency of the perturbation

Definition at line 46 of file PenningTrap.cpp.

◆ simulate()

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.

Parameters
timeThe time to simulate in microseconds
stepsThe amount of steps for the whole simulation
methodThe method to use when moving forward a timestep
particle_interactionTurn particle interactions on/off
Returns
simulation_t

Definition at line 228 of file PenningTrap.cpp.

◆ total_force()

vec3 PenningTrap::total_force ( uint  i)
private

calculate the total force on a particle p_i.

Parameters
iThe index of particle p_i
Returns
vec3

Definition at line 155 of file PenningTrap.cpp.

◆ total_force_external()

vec3 PenningTrap::total_force_external ( uint  i)
private

Calculate the total external force on a particle.

Calculate the total amount of force that E and B exhibits on particle p_i.

Parameters
iThe index of particle p_i
Returns
vec3

Definition at line 130 of file PenningTrap.cpp.

◆ total_force_particles()

vec3 PenningTrap::total_force_particles ( uint  i)
private

Calculate the total force on a particle p_i from other particles.

Parameters
iThe index of particle p_i
Returns
vec3

Definition at line 143 of file PenningTrap.cpp.

◆ v_func()

vec3 PenningTrap::v_func ( uint  i,
uint  j,
double  dt 
)
private

Helper for evolve_RK4 when calculating \(k_{v,i,j}\) values.

Something

Parameters
iIndex i for \(k_{v,i,j}\)
jIndex j for \(k_{v,i,j}\)
dtthe step length (delta time)
Returns
vec3

Definition at line 63 of file PenningTrap.cpp.

◆ write_simulation_to_dir()

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.

Parameters
pathThe directory to save the data
timeThe time to simulate in microseconds
stepsThe amount of steps for the whole simulation
methodThe method to use when moving forward a timestep
particle_interactionTurn particle interactions on/off

Definition at line 259 of file PenningTrap.cpp.

Friends And Related Function Documentation

◆ PenningTrapTest

friend class PenningTrapTest
friend

Definition at line 232 of file PenningTrap.hpp.

Member Data Documentation

◆ B_0

double PenningTrap::B_0
private

Magnetic field strength.

Definition at line 34 of file PenningTrap.hpp.

◆ d

double PenningTrap::d
private

Characteristic dimension.

Definition at line 37 of file PenningTrap.hpp.

◆ k_r

sim_arr PenningTrap::k_r
private

A 2D vector containing all \(k_{i,j}\) where \(j\) is the index of a particle

Definition at line 42 of file PenningTrap.hpp.

◆ k_v

sim_arr PenningTrap::k_v
private

A 2D vector containing all \(k_{i,j}\) where \(j\) is the index of a particle

Definition at line 40 of file PenningTrap.hpp.

◆ particles

std::vector<Particle> PenningTrap::particles
private

The particles in the Penning trap.

Definition at line 39 of file PenningTrap.hpp.

◆ perturbation

std::function<double(double)> PenningTrap::perturbation
private

Time-dependent perturbation.

Definition at line 36 of file PenningTrap.hpp.

◆ t

double PenningTrap::t
private

Current time.

Definition at line 38 of file PenningTrap.hpp.

◆ V_0

double PenningTrap::V_0
private

Applied potential.

Definition at line 35 of file PenningTrap.hpp.


The documentation for this class was generated from the following files: