diff --git a/.gitignore b/.gitignore
index 5f54c8c..17c5519 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,3 +47,4 @@ src/*
!src/*.hpp
!src/*.py
!src/Doxyfile
+!src/scripts
diff --git a/Doxyfile b/Doxyfile
index eeba27f..7b951c6 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -2174,7 +2174,7 @@ RTF_EXTENSIONS_FILE =
# classes and files.
# The default value is: NO.
-GENERATE_MAN = YES
+GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
diff --git a/docs/100_particles.gif b/docs/100_particles.gif
index 3dde053..337c6e5 100644
Binary files a/docs/100_particles.gif and b/docs/100_particles.gif differ
diff --git a/docs/Particle_8cpp.html b/docs/Particle_8cpp.html
index 98aaf8d..b3fd0e9 100644
--- a/docs/Particle_8cpp.html
+++ b/docs/Particle_8cpp.html
@@ -113,7 +113,7 @@ $(document).ready(function(){initNavTree('Particle_8cpp.html',''); initResizable
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version 0.1
-Bug: No known bugs
+Bug: No known bugs
Definition in file Particle.cpp .
diff --git a/docs/Particle_8cpp_source.html b/docs/Particle_8cpp_source.html
index 2eaf72e..13c1950 100644
--- a/docs/Particle_8cpp_source.html
+++ b/docs/Particle_8cpp_source.html
@@ -102,24 +102,24 @@ $(document).ready(function(){initNavTree('Particle_8cpp_source.html',''); initRe
Go to the documentation of this file.
-
-
-
-
17 arma::vec::fixed<3> r_vec,
-
18 arma::vec::fixed<3> v_vec)
-
-
-
-
-
-
-
+
+
+
+
16 arma::vec::fixed<3> r_vec,
+
17 arma::vec::fixed<3> v_vec)
+
+
+
+
+
+
+
A class that holds the properties of a particle.
-
Particle(double q, double m, arma::vec::fixed< 3 > r_vec, arma::vec::fixed< 3 > v_vec)
Initialize the particle.
-
arma::vec::fixed< 3 > v_vec
velocity
-
-
arma::vec::fixed< 3 > r_vec
position
-
+
+
Particle(double q, double m, vec_3d r_vec, vec_3d v_vec)
Initialize the particle.
+
+
+
diff --git a/docs/Particle_8hpp.html b/docs/Particle_8hpp.html
index 3516260..00fc0e2 100644
--- a/docs/Particle_8hpp.html
+++ b/docs/Particle_8hpp.html
@@ -107,6 +107,7 @@ $(document).ready(function(){initNavTree('Particle_8hpp.html',''); initResizable
A class that holds the properties of a particle.
More...
#include <armadillo>
+
#include "typedefs.hpp "
Go to the source code of this file.
diff --git a/docs/Particle_8hpp_source.html b/docs/Particle_8hpp_source.html
index dbb28de..f3339f5 100644
--- a/docs/Particle_8hpp_source.html
+++ b/docs/Particle_8hpp_source.html
@@ -107,28 +107,30 @@ $(document).ready(function(){initNavTree('Particle_8hpp_source.html',''); initRe
-
-
-
-
-
-
-
-
-
- 33 arma::vec::fixed<3>
r_vec ,
- 34 arma::vec::fixed<3>
v_vec );
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-A class that holds attributes of a particle.
-arma::vec::fixed< 3 > v_vec
velocity
-
-arma::vec::fixed< 3 > r_vec
position
-
-A class that simulates a Penning trap.
+
+
+
+
+A class that holds attributes of a particle.
+
+
+
+
+A class that simulates a Penning trap.
+Useful typedefs for cleaner code.
+arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
diff --git a/docs/PenningTrap_8cpp.html b/docs/PenningTrap_8cpp.html
index 62355e1..5817ff6 100644
--- a/docs/PenningTrap_8cpp.html
+++ b/docs/PenningTrap_8cpp.html
@@ -106,6 +106,7 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp.html',''); initResiza
More...
Go to the source code of this file.
@@ -115,10 +116,7 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp.html',''); initResiza
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version 0.1
-Bug: No known bugs
-Todo: Implement evolve_RK4
-Implement evolve_forward_euler
-
+Bug: No known bugs
Definition in file PenningTrap.cpp .
diff --git a/docs/PenningTrap_8cpp_source.html b/docs/PenningTrap_8cpp_source.html
index 993de8e..282e5c2 100644
--- a/docs/PenningTrap_8cpp_source.html
+++ b/docs/PenningTrap_8cpp_source.html
@@ -102,205 +102,311 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp_source.html',''); ini
Go to the documentation of this file.
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
34 arma::vec::fixed<3> res;
-
35 double f = this->
V_0 / (this->
d * this->
d );
-
-
-
-
-
-
-
-
-
-
45 arma::vec::fixed<3> res{0., 0., this->
B_0 };
-
-
-
-
-
-
-
-
53 arma::vec::fixed<3> res =
-
-
-
-
57 double norm = arma::norm(res);
-
-
-
60 res *= this->
particles .at(j).q / (norm * norm * norm);
-
-
-
-
-
-
-
-
-
-
-
71 arma::vec::fixed<3> v_cross_B{p.
v_vec (1) * B(2) - p.
v_vec (2) * B(1),
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
86 for (
int j = 0; j < this->
particles .size(); j++) {
-
-
-
-
-
-
-
-
94 res *=
K_E * (p.
q / p.
m );
-
-
-
-
-
-
-
-
-
-
-
-
106 std::vector<Particle> tmp_particles = this->
particles ;
-
-
108 arma::vec::fixed<3> *k_v =
new arma::vec::fixed<3>[this->
particles .size()*4];
-
109 arma::vec::fixed<3> *k_r =
new arma::vec::fixed<3>[this->
particles .size()*4];
+
+
28 std::function<
double (
double )> V_0,
double d,
double t)
+
+
+
+
32 for (
size_t j = 0; j < i; j++) {
+
33 r =
vec_3d ().randn() * .1 * this->
d ;
+
34 v =
vec_3d ().randn() * .1 * this->
d ;
+
+
+
+
+
+
40 std::function<
double (
double )> V_0,
double d,
double t)
+
+
+
+
+
+
+
+
+
+
50 return .5 * dt * this->
k_v [0][j];
+
+
52 return .5 * dt * this->k_v[1][j];
+
+
54 return dt * this->k_v[2][j];
+
+
56 return (dt / 6.) * (this->k_v[0][j].eval() + this->k_v[1][j].eval() +
+
57 this->k_v[2][j].eval() + this->k_v[3][j].eval());
+
+
59 std::cout <<
"Not valid!" << std::endl;
+
+
+
+
+
+
+
+
+
68 return .5 * dt * this->
k_r [0][j];
+
+
70 return .5 * dt * this->k_r[1][j];
+
+
72 return dt * this->k_r[2][j];
+
+
74 return (dt / 6.) * (this->k_r[0][j].eval() + this->k_r[1][j].eval() +
+
75 this->k_r[2][j].eval() + this->k_r[3][j].eval());
+
+
77 std::cout <<
"Not valid!" << std::endl;
+
+
+
+
+
+
+
84 this->particles.push_back(particle);
+
+
+
+
+
+
90 double f = this->
V_0 (this->
t ) / (this->
d * this->
d );
+
+
+
+
+
+
+
97 return vec_3d {0., 0., this->B_0};
+
+
+
+
+
+
+
+
+
+
107 double norm = arma::norm(res, 2);
+
+
-
-
-
113 for (
int i=0; i<size; i++) {
-
-
-
+
111 return vec_3d (res * p_j.
q / (norm * norm * norm));
+
+
+
+
+
-
118 for (
int i=0; i<size; i++) {
-
-
-
121 p->
v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[i];
-
122 p->
r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[i];
-
-
+
118 if (arma::norm(p.
r_vec ) > this->d) {
+
119 return vec_3d {0., 0., 0.};
+
+
+
+
+
124 arma::cross(p.
v_vec , this->external_B_field(p.
r_vec )));
-
126 for (
int i=0; i<size; i++) {
-
-
128 k_r[1*size + i] = this->
particles .at(i).v_vec;
-
-
-
131 for (
int i=0; i<size; i++) {
-
-
-
134 p->
v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[1*size + i];
-
135 p->
r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[1*size + i];
-
-
-
138 for (
int i=0; i<size; i++) {
-
-
140 k_r[2*size + i] = this->
particles .at(i).v_vec;
+
+
+
+
+
+
+
+
+
+
135 for (
size_t j = 0; j < this->particles.size(); j++) {
+
+
+
+
+
-
143 for (
int i=0; i<size; i++) {
-
+
+
-
146 p->
v_vec = tmp_particles.at(i).v_vec + dt*k_v[2*size + i];
-
147 p->
r_vec = tmp_particles.at(i).r_vec + dt*k_r[2*size + i];
-
-
+
+
+
+
-
151 for (
int i=0; i<size; i++) {
-
-
153 k_r[3*size + i] = this->
particles .at(i).v_vec;
-
-
-
156 for (
int i=0; i<size; i++) {
-
-
-
159 p->
v_vec = tmp_particles.at(i).v_vec + dt*(k_v[i] + k_v[size + i] + k_v[2*size + i] + k_v[3*size + i])/6;
-
160 p->
r_vec = tmp_particles.at(i).r_vec + dt*(k_r[i] + k_r[size + i] + k_r[2*size + i] + k_r[3*size + i])/6;
-
-
-
-
-
+
+
+
+
154 std::vector<Particle> original_particles = this->
particles ;
+
155 std::vector<Particle> tmp_particles = this->
particles ;
+
+
+
158 if (particle_interaction) {
+
+
+
+
+
+
+
165 size_t size = this->particles.size();
-
-
-
169 std::vector<Particle> new_state = this->
particles ;
-
-
-
-
173 #pragma omp parallel for private(p)
-
174 for (
int i = 0; i < this->
particles .size(); i++) {
-
175 p = &new_state.at(i);
-
-
-
-
-
-
-
-
183 arma::vec PenningTrap::get_particle(
int i)
-
-
-
-
-
188 double PenningTrap::get_d()
-
-
-
+
+
+
+
170 for (
size_t i = 0; i < 4; i++) {
+
171 #pragma omp parallel for
+
172 for (
size_t j = 0; j < this->particles.size(); j++) {
+
173 this->
k_v [i][j] = (this->*force)(j) / this->particles[j].m;
+
174 this->
k_r [i][j] = this->particles[j].v_vec;
+
+
+
+
178 p->
v_vec = original_particles[j].v_vec + this->
v_func (i, j, dt);
+
179 p->
r_vec = original_particles[j].r_vec + this->
r_func (i, j, dt);
+
+
181 this->particles = tmp_particles;
+
+
+
+
+
+
+
188 std::vector<Particle> new_state = this->
particles ;
+
+
+
+
+
193 if (particle_interaction) {
+
+
+
+
+
+
+
200 #pragma omp parallel for private(p)
+
201 for (
size_t i = 0; i < this->particles.size(); i++) {
+
+
203 p->
v_vec += dt * (this->*force)(i) / p->
m ;
+
204 p->
r_vec += dt * this->particles[i].v_vec;
+
+
+
207 this->particles = new_state;
+
+
+
+
+
212 std::string method,
bool particle_interaction)
+
+
214 double dt = time / (double)steps;
+
+
+
+
+
219 if (method ==
"rk4" ) {
+
+
+
222 else if (method ==
"euler" ) {
+
+
+
+
226 std::cout <<
"Not a valid method!" << std::endl;
+
+
+
+
230 for (
size_t j = 0; j < steps; j++) {
+
231 for (
size_t i = 0; i < this->particles.size(); i++) {
+
232 res[i][j] = this->particles[i].r_vec;
+
+
234 (this->*func)(dt, particle_interaction);
+
+
+
+
+
+
+
241 int steps, std::string method,
+
242 bool particle_interaction)
+
+
244 if (path.back() !=
'/' ) {
+
+
+
247 if (
mkpath (path, 0777) != 0) {
+
248 std::cout <<
"Hello" << std::endl;
+
+
+
+
252 sim_arr res = this->
simulate (time, steps, method, particle_interaction);
+
+
+
+
256 #pragma omp parallel for private(ofile)
+
257 for (
size_t i = 0; i < this->particles.size(); i++) {
+
258 ofile.open(path +
"particle_" + std::to_string(i) +
".txt" );
+
259 for (
vec_3d &vec : res[i]) {
+
260 ofile << vec(0) <<
"," << vec(1) <<
"," << vec(2) <<
"\n" ;
+
+
+
+
+
+
+
+
268 sim_arr res = this->
simulate (time, steps, method, particle_interaction);
+
+
270 int particles_left = 0;
+
+
272 for (
Particle p : this->particles) {
+
273 if (arma::norm(p.r_vec) < this->d) {
+
+
+
+
+
278 return (
double ) particles_left / (double) this->particles.size();
+
+
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.
+
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.
+
sim_arr 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.
+
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.
+
PenningTrap(double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)
Constructor for the PenningTrap class.
+
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.
#define K_E
Coulomb constant. unit: .
+
Useful typedefs for cleaner code.
+
std::vector< arma::vec::fixed< 3 > > sim_cols
Typedef for the column of the result vector from simulating particles.
+
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.
+
bool mkpath(std::string path, int mode=0777)
Make path given.
diff --git a/docs/PenningTrap_8hpp.html b/docs/PenningTrap_8hpp.html
index 306bc89..5f6ee45 100644
--- a/docs/PenningTrap_8hpp.html
+++ b/docs/PenningTrap_8hpp.html
@@ -110,6 +110,7 @@ $(document).ready(function(){initNavTree('PenningTrap_8hpp.html',''); initResiza
#include <omp.h>
#include "Particle.hpp "
#include "constants.hpp "
+#include "typedefs.hpp "
Go to the source code of this file.
diff --git a/docs/PenningTrap_8hpp_source.html b/docs/PenningTrap_8hpp_source.html
index 02b2aed..dfdddbe 100644
--- a/docs/PenningTrap_8hpp_source.html
+++ b/docs/PenningTrap_8hpp_source.html
@@ -110,63 +110,106 @@ $(document).ready(function(){initNavTree('PenningTrap_8hpp_source.html',''); ini
-
- 21 #pragma omp declare reduction( + : arma::vec : omp_out += omp_in ) \
- 22 initializer( omp_priv = omp_orig )
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 83 arma::vec get_particle(
int i);
-
-
-
-
-
+
+
+ 22 #pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
+ 23 initializer(omp_priv = omp_orig)
+
+
+
+
+ 33 std::function<double(
double )>
V_0 ;
+
+
+
+
+
+
+ 52 vec_3d v_func (
unsigned int i,
unsigned int j,
double dt);
+
+ 64 vec_3d r_func (
unsigned int i,
unsigned int j,
double dt);
+
+
+
+
+ 76 std::function<
double (
double )>
V_0 =
+ 77 [](
double t ) {
return 25. *
V / 1000.; },
+ 78 double d = 500.,
double t = 0.);
+
+
+ 89 unsigned int i,
double B_0 =
T ,
+ 90 std::function<
double (
double )>
V_0 =
+ 91 [](
double t ) {
return 25. *
V / 1000.; },
+ 92 double d = 500.,
double t = 0.);
+
+
+
+ 104 std::function<
double (
double )>
V_0 =
+ 105 [](
double t ) {
return 25. *
V / 1000.; },
+ 106 double d = 500.,
double t = 0.);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 174 void evolve_RK4 (
double dt,
bool particle_interaction =
true );
+
+
+
+
+ 192 std::string method =
"rk4" ,
+ 193 bool particle_interaction =
true );
+
+
+ 204 unsigned int steps, std::string method =
"rk4" ,
+ 205 bool particle_interaction =
true );
+
+
+ 218 std::string method =
"rk4" ,
+ 219 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.
-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.
-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.
+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.
+sim_arr 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.
+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.
+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.
+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.
diff --git a/docs/animate__100__particles_8py_source.html b/docs/animate__100__particles_8py_source.html
index 80feb43..af734ca 100644
--- a/docs/animate__100__particles_8py_source.html
+++ b/docs/animate__100__particles_8py_source.html
@@ -103,68 +103,75 @@ $(document).ready(function(){initNavTree('animate__100__particles_8py_source.htm
1 import matplotlib.pyplot
as plt
-
3 from mpl_toolkits.mplot3d
import Axes3D
-
4 from matplotlib
import animation
+
3 from matplotlib
import animation
+
4 from mpl_toolkits.mplot3d
import Axes3D
-
-
-
-
-
10 with open(file, encoding=
"utf8" )
as f:
-
-
-
-
14 xi,yi,zi = map(float, line.strip().split(
"," ))
-
-
-
-
-
-
-
-
22 def update(num, lines, arr):
-
23 for line, a
in zip(lines, arr):
-
24 line.set_data(a[:2, num])
-
25 line.set_3d_properties(a[2, num])
-
-
+
+
+
+
+
+
11 with open(file, encoding=
"utf8" )
as f:
+
+
+
+
15 xi, yi, zi = map(float, line.strip().split(
"," ))
+
+
+
+
+
+
+
+
+
24 def update(num, lines, arr):
+
25 for line, a
in zip(lines, arr):
+
26 line.set_data(a[:2, num - 1 : num])
+
27 line.set_3d_properties(a[2, num])
-
-
30 plt.style.use(
"dark_background" )
-
-
32 ax = fig.add_subplot(projection=
"3d" )
-
+
+
+
31 plt.style.use(
"dark_background" )
+
+
33 ax = fig.add_subplot(projection=
"3d" )
-
35 arr = get_data([f
"output/p{i}_RK4.txt" for i
in range(100)])
+
35 arr = get_data([f
"output/simulate_100_particles/particle_{i}.txt" for i
in range(100)])
-
+
-
41 lines = [ax.plot(*a[:,1],
"o" )[0]
for a
in arr]
+
41 lines = [ax.plot(*a[:, 1],
"o" )[0]
for a
in arr]
-
43 ax.set_xlim3d([-500.0, 500.0])
-
-
-
46 ax.set_ylim3d([-500.0, 500.0])
-
-
-
49 ax.set_zlim3d([-500.0, 500.0])
-
-
-
52 ani = animation.FuncAnimation(fig, update, N, fargs=(lines, arr),
-
-
+
43 ax.set_title(
"100 particles inside a Penning trap" )
+
+
+
+
47 "100 randomly generated particles "
+
48 "evolving over a time of 50 microseconds." ,
+
+
50 horizontalalignment=
"center" ,
+
+
+
53 ax.set_xlim3d([-500.0, 500.0])
+
54 ax.set_xlabel(
"X (micrometers)" )
-
-
57 ani.save(
"100_particles.gif" , writer=animation.FFMpegFileWriter(fps=30))
-
-
-
-
61 if __name__ ==
"__main__" :
-
-
-
+
56 ax.set_ylim3d([-500.0, 500.0])
+
57 ax.set_ylabel(
"Y (micrometers)" )
+
+
59 ax.set_zlim3d([-500.0, 500.0])
+
60 ax.set_zlabel(
"Z (micrometers)" )
+
+
62 ani = animation.FuncAnimation(
+
63 fig, update, N, fargs=(lines, arr), interval=1, blit=
False
+
+
+
+
+
+
+
70 if __name__ ==
"__main__" :
+
diff --git a/docs/bug.html b/docs/bug.html
index bbcbbea..8ed5241 100644
--- a/docs/bug.html
+++ b/docs/bug.html
@@ -105,21 +105,23 @@ $(document).ready(function(){initNavTree('bug.html',''); initResizable(); });
File constants.hpp
No known bugs
File main.cpp
- No known bugs
+ No known bugs
File Particle.cpp
- No known bugs
+ No known bugs
File Particle.hpp
No known bugs
File PenningTrap.cpp
- No known bugs
+ No known bugs
File PenningTrap.hpp
No known bugs
File test_suite.cpp
- No known bugs
-File utils.cpp
No known bugs
+File typedefs.hpp
+ No known bugs
+File utils.cpp
+ No known bugs
File utils.hpp
- No known bugs
+ No known bugs
diff --git a/docs/classParticle-members.html b/docs/classParticle-members.html
index 02f2b23..b3fc92b 100644
--- a/docs/classParticle-members.html
+++ b/docs/classParticle-members.html
@@ -105,11 +105,11 @@ $(document).ready(function(){initNavTree('classParticle.html',''); initResizable
This is the complete list of members for Particle , including all inherited members.
diff --git a/docs/classParticle.html b/docs/classParticle.html
index 997eb37..271a213 100644
--- a/docs/classParticle.html
+++ b/docs/classParticle.html
@@ -114,9 +114,9 @@ $(document).ready(function(){initNavTree('classParticle.html',''); initResizable
@@ -126,12 +126,12 @@ Private Attributes
double m
Mass.
-arma::vec::fixed< 3 > r_vec
- position
-
-arma::vec::fixed< 3 > v_vec
- velocity
-
+vec_3d r_vec
+ position
+
+vec_3d v_vec
+ velocity
+
@@ -142,10 +142,10 @@ Friends
A class that holds attributes of a particle.
-
Definition at line 19 of file Particle.hpp .
+
Definition at line 21 of file Particle.hpp .
-
-◆ Particle()
+
+◆ Particle()
@@ -165,13 +165,13 @@ Friends
- arma::vec::fixed< 3 >
+ vec_3d
r_vec ,
- arma::vec::fixed< 3 >
+ vec_3d
v_vec
@@ -183,9 +183,18 @@ Friends
Initialize the particle.
-
Initialize the particle with a charge, mass, position and velocity.
+
Initialize the particle with a charge, mass, position and velocity.
+
Parameters
+
+ q The charge of the particle
+ m The mass of the particle
+ r_vec The initial position of the particle
+ v_vec The initial velocity of the particle
+
+
+
-
Definition at line 16 of file Particle.cpp .
+
Definition at line 15 of file Particle.cpp .
@@ -212,7 +221,7 @@ Friends
Make private attributes available for PenningTrap .
-Definition at line 38 of file Particle.hpp .
+Definition at line 43 of file Particle.hpp .
@@ -239,7 +248,7 @@ Friends
Mass.
-Definition at line 22 of file Particle.hpp .
+Definition at line 24 of file Particle.hpp .
@@ -265,12 +274,12 @@ Friends
Charge.
-Definition at line 21 of file Particle.hpp .
+Definition at line 23 of file Particle.hpp .
-
-◆ r_vec
+
+◆ r_vec
@@ -279,7 +288,7 @@ Friends
- arma::vec::fixed<3> Particle::r_vec
+ vec_3d Particle::r_vec
@@ -291,12 +300,12 @@ Friends
position
-
Definition at line 23 of file Particle.hpp .
+
Definition at line 25 of file Particle.hpp .
-
-◆ v_vec
+
+◆ v_vec
@@ -305,7 +314,7 @@ Friends
- arma::vec::fixed<3> Particle::v_vec
+ vec_3d Particle::v_vec
@@ -317,7 +326,7 @@ Friends
velocity
-
Definition at line 24 of file Particle.hpp .
+
Definition at line 26 of file Particle.hpp .
diff --git a/docs/classParticle.js b/docs/classParticle.js
index 113132c..71255c1 100644
--- a/docs/classParticle.js
+++ b/docs/classParticle.js
@@ -1,9 +1,9 @@
var classParticle =
[
- [ "Particle", "classParticle.html#a00e108823877a25513ccae7cac011b4c", null ],
+ [ "Particle", "classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4", null ],
[ "PenningTrap", "classParticle.html#aa797d319549dc2a0beb06cdbfd430232", null ],
[ "m", "classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563", null ],
[ "q", "classParticle.html#a566dcc1de4bdc01251776948798ea8e1", null ],
- [ "r_vec", "classParticle.html#acf1a0f3c978b06d76df5bb4279594467", null ],
- [ "v_vec", "classParticle.html#a4a5d22c7aeca66f67d083f270cba25df", null ]
+ [ "r_vec", "classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6", null ],
+ [ "v_vec", "classParticle.html#a879692772803d6ab65fa4993b54aea6e", null ]
];
\ No newline at end of file
diff --git a/docs/classPenningTrap-members.html b/docs/classPenningTrap-members.html
index 5a26d52..859c052 100644
--- a/docs/classPenningTrap-members.html
+++ b/docs/classPenningTrap-members.html
@@ -107,19 +107,27 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza
add_particle (Particle particle)PenningTrap
B_0 PenningTrap private
d PenningTrap private
- evolve_forward_euler (double dt)PenningTrap
- evolve_RK4 (double dt)PenningTrap
- external_B_field (arma::vec r)PenningTrap
- external_E_field (arma::vec r)PenningTrap
- force_on_particle (int i, int j)PenningTrap
- get_d () (defined in PenningTrap )PenningTrap
- get_particle (int i) (defined in PenningTrap )PenningTrap
- particles PenningTrap private
- PenningTrap (double B_0=T, double V_0=25.*V/1000., double d=500.)PenningTrap
- total_force (int i)PenningTrap
- total_force_external (int i)PenningTrap
- total_force_particles (int i)PenningTrap
- V_0 PenningTrap private
+ evolve_forward_euler (double dt, bool particle_interaction=true)PenningTrap
+ evolve_RK4 (double dt, bool particle_interaction=true)PenningTrap
+ external_B_field (vec_3d r)PenningTrap
+ external_E_field (vec_3d r)PenningTrap
+ force_on_particle (unsigned int i, unsigned int j)PenningTrap
+ fraction_of_particles_left (double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
+ k_r PenningTrap private
+ k_v PenningTrap private
+ particles PenningTrap private
+ PenningTrap (double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)PenningTrap
+ PenningTrap (unsigned int i, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)PenningTrap
+ PenningTrap (std::vector< Particle > particles, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)PenningTrap
+ r_func (unsigned int i, unsigned int j, double dt)PenningTrap private
+ simulate (double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
+ t PenningTrap private
+ total_force (unsigned int i)PenningTrap
+ total_force_external (unsigned int i)PenningTrap
+ total_force_particles (unsigned int i)PenningTrap
+ V_0 PenningTrap private
+ v_func (unsigned int i, unsigned int j, double dt)PenningTrap private
+ write_simulation_to_dir (std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
diff --git a/docs/classPenningTrap.html b/docs/classPenningTrap.html
index af62e25..9afb617 100644
--- a/docs/classPenningTrap.html
+++ b/docs/classPenningTrap.html
@@ -100,6 +100,7 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza
-
Set B_0, V_0 and d.
+
Constructor for the PenningTrap class.
+
Parameters
+
+ B_0 The magnetic field strength
+ V_0 The time dependent applied potential
+ d The characteristic dimension
+ t The starting time
+
+
+
-
Definition at line 20 of file PenningTrap.cpp .
+
Definition at line 18 of file PenningTrap.cpp .
+
+
+
+
+◆ PenningTrap() [2/3]
+
+
+
+
+
+ PenningTrap::PenningTrap
+ (
+ unsigned int
+ i ,
+
+
+
+
+ double
+ B_0 = T ,
+
+
+
+
+ std::function< double(double)>
+ V_0 = [](double t ) { return 25. * V / 1000.; },
+
+
+
+
+ double
+ d = 500.,
+
+
+
+
+ double
+ t = 0.
+
+
+
+ )
+
+
+
+
+
+
Constructor for the PenningTrap class.
+
Parameters
+
+ 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 27 of file PenningTrap.cpp .
+
+
+
+
+◆ PenningTrap() [3/3]
+
+
+
+
+
+ PenningTrap::PenningTrap
+ (
+ std::vector< Particle >
+ particles ,
+
+
+
+
+ double
+ B_0 = T ,
+
+
+
+
+ std::function< double(double)>
+ V_0 = [](double t ) { return 25. * V / 1000.; },
+
+
+
+
+ double
+ d = 500.,
+
+
+
+
+ double
+ t = 0.
+
+
+
+ )
+
+
+
+
+
+
Constructor for the PenningTrap class.
+
Parameters
+
+ 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 39 of file PenningTrap.cpp .
@@ -225,13 +388,19 @@ Private Attributes
Add a particle to the system.
+
Parameters
+
+ particle The particle to add to the Penning trap
+
+
+
-
Definition at line 27 of file PenningTrap.cpp .
+
Definition at line 82 of file PenningTrap.cpp .
-
-◆ evolve_forward_euler()
+
+◆ evolve_forward_euler()
@@ -240,20 +409,37 @@ Private Attributes
void PenningTrap::evolve_forward_euler
(
double
- dt )
+ dt ,
+
+
+
+ bool
+ particle_interaction = true
+
+
+
+ )
+
Go forward one timestep using the forward Euler method.
+
Parameters
+
+ dt The step length
+ particle_interaction Turn particle interactions on/off
+
+
+
-
Definition at line 167 of file PenningTrap.cpp .
+
Definition at line 186 of file PenningTrap.cpp .
-
-◆ evolve_RK4()
+
+◆ evolve_RK4()
@@ -262,28 +448,45 @@ Private Attributes
void PenningTrap::evolve_RK4
(
double
- dt )
+ dt ,
+
+
+
+ bool
+ particle_interaction = true
+
+
+
+ )
+
Go forward one timestep using the RK4 method.
+
Parameters
+
+ dt The step length
+ particle_interaction Turn particle interactions on/off
+
+
+
-
Definition at line 104 of file PenningTrap.cpp .
+
Definition at line 151 of file PenningTrap.cpp .
-
-◆ external_B_field()
+
+◆ external_B_field()
- arma::vec PenningTrap::external_B_field
+ vec_3d PenningTrap::external_B_field
(
- arma::vec
+ vec_3d
r )
@@ -291,21 +494,28 @@ Private Attributes
Calculate B at point r.
+
Parameters
+
+ r The position where we want to calculate the B field
+
+
+
+
Returns vec_3d
-
Definition at line 43 of file PenningTrap.cpp .
+
Definition at line 95 of file PenningTrap.cpp .
-
-◆ external_E_field()
+
+◆ external_E_field()
- arma::vec PenningTrap::external_E_field
+ vec_3d PenningTrap::external_E_field
(
- arma::vec
+ vec_3d
r )
@@ -313,27 +523,34 @@ Private Attributes
Calculate E at point r.
+
Parameters
+
+ r The position where we want to calculate the E field
+
+
+
+
Returns vec_3d
-
Definition at line 32 of file PenningTrap.cpp .
+
Definition at line 87 of file PenningTrap.cpp .
-
-◆ force_on_particle()
+
+◆ force_on_particle()
- arma::vec PenningTrap::force_on_particle
+ vec_3d PenningTrap::force_on_particle
(
- int
+ unsigned int
i ,
- int
+ unsigned int
j
@@ -345,83 +562,222 @@ Private Attributes
Calculate the force between 2 particles.
-
Calculate the force exhibited on particle p_i from particle p_j.
+
Calculate the force exhibited on particle p_i from particle p_j.
+
Parameters
+
+ i The index of particle p_i
+ j The index of particle p_j
+
+
+
+
Returns vec_3d
-
Definition at line 50 of file PenningTrap.cpp .
+
Definition at line 100 of file PenningTrap.cpp .
-
-◆ get_d()
+
+◆ fraction_of_particles_left()
- double PenningTrap::get_d
+ double PenningTrap::fraction_of_particles_left
(
- )
+ double
+ time ,
+
+
+
+ unsigned int
+ steps ,
+
+
+
+
+ std::string
+ method = "rk4",
+
+
+
+
+ bool
+ particle_interaction = true
+
+
+
+ )
+
-
Definition at line 188 of file PenningTrap.cpp .
+
Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation.
+
Parameters
+
+ 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
+
+
+
+
Returns double
+
+
Definition at line 266 of file PenningTrap.cpp .
-
-◆ get_particle()
+
+◆ r_func()
+
+
+
+
+
+
+
+
+ vec_3d PenningTrap::r_func
+ (
+ unsigned int
+ i ,
+
+
+
+
+ unsigned int
+ j ,
+
+
+
+
+ double
+ dt
+
+
+
+ )
+
+
+
+
+
+private
+
+
+
+
+
Helper for evolve_RK4 when calculating \(k_{r,i,j}\) values.
+
Something
+
Parameters
+
+ i Index i for \(k_{r,i,j}\)
+ j Index j for \(k_{r,i,j}\)
+ dt the step length (delta time)
+
+
+
+
Returns vec_3d
+
+
Definition at line 64 of file PenningTrap.cpp .
+
+
+
+
+◆ simulate()
- arma::vec PenningTrap::get_particle
+ sim_arr PenningTrap::simulate
(
- int
+ 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.
+
Parameters
+
+ 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 211 of file PenningTrap.cpp .
+
+
+
+
+◆ total_force()
+
+
+
+
+
+ vec_3d PenningTrap::total_force
+ (
+ unsigned int
i )
-
Definition at line 183 of file PenningTrap.cpp .
+
calculate the total force on a particle p_i.
+
Parameters
+
+ i The index of particle p_i
+
+
+
+
Returns vec_3d
+
+
Definition at line 146 of file PenningTrap.cpp .
-
-◆ total_force()
+
+◆ total_force_external()
- arma::vec PenningTrap::total_force
+ vec_3d PenningTrap::total_force_external
(
- int
- i )
-
-
-
-
-
-
calculate the total force on a particle.
-
-
Definition at line 99 of file PenningTrap.cpp .
-
-
-
-
-◆ total_force_external()
-
-
-
-
-
- arma::vec PenningTrap::total_force_external
- (
- int
+ unsigned int
i )
@@ -429,31 +785,161 @@ Private Attributes
Calculate the total external force on a particle.
-
Calculate the total amount of force that E and B exhibits on particle p_i.
+
Calculate the total amount of force that E and B exhibits on particle p_i.
+
Parameters
+
+ i The index of particle p_i
+
+
+
+
Returns vec_3d
-
Definition at line 65 of file PenningTrap.cpp .
+
Definition at line 114 of file PenningTrap.cpp .
-
-◆ total_force_particles()
+
+◆ total_force_particles()
- arma::vec PenningTrap::total_force_particles
+ vec_3d PenningTrap::total_force_particles
(
- int
+ unsigned int
i )
-
Calculate the total force on a particle from other particles.
+
Calculate the total force on a particle p_i from other particles.
+
Parameters
+
+ i The index of particle p_i
+
+
+
+
Returns vec_3d
-
Definition at line 80 of file PenningTrap.cpp .
+
Definition at line 129 of file PenningTrap.cpp .
+
+
+
+
+◆ v_func()
+
+
+
+
+
+
+
+
+ vec_3d PenningTrap::v_func
+ (
+ unsigned int
+ i ,
+
+
+
+
+ unsigned int
+ j ,
+
+
+
+
+ double
+ dt
+
+
+
+ )
+
+
+
+
+
+private
+
+
+
+
+
Helper for evolve_RK4 when calculating \(k_{v,i,j}\) values.
+
Something
+
Parameters
+
+ i Index i for \(k_{v,i,j}\)
+ j Index j for \(k_{v,i,j}\)
+ dt the step length (delta time)
+
+
+
+
Returns vec_3d
+
+
Definition at line 46 of file PenningTrap.cpp .
+
+
+
+
+◆ write_simulation_to_dir()
+
+
+
+
+
+ void PenningTrap::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.
+
Parameters
+
+ 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 240 of file PenningTrap.cpp .
@@ -480,7 +966,7 @@ Private Attributes
Magnetic field strength.
-Definition at line 31 of file PenningTrap.hpp .
+Definition at line 32 of file PenningTrap.hpp .
@@ -506,7 +992,57 @@ Private Attributes
Characteristic dimension.
-Definition at line 33 of file PenningTrap.hpp .
+Definition at line 34 of file PenningTrap.hpp .
+
+
+
+
+◆ k_r
+
+
+
+
A 2D vector containing all \(k_{i,j}\) where \(j\) is the index of a particle
+
+
Definition at line 39 of file PenningTrap.hpp .
+
+
+
+
+◆ k_v
+
+
+
+
A 2D vector containing all \(k_{i,j}\) where \(j\) is the index of a particle
+
+
Definition at line 37 of file PenningTrap.hpp .
@@ -532,12 +1068,12 @@ Private Attributes
The particles in the Penning trap.
-Definition at line 34 of file PenningTrap.hpp .
+Definition at line 36 of file PenningTrap.hpp .
-
-◆ V_0
+
+
@@ -546,7 +1082,33 @@ Private Attributes
- double PenningTrap::V_0
+ double PenningTrap::t
+
+
+
+
+private
+
+
+
+
+
+◆ V_0
+
+
+
+
+
+
+
+
+ std::function<double(double)> PenningTrap::V_0
@@ -558,7 +1120,7 @@ Private Attributes
Applied potential.
-Definition at line 32 of file PenningTrap.hpp .
+Definition at line 33 of file PenningTrap.hpp .
diff --git a/docs/classPenningTrap.js b/docs/classPenningTrap.js
index 743d3ea..0fd7f36 100644
--- a/docs/classPenningTrap.js
+++ b/docs/classPenningTrap.js
@@ -1,17 +1,27 @@
var classPenningTrap =
[
- [ "PenningTrap", "classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560", null ],
+ [ "PenningTrap", "classPenningTrap.html#ae670d7de621acdb343b01af098086f63", null ],
+ [ "PenningTrap", "classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1", null ],
+ [ "PenningTrap", "classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73", null ],
[ "add_particle", "classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8", null ],
- [ "evolve_forward_euler", "classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965", null ],
- [ "evolve_RK4", "classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9", null ],
- [ "external_B_field", "classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784", null ],
- [ "external_E_field", "classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b", null ],
- [ "force_on_particle", "classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182", null ],
- [ "total_force", "classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be", null ],
- [ "total_force_external", "classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee", null ],
- [ "total_force_particles", "classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d", null ],
+ [ "evolve_forward_euler", "classPenningTrap.html#ab9ea97a406534bbe621a95215144875e", null ],
+ [ "evolve_RK4", "classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e", null ],
+ [ "external_B_field", "classPenningTrap.html#acbf065c9c125682329ad82a8d166554c", null ],
+ [ "external_E_field", "classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9", null ],
+ [ "force_on_particle", "classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce", null ],
+ [ "fraction_of_particles_left", "classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b", null ],
+ [ "r_func", "classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648", null ],
+ [ "simulate", "classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854", null ],
+ [ "total_force", "classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8", null ],
+ [ "total_force_external", "classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56", null ],
+ [ "total_force_particles", "classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b", null ],
+ [ "v_func", "classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e", null ],
+ [ "write_simulation_to_dir", "classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57", null ],
[ "B_0", "classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716", null ],
[ "d", "classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2", null ],
+ [ "k_r", "classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640", null ],
+ [ "k_v", "classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4", null ],
[ "particles", "classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f", null ],
- [ "V_0", "classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89", null ]
+ [ "t", "classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e", null ],
+ [ "V_0", "classPenningTrap.html#aaf105828121c4a33cc2b217453c20317", null ]
];
\ No newline at end of file
diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html
index 81efd6b..4313bbd 100644
--- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html
+++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html
@@ -115,6 +115,8 @@ Files
file PenningTrap.cpp [code]
The implementation of the PenningTrap class.
+file plot_particles_left.py [code]
+
file test_suite.cpp [code]
The test suite for the project.
diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js
index 13a8a58..64ce7a5 100644
--- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js
+++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js
@@ -4,6 +4,7 @@ var dir_68267d1309a1af8e8297ef4c3efbcdba =
[ "main.cpp", "main_8cpp.html", null ],
[ "Particle.cpp", "Particle_8cpp.html", null ],
[ "PenningTrap.cpp", "PenningTrap_8cpp.html", null ],
+ [ "plot_particles_left.py", "plot__particles__left_8py_source.html", null ],
[ "test_suite.cpp", "test__suite_8cpp.html", "test__suite_8cpp" ],
[ "utils.cpp", "utils_8cpp.html", "utils_8cpp" ]
];
\ No newline at end of file
diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.html b/docs/dir_d44c64559bbebec7f509842c48db8b23.html
index 21e883c..289eee3 100644
--- a/docs/dir_d44c64559bbebec7f509842c48db8b23.html
+++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.html
@@ -113,6 +113,9 @@ Files
file PenningTrap.hpp [code]
A class for simulating a Penning trap.
+file typedefs.hpp [code]
+ Useful typedefs for cleaner code.
+
file utils.hpp [code]
Function prototypes and macros that are useful.
diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.js b/docs/dir_d44c64559bbebec7f509842c48db8b23.js
index 48feb88..192eaa8 100644
--- a/docs/dir_d44c64559bbebec7f509842c48db8b23.js
+++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.js
@@ -3,5 +3,6 @@ var dir_d44c64559bbebec7f509842c48db8b23 =
[ "constants.hpp", "constants_8hpp.html", "constants_8hpp" ],
[ "Particle.hpp", "Particle_8hpp.html", "Particle_8hpp" ],
[ "PenningTrap.hpp", "PenningTrap_8hpp.html", "PenningTrap_8hpp" ],
+ [ "typedefs.hpp", "typedefs_8hpp.html", "typedefs_8hpp" ],
[ "utils.hpp", "utils_8hpp.html", "utils_8hpp" ]
];
\ No newline at end of file
diff --git a/docs/files.html b/docs/files.html
index b07cc8d..e842a47 100644
--- a/docs/files.html
+++ b/docs/files.html
@@ -107,14 +107,16 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); });
constants.hpp Library of constants
Particle.hpp A class that holds the properties of a particle
PenningTrap.hpp A class for simulating a Penning trap
- utils.hpp Function prototypes and macros that are useful
- ▼ src
- animate_100_particles.py
- main.cpp The main program for this project
- Particle.cpp The implementation of the Particle class
- PenningTrap.cpp The implementation of the PenningTrap class
- test_suite.cpp The test suite for the project
- utils.cpp Implementation of the utils
+ typedefs.hpp Useful typedefs for cleaner code
+ utils.hpp Function prototypes and macros that are useful
+ ▼ src
+ animate_100_particles.py
+ main.cpp The main program for this project
+ Particle.cpp The implementation of the Particle class
+ PenningTrap.cpp The implementation of the PenningTrap class
+ plot_particles_left.py
+ test_suite.cpp The test suite for the project
+ utils.cpp Implementation of the utils
diff --git a/docs/functions.html b/docs/functions.html
index eb473bb..a2f04ea 100644
--- a/docs/functions.html
+++ b/docs/functions.html
@@ -102,22 +102,30 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable();
add_particle() : PenningTrap
B_0 : PenningTrap
d : PenningTrap
-evolve_forward_euler() : PenningTrap
-evolve_RK4() : PenningTrap
-external_B_field() : PenningTrap
-external_E_field() : PenningTrap
-force_on_particle() : PenningTrap
+evolve_forward_euler() : PenningTrap
+evolve_RK4() : PenningTrap
+external_B_field() : PenningTrap
+external_E_field() : PenningTrap
+force_on_particle() : PenningTrap
+fraction_of_particles_left() : PenningTrap
+k_r : PenningTrap
+k_v : PenningTrap
m : Particle
-Particle() : Particle
+Particle() : Particle
particles : PenningTrap
-PenningTrap : Particle , PenningTrap
+PenningTrap : Particle , PenningTrap
q : Particle
-r_vec : Particle
-total_force() : PenningTrap
-total_force_external() : PenningTrap
-total_force_particles() : PenningTrap
-V_0 : PenningTrap
-v_vec : Particle
+r_func() : PenningTrap
+r_vec : Particle
+simulate() : PenningTrap
+t : PenningTrap
+total_force() : PenningTrap
+total_force_external() : PenningTrap
+total_force_particles() : PenningTrap
+V_0 : PenningTrap
+v_func() : PenningTrap
+v_vec : Particle
+write_simulation_to_dir() : PenningTrap
diff --git a/docs/functions_func.html b/docs/functions_func.html
index 4a36dd3..1182b1d 100644
--- a/docs/functions_func.html
+++ b/docs/functions_func.html
@@ -100,16 +100,21 @@ $(document).ready(function(){initNavTree('functions_func.html',''); initResizabl
diff --git a/docs/functions_vars.html b/docs/functions_vars.html
index 8c0729a..3ca2e5b 100644
--- a/docs/functions_vars.html
+++ b/docs/functions_vars.html
@@ -101,12 +101,15 @@ $(document).ready(function(){initNavTree('functions_vars.html',''); initResizabl
diff --git a/docs/globals.html b/docs/globals.html
index 9107eef..19a9638 100644
--- a/docs/globals.html
+++ b/docs/globals.html
@@ -99,14 +99,20 @@ $(document).ready(function(){initNavTree('globals.html',''); initResizable(); })
Here is a list of all documented file members with links to the documentation:
diff --git a/docs/globals_defs.html b/docs/globals_defs.html
index 332fce0..c7eb483 100644
--- a/docs/globals_defs.html
+++ b/docs/globals_defs.html
@@ -99,6 +99,7 @@ $(document).ready(function(){initNavTree('globals_defs.html',''); initResizable(
+__METHOD_NAME__ : utils.hpp
ASSERT : utils.hpp
DEBUG : utils.hpp
K_E : constants.hpp
diff --git a/docs/globals_func.html b/docs/globals_func.html
index e38f2c1..c73a436 100644
--- a/docs/globals_func.html
+++ b/docs/globals_func.html
@@ -101,6 +101,7 @@ $(document).ready(function(){initNavTree('globals_func.html',''); initResizable(
diff --git a/docs/globals_type.html b/docs/globals_type.html
new file mode 100644
index 0000000..b7735cc
--- /dev/null
+++ b/docs/globals_type.html
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+Penning Trap Simulation: File Members
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Penning Trap Simulation
+
+ Simulate particle behavior inside a Penning Trap
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/main_8cpp.html b/docs/main_8cpp.html
index 5e67722..b83f224 100644
--- a/docs/main_8cpp.html
+++ b/docs/main_8cpp.html
@@ -100,17 +100,22 @@ $(document).ready(function(){initNavTree('main_8cpp.html',''); initResizable();
The main program for this project.
More...
-
#include <fstream>
+
#include <cmath>
+
#include <fstream>
#include <omp.h>
+
#include <string>
#include <sys/stat.h>
+
#include <vector>
#include "PenningTrap.hpp "
+
#include "utils.hpp "
Go to the source code of this file.
@@ -127,10 +132,27 @@ Macros
+
+
+Particle p1 (CHARGE, MASS, vec_3d {20., 0., 20.}, vec_3d {0., 25., 0.})
+
+
+Particle p2 (CHARGE, MASS, vec_3d {25., 25., 0.}, vec_3d {0., 40., 5.})
+
The main program for this project.
@@ -138,7 +160,7 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version 0.1
-
Bug: No known bugs
+
Bug: No known bugs
Definition in file main.cpp .
@@ -154,7 +176,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
@@ -170,7 +192,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
@@ -186,7 +208,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
@@ -202,7 +224,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
@@ -222,7 +244,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
@@ -241,7 +263,83 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
+
+
+◆ simulate_100_particles_with_time_potential()
+
+
+
+
+
+ void simulate_100_particles_with_time_potential
+ (
+ )
+
+
+
+
+
+
+◆ simulate_single_particle()
+
+
+
+
+
+ void simulate_single_particle
+ (
+ )
+
+
+
+
+
+
+◆ simulate_single_particle_with_different_steps()
+
+
+
+
+
+ void simulate_single_particle_with_different_steps
+ (
+ )
+
+
+
+
+
+
+◆ simulate_two_particles()
+
+
+
+
+
+ void simulate_two_particles
+ (
+ )
+
+
+
+
diff --git a/docs/main_8cpp_source.html b/docs/main_8cpp_source.html
index 5542b5a..d437689 100644
--- a/docs/main_8cpp_source.html
+++ b/docs/main_8cpp_source.html
@@ -102,87 +102,149 @@ $(document).ready(function(){initNavTree('main_8cpp_source.html',''); initResiza
Go to the documentation of this file.
-
-
-
-
-
-
-
-
-
-
-
-
24 void simulate_100_particles()
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
29 for (
int i = 0; i < PARTICLES; i++) {
-
30 arma::vec r = arma::vec(3).randn() * 0.1 *
-
-
32 arma::vec v = arma::vec(3).randn() * 0.1 *
-
-
-
-
-
-
38 double dt = time / (double)N;
-
-
40 auto res =
new arma::vec::fixed<3>[PARTICLES][N];
+
+
+
+
31 void simulate_single_particle()
+
+
33 DEBUG (
"Inside single particle sim" );
+
+
+
+
+
38 DEBUG (
"Write to dir" );
+
39 trap.write_simulation_to_dir(
"output/simulate_single_particle" , time, N);
+
-
-
-
-
45 for (
int j = 0; j < N; j++) {
-
46 #pragma omp parallel for
-
47 for (
int i = 0; i < PARTICLES; i++) {
-
48 res[i][j] = trap.get_particle(i);
-
-
-
-
-
53 std::cout << counter << std::endl;
+
42 void simulate_two_particles()
+
+
44 PenningTrap trap_no_interaction(std::vector<Particle>{p1, p2});
+
45 PenningTrap trap_with_interaction(std::vector<Particle>{p1, p2});
+
+
+
+
+
50 "output/simulate_2_particles/no_interaction" , time, N,
"rk4" ,
false );
+
51 trap_with_interaction.write_simulation_to_dir(
+
52 "output/simulate_2_particles/with_interaction" , time, N);
+
-
55 arma::vec::fixed<3> *cur_row;
-
56 arma::vec::fixed<3> cur_elem;
+
55 void simulate_single_particle_with_different_steps()
+
-
58 mkdir(
"output" , 0777);
-
59 mkdir(
"output/simulate_100_particles" , 0777);
-
-
-
-
-
64 #pragma omp parallel for private(cur_row, cur_elem, ofile)
-
65 for (
int i = 0; i < PARTICLES; i++) {
-
-
67 ofile.open(
"output/simulate_100_particles/p" + std::to_string(i) +
".txt" );
-
68 for (
int j = 0; j < N; j++) {
-
69 cur_elem = cur_row[j];
-
70 ofile << cur_elem(0) <<
"," << cur_elem(1) <<
"," << cur_elem(2)
-
-
-
+
+
+
60 for (
int i = 0; i < 4; i++) {
+
61 int steps = 4000 * (i + 1);
+
+
+
64 std::to_string(steps) +
"_steps" ,
+
65 time, steps,
"rk4" ,
false );
+
+
+
68 for (
int i = 0; i < 4; i++) {
+
69 int steps = 4000 * (i + 1);
+
+
+
72 std::to_string(steps) +
"_steps" ,
+
73 time, steps,
"euler" ,
false );
-
+
77 void simulate_100_particles()
-
79 double start = omp_get_wtime();
-
-
81 simulate_100_particles();
-
-
83 double end = omp_get_wtime();
-
-
85 std::cout <<
"Time: " << end - start <<
" seconds" << std::endl;
-
-
-
+
+
+
81 return 25. *
V / 1000. *
+
82 (1. + .4 * std::cos(1.5 * t));
+
+
+
+
+
+
+
+
+
91 void simulate_100_particles_with_time_potential()
+
+
93 double amplitudes[]{.1, .4, .7};
+
+
95 double freq_start = .2;
+
96 double freq_end = 2.5;
+
97 double freq_increment = .02;
+
98 size_t freq_iterations = (size_t) ((freq_end - freq_start) / freq_increment);
+
+
100 std::string path =
"output/time_dependent_potential/" ;
+
+
+
+
+
105 for (
double f : amplitudes) {
+
106 ofile.open(path +
"f_" + std::to_string(f) +
".txt" );
+
107 #pragma omp parallel for ordered schedule(static, 1)
+
108 for (
size_t i=0; i < freq_iterations; i++) {
+
109 double freq = freq_start + i*freq_increment;
+
+
111 [f, freq](
double t) {
+
112 return (25. *
V / 1000.) *
+
113 (1. + f * std::cos(freq * t));
+
+
+
+
+
118 ofile << freq <<
"," << res <<
"\n" ;
+
+
+
+
+
+
+
+
+
127 simulate_single_particle();
+
+
129 simulate_two_particles();
+
+
131 simulate_single_particle_with_different_steps();
+
+
133 double start = omp_get_wtime();
+
+
+
+
137 simulate_100_particles_with_time_potential();
+
+
139 double end = omp_get_wtime();
+
+
141 std::cout <<
"Time: " << end - start <<
" seconds" << std::endl;
+
+
+
A class for simulating a Penning trap.
-
A class that holds attributes of a particle.
-
A class that simulates a Penning trap.
-
void add_particle(Particle particle)
Add a particle to the system.
-
void evolve_RK4(double dt)
Go forward one timestep using the RK4 method.
+
A class that holds attributes of a particle.
+
A class that simulates a 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...
+
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.
+
+
+
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
+
Function prototypes and macros that are useful.
+
bool mkpath(std::string path, int mode=0777)
Make path given.
+
#define DEBUG(msg)
Writes a debug message.
diff --git a/docs/menudata.js b/docs/menudata.js
index 88ec31f..74c1d7b 100644
--- a/docs/menudata.js
+++ b/docs/menudata.js
@@ -38,4 +38,5 @@ var menudata={children:[
{text:"File Members",url:"globals.html",children:[
{text:"All",url:"globals.html"},
{text:"Functions",url:"globals_func.html"},
+{text:"Typedefs",url:"globals_type.html"},
{text:"Macros",url:"globals_defs.html"}]}]}]}
diff --git a/docs/navtreedata.js b/docs/navtreedata.js
index 10ee5ad..9640812 100644
--- a/docs/navtreedata.js
+++ b/docs/navtreedata.js
@@ -27,7 +27,6 @@ var NAVTREE =
[ "Penning Trap Simulation", "index.html", [
[ "Credits", "index.html#autotoc_md1", null ],
[ "Bug List", "bug.html", null ],
- [ "Todo List", "todo.html", null ],
[ "Classes", "annotated.html", [
[ "Class List", "annotated.html", "annotated_dup" ],
[ "Class Index", "classes.html", null ],
@@ -43,6 +42,7 @@ var NAVTREE =
[ "File Members", "globals.html", [
[ "All", "globals.html", null ],
[ "Functions", "globals_func.html", null ],
+ [ "Typedefs", "globals_type.html", null ],
[ "Macros", "globals_defs.html", null ]
] ]
] ]
diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js
index 27aef05..16caa0e 100644
--- a/docs/navtreeindex0.js
+++ b/docs/navtreeindex0.js
@@ -1,75 +1,95 @@
var NAVTREEINDEX0 =
{
-"Particle_8cpp.html":[4,0,1,2],
-"Particle_8cpp_source.html":[4,0,1,2],
-"Particle_8hpp.html":[4,0,0,1],
-"Particle_8hpp_source.html":[4,0,0,1],
-"PenningTrap_8cpp.html":[4,0,1,3],
-"PenningTrap_8cpp_source.html":[4,0,1,3],
-"PenningTrap_8hpp.html":[4,0,0,2],
-"PenningTrap_8hpp_source.html":[4,0,0,2],
-"animate__100__particles_8py_source.html":[4,0,1,0],
-"annotated.html":[3,0],
+"Particle_8cpp.html":[3,0,1,2],
+"Particle_8cpp_source.html":[3,0,1,2],
+"Particle_8hpp.html":[3,0,0,1],
+"Particle_8hpp_source.html":[3,0,0,1],
+"PenningTrap_8cpp.html":[3,0,1,3],
+"PenningTrap_8cpp_source.html":[3,0,1,3],
+"PenningTrap_8hpp.html":[3,0,0,2],
+"PenningTrap_8hpp_source.html":[3,0,0,2],
+"animate__100__particles_8py_source.html":[3,0,1,0],
+"annotated.html":[2,0],
"bug.html":[1],
-"classParticle.html":[3,0,0],
-"classParticle.html#a00e108823877a25513ccae7cac011b4c":[3,0,0,0],
-"classParticle.html#a4a5d22c7aeca66f67d083f270cba25df":[3,0,0,5],
-"classParticle.html#a566dcc1de4bdc01251776948798ea8e1":[3,0,0,3],
-"classParticle.html#aa797d319549dc2a0beb06cdbfd430232":[3,0,0,1],
-"classParticle.html#acf1a0f3c978b06d76df5bb4279594467":[3,0,0,4],
-"classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563":[3,0,0,2],
-"classPenningTrap.html":[3,0,1],
-"classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f":[3,0,1,12],
-"classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee":[3,0,1,8],
-"classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716":[3,0,1,10],
-"classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d":[3,0,1,9],
-"classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784":[3,0,1,4],
-"classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182":[3,0,1,6],
-"classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965":[3,0,1,2],
-"classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2":[3,0,1,11],
-"classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8":[3,0,1,1],
-"classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89":[3,0,1,13],
-"classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560":[3,0,1,0],
-"classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be":[3,0,1,7],
-"classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b":[3,0,1,5],
-"classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9":[3,0,1,3],
-"classPenningTrapTest.html":[3,0,2],
-"classes.html":[3,1],
-"constants_8hpp.html":[4,0,0,0],
-"constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5":[4,0,0,0,1],
-"constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb":[4,0,0,0,0],
-"constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb":[4,0,0,0,2],
-"constants_8hpp_source.html":[4,0,0,0],
-"dir_68267d1309a1af8e8297ef4c3efbcdba.html":[4,0,1],
-"dir_d44c64559bbebec7f509842c48db8b23.html":[4,0,0],
-"files.html":[4,0],
-"functions.html":[3,2,0],
-"functions_func.html":[3,2,1],
-"functions_rela.html":[3,2,3],
-"functions_vars.html":[3,2,2],
-"globals.html":[4,1,0],
-"globals_defs.html":[4,1,2],
-"globals_func.html":[4,1,1],
+"classParticle.html":[2,0,0],
+"classParticle.html#a566dcc1de4bdc01251776948798ea8e1":[2,0,0,3],
+"classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4":[2,0,0,0],
+"classParticle.html#a879692772803d6ab65fa4993b54aea6e":[2,0,0,5],
+"classParticle.html#aa797d319549dc2a0beb06cdbfd430232":[2,0,0,1],
+"classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563":[2,0,0,2],
+"classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6":[2,0,0,4],
+"classPenningTrap.html":[2,0,1],
+"classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f":[2,0,1,21],
+"classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b":[2,0,1,9],
+"classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716":[2,0,1,17],
+"classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9":[2,0,1,7],
+"classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8":[2,0,1,12],
+"classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640":[2,0,1,19],
+"classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e":[2,0,1,5],
+"classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648":[2,0,1,10],
+"classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b":[2,0,1,14],
+"classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854":[2,0,1,11],
+"classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2":[2,0,1,18],
+"classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73":[2,0,1,2],
+"classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8":[2,0,1,3],
+"classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1":[2,0,1,1],
+"classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e":[2,0,1,22],
+"classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce":[2,0,1,8],
+"classPenningTrap.html#aaf105828121c4a33cc2b217453c20317":[2,0,1,23],
+"classPenningTrap.html#ab9ea97a406534bbe621a95215144875e":[2,0,1,4],
+"classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57":[2,0,1,16],
+"classPenningTrap.html#acbf065c9c125682329ad82a8d166554c":[2,0,1,6],
+"classPenningTrap.html#ae670d7de621acdb343b01af098086f63":[2,0,1,0],
+"classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56":[2,0,1,13],
+"classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4":[2,0,1,20],
+"classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e":[2,0,1,15],
+"classPenningTrapTest.html":[2,0,2],
+"classes.html":[2,1],
+"constants_8hpp.html":[3,0,0,0],
+"constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5":[3,0,0,0,1],
+"constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb":[3,0,0,0,0],
+"constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb":[3,0,0,0,2],
+"constants_8hpp_source.html":[3,0,0,0],
+"dir_68267d1309a1af8e8297ef4c3efbcdba.html":[3,0,1],
+"dir_d44c64559bbebec7f509842c48db8b23.html":[3,0,0],
+"files.html":[3,0],
+"functions.html":[2,2,0],
+"functions_func.html":[2,2,1],
+"functions_rela.html":[2,2,3],
+"functions_vars.html":[2,2,2],
+"globals.html":[3,1,0],
+"globals_defs.html":[3,1,3],
+"globals_func.html":[3,1,1],
+"globals_type.html":[3,1,2],
"index.html":[],
"index.html#autotoc_md1":[0],
-"main_8cpp.html":[4,0,1,1],
-"main_8cpp_source.html":[4,0,1,1],
+"main_8cpp.html":[3,0,1,1],
+"main_8cpp_source.html":[3,0,1,1],
"pages.html":[],
-"test__suite_8cpp.html":[4,0,1,4],
-"test__suite_8cpp_source.html":[4,0,1,4],
-"todo.html":[2],
-"utils_8cpp.html":[4,0,1,5],
-"utils_8cpp.html#a58565270b643b24e3132f38c653e0199":[4,0,1,5,2],
-"utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a":[4,0,1,5,0],
-"utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746":[4,0,1,5,3],
-"utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b":[4,0,1,5,1],
-"utils_8cpp_source.html":[4,0,1,5],
-"utils_8hpp.html":[4,0,0,3],
-"utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772":[4,0,0,3,2],
-"utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38":[4,0,0,3,3],
-"utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[4,0,0,3,0],
-"utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d":[4,0,0,3,4],
-"utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384":[4,0,0,3,5],
-"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[4,0,0,3,1],
-"utils_8hpp_source.html":[4,0,0,3]
+"plot__particles__left_8py_source.html":[3,0,1,4],
+"test__suite_8cpp.html":[3,0,1,5],
+"test__suite_8cpp_source.html":[3,0,1,5],
+"typedefs_8hpp.html":[3,0,0,3],
+"typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23":[3,0,0,3,1],
+"typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66":[3,0,0,3,2],
+"typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df":[3,0,0,3,3],
+"typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af":[3,0,0,3,0],
+"typedefs_8hpp_source.html":[3,0,0,3],
+"utils_8cpp.html":[3,0,1,6],
+"utils_8cpp.html#a58565270b643b24e3132f38c653e0199":[3,0,1,6,3],
+"utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a":[3,0,1,6,0],
+"utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746":[3,0,1,6,4],
+"utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de":[3,0,1,6,2],
+"utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b":[3,0,1,6,1],
+"utils_8cpp_source.html":[3,0,1,6],
+"utils_8hpp.html":[3,0,0,4],
+"utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772":[3,0,0,4,3],
+"utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38":[3,0,0,4,4],
+"utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168":[3,0,0,4,0],
+"utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa":[3,0,0,4,5],
+"utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[3,0,0,4,1],
+"utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d":[3,0,0,4,6],
+"utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384":[3,0,0,4,7],
+"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[3,0,0,4,2],
+"utils_8hpp_source.html":[3,0,0,4]
};
diff --git a/docs/pages.html b/docs/pages.html
index eb4abe8..a84d908 100644
--- a/docs/pages.html
+++ b/docs/pages.html
@@ -104,7 +104,6 @@ $(document).ready(function(){initNavTree('pages.html',''); initResizable(); });
Here is a list of all related documentation pages:
diff --git a/docs/plot__particles__left_8py_source.html b/docs/plot__particles__left_8py_source.html
new file mode 100644
index 0000000..c9ab258
--- /dev/null
+++ b/docs/plot__particles__left_8py_source.html
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+Penning Trap Simulation: src/plot_particles_left.py Source File
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Penning Trap Simulation
+
+ Simulate particle behavior inside a Penning Trap
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+
+
+
+
1 import matplotlib.pyplot
as plt
+
+
+
+
5 "output/time_dependent_potential/f_0.100000.txt" ,
+
6 "output/time_dependent_potential/f_0.400000.txt" ,
+
7 "output/time_dependent_potential/f_0.700000.txt" ,
+
+
+
+
+
+
+
+
15 with open(files[i])
as f:
+
+
+
+
+
20 a,b = line.strip().split(
"," )
+
+
+
23 plt.plot(x,y,label=f
"amplitude: {vals[i]}" )
+
+
25 plt.xlabel(
r"$\omega_V$" )
+
26 plt.ylabel(
r"Fraction of particles left" )
+
27 plt.title(
r"The fraction of particles left in the Penning trap "
+
28 "after 500 microseconds for different amplitudes and frequencies" )
+
+
+
+
32 if __name__ ==
"__main__" :
+
+
+
+
+
+
+ src plot_particles_left.py
+
+
+
+
+
diff --git a/docs/search/all_0.js b/docs/search/all_0.js
index 4fc815a..1e5c227 100644
--- a/docs/search/all_0.js
+++ b/docs/search/all_0.js
@@ -1,6 +1,4 @@
var searchData=
[
- ['add_5fparticle_0',['add_particle',['../classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8',1,'PenningTrap']]],
- ['arma_5fvector_5fclose_5fto_1',['arma_vector_close_to',['../utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8): utils.cpp'],['../utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol): utils.cpp']]],
- ['assert_2',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]]
+ ['_5f_5fmethod_5fname_5f_5f_0',['__METHOD_NAME__',['../utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168',1,'utils.hpp']]]
];
diff --git a/docs/search/all_1.js b/docs/search/all_1.js
index 80ed042..4fc815a 100644
--- a/docs/search/all_1.js
+++ b/docs/search/all_1.js
@@ -1,5 +1,6 @@
var searchData=
[
- ['b_5f0_0',['B_0',['../classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716',1,'PenningTrap']]],
- ['bug_20list_1',['Bug List',['../bug.html',1,'']]]
+ ['add_5fparticle_0',['add_particle',['../classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8',1,'PenningTrap']]],
+ ['arma_5fvector_5fclose_5fto_1',['arma_vector_close_to',['../utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8): utils.cpp'],['../utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol): utils.cpp']]],
+ ['assert_2',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]]
];
diff --git a/docs/search/all_10.js b/docs/search/all_10.js
new file mode 100644
index 0000000..1b9fc74
--- /dev/null
+++ b/docs/search/all_10.js
@@ -0,0 +1,4 @@
+var searchData=
+[
+ ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57',1,'PenningTrap']]]
+];
diff --git a/docs/search/all_2.js b/docs/search/all_2.js
index 0648f09..80ed042 100644
--- a/docs/search/all_2.js
+++ b/docs/search/all_2.js
@@ -1,4 +1,5 @@
var searchData=
[
- ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]]
+ ['b_5f0_0',['B_0',['../classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716',1,'PenningTrap']]],
+ ['bug_20list_1',['Bug List',['../bug.html',1,'']]]
];
diff --git a/docs/search/all_3.js b/docs/search/all_3.js
index e50dce3..0648f09 100644
--- a/docs/search/all_3.js
+++ b/docs/search/all_3.js
@@ -1,5 +1,4 @@
var searchData=
[
- ['d_0',['d',['../classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2',1,'PenningTrap']]],
- ['debug_1',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]]
+ ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]]
];
diff --git a/docs/search/all_4.js b/docs/search/all_4.js
index c031fe4..e50dce3 100644
--- a/docs/search/all_4.js
+++ b/docs/search/all_4.js
@@ -1,7 +1,5 @@
var searchData=
[
- ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965',1,'PenningTrap']]],
- ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9',1,'PenningTrap']]],
- ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784',1,'PenningTrap']]],
- ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b',1,'PenningTrap']]]
+ ['d_0',['d',['../classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2',1,'PenningTrap']]],
+ ['debug_1',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]]
];
diff --git a/docs/search/all_5.js b/docs/search/all_5.js
index ccf47d2..c4c479f 100644
--- a/docs/search/all_5.js
+++ b/docs/search/all_5.js
@@ -1,4 +1,7 @@
var searchData=
[
- ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182',1,'PenningTrap']]]
+ ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#ab9ea97a406534bbe621a95215144875e',1,'PenningTrap']]],
+ ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e',1,'PenningTrap']]],
+ ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#acbf065c9c125682329ad82a8d166554c',1,'PenningTrap']]],
+ ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9',1,'PenningTrap']]]
];
diff --git a/docs/search/all_6.js b/docs/search/all_6.js
index cb8673f..d1d9acc 100644
--- a/docs/search/all_6.js
+++ b/docs/search/all_6.js
@@ -1,4 +1,5 @@
var searchData=
[
- ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]]
+ ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce',1,'PenningTrap']]],
+ ['fraction_5fof_5fparticles_5fleft_1',['fraction_of_particles_left',['../classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b',1,'PenningTrap']]]
];
diff --git a/docs/search/all_7.js b/docs/search/all_7.js
index 959abdd..6af262e 100644
--- a/docs/search/all_7.js
+++ b/docs/search/all_7.js
@@ -1,6 +1,6 @@
var searchData=
[
- ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]],
- ['m_5fassert_1',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]],
- ['main_2ecpp_2',['main.cpp',['../main_8cpp.html',1,'']]]
+ ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]],
+ ['k_5fr_1',['k_r',['../classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640',1,'PenningTrap']]],
+ ['k_5fv_2',['k_v',['../classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4',1,'PenningTrap']]]
];
diff --git a/docs/search/all_8.js b/docs/search/all_8.js
index 3ec818e..d86b301 100644
--- a/docs/search/all_8.js
+++ b/docs/search/all_8.js
@@ -1,12 +1,7 @@
var searchData=
[
- ['particle_0',['Particle',['../classParticle.html',1,'Particle'],['../classParticle.html#a00e108823877a25513ccae7cac011b4c',1,'Particle::Particle()']]],
- ['particle_2ecpp_1',['Particle.cpp',['../Particle_8cpp.html',1,'']]],
- ['particle_2ehpp_2',['Particle.hpp',['../Particle_8hpp.html',1,'']]],
- ['particles_3',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]],
- ['penning_20trap_20simulation_4',['Penning trap simulation',['../index.html',1,'']]],
- ['penningtrap_5',['PenningTrap',['../classPenningTrap.html',1,'PenningTrap'],['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle::PenningTrap()'],['../classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560',1,'PenningTrap::PenningTrap()']]],
- ['penningtrap_2ecpp_6',['PenningTrap.cpp',['../PenningTrap_8cpp.html',1,'']]],
- ['penningtrap_2ehpp_7',['PenningTrap.hpp',['../PenningTrap_8hpp.html',1,'']]],
- ['penningtraptest_8',['PenningTrapTest',['../classPenningTrapTest.html',1,'']]]
+ ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]],
+ ['m_5fassert_1',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]],
+ ['main_2ecpp_2',['main.cpp',['../main_8cpp.html',1,'']]],
+ ['mkpath_3',['mkpath',['../utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa',1,'mkpath(std::string path, int mode=0777): utils.cpp'],['../utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de',1,'mkpath(std::string path, int mode): utils.cpp']]]
];
diff --git a/docs/search/all_9.js b/docs/search/all_9.js
index a43f9bc..962dfef 100644
--- a/docs/search/all_9.js
+++ b/docs/search/all_9.js
@@ -1,4 +1,12 @@
var searchData=
[
- ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]]
+ ['particle_0',['Particle',['../classParticle.html',1,'Particle'],['../classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4',1,'Particle::Particle()']]],
+ ['particle_2ecpp_1',['Particle.cpp',['../Particle_8cpp.html',1,'']]],
+ ['particle_2ehpp_2',['Particle.hpp',['../Particle_8hpp.html',1,'']]],
+ ['particles_3',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]],
+ ['penning_20trap_20simulation_4',['Penning trap simulation',['../index.html',1,'']]],
+ ['penningtrap_5',['PenningTrap',['../classPenningTrap.html',1,'PenningTrap'],['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle::PenningTrap()'],['../classPenningTrap.html#ae670d7de621acdb343b01af098086f63',1,'PenningTrap::PenningTrap(double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1',1,'PenningTrap::PenningTrap(unsigned int i, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73',1,'PenningTrap::PenningTrap(std::vector< Particle > particles, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)']]],
+ ['penningtrap_2ecpp_6',['PenningTrap.cpp',['../PenningTrap_8cpp.html',1,'']]],
+ ['penningtrap_2ehpp_7',['PenningTrap.hpp',['../PenningTrap_8hpp.html',1,'']]],
+ ['penningtraptest_8',['PenningTrapTest',['../classPenningTrapTest.html',1,'']]]
];
diff --git a/docs/search/all_a.js b/docs/search/all_a.js
index b78ca6a..a43f9bc 100644
--- a/docs/search/all_a.js
+++ b/docs/search/all_a.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['r_5fvec_0',['r_vec',['../classParticle.html#acf1a0f3c978b06d76df5bb4279594467',1,'Particle']]]
+ ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]]
];
diff --git a/docs/search/all_b.js b/docs/search/all_b.js
index bf61385..fb8b113 100644
--- a/docs/search/all_b.js
+++ b/docs/search/all_b.js
@@ -1,4 +1,5 @@
var searchData=
[
- ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]]
+ ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648',1,'PenningTrap']]],
+ ['r_5fvec_1',['r_vec',['../classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6',1,'Particle']]]
];
diff --git a/docs/search/all_c.js b/docs/search/all_c.js
index 89cf6c6..f0c09d2 100644
--- a/docs/search/all_c.js
+++ b/docs/search/all_c.js
@@ -1,9 +1,8 @@
var searchData=
[
- ['t_0',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]],
- ['test_5fsuite_2ecpp_1',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]],
- ['todo_20list_2',['Todo List',['../todo.html',1,'']]],
- ['total_5fforce_3',['total_force',['../classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be',1,'PenningTrap']]],
- ['total_5fforce_5fexternal_4',['total_force_external',['../classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee',1,'PenningTrap']]],
- ['total_5fforce_5fparticles_5',['total_force_particles',['../classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d',1,'PenningTrap']]]
+ ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]],
+ ['sim_5farr_1',['sim_arr',['../typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af',1,'typedefs.hpp']]],
+ ['sim_5fcols_2',['sim_cols',['../typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23',1,'typedefs.hpp']]],
+ ['sim_5frows_3',['sim_rows',['../typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66',1,'typedefs.hpp']]],
+ ['simulate_4',['simulate',['../classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854',1,'PenningTrap']]]
];
diff --git a/docs/search/all_d.js b/docs/search/all_d.js
index cd921db..c04457d 100644
--- a/docs/search/all_d.js
+++ b/docs/search/all_d.js
@@ -1,5 +1,10 @@
var searchData=
[
- ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]],
- ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]]
+ ['t_0',['t',['../classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e',1,'PenningTrap']]],
+ ['t_1',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]],
+ ['test_5fsuite_2ecpp_2',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]],
+ ['total_5fforce_3',['total_force',['../classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8',1,'PenningTrap']]],
+ ['total_5fforce_5fexternal_4',['total_force_external',['../classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56',1,'PenningTrap']]],
+ ['total_5fforce_5fparticles_5',['total_force_particles',['../classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b',1,'PenningTrap']]],
+ ['typedefs_2ehpp_6',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]]
];
diff --git a/docs/search/all_e.js b/docs/search/all_e.js
index b447fa7..cd921db 100644
--- a/docs/search/all_e.js
+++ b/docs/search/all_e.js
@@ -1,6 +1,5 @@
var searchData=
[
- ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]],
- ['v_5f0_1',['V_0',['../classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89',1,'PenningTrap']]],
- ['v_5fvec_2',['v_vec',['../classParticle.html#a4a5d22c7aeca66f67d083f270cba25df',1,'Particle']]]
+ ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]],
+ ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]]
];
diff --git a/docs/search/all_f.js b/docs/search/all_f.js
new file mode 100644
index 0000000..bb9c0eb
--- /dev/null
+++ b/docs/search/all_f.js
@@ -0,0 +1,8 @@
+var searchData=
+[
+ ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]],
+ ['v_5f0_1',['V_0',['../classPenningTrap.html#aaf105828121c4a33cc2b217453c20317',1,'PenningTrap']]],
+ ['v_5ffunc_2',['v_func',['../classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e',1,'PenningTrap']]],
+ ['v_5fvec_3',['v_vec',['../classParticle.html#a879692772803d6ab65fa4993b54aea6e',1,'Particle']]],
+ ['vec_5f3d_4',['vec_3d',['../typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df',1,'typedefs.hpp']]]
+];
diff --git a/docs/search/defines_0.js b/docs/search/defines_0.js
index 97ce9d9..1e5c227 100644
--- a/docs/search/defines_0.js
+++ b/docs/search/defines_0.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['assert_0',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]]
+ ['_5f_5fmethod_5fname_5f_5f_0',['__METHOD_NAME__',['../utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168',1,'utils.hpp']]]
];
diff --git a/docs/search/defines_1.js b/docs/search/defines_1.js
index c6466cb..97ce9d9 100644
--- a/docs/search/defines_1.js
+++ b/docs/search/defines_1.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['debug_0',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]]
+ ['assert_0',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]]
];
diff --git a/docs/search/defines_2.js b/docs/search/defines_2.js
index cb8673f..c6466cb 100644
--- a/docs/search/defines_2.js
+++ b/docs/search/defines_2.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]]
+ ['debug_0',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]]
];
diff --git a/docs/search/defines_3.js b/docs/search/defines_3.js
index 6eef01f..cb8673f 100644
--- a/docs/search/defines_3.js
+++ b/docs/search/defines_3.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['t_0',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]]
+ ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]]
];
diff --git a/docs/search/defines_4.js b/docs/search/defines_4.js
index 06f433f..6eef01f 100644
--- a/docs/search/defines_4.js
+++ b/docs/search/defines_4.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]]
+ ['t_0',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]]
];
diff --git a/docs/search/defines_5.js b/docs/search/defines_5.js
new file mode 100644
index 0000000..06f433f
--- /dev/null
+++ b/docs/search/defines_5.js
@@ -0,0 +1,4 @@
+var searchData=
+[
+ ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]]
+];
diff --git a/docs/search/files_3.js b/docs/search/files_3.js
index 1ca9264..5e3fea9 100644
--- a/docs/search/files_3.js
+++ b/docs/search/files_3.js
@@ -1,4 +1,5 @@
var searchData=
[
- ['test_5fsuite_2ecpp_0',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]]
+ ['test_5fsuite_2ecpp_0',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]],
+ ['typedefs_2ehpp_1',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]]
];
diff --git a/docs/search/functions_1.js b/docs/search/functions_1.js
index c031fe4..c4c479f 100644
--- a/docs/search/functions_1.js
+++ b/docs/search/functions_1.js
@@ -1,7 +1,7 @@
var searchData=
[
- ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965',1,'PenningTrap']]],
- ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9',1,'PenningTrap']]],
- ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784',1,'PenningTrap']]],
- ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b',1,'PenningTrap']]]
+ ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#ab9ea97a406534bbe621a95215144875e',1,'PenningTrap']]],
+ ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e',1,'PenningTrap']]],
+ ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#acbf065c9c125682329ad82a8d166554c',1,'PenningTrap']]],
+ ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9',1,'PenningTrap']]]
];
diff --git a/docs/search/functions_2.js b/docs/search/functions_2.js
index ccf47d2..d1d9acc 100644
--- a/docs/search/functions_2.js
+++ b/docs/search/functions_2.js
@@ -1,4 +1,5 @@
var searchData=
[
- ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182',1,'PenningTrap']]]
+ ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce',1,'PenningTrap']]],
+ ['fraction_5fof_5fparticles_5fleft_1',['fraction_of_particles_left',['../classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b',1,'PenningTrap']]]
];
diff --git a/docs/search/functions_3.js b/docs/search/functions_3.js
index 30ce46b..ffb26d6 100644
--- a/docs/search/functions_3.js
+++ b/docs/search/functions_3.js
@@ -1,4 +1,5 @@
var searchData=
[
- ['m_5fassert_0',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]]
+ ['m_5fassert_0',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]],
+ ['mkpath_1',['mkpath',['../utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa',1,'mkpath(std::string path, int mode=0777): utils.cpp'],['../utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de',1,'mkpath(std::string path, int mode): utils.cpp']]]
];
diff --git a/docs/search/functions_4.js b/docs/search/functions_4.js
index 2dc79c5..852716e 100644
--- a/docs/search/functions_4.js
+++ b/docs/search/functions_4.js
@@ -1,5 +1,5 @@
var searchData=
[
- ['particle_0',['Particle',['../classParticle.html#a00e108823877a25513ccae7cac011b4c',1,'Particle']]],
- ['penningtrap_1',['PenningTrap',['../classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560',1,'PenningTrap']]]
+ ['particle_0',['Particle',['../classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4',1,'Particle']]],
+ ['penningtrap_1',['PenningTrap',['../classPenningTrap.html#ae670d7de621acdb343b01af098086f63',1,'PenningTrap::PenningTrap(double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1',1,'PenningTrap::PenningTrap(unsigned int i, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73',1,'PenningTrap::PenningTrap(std::vector< Particle > particles, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)']]]
];
diff --git a/docs/search/functions_5.js b/docs/search/functions_5.js
index bf61385..07b3041 100644
--- a/docs/search/functions_5.js
+++ b/docs/search/functions_5.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]]
+ ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648',1,'PenningTrap']]]
];
diff --git a/docs/search/functions_6.js b/docs/search/functions_6.js
index 83f26c2..a7b65b4 100644
--- a/docs/search/functions_6.js
+++ b/docs/search/functions_6.js
@@ -1,6 +1,5 @@
var searchData=
[
- ['total_5fforce_0',['total_force',['../classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be',1,'PenningTrap']]],
- ['total_5fforce_5fexternal_1',['total_force_external',['../classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee',1,'PenningTrap']]],
- ['total_5fforce_5fparticles_2',['total_force_particles',['../classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d',1,'PenningTrap']]]
+ ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]],
+ ['simulate_1',['simulate',['../classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854',1,'PenningTrap']]]
];
diff --git a/docs/search/functions_7.js b/docs/search/functions_7.js
new file mode 100644
index 0000000..73e1881
--- /dev/null
+++ b/docs/search/functions_7.js
@@ -0,0 +1,6 @@
+var searchData=
+[
+ ['total_5fforce_0',['total_force',['../classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8',1,'PenningTrap']]],
+ ['total_5fforce_5fexternal_1',['total_force_external',['../classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56',1,'PenningTrap']]],
+ ['total_5fforce_5fparticles_2',['total_force_particles',['../classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b',1,'PenningTrap']]]
+];
diff --git a/docs/search/functions_8.js b/docs/search/functions_8.js
new file mode 100644
index 0000000..8d7b6ff
--- /dev/null
+++ b/docs/search/functions_8.js
@@ -0,0 +1,4 @@
+var searchData=
+[
+ ['v_5ffunc_0',['v_func',['../classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e',1,'PenningTrap']]]
+];
diff --git a/docs/search/functions_9.js b/docs/search/functions_9.js
new file mode 100644
index 0000000..1b9fc74
--- /dev/null
+++ b/docs/search/functions_9.js
@@ -0,0 +1,4 @@
+var searchData=
+[
+ ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57',1,'PenningTrap']]]
+];
diff --git a/docs/search/searchdata.js b/docs/search/searchdata.js
index 906104d..4d47bbf 100644
--- a/docs/search/searchdata.js
+++ b/docs/search/searchdata.js
@@ -1,13 +1,14 @@
var indexSectionsWithContent =
{
- 0: "abcdefkmpqrstuv",
+ 0: "_abcdefkmpqrstuvw",
1: "p",
2: "cmptu",
- 3: "aefmpst",
- 4: "bdmpqrv",
- 5: "p",
- 6: "adktv",
- 7: "bpt"
+ 3: "aefmprstvw",
+ 4: "bdkmpqrtv",
+ 5: "sv",
+ 6: "p",
+ 7: "_adktv",
+ 8: "bp"
};
var indexSectionNames =
@@ -17,9 +18,10 @@ var indexSectionNames =
2: "files",
3: "functions",
4: "variables",
- 5: "related",
- 6: "defines",
- 7: "pages"
+ 5: "typedefs",
+ 6: "related",
+ 7: "defines",
+ 8: "pages"
};
var indexSectionLabels =
@@ -29,8 +31,9 @@ var indexSectionLabels =
2: "Files",
3: "Functions",
4: "Variables",
- 5: "Friends",
- 6: "Macros",
- 7: "Pages"
+ 5: "Typedefs",
+ 6: "Friends",
+ 7: "Macros",
+ 8: "Pages"
};
diff --git a/docs/search/typedefs_0.js b/docs/search/typedefs_0.js
new file mode 100644
index 0000000..e79ff95
--- /dev/null
+++ b/docs/search/typedefs_0.js
@@ -0,0 +1,6 @@
+var searchData=
+[
+ ['sim_5farr_0',['sim_arr',['../typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af',1,'typedefs.hpp']]],
+ ['sim_5fcols_1',['sim_cols',['../typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23',1,'typedefs.hpp']]],
+ ['sim_5frows_2',['sim_rows',['../typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66',1,'typedefs.hpp']]]
+];
diff --git a/docs/search/typedefs_1.js b/docs/search/typedefs_1.js
new file mode 100644
index 0000000..fe88abf
--- /dev/null
+++ b/docs/search/typedefs_1.js
@@ -0,0 +1,4 @@
+var searchData=
+[
+ ['vec_5f3d_0',['vec_3d',['../typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df',1,'typedefs.hpp']]]
+];
diff --git a/docs/search/variables_2.js b/docs/search/variables_2.js
index 8411aec..7ff6c24 100644
--- a/docs/search/variables_2.js
+++ b/docs/search/variables_2.js
@@ -1,4 +1,5 @@
var searchData=
[
- ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]]
+ ['k_5fr_0',['k_r',['../classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640',1,'PenningTrap']]],
+ ['k_5fv_1',['k_v',['../classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4',1,'PenningTrap']]]
];
diff --git a/docs/search/variables_3.js b/docs/search/variables_3.js
index c9f603d..8411aec 100644
--- a/docs/search/variables_3.js
+++ b/docs/search/variables_3.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['particles_0',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]]
+ ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]]
];
diff --git a/docs/search/variables_4.js b/docs/search/variables_4.js
index a43f9bc..c9f603d 100644
--- a/docs/search/variables_4.js
+++ b/docs/search/variables_4.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]]
+ ['particles_0',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]]
];
diff --git a/docs/search/variables_5.js b/docs/search/variables_5.js
index b78ca6a..a43f9bc 100644
--- a/docs/search/variables_5.js
+++ b/docs/search/variables_5.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['r_5fvec_0',['r_vec',['../classParticle.html#acf1a0f3c978b06d76df5bb4279594467',1,'Particle']]]
+ ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]]
];
diff --git a/docs/search/variables_6.js b/docs/search/variables_6.js
index 01f3a29..fa44d82 100644
--- a/docs/search/variables_6.js
+++ b/docs/search/variables_6.js
@@ -1,5 +1,4 @@
var searchData=
[
- ['v_5f0_0',['V_0',['../classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89',1,'PenningTrap']]],
- ['v_5fvec_1',['v_vec',['../classParticle.html#a4a5d22c7aeca66f67d083f270cba25df',1,'Particle']]]
+ ['r_5fvec_0',['r_vec',['../classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6',1,'Particle']]]
];
diff --git a/docs/search/variables_7.js b/docs/search/variables_7.js
new file mode 100644
index 0000000..c7c5d99
--- /dev/null
+++ b/docs/search/variables_7.js
@@ -0,0 +1,4 @@
+var searchData=
+[
+ ['t_0',['t',['../classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e',1,'PenningTrap']]]
+];
diff --git a/docs/search/variables_8.js b/docs/search/variables_8.js
new file mode 100644
index 0000000..601b41d
--- /dev/null
+++ b/docs/search/variables_8.js
@@ -0,0 +1,5 @@
+var searchData=
+[
+ ['v_5f0_0',['V_0',['../classPenningTrap.html#aaf105828121c4a33cc2b217453c20317',1,'PenningTrap']]],
+ ['v_5fvec_1',['v_vec',['../classParticle.html#a879692772803d6ab65fa4993b54aea6e',1,'Particle']]]
+];
diff --git a/docs/test__suite_8cpp.html b/docs/test__suite_8cpp.html
index 787939b..7c69921 100644
--- a/docs/test__suite_8cpp.html
+++ b/docs/test__suite_8cpp.html
@@ -131,7 +131,7 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version 0.1
-Bug: No known bugs
+Bug: No known bugs
Definition in file test_suite.cpp .
diff --git a/docs/test__suite_8cpp_source.html b/docs/test__suite_8cpp_source.html
index 3fab92c..b317c82 100644
--- a/docs/test__suite_8cpp_source.html
+++ b/docs/test__suite_8cpp_source.html
@@ -136,9 +136,9 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
46 std::stringstream msg;
- 47 for (
int i = 0; i < tests.size(); i++) {
+ 47 for (
size_t i = 0; i < tests.size(); i++) {
48 v = tests.at(i).first;
-
+
52 msg <<
"Testing the external E field at (" << std::setprecision(2)
@@ -154,7 +154,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
64 arma::vec expected{0., 0.,
T };
-
+
67 "Testing the external B field at (0,0,0)" );
@@ -171,14 +171,14 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
81 arma::vec expected{-1., 0., 0.};
-
+
84 "Testing the force on a particle at (0,0,0) from a "
85 "particle at (1,0,0)." );
88 expected = arma::vec{0, -.024, -.032};
-
+
91 "Testing the force on a particle at (0,0,0) from a "
92 "particle at (0,3,4)." );
@@ -191,7 +191,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
99 Particle (1., 40., arma::vec{1., 2., 3.}, arma::vec{3., 4., 5.}));
101 arma::vec expected{395.58954878, -270.15871624, -57.89115348};
-
+
104 "Testing the total external force on a particle at "
105 "(1,2,3) with velocity (3,4,5)" );
@@ -204,7 +204,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
112 Particle (1., 40., arma::vec{0., 0., 0.}, arma::vec{0., 0., 0.}));
114 arma::vec expected{0., 0., 0.};
-
+
117 "Testing the total force of all particles on particle 0 "
118 "with only a single particle" );
@@ -217,7 +217,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
125 Particle (1., 40., arma::vec{0., 0., 1.}, arma::vec{0., 0., 0.}));
127 expected = arma::vec(3, arma::fill::value(-3473.383325));
-
+
130 "Testing the total force of all particles on particle 0 "
131 "with 3 other particles." );
@@ -234,18 +234,18 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
A class for simulating a Penning trap.
-A class that holds attributes of a particle.
+A class that holds attributes of a particle.
-A class that simulates a Penning trap.
-arma::vec total_force_external(int i)
Calculate the total external force on a particle.
-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 add_particle(Particle particle)
Add a particle to the system.
-arma::vec external_E_field(arma::vec r)
Calculate E at point r.
+A class that simulates a Penning trap.
+vec_3d external_E_field(vec_3d r)
Calculate E at point r.
+vec_3d total_force_particles(unsigned int i)
Calculate the total force on a particle p_i from other particles.
+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.
+vec_3d external_B_field(vec_3d r)
Calculate B at point r.
+vec_3d total_force_external(unsigned int i)
Calculate the total external force on a particle.
Function prototypes and macros that are useful.
-bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
Test if two armadillo vectors are close to each other.
+bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
Test if two armadillo vectors are close to each other.
#define ASSERT(expr, msg)
A prettier assertion function.
diff --git a/docs/typedefs_8hpp.html b/docs/typedefs_8hpp.html
new file mode 100644
index 0000000..1f2eedb
--- /dev/null
+++ b/docs/typedefs_8hpp.html
@@ -0,0 +1,222 @@
+
+
+
+
+
+
+
+Penning Trap Simulation: include/typedefs.hpp File Reference
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Penning Trap Simulation
+
+ Simulate particle behavior inside a Penning Trap
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+
+
+
+
+
Useful typedefs for cleaner code.
+More...
+
#include <vector>
+#include <armadillo>
+
+
Go to the source code of this file.
+
+
+typedef std::vector< arma::vec::fixed< 3 > > sim_cols
+ Typedef for the column of the result vector from simulating particles.
+
+typedef std::vector< arma::vec::fixed< 3 > > sim_rows
+ Typedef for the row of the result vector from simulating particles.
+
+typedef std::vector< sim_cols > sim_arr
+ Typedef for the result of the simulate method.
+
+typedef arma::vec::fixed< 3 > vec_3d
+ Typedef for a fixed 3d arma vector.
+
+
+
+
Useful typedefs for cleaner code.
+
Author Cory Alexander Balaton (coryab)
+
+Janita Ovidie Sandtrøen Willumsen (janitaws)
+
Version 1.0
+
These typedefs make the code more readable and easy to follow along.
+
Bug: No known bugs
+
+
Definition in file typedefs.hpp .
+
+
+
◆ sim_arr
+
+
+
+
+
Typedef for the result of the simulate method.
+
+
Definition at line 32 of file typedefs.hpp .
+
+
+
+
+
◆ sim_cols
+
+
+
+
+
+ typedef std::vector<arma::vec::fixed<3> > sim_cols
+
+
+
+
+
Typedef for the column of the result vector from simulating particles.
+
+
Definition at line 24 of file typedefs.hpp .
+
+
+
+
+
◆ sim_rows
+
+
+
+
+
+ typedef std::vector<arma::vec::fixed<3> > sim_rows
+
+
+
+
+
Typedef for the row of the result vector from simulating particles.
+
+
Definition at line 28 of file typedefs.hpp .
+
+
+
+
+
◆ vec_3d
+
+
+
+
+
+ typedef arma::vec::fixed<3> vec_3d
+
+
+
+
+
Typedef for a fixed 3d arma vector.
+
+
Definition at line 36 of file typedefs.hpp .
+
+
+
+
+
+
+
+
+
diff --git a/docs/typedefs_8hpp.js b/docs/typedefs_8hpp.js
new file mode 100644
index 0000000..d014844
--- /dev/null
+++ b/docs/typedefs_8hpp.js
@@ -0,0 +1,7 @@
+var typedefs_8hpp =
+[
+ [ "sim_arr", "typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af", null ],
+ [ "sim_cols", "typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23", null ],
+ [ "sim_rows", "typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66", null ],
+ [ "vec_3d", "typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df", null ]
+];
\ No newline at end of file
diff --git a/docs/typedefs_8hpp_source.html b/docs/typedefs_8hpp_source.html
new file mode 100644
index 0000000..475ff07
--- /dev/null
+++ b/docs/typedefs_8hpp_source.html
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+
+Penning Trap Simulation: include/typedefs.hpp Source File
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Penning Trap Simulation
+
+ Simulate particle behavior inside a Penning Trap
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+
+
+
+
Go to the documentation of this file.
+
+
+
+
+
+
+
24 typedef std::vector<arma::vec::fixed<3>>
sim_cols ;
+
+
28 typedef std::vector<arma::vec::fixed<3>>
sim_rows ;
+
+
+
+
+
+
+
std::vector< arma::vec::fixed< 3 > > sim_cols
Typedef for the column of the result vector from simulating particles.
+
std::vector< arma::vec::fixed< 3 > > sim_rows
Typedef for the row of the result vector from simulating particles.
+
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.
+
+
+
+
+
+
diff --git a/docs/utils_8cpp.html b/docs/utils_8cpp.html
index c2ffd2e..9401b51 100644
--- a/docs/utils_8cpp.html
+++ b/docs/utils_8cpp.html
@@ -106,7 +106,8 @@ $(document).ready(function(){initNavTree('utils_8cpp.html',''); initResizable();
Implementation of the utils.
More...
-#include "utils.hpp "
+
#include <sys/stat.h>
+
#include "utils.hpp "
Go to the source code of this file.
@@ -124,6 +125,9 @@ Functions
bool arma_vector_close_to (arma::vec &a, arma::vec &b, double tol)
Test if two armadillo vectors are close to each other.
+bool mkpath (std::string path, int mode)
+ Make path given.
+
Implementation of the utils.
@@ -131,7 +135,7 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version 1.0
-
Bug: No known bugs
+
Bug: No known bugs
Definition in file utils.cpp .
@@ -177,9 +181,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Returns Boolean
+
Returns bool
-
Definition at line 59 of file utils.cpp .
+
Definition at line 62 of file utils.cpp .
@@ -247,7 +251,48 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-Definition at line 40 of file utils.cpp .
+Definition at line 43 of file utils.cpp .
+
+
+
+
+◆ mkpath()
+
+
+
+
+
+ bool mkpath
+ (
+ std::string
+ path ,
+
+
+
+
+ int
+ mode = 0777
+
+
+
+ )
+
+
+
+
+
+
Make path given.
+
This tries to be the equivalent to "mkdir -p" and creates a new directory whenever it needs to.
+
Parameters
+
+ path The path to be created
+ mode The mode/permissions for all the new directories
+
+
+
+
Returns bool
+
+
Definition at line 76 of file utils.cpp .
@@ -284,6 +329,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
Turns a vector of doubles into a string written in scientific format.
+
The code is stolen from https://github.com/anderkve/FYS3150 .
Parameters
v The vector to stringify
@@ -292,9 +338,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Returns String
+
Returns std::string
-
Definition at line 21 of file utils.cpp .
+
Definition at line 24 of file utils.cpp .
@@ -331,7 +377,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
diff --git a/docs/utils_8cpp.js b/docs/utils_8cpp.js
index 36c50fa..362b36a 100644
--- a/docs/utils_8cpp.js
+++ b/docs/utils_8cpp.js
@@ -2,6 +2,7 @@ var utils_8cpp =
[
[ "arma_vector_close_to", "utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a", null ],
[ "m_assert", "utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b", null ],
+ [ "mkpath", "utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de", null ],
[ "scientific_format", "utils_8cpp.html#a58565270b643b24e3132f38c653e0199", null ],
[ "scientific_format", "utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746", null ]
];
\ No newline at end of file
diff --git a/docs/utils_8cpp_source.html b/docs/utils_8cpp_source.html
index 069cd7c..5ed9571 100644
--- a/docs/utils_8cpp_source.html
+++ b/docs/utils_8cpp_source.html
@@ -102,69 +102,97 @@ $(document).ready(function(){initNavTree('utils_8cpp_source.html',''); initResiz
Go to the documentation of this file.
-
-
-
-
-
-
17 ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
-
-
-
-
-
-
-
24 for (
double elem : v) {
-
-
-
-
-
-
30 static void print_message(std::string msg)
-
-
-
33 std::cout <<
"message: " << msg <<
"\n\n" ;
-
-
-
+
+
+
+
+
+
+
+
20 ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
+
+
+
+
+
+
+
27 for (
double elem : v) {
+
+
+
+
+
+
33 static void print_message(std::string msg)
+
+
+
36 std::cout <<
"message: " << msg <<
"\n\n" ;
-
-
-
40 void m_assert (
bool expr, std::string expr_str, std::string f, std::string file,
-
41 int line, std::string msg)
-
-
43 std::string new_assert(f.size() + (expr ? 4 : 6),
'-' );
-
44 std::cout <<
"\x1B[36m" << new_assert <<
"\033[0m\n" ;
-
45 std::cout << f <<
": " ;
-
-
47 std::cout <<
"\x1B[32mOK\033[0m\n" ;
-
-
-
-
51 std::cout <<
"\x1B[31mFAIL\033[0m\n" ;
-
-
53 std::cout << file <<
" " << line <<
": Assertion \"" << expr_str
-
-
-
-
-
-
-
-
61 if (a.n_elem != b.n_elem) {
-
-
-
-
65 for (
int i = 0; i < a.n_elem; i++) {
-
66 if (std::abs(a(i) - b(i)) >= tol) {
-
-
-
-
-
-
bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol)
Test if two armadillo vectors are close to each other.
-
std::string scientific_format(double d, int width, int prec)
Turns a double into a string written in scientific format.
-
void m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
+
+
+
+
+
+
43 void m_assert (
bool expr, std::string expr_str, std::string f, std::string file,
+
44 int line, std::string msg)
+
+
46 std::string new_assert(f.size() + (expr ? 4 : 6),
'-' );
+
47 std::cout <<
"\x1B[36m" << new_assert <<
"\033[0m\n" ;
+
48 std::cout << f <<
": " ;
+
+
50 std::cout <<
"\x1B[32mOK\033[0m\n" ;
+
+
+
+
54 std::cout <<
"\x1B[31mFAIL\033[0m\n" ;
+
+
56 std::cout << file <<
" " << line <<
": Assertion \"" << expr_str
+
+
+
+
+
+
+
+
64 if (a.n_elem != b.n_elem) {
+
+
+
+
68 for (
size_t i = 0; i < a.n_elem; i++) {
+
69 if (std::abs(a(i) - b(i)) >= tol) {
+
+
+
+
+
+
+
76 bool mkpath (std::string path,
int mode)
+
+
+
79 std::string::size_type pos = -1;
+
+
+
82 if (path.back() !=
'/' ) {
+
+
+
+
+
87 pos = path.find(
'/' , pos);
+
88 if (pos != std::string::npos) {
+
89 cur_dir = path.substr(0, pos);
+
90 if (mkdir(cur_dir.c_str(), mode) != 0 && stat(cur_dir.c_str(), &buf) != 0) {
+
+
+
+
+
+
+
+
+
+
bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol)
Test if two armadillo vectors are close to each other.
+
std::string scientific_format(double d, int width, int prec)
Turns a double into a string written in scientific format.
+
bool mkpath(std::string path, int mode)
Make path given.
+
void m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
Function prototypes and macros that are useful.
diff --git a/docs/utils_8hpp.html b/docs/utils_8hpp.html
index dea4601..2866ae0 100644
--- a/docs/utils_8hpp.html
+++ b/docs/utils_8hpp.html
@@ -124,6 +124,7 @@ Macros
A prettier assertion function.
#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
+ Get the name of the current method/function.
bool arma_vector_close_to (arma::vec &a, arma::vec &b, double tol=1e-8)
Test if two armadillo vectors are close to each other.
+bool mkpath (std::string path, int mode=0777)
+ Make path given.
+
Function prototypes and macros that are useful.
@@ -148,7 +152,7 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version 1.0
These utility function are mainly for convenience and aren't directly related to the project.
-
Bug: No known bugs
+
Bug: No known bugs
Definition in file utils.hpp .
@@ -164,7 +168,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Definition at line 48 of file utils.hpp .
+
Get the name of the current method/function.
+
+
Definition at line 51 of file utils.hpp .
@@ -193,9 +199,10 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Value: m_assert (expr, #expr, __METHOD_NAME__, __FILE__, \
+
Value:
__LINE__, msg)
-
void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
+
void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
+
#define __METHOD_NAME__
Get the name of the current method/function.
A prettier assertion function.
This macro calls the m_assert function which is a more informative assertion function than the regular assert function from cassert.
@@ -270,9 +277,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Returns Boolean
+
Returns bool
-
Definition at line 59 of file utils.cpp .
+
Definition at line 62 of file utils.cpp .
@@ -340,7 +347,48 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-Definition at line 40 of file utils.cpp .
+Definition at line 43 of file utils.cpp .
+
+
+
+
+◆ mkpath()
+
+
+
+
+
+ bool mkpath
+ (
+ std::string
+ path ,
+
+
+
+
+ int
+ mode = 0777
+
+
+
+ )
+
+
+
+
+
+
Make path given.
+
This tries to be the equivalent to "mkdir -p" and creates a new directory whenever it needs to.
+
Parameters
+
+ path The path to be created
+ mode The mode/permissions for all the new directories
+
+
+
+
Returns bool
+
+
Definition at line 76 of file utils.cpp .
@@ -377,6 +425,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
Turns a vector of doubles into a string written in scientific format.
+
The code is stolen from https://github.com/anderkve/FYS3150 .
Parameters
v The vector to stringify
@@ -385,9 +434,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Returns String
+
Returns std::string
-
Definition at line 21 of file utils.cpp .
+
Definition at line 24 of file utils.cpp .
@@ -424,7 +473,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
diff --git a/docs/utils_8hpp.js b/docs/utils_8hpp.js
index 34c7b36..68951df 100644
--- a/docs/utils_8hpp.js
+++ b/docs/utils_8hpp.js
@@ -1,9 +1,11 @@
var utils_8hpp =
[
+ [ "__METHOD_NAME__", "utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168", null ],
[ "ASSERT", "utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9", null ],
[ "DEBUG", "utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b", null ],
[ "arma_vector_close_to", "utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772", null ],
[ "m_assert", "utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38", null ],
+ [ "mkpath", "utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa", null ],
[ "scientific_format", "utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d", null ],
[ "scientific_format", "utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384", null ]
];
\ No newline at end of file
diff --git a/docs/utils_8hpp_source.html b/docs/utils_8hpp_source.html
index 33ddc52..1c7052d 100644
--- a/docs/utils_8hpp_source.html
+++ b/docs/utils_8hpp_source.html
@@ -121,39 +121,45 @@ $(document).ready(function(){initNavTree('utils_8hpp_source.html',''); initResiz
45 #define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
- 48 #define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
-
-
+ 51 #define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 112 static inline std::string methodName(
const std::string& prettyFunction)
-
- 114 size_t colons = prettyFunction.find(
"::" );
- 115 size_t begin = prettyFunction.substr(0,colons).rfind(
" " ) + 1;
- 116 size_t end = prettyFunction.rfind(
"(" ) - begin;
-
- 118 return prettyFunction.substr(begin,end) +
"()" ;
-
-
-
-bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
Test if two armadillo vectors are close to each other.
-void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
-std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 126 static inline std::string methodName(
const std::string& pretty_function)
+
+ 128 size_t colons = pretty_function.find(
"::" );
+ 129 size_t begin = pretty_function.substr(0,colons).rfind(
" " ) + 1;
+ 130 size_t end = pretty_function.rfind(
"(" ) - begin;
+
+ 132 return pretty_function.substr(begin,end) +
"()" ;
+
+
+
+ 146 bool mkpath (std::string path,
int mode = 0777);
+
+
+bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
Test if two armadillo vectors are close to each other.
+void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
+bool mkpath(std::string path, int mode=0777)
Make path given.
+std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
diff --git a/include/Particle.hpp b/include/Particle.hpp
index 29b4ccb..4b5e716 100644
--- a/include/Particle.hpp
+++ b/include/Particle.hpp
@@ -14,24 +14,29 @@
#include
+#include "typedefs.hpp"
+
/** @brief A class that holds attributes of a particle
* */
class Particle {
private:
- double q; ///< Charge
- double m; ///< Mass
- arma::vec::fixed<3> r_vec; ///< position
- arma::vec::fixed<3> v_vec; ///< velocity
+ double q; ///< Charge
+ double m; ///< Mass
+ vec_3d r_vec; ///< position
+ vec_3d v_vec; ///< velocity
public:
/** @brief Initialize the particle.
*
* @details Initialize the particle with a charge, mass, position and
* velocity.
+ *
+ * @param q The charge of the particle
+ * @param m The mass of the particle
+ * @param r_vec The initial position of the particle
+ * @param v_vec The initial velocity of the particle
* */
- Particle(double q, double m,
- arma::vec::fixed<3> r_vec,
- arma::vec::fixed<3> v_vec);
+ Particle(double q, double m, vec_3d r_vec, vec_3d v_vec);
/** @brief Make private attributes available for PenningTrap.
* */
diff --git a/include/PenningTrap.hpp b/include/PenningTrap.hpp
index 3601634..9a78784 100644
--- a/include/PenningTrap.hpp
+++ b/include/PenningTrap.hpp
@@ -17,9 +17,15 @@
#include "Particle.hpp"
#include "constants.hpp"
+#include "typedefs.hpp"
-#pragma omp declare reduction( + : arma::vec : omp_out += omp_in ) \
- initializer( omp_priv = omp_orig )
+#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
+ initializer(omp_priv = omp_orig)
+
+typedef struct simulation {
+ sim_arr r_vecs;
+ sim_arr v_vecs;
+} simulation_t;
/** @brief A class that simulates a Penning trap.
*
@@ -28,61 +34,197 @@
* */
class PenningTrap {
private:
- double B_0; ///< Magnetic field strength
- double V_0; ///< Applied potential
- double d; ///< Characteristic dimension
- std::vector particles; ///< The particles in the Penning trap
+ double B_0; ///< Magnetic field strength
+ std::function V_0; ///< Applied potential
+ double d; ///< Characteristic dimension
+ double t; ///< Current time
+ std::vector particles; ///< The particles in the Penning trap
+ sim_arr k_v; ///< A 2D vector containing all \f$k_{i,j}\f$ where \f$j\f$ is
+ ///< the index of a particle
+ sim_arr k_r; ///< A 2D vector containing all \f$k_{i,j}\f$ where \f$j\f$ is
+ ///< the index of a particle
+
+ /** @brief Helper for evolve_RK4 when calculating \f$k_{v,i,j}\f$ values
+ *
+ * @details Something
+ *
+ * @param i Index i for \f$k_{v,i,j}\f$
+ * @param j Index j for \f$k_{v,i,j}\f$
+ * @param dt the step length (delta time)
+ *
+ * @return vec_3d
+ * */
+ vec_3d v_func(unsigned int i, unsigned int j, double dt);
+
+ /** @brief Helper for evolve_RK4 when calculating \f$k_{r,i,j}\f$ values
+ *
+ * @details Something
+ *
+ * @param i Index i for \f$k_{r,i,j}\f$
+ * @param j Index j for \f$k_{r,i,j}\f$
+ * @param dt the step length (delta time)
+ *
+ * @return vec_3d
+ * */
+ vec_3d r_func(unsigned int i, unsigned int j, double dt);
public:
- /** @brief Set B_0, V_0 and d.
+ /** @brief Constructor for the PenningTrap class
+ *
+ * @param B_0 The magnetic field strength
+ * @param V_0 The time dependent applied potential
+ * @param d The characteristic dimension
+ * @param t The starting time
* */
- PenningTrap(double B_0 = T, double V_0 = 25.*V/1000., double d = 500.);
+ PenningTrap(
+ double B_0 = T,
+ std::function V_0 =
+ [](double t) { return 25. * V / 1000.; },
+ double d = 500., double t = 0.);
+
+ /** @brief Constructor for the PenningTrap class
+ *
+ * @param i The number of particles to generate
+ * @param B_0 The magnetic field strength
+ * @param V_0 The time dependent applied potential
+ * @param d The characteristic dimension
+ * @param t The starting time
+ * */
+ PenningTrap(
+ unsigned int i, double B_0 = T,
+ std::function V_0 =
+ [](double t) { return 25. * V / 1000.; },
+ double d = 500., double t = 0.);
+
+ /** @brief Constructor for the PenningTrap class
+ *
+ * @param particles The starting particles
+ * @param B_0 The magnetic field strength
+ * @param V_0 The time dependent applied potential
+ * @param d The characteristic dimension
+ * @param t The starting time
+ * */
+ PenningTrap(
+ std::vector particles, double B_0 = T,
+ std::function V_0 =
+ [](double t) { return 25. * V / 1000.; },
+ double d = 500., double t = 0.);
/** @brief Add a particle to the system
+ *
+ * @param particle The particle to add to the Penning trap
* */
void add_particle(Particle particle);
/** @brief Calculate E at point r
+ *
+ * @param r The position where we want to calculate the E field
+ *
+ * @return vec_3d
* */
- arma::vec external_E_field(arma::vec r);
+ vec_3d external_E_field(vec_3d r);
/** @brief Calculate B at point r
+ *
+ * @param r The position where we want to calculate the B field
+ *
+ * @return vec_3d
* */
- arma::vec external_B_field(arma::vec r);
+ vec_3d external_B_field(vec_3d r);
/** @brief Calculate the force between 2 particles.
*
- * @details Calculate the force exhibited on particle p_i from
+ * @details Calculate the force exhibited on particle p_i from
* particle p_j.
+ *
+ * @param i The index of particle p_i
+ * @param j The index of particle p_j
+ *
+ * @return vec_3d
* */
- arma::vec force_on_particle(int i, int j);
+ vec_3d force_on_particle(unsigned int i, unsigned int j);
/** @brief Calculate the total external force on a particle.
*
* @details Calculate the total amount of force that E and B exhibits
* on particle p_i.
+ *
+ * @param i The index of particle p_i
+ *
+ * @return vec_3d
* */
- arma::vec total_force_external(int i);
+ vec_3d total_force_external(unsigned int i);
- /** @brief Calculate the total force on a particle from other particles.
+ /** @brief Calculate the total force on a particle p_i from other particles.
+ *
+ * @param i The index of particle p_i
+ *
+ * @return vec_3d
* */
- arma::vec total_force_particles(int i);
+ vec_3d total_force_particles(unsigned int i);
- /** @brief calculate the total force on a particle.
- * */
- arma::vec total_force(int i);
+ /** @brief calculate the total force on a particle p_i.
+ *
+ * @param i The index of particle p_i
+ *
+ * @return vec_3d
+ * */
+ vec_3d total_force(unsigned int i);
/** @brief Go forward one timestep using the RK4 method
+ *
+ * @param dt The step length
+ * @param particle_interaction Turn particle interactions on/off
* */
- void evolve_RK4(double dt);
+ void evolve_RK4(double dt, bool particle_interaction = true);
/** @brief Go forward one timestep using the forward Euler method
+ *
+ * @param dt The step length
+ * @param particle_interaction Turn particle interactions on/off
* */
- void evolve_forward_euler(double dt);
+ void evolve_forward_euler(double dt, bool particle_interaction = true);
- arma::vec get_particle(int i);
+ /** @brief Simulate the particle system inside the Penning trap over
+ * a certain amount of time.
+ *
+ * @param time The time to simulate in microseconds
+ * @param steps The amount of steps for the whole simulation
+ * @param method The method to use when moving forward a timestep
+ * @param particle_interaction Turn particle interactions on/off
+ * */
+ simulation_t simulate(double time, unsigned int steps,
+ std::string method = "rk4",
+ bool particle_interaction = true);
- double get_d();
+ /** @brief Simulate and write the displacement of all particles to files.
+ *
+ * @param path The directory to save the data
+ * @param time The time to simulate in microseconds
+ * @param steps The amount of steps for the whole simulation
+ * @param method The method to use when moving forward a timestep
+ * @param particle_interaction Turn particle interactions on/off
+ * */
+ void write_simulation_to_dir(std::string path, double time,
+ unsigned int steps, std::string method = "rk4",
+ bool particle_interaction = true);
+
+ /** @brief Simulate and calculate what fraction of particles are still
+ * left inside the Penning trap after the simulation.
+ *
+ * @param time The time to simulate in microseconds
+ * @param steps The amount of steps for the whole simulation
+ * @param method The method to use when moving forward a timestep
+ * @param particle_interaction Turn particle interactions on/off
+ *
+ * @return double
+ * */
+ double fraction_of_particles_left(double time, unsigned int steps,
+ std::string method = "rk4",
+ bool particle_interaction = true);
+
+ vec_3d get_r(int i);
+ double get_t();
};
#endif
diff --git a/include/typedefs.hpp b/include/typedefs.hpp
new file mode 100644
index 0000000..f0ceca2
--- /dev/null
+++ b/include/typedefs.hpp
@@ -0,0 +1,38 @@
+/** @file typedefs.hpp
+ *
+ * @author Cory Alexander Balaton (coryab)
+ * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+ *
+ * @version 1.0
+ *
+ * @brief Useful typedefs for cleaner code.
+ *
+ * @details These typedefs make the code more readable and easy to follow
+ * along.
+ *
+ * @bug No known bugs
+ * */
+#ifndef __TYPEDEFS__
+#define __TYPEDEFS__
+
+#include
+#include
+
+/** @brief Typedef for the column of the result vector from simulating
+ * particles.
+ * */
+typedef std::vector> sim_cols;
+
+/** @brief Typedef for the row of the result vector from simulating particles.
+ * */
+typedef std::vector> sim_rows;
+
+/** @brief Typedef for the result of the simulate method.
+ * */
+typedef std::vector sim_arr;
+
+/** @brief Typedef for a fixed 3d arma vector.
+ * */
+typedef arma::vec::fixed<3> vec_3d;
+
+#endif
diff --git a/include/utils.hpp b/include/utils.hpp
index 7a03149..c9c9485 100644
--- a/include/utils.hpp
+++ b/include/utils.hpp
@@ -45,40 +45,44 @@
#define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
__LINE__, msg)
+/** @def __METHOD_NAME__
+ * @brief Get the name of the current method/function.
+ * */
#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
-/** Code stolen from https://github.com/anderkve/FYS3150
- * Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp
- * Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp
- * */
-
/** @brief Turns a double into a string written in scientific format.
+ *
+ * @details The code is stolen from https://github.com/anderkve/FYS3150.
*
* @param d The number to stringify
* @param width The reserved width of the string
* @param prec The precision of the stringified number
*
- * @return String
+ * @return std::string
* */
std::string scientific_format(double d, int width=20, int prec=10);
+
/** @brief Turns a vector of doubles into a string written in scientific format.
+ *
+ * @details The code is stolen from https://github.com/anderkve/FYS3150.
*
* @param v The vector to stringify
* @param width The reserved width of the string
* @param prec The precision of the stringified number
*
- * @return String
+ * @return std::string
* */
std::string scientific_format(const std::vector& v,
int width=20,
int prec=10);
+
/** @brief Test an expression, confirm that test is ok, or abort execution.
*
- * This function takes in an expression and prints an OK message if it's
- * true, or it prints a fail message and aborts execution if it fails.
+ * @details This function takes in an expression and prints an OK message if
+ * it's true, or it prints a fail message and aborts execution if it fails.
*
* @param expr The expression to be evaluated
* @param expr_str The stringified version of the expression
@@ -97,25 +101,48 @@ void m_assert(bool expr,
/** @brief Test if two armadillo vectors are close to each other.
*
- * This function takes in 2 vectors and checks if they are approximately
- * equal to each other given a tolerance.
+ * @details This function takes in 2 vectors and checks if they are
+ * approximately equal to each other given a tolerance.
*
* @param a Vector a
* @param b Vector b
* @param tol The tolerance
*
- * @return Boolean
+ * @return bool
* */
bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
-static inline std::string methodName(const std::string& prettyFunction)
+/** @brief Takes in the __PRETTY_FUNCTION__ string and removes the return type.
+ *
+ * @details This function should only be used for the __METHOD_NAME__ macro,
+ * since it takes the output from __PRETTY_FUNCTION__ and strips the return
+ * type.
+ *
+ * @param pretty_function The string from __PRETTY_FUNCTION__
+ *
+ * @return std::string
+ * */
+static inline std::string methodName(const std::string& pretty_function)
{
- size_t colons = prettyFunction.find("::");
- size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
- size_t end = prettyFunction.rfind("(") - begin;
+ size_t colons = pretty_function.find("::");
+ size_t begin = pretty_function.substr(0,colons).rfind(" ") + 1;
+ size_t end = pretty_function.rfind("(") - begin;
- return prettyFunction.substr(begin,end) + "()";
+ return pretty_function.substr(begin,end) + "()";
}
+
+/** @brief Make path given.
+ *
+ * @details This tries to be the equivalent to "mkdir -p" and creates a new
+ * directory whenever it needs to.
+ *
+ * @param path The path to be created
+ * @param mode The mode/permissions for all the new directories
+ *
+ * @return bool
+ * */
+bool mkpath(std::string path, int mode = 0777);
+
#endif
diff --git a/latex/images/3d_plot.pdf b/latex/images/3d_plot.pdf
new file mode 100644
index 0000000..78b115e
Binary files /dev/null and b/latex/images/3d_plot.pdf differ
diff --git a/latex/images/particles_left.pdf b/latex/images/particles_left.pdf
new file mode 100644
index 0000000..cc065d4
Binary files /dev/null and b/latex/images/particles_left.pdf differ
diff --git a/latex/images/phase_space_2_particles.pdf b/latex/images/phase_space_2_particles.pdf
new file mode 100644
index 0000000..6c006d4
Binary files /dev/null and b/latex/images/phase_space_2_particles.pdf differ
diff --git a/latex/images/phase_space_2_particles_x.pdf b/latex/images/phase_space_2_particles_x.pdf
new file mode 100644
index 0000000..7af3a9c
Binary files /dev/null and b/latex/images/phase_space_2_particles_x.pdf differ
diff --git a/latex/images/phase_space_2_particles_z.pdf b/latex/images/phase_space_2_particles_z.pdf
new file mode 100644
index 0000000..86fe6c3
Binary files /dev/null and b/latex/images/phase_space_2_particles_z.pdf differ
diff --git a/latex/images/plot_2_particles_xy.pdf b/latex/images/plot_2_particles_xy.pdf
new file mode 100644
index 0000000..8e44ccd
Binary files /dev/null and b/latex/images/plot_2_particles_xy.pdf differ
diff --git a/latex/images/single_particle.pdf b/latex/images/single_particle.pdf
new file mode 100644
index 0000000..cf0ee5a
Binary files /dev/null and b/latex/images/single_particle.pdf differ
diff --git a/latex/main.tex b/latex/main.tex
index 4bd63f2..f9c63f7 100644
--- a/latex/main.tex
+++ b/latex/main.tex
@@ -63,6 +63,9 @@
% Introduction
\subfile{sections/introduction}
+% Theory
+\subfile{sections/theory}
+
% Methods
\subfile{sections/methods}
diff --git a/latex/references/references.bib b/latex/references/references.bib
index b8d6413..6a49b46 100644
--- a/latex/references/references.bib
+++ b/latex/references/references.bib
@@ -74,4 +74,14 @@
publisher = {Farleia Forlag},
year = {2018},
pages = {162--163}
-}
\ No newline at end of file
+}
+
+
+@article{rk4_method,
+ author = "Morten Hjorth-Jensen",
+ title = "Computational Physics, Lecture Notes Fall 2015",
+ journal = "Department of Physics, University of Oslo",
+ year = "2015",
+ chapter = "8.4",
+ pages = "250--252",
+}
diff --git a/latex/sections/methods.tex b/latex/sections/methods.tex
index 409b5bc..125bd37 100644
--- a/latex/sections/methods.tex
+++ b/latex/sections/methods.tex
@@ -3,67 +3,234 @@
\begin{document}
\section{Methods}
-% problem 1
-When we study the Penning traps effect on a particle with a charge $q$, we need to consider the forces acting on the particle. The sum of all forces acting on the particle, is given by the Lorentz force \eqref{eq:lorentz_force}.
-\begin{equation}\label{eq:lorentz_force}
- \mathbf{F} = q \mathbf{E} + q \mathbf{v} \times \mathbf{B},
+
+\subsection{Units and constants}
+
+Before continuing, we need to define the units we'll be working with.
+Since we are working with particles, we need small units to work with so the
+numbers we are working with aren't so small that they could potentially lead
+to large round-off errors in our simulation. The units that we will use are listed in Table~\ref{tab:units}.
+\begin{table}[H]
+ \begin{center}
+ \begin{tabular}[c]{lll}
+ Dimension & Unit & Symbol \\
+ \hline
+ Length & micrometer & $\mu m$ \\
+ Time & microseconds & $\mu s$ \\
+ Mass & atomic mass unit & $u$ \\
+ Charge & the elementary charge & $e$ \\
+ \hline
+ \end{tabular}
+ \end{center}
+ \caption{The set of units we'll be working with.}\label{tab:units}
+\end{table}
+With these base units, we get
+\begin{equation}
+ k_e = 1.3893533 \cdot 10^5 \frac{u(\mu m)^3}{(\mu s)^2 e},
\end{equation}
-We can use Newton's second law \eqref{eq:newton_second} to determine this sum by
-\begin{align*}
- \ddot{\mathbf{r}} &= \frac{1}{m} \sum_{i} \mathbf{F}_{i} \\
- &= \frac{1}{m} (q \mathbf{E} + q \mathbf{v} \times \mathbf{B}) \\
- &= \frac{q}{m} \big(\frac{V_{0}}{d^{2}} (x, y, -2z) + (B_{0}\dot{y}, -B_{0}\dot{x}, 0) \big),
-\end{align*}
-where the complete derivation can be found in \ref{sec:appendix_b}. We can now write the particle's position as
-\begin{align}
- \label{eq:motion_x}
- \ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x &= 0, \\
- \label{eq:motion_y}
- \ddot{y} + \omega_{0} \dot{x} - \frac{1}{2} \omega_{z}^{2} y &= 0, \\
- \label{eq:motion_z}
- \ddot{z} + \omega_{z}^{2} z &= 0,
-\end{align}
-% define w_0 og w_z i appendix?
-In addition, we can find the general solution for eq. \eqref{eq:motion_z}, when we consider the characteristic equation of a second order differential equation \cite{lindstrom:2016:ch10:5}.
-\begin{align*}
- r^{2} + \omega_{z}^{2} &= 0 \\
- r &= \pm \sqrt{- \omega_{z}^{2}} = \mp i \omega_{z},
-\end{align*}
-two complex roots which gives us solutions in the form of
-\begin{equation}\label{eq:all_diff_sol}
- z = c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t},
+and we get that the unit for magnetic field strength (Tesla, $T$) and electric potential (Volt, $V$) are
+\begin{equation}
+ \begin{split}
+ T &= 9.64852558 \cdot 10^1 \frac{u}{(\mu s) e} \\
+ V &= 9.64852558 \cdot 10^7 \frac{u (\mu m)^2}{(\mu s)^2 e}. \\
+ \end{split}
+ \label{eq:}
\end{equation}
-For a complex number $z = a + ib$, we can define $e^{z} \equiv e^{a} (\cos{b} + i \sin{b})$ \cite{lindstrom:2016:ch3}. We can rewrite \eqref{eq:all_diff_sol} as
-\begin{align*}
- c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t} &= c_{1} (\cos{\omega_{z} t} + i \sin{\omega_{z} t}) + c_{2} (\cos{\omega_{z} t} - i \sin{\omega_{z} t} \\
- &= E \cos{\omega_{z} t} + i F \sin{\omega_{z} t}
-\end{align*}
-%
-Since \eqref{eq:motion_x} and \eqref{eq:motion_y} are coupled, we want to rewrite it as a single differential equation. We can obtain this by introducing $f(t) = x(t) + iy(t)$,
-\begin{align*}
- (\ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x) + i (\ddot{y} + \omega_{0} \dot{x} - \frac{1}{2} \omega_{z}^{2} y) &= 0 \\
- \ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x + i\ddot{y} + i\omega_{0} \dot{x} - i \frac{1}{2} \omega_{z}^{2} y &= 0 \\
- \ddot{x} + i\ddot{y} + i\omega_{0} \dot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x - i \frac{1}{2} \omega_{z}^{2} y &= 0 \\
- \ddot{x} + i\ddot{y} + i\omega_{0} (\dot{x} + i \dot{y}) - \frac{1}{2} \omega_{z}^{2} x - i \frac{1}{2} \omega_{z}^{2} y &= 0 \text{where $i \omega_{0} \dot{x} + (-1) \omega_{0} \dot{y} = i \omega_{0} \dot{x} + i^{2} \omega_{0} \dot{y}$} \\
- \ddot{f} + i \omega_{0} \dot{f} - \frac{1}{2} \omega_{z}^{2} f &= 0
-\end{align*}
-
+\subsection{Dealing with a multi--particle system}
-
-
-
-
-Physical properties given by newtons second law \eqref{eq:newton_second}
-\begin{equation}\label{eq:general_solution}
- f(t) = A_{+}e^{-i(\omega_{+} t + \phi_{+})} + A_{-}e^{-i(\omega_{-} t + \phi_{-})}
+For a multi-particles system, we need to modify $\vb{F}$ to account for the
+force of other particles in the system acting upon each other. To do that, we
+add another term to $\vb{F}$
+\begin{equation}
+ \vb{F}_i(t, \vb{v}_i, \vb{r}_i) = q_i \vb{E}(t, \vb{r}_i) + q_i \vb{v}_i \cross \vb{B} - \vb{E}_p(t, \vb{r}_i),
+\end{equation}
+where $i$ and $j$ are particle indices and
+\begin{equation}
+ \vb{E}_p(t, \vb{r}_i) = q_i k_e \sum_{j \neq i}
+ q_j \frac{\vb{r_i} - \vb{r_j}}{\left| \vb{r_i} - \vb{r_j} \right|^3}.
+ \label{eq:}
\end{equation}
-The particle moves and its position can be determined using newton. where the electric field
-\subsection*{Algorithm}
+Newton's second law for a particle $i$ is then
+\begin{equation}
+ \frac{d^2\vb{r}_i}{dt^2} = \frac{\vb{F}_i\left(t, \frac{d\vb{r}_i}{dt}, \vb{r_i}\right)}{m_i},
+ \label{eq:newtonlaw2}
+\end{equation}
+We can then rewrite the second order ODE from equation~\ref{eq:newtonlaw2}
+into a set of coupled first order ODEs.
+We now rewrite Newton's second law of motion as
+\begin{equation}
+ \begin{split}
+ \frac{d\vb{r}_i}{dt} &= \vb{v}_i \\
+ \frac{d\vb{v}_i}{dt} &= \frac{\vb{F}_i(t, \vb{v}_i, \vb{r}_i)}{m_i}.
+ \end{split}
+ \label{eq:coupled}
+\end{equation}
+
+\subsection{Forward Euler}
+
+For a particle $i$, the forward Euler method for a coupled system is
+expressed as
+\begin{equation}
+ \begin{split}
+ \vb{r}_{i,j+1} &= \vb{r}_{i,j} + h \cdot \frac{d\vb{r}_{i,j}}{dt} = \vb{r}_{i,j} + h \cdot \vb{v}_{i,j} \\
+ \vb{v}_{i,j+1} &= \vb{v}_{i,j} + h \cdot \frac{\vb{v}_{i,j}}{dt} = \vb{v}_{i,j} + h \cdot \frac{\vb{F}\left( t_{j}, \vb{v}_{i,j}, \vb{r}_{i,j} \right)}{m},
+ \end{split}
+\end{equation}
+for particle $i$ where $j$ is the current time step of the particle,
+$m$ is the mass of the particle, and $h$ is the step length.
+
+When dealing with a multi-particle system, we need to ensure that we do not
+update the position of any particles until every particle has calculated their
+next step. An easy way of doing this is to create a copy of all the particles,
+then update the copy, and when all the particles have calculated their next
+step, simply replace the particles with the copies.
+Algorithm~\ref{algo:forwardeuler} provides an overview on how that can be achieved. % Make this better
+
+\begin{figure}[H]
+ \begin{algorithm}[H]
+ \caption{Forward Euler method}
+ \label{algo:forwardeuler}
+ \begin{algorithmic}
+ \Procedure{Evolve forward Euler}{$particles, dt$}
+ \State $N \leftarrow \text{Number of particles in } particles$
+ \State $a \leftarrow \text{Calculate } \frac{\vb{F_i}}{m_i} \text{ for each particle in } particles$
+ \For{ $i = 1, 2, \ldots , N$ }
+ \State $particles_i.\vb{r} \leftarrow particles_i.\vb{r} + dt \cdot particles_i.\vb{v}$
+ \State $particles_i.\vb{v} \leftarrow particles_i.\vb{v} + dt \cdot a_i$
+ \EndFor
+ \EndProcedure
+ \end{algorithmic}
+ \end{algorithm}
+\end{figure}
+
+\subsection{4th order Runge-Kutta}
+
+For a particle $i$, we can express the 4th order Runge-Kutta (RK4) method as
+\begin{equation}
+ \begin{split}
+ \vb{v}_{i,j+1} &= \vb{v}_{i,j} + \frac{h}{6} \left( \vb{k}_{\vb{v},1,i}
+ + 2\vb{k}_{\vb{v},2,i} + 2\vb{k}_{\vb{v},3,i} + \vb{k}_{\vb{v},4,i}
+ \right) \\
+ \vb{r}_{i,j+1} &= \vb{r}_{i,j} + \frac{h}{6} \left( \vb{k}_{\vb{r},1,i}
+ + 2\vb{k}_{\vb{r},2,i} + 2\vb{k}_{\vb{r},3,i} + \vb{k}_{\vb{r},4,i}
+ \right),
+ \end{split}
+\end{equation}
+where
+\begin{equation}
+ \begin{split}
+ \vb{k}_{\vb{v},1,i} &= \frac{\vb{F}_i(t_j, \vb{v}_{i,j},
+ \vb{r}_{i,j})}{m} \\
+ \vb{k}_{\vb{r},1,i} &= \vb{v}_{i,j} \\
+ \vb{k}_{\vb{v},2,i} &= \frac{\vb{F}_i(t_j+\frac{h}{2}, \vb{v}_{i,j}
+ + h \cdot \frac{\vb{k}_{\vb{v},1,i}}{2}, \vb{r}_{i,j}
+ + h \cdot \frac{\vb{k}_{\vb{r},1,i}}{2})}{m} \\
+ \vb{k}_{\vb{r},2,i} &= \vb{v}_{i,j}
+ + h \cdot \frac{\vb{k}_{\vb{v},1,i}}{2} \\
+ \vb{k}_{\vb{v},3,i} &= \frac{\vb{F}_i(t_j+\frac{h}{2}, \vb{v}_{i,j}
+ + h \cdot \frac{\vb{k}_{\vb{v},2,i}}{2}, \vb{r}_{i,j}
+ + h \frac{\cdot \vb{k}_{\vb{r},2,i}}{2})}{m} \\
+ \vb{k}_{\vb{r},3,i} &= \vb{v}_{i,j}
+ + h \cdot \frac{\vb{k}_{\vb{v},2,i}}{2} \\
+ \vb{k}_{\vb{v},4,i} &= \frac{\vb{F}_i(t_j+h, \vb{v}_{i,j}
+ + h \cdot \vb{k}_{\vb{v},3,i}, \vb{r}_{i,j}
+ + h \cdot \vb{k}_{\vb{r},3,i})}{m} \\
+ \vb{k}_{\vb{r},4,i} &= \vb{v}_{i,j}
+ + h \cdot \frac{\vb{k}_{\vb{v},1,i}}{2}.
+ \end{split}
+\end{equation}
+
+In order to find each $\vb{k}_{\vb{r},i}$ and $\vb{k}_{\vb{v},i}$,
+we need to first compute all $\vb{k}_{\vb{r},i}$ and $\vb{k}_{\vb{v},i}$
+for all particles, then we can update the particles in order to compute
+$\vb{k}_{\vb{r},i+1}$ and $\vb{k}_{\vb{v},i+1}$. In order for the algorithm
+to work, we need to save a copy of each particle before starting so that we
+can update the particles correctly for each step.
+
+This approach would require 8 loops to be able to complete the calculation since
+we cannot update the particles until after all $\vb{k}$ values have been
+computed, however if we create a temporary array that holds particles, we can
+put the updated particles in there, and then use that array in the next loop,
+and would reduce the required amount of loops down to 4.
+
+\begin{figure}
+ \begin{algorithm}[H]
+ \caption{RK4 method}
+ \label{algo:rk4}
+ \begin{algorithmic}
+ \Procedure{Evolve RK4}{$particles, dt$}
+ \State $N \leftarrow \text{Number of particles inside the Penning trap}$
+ \State $orig\_p \leftarrow \text{Copy of particles}$
+ \State $tmp\_p \leftarrow \text{Array of particles of size }N$
+ \State $\vb{k}_{\vb{r}} \leftarrow \text{2D array of vectors of size } 4 \cross N$
+ \State $\vb{k}_{\vb{v}} \leftarrow \text{2D array of vectors of size } 4 \cross N$
+
+ \For{ $i = 1, 2, \ldots, N$ }
+ \State $\vb{k}_{\vb{r},1,i} \leftarrow particles_i.\vb{v}$
+ \State $\vb{k}_{\vb{v},1,i} \leftarrow \frac{\vb{F}_i}{m_i}$
+
+ \State $tmp\_p_i.\vb{r} \leftarrow orig\_p_i.\vb{r}
+ + \frac{dt}{2} \cdot \vb{k}_{\vb{r},1,i}$
+ \State $tmp\_p_i.\vb{v} \leftarrow orig\_p_i.\vb{v}
+ + \frac{dt}{2} \cdot \vb{k}_{\vb{v},1,i}$
+ \EndFor
+
+ \State $particles \leftarrow tmp\_p$ \Comment{Update particles}
+
+ \For{ $i = 1, 2, \ldots, N$ }
+ \State $\vb{k}_{\vb{r},2,i} \leftarrow particles_i.\vb{v}$
+ \State $\vb{k}_{\vb{v},2,i} \leftarrow \frac{\vb{F}_i}{m_i}$
+
+ \State $tmp\_p_i.\vb{r} \leftarrow orig\_p_i.\vb{r}
+ + \frac{dt}{2} \cdot \vb{k}_{\vb{r},2,i}$
+ \State $tmp\_p_i.\vb{v} \leftarrow orig\_p_i.\vb{v}
+ + \frac{dt}{2} \cdot \vb{k}_{\vb{v},2,i}$
+ \EndFor
+
+ \State $particles \leftarrow tmp\_p$ \Comment{Update particles}
+
+ \For{ $i = 1, 2, \ldots, N$ }
+ \State $\vb{k}_{\vb{r},3,i} \leftarrow particles_i.\vb{v}$
+ \State $\vb{k}_{\vb{v},3,i} \leftarrow \frac{\vb{F}_i}{m}$
+
+ \State $tmp\_p_i.\vb{r} \leftarrow orig\_p_i.\vb{r} + dt \cdot \vb{k}_{\vb{r},3,i}$
+ \State $tmp\_p_i.\vb{v} \leftarrow orig\_p_i.\vb{v} + dt \cdot \vb{k}_{\vb{v},3,i}$
+ \EndFor
+
+ \State $particles \leftarrow tmp\_p$ \Comment{Update particles}
+
+ \For{ $i = 1, 2, \ldots, N$ }
+ \State $\vb{k}_{\vb{r},4,i} \leftarrow particles_i.\vb{v}$
+ \State $\vb{k}_{\vb{v},4,i} \leftarrow \frac{\vb{F}}{m}$
+
+ \State $tmp\_p_i.\vb{r} \leftarrow orig\_p_i.\vb{r} + \frac{dt}{6}
+ \cdot \left( \vb{k}_{\vb{r},1,i} + \vb{k}_{\vb{r},2,i}
+ + \vb{k}_{\vb{r},3,i} + \vb{k}_{\vb{r},4,i} \right)$
+
+ \State $tmp\_p_i.\vb{v} \leftarrow orig\_p_i.\vb{v} + \frac{dt}{6}
+ \cdot \left( \vb{k}_{\vb{v},1,i} + \vb{k}_{\vb{v},2,i}
+ + \vb{k}_{\vb{v},3,i} + \vb{k}_{\vb{v},4,i} \right)$
+
+ \EndFor
+
+ \State $particles \leftarrow tmp\_p$ \Comment{Final update}
+ \EndProcedure
+ \end{algorithmic}
+ \end{algorithm}
+ $\vb{F}$ in the algorithm does not take any arguments as it uses the
+ velocities and positions of the particles inside the array $particles$ to
+ calculate the total force acting on particle $i$.
+\end{figure}
-\subsection*{Tools}
+\subsection{Testing the simulation}
+
+\subsection{Relative error and error convergance rate}
+
+\subsection{Tools}
We used matplotlib
-\end{document}
\ No newline at end of file
+%\biblio
+\end{document}
diff --git a/latex/sections/theory.tex b/latex/sections/theory.tex
new file mode 100644
index 0000000..e8d43c8
--- /dev/null
+++ b/latex/sections/theory.tex
@@ -0,0 +1,61 @@
+\documentclass[../main.tex]{subfiles}
+\graphicspath{{\subfix{../images/}}}
+
+\begin{document}
+\section{Theory}
+% problem 1
+When we study the Penning traps effect on a particle with a charge $q$, we need to consider the forces acting on the particle. The sum of all forces acting on the particle, is given by the Lorentz force \eqref{eq:lorentz_force}.
+\begin{equation}\label{eq:lorentz_force}
+ \mathbf{F} = q \mathbf{E} + q \mathbf{v} \times \mathbf{B},
+\end{equation}
+We can use Newton's second law \eqref{eq:newton_second} to determine this sum by
+\begin{align*}
+ \ddot{\mathbf{r}} &= \frac{1}{m} \sum_{i} \mathbf{F}_{i} \\
+ &= \frac{1}{m} (q \mathbf{E} + q \mathbf{v} \times \mathbf{B}) \\
+ &= \frac{q}{m} \big(\frac{V_{0}}{d^{2}} (x, y, -2z) + (B_{0}\dot{y}, -B_{0}\dot{x}, 0) \big),
+\end{align*}
+where the complete derivation can be found in \ref{sec:appendix_b}. We can now write the particle's position as
+\begin{align}
+ \label{eq:motion_x}
+ \ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x &= 0, \\
+ \label{eq:motion_y}
+ \ddot{y} + \omega_{0} \dot{x} - \frac{1}{2} \omega_{z}^{2} y &= 0, \\
+ \label{eq:motion_z}
+ \ddot{z} + \omega_{z}^{2} z &= 0,
+\end{align}
+% define w_0 og w_z i appendix?
+In addition, we can find the general solution for eq. \eqref{eq:motion_z}, when we consider the characteristic equation of a second order differential equation \cite{lindstrom:2016:ch10:5}.
+\begin{align*}
+ r^{2} + \omega_{z}^{2} &= 0 \\
+ r &= \pm \sqrt{- \omega_{z}^{2}} = \mp i \omega_{z},
+\end{align*}
+two complex roots which gives us solutions in the form of
+\begin{equation}\label{eq:all_diff_sol}
+ z = c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t},
+\end{equation}
+For a complex number $z = a + ib$, we can define $e^{z} \equiv e^{a} (\cos{b} + i \sin{b})$ \cite{lindstrom:2016:ch3}. We can rewrite \eqref{eq:all_diff_sol} as
+\begin{align*}
+ c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t} &= c_{1} (\cos{\omega_{z} t} + i \sin{\omega_{z} t}) + c_{2} (\cos{\omega_{z} t} - i \sin{\omega_{z} t} \\
+ &= E \cos{\omega_{z} t} + i F \sin{\omega_{z} t}
+\end{align*}
+%
+Since \eqref{eq:motion_x} and \eqref{eq:motion_y} are coupled, we want to rewrite it as a single differential equation. We can obtain this by introducing $f(t) = x(t) + iy(t)$,
+\begin{align*}
+ (\ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x) + i (\ddot{y} + \omega_{0} \dot{x} - \frac{1}{2} \omega_{z}^{2} y) &= 0 \\
+ \ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x + i\ddot{y} + i\omega_{0} \dot{x} - i \frac{1}{2} \omega_{z}^{2} y &= 0 \\
+ \ddot{x} + i\ddot{y} + i\omega_{0} \dot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x - i \frac{1}{2} \omega_{z}^{2} y &= 0 \\
+ \ddot{x} + i\ddot{y} + i\omega_{0} (\dot{x} + i \dot{y}) - \frac{1}{2} \omega_{z}^{2} x - i \frac{1}{2} \omega_{z}^{2} y &= 0 \text{where $i \omega_{0} \dot{x} + (-1) \omega_{0} \dot{y} = i \omega_{0} \dot{x} + i^{2} \omega_{0} \dot{y}$} \\
+ \ddot{f} + i \omega_{0} \dot{f} - \frac{1}{2} \omega_{z}^{2} f &= 0
+\end{align*}
+
+
+Physical properties given by newtons second law \eqref{eq:newton_second}
+\begin{equation}\label{eq:general_solution}
+ f(t) = A_{+}e^{-i(\omega_{+} t + \phi_{+})} + A_{-}e^{-i(\omega_{-} t + \phi_{-})}
+\end{equation}
+The particle moves and its position can be determined using newton. where the electric field
+
+
+
+%\biblio
+\end{document}
diff --git a/man_pages/man3/Particle.3 b/man_pages/man3/Particle.3
deleted file mode 100644
index f37639d..0000000
--- a/man_pages/man3/Particle.3
+++ /dev/null
@@ -1,98 +0,0 @@
-.TH "Particle" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-Particle \- A class that holds attributes of a particle\&.
-
-.SH SYNOPSIS
-.br
-.PP
-.PP
-\fC#include \fP
-.SS "Public Member Functions"
-
-.in +1c
-.ti -1c
-.RI "\fBParticle\fP (double \fBq\fP, double \fBm\fP, arma::vec::fixed< 3 > \fBr_vec\fP, arma::vec::fixed< 3 > \fBv_vec\fP)"
-.br
-.RI "Initialize the particle\&. "
-.in -1c
-.SS "Private Attributes"
-
-.in +1c
-.ti -1c
-.RI "double \fBq\fP"
-.br
-.RI "Charge\&. "
-.ti -1c
-.RI "double \fBm\fP"
-.br
-.RI "Mass\&. "
-.ti -1c
-.RI "arma::vec::fixed< 3 > \fBr_vec\fP"
-.br
-.RI "position "
-.ti -1c
-.RI "arma::vec::fixed< 3 > \fBv_vec\fP"
-.br
-.RI "velocity "
-.in -1c
-.SS "Friends"
-
-.in +1c
-.ti -1c
-.RI "class \fBPenningTrap\fP"
-.br
-.RI "Make private attributes available for \fBPenningTrap\fP\&. "
-.in -1c
-.SH "Detailed Description"
-.PP
-A class that holds attributes of a particle\&.
-.PP
-Definition at line \fB19\fP of file \fBParticle\&.hpp\fP\&.
-.SH "Constructor & Destructor Documentation"
-.PP
-.SS "Particle::Particle (double q, double m, arma::vec::fixed< 3 > r_vec, arma::vec::fixed< 3 > v_vec)"
-
-.PP
-Initialize the particle\&. Initialize the particle with a charge, mass, position and velocity\&.
-.PP
-Definition at line \fB16\fP of file \fBParticle\&.cpp\fP\&.
-.SH "Friends And Related Function Documentation"
-.PP
-.SS "friend class \fBPenningTrap\fP\fC [friend]\fP"
-
-.PP
-Make private attributes available for \fBPenningTrap\fP\&.
-.PP
-Definition at line \fB38\fP of file \fBParticle\&.hpp\fP\&.
-.SH "Member Data Documentation"
-.PP
-.SS "double Particle::m\fC [private]\fP"
-
-.PP
-Mass\&.
-.PP
-Definition at line \fB22\fP of file \fBParticle\&.hpp\fP\&.
-.SS "double Particle::q\fC [private]\fP"
-
-.PP
-Charge\&.
-.PP
-Definition at line \fB21\fP of file \fBParticle\&.hpp\fP\&.
-.SS "arma::vec::fixed<3> Particle::r_vec\fC [private]\fP"
-
-.PP
-position
-.PP
-Definition at line \fB23\fP of file \fBParticle\&.hpp\fP\&.
-.SS "arma::vec::fixed<3> Particle::v_vec\fC [private]\fP"
-
-.PP
-velocity
-.PP
-Definition at line \fB24\fP of file \fBParticle\&.hpp\fP\&.
-
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/Particle.cpp.3 b/man_pages/man3/Particle.cpp.3
deleted file mode 100644
index 7a93b45..0000000
--- a/man_pages/man3/Particle.cpp.3
+++ /dev/null
@@ -1,42 +0,0 @@
-.TH "src/Particle.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-src/Particle.cpp \- The implementation of the \fBParticle\fP class\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include 'Particle\&.hpp'\fP
-.br
-
-.SH "Detailed Description"
-.PP
-The implementation of the \fBParticle\fP class\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-0\&.1
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fBParticle\&.cpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/Particle.hpp.3 b/man_pages/man3/Particle.hpp.3
deleted file mode 100644
index abb26a7..0000000
--- a/man_pages/man3/Particle.hpp.3
+++ /dev/null
@@ -1,50 +0,0 @@
-.TH "include/Particle.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-include/Particle.hpp \- A class that holds the properties of a particle\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include \fP
-.br
-
-.SS "Classes"
-
-.in +1c
-.ti -1c
-.RI "class \fBParticle\fP"
-.br
-.RI "A class that holds attributes of a particle\&. "
-.in -1c
-.SH "Detailed Description"
-.PP
-A class that holds the properties of a particle\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-0\&.1
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fBParticle\&.hpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/PenningTrap.3 b/man_pages/man3/PenningTrap.3
deleted file mode 100644
index 2087bb5..0000000
--- a/man_pages/man3/PenningTrap.3
+++ /dev/null
@@ -1,190 +0,0 @@
-.TH "PenningTrap" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-PenningTrap \- A class that simulates a Penning trap\&.
-
-.SH SYNOPSIS
-.br
-.PP
-.PP
-\fC#include \fP
-.SS "Public Member Functions"
-
-.in +1c
-.ti -1c
-.RI "\fBPenningTrap\fP (double \fBB_0\fP=\fBT\fP, double \fBV_0\fP=25\&.*\fBV\fP/1000\&., double \fBd\fP=500\&.)"
-.br
-.RI "Set B_0, V_0 and d\&. "
-.ti -1c
-.RI "void \fBadd_particle\fP (\fBParticle\fP particle)"
-.br
-.RI "Add a particle to the system\&. "
-.ti -1c
-.RI "arma::vec \fBexternal_E_field\fP (arma::vec r)"
-.br
-.RI "Calculate E at point r\&. "
-.ti -1c
-.RI "arma::vec \fBexternal_B_field\fP (arma::vec r)"
-.br
-.RI "Calculate B at point r\&. "
-.ti -1c
-.RI "arma::vec \fBforce_on_particle\fP (int i, int j)"
-.br
-.RI "Calculate the force between 2 particles\&. "
-.ti -1c
-.RI "arma::vec \fBtotal_force_external\fP (int i)"
-.br
-.RI "Calculate the total external force on a particle\&. "
-.ti -1c
-.RI "arma::vec \fBtotal_force_particles\fP (int i)"
-.br
-.RI "Calculate the total force on a particle from other particles\&. "
-.ti -1c
-.RI "arma::vec \fBtotal_force\fP (int i)"
-.br
-.RI "calculate the total force on a particle\&. "
-.ti -1c
-.RI "void \fBevolve_RK4\fP (double dt)"
-.br
-.RI "Go forward one timestep using the RK4 method\&. "
-.ti -1c
-.RI "void \fBevolve_forward_euler\fP (double dt)"
-.br
-.RI "Go forward one timestep using the forward Euler method\&. "
-.ti -1c
-.RI "arma::vec \fBget_particle\fP (int i)"
-.br
-.ti -1c
-.RI "double \fBget_d\fP ()"
-.br
-.in -1c
-.SS "Private Attributes"
-
-.in +1c
-.ti -1c
-.RI "double \fBB_0\fP"
-.br
-.RI "Magnetic field strength\&. "
-.ti -1c
-.RI "double \fBV_0\fP"
-.br
-.RI "Applied potential\&. "
-.ti -1c
-.RI "double \fBd\fP"
-.br
-.RI "Characteristic dimension\&. "
-.ti -1c
-.RI "std::vector< \fBParticle\fP > \fBparticles\fP"
-.br
-.RI "The particles in the Penning trap\&. "
-.in -1c
-.SH "Detailed Description"
-.PP
-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\&.
-.PP
-Definition at line \fB29\fP of file \fBPenningTrap\&.hpp\fP\&.
-.SH "Constructor & Destructor Documentation"
-.PP
-.SS "PenningTrap::PenningTrap (double B_0 = \fC\fBT\fP\fP, double V_0 = \fC25\&.*\fBV\fP/1000\&.\fP, double d = \fC500\&.\fP)"
-
-.PP
-Set B_0, V_0 and d\&.
-.PP
-Definition at line \fB20\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SH "Member Function Documentation"
-.PP
-.SS "void PenningTrap::add_particle (\fBParticle\fP particle)"
-
-.PP
-Add a particle to the system\&.
-.PP
-Definition at line \fB27\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "void PenningTrap::evolve_forward_euler (double dt)"
-
-.PP
-Go forward one timestep using the forward Euler method\&.
-.PP
-Definition at line \fB167\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "void PenningTrap::evolve_RK4 (double dt)"
-
-.PP
-Go forward one timestep using the RK4 method\&.
-.PP
-Definition at line \fB104\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "arma::vec PenningTrap::external_B_field (arma::vec r)"
-
-.PP
-Calculate B at point r\&.
-.PP
-Definition at line \fB43\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "arma::vec PenningTrap::external_E_field (arma::vec r)"
-
-.PP
-Calculate E at point r\&.
-.PP
-Definition at line \fB32\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "arma::vec PenningTrap::force_on_particle (int i, int j)"
-
-.PP
-Calculate the force between 2 particles\&. Calculate the force exhibited on particle p_i from particle p_j\&.
-.PP
-Definition at line \fB50\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "double PenningTrap::get_d ()"
-
-.PP
-Definition at line \fB188\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "arma::vec PenningTrap::get_particle (int i)"
-
-.PP
-Definition at line \fB183\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "arma::vec PenningTrap::total_force (int i)"
-
-.PP
-calculate the total force on a particle\&.
-.PP
-Definition at line \fB99\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "arma::vec PenningTrap::total_force_external (int i)"
-
-.PP
-Calculate the total external force on a particle\&. Calculate the total amount of force that E and B exhibits on particle p_i\&.
-.PP
-Definition at line \fB65\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SS "arma::vec PenningTrap::total_force_particles (int i)"
-
-.PP
-Calculate the total force on a particle from other particles\&.
-.PP
-Definition at line \fB80\fP of file \fBPenningTrap\&.cpp\fP\&.
-.SH "Member Data Documentation"
-.PP
-.SS "double PenningTrap::B_0\fC [private]\fP"
-
-.PP
-Magnetic field strength\&.
-.PP
-Definition at line \fB31\fP of file \fBPenningTrap\&.hpp\fP\&.
-.SS "double PenningTrap::d\fC [private]\fP"
-
-.PP
-Characteristic dimension\&.
-.PP
-Definition at line \fB33\fP of file \fBPenningTrap\&.hpp\fP\&.
-.SS "std::vector<\fBParticle\fP> PenningTrap::particles\fC [private]\fP"
-
-.PP
-The particles in the Penning trap\&.
-.PP
-Definition at line \fB34\fP of file \fBPenningTrap\&.hpp\fP\&.
-.SS "double PenningTrap::V_0\fC [private]\fP"
-
-.PP
-Applied potential\&.
-.PP
-Definition at line \fB32\fP of file \fBPenningTrap\&.hpp\fP\&.
-
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/PenningTrap.cpp.3 b/man_pages/man3/PenningTrap.cpp.3
deleted file mode 100644
index f850299..0000000
--- a/man_pages/man3/PenningTrap.cpp.3
+++ /dev/null
@@ -1,54 +0,0 @@
-.TH "src/PenningTrap.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-src/PenningTrap.cpp \- The implementation of the \fBPenningTrap\fP class\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include 'PenningTrap\&.hpp'\fP
-.br
-\fC#include 'constants\&.hpp'\fP
-.br
-\fC#include 'utils\&.hpp'\fP
-.br
-
-.SH "Detailed Description"
-.PP
-The implementation of the \fBPenningTrap\fP class\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-0\&.1
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-.PP
-\fBTodo\fP
-.RS 4
-Implement evolve_RK4
-.PP
-Implement evolve_forward_euler
-.RE
-.PP
-
-.PP
-Definition in file \fBPenningTrap\&.cpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/PenningTrap.hpp.3 b/man_pages/man3/PenningTrap.hpp.3
deleted file mode 100644
index c16a94b..0000000
--- a/man_pages/man3/PenningTrap.hpp.3
+++ /dev/null
@@ -1,56 +0,0 @@
-.TH "include/PenningTrap.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-include/PenningTrap.hpp \- A class for simulating a Penning trap\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-\fC#include 'Particle\&.hpp'\fP
-.br
-\fC#include 'constants\&.hpp'\fP
-.br
-
-.SS "Classes"
-
-.in +1c
-.ti -1c
-.RI "class \fBPenningTrap\fP"
-.br
-.RI "A class that simulates a Penning trap\&. "
-.in -1c
-.SH "Detailed Description"
-.PP
-A class for simulating a Penning trap\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-0\&.1
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fBPenningTrap\&.hpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/PenningTrapTest.3 b/man_pages/man3/PenningTrapTest.3
deleted file mode 100644
index 07c0b75..0000000
--- a/man_pages/man3/PenningTrapTest.3
+++ /dev/null
@@ -1,56 +0,0 @@
-.TH "PenningTrapTest" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-PenningTrapTest
-.SH SYNOPSIS
-.br
-.PP
-.SS "Static Public Member Functions"
-
-.in +1c
-.ti -1c
-.RI "static void \fBtest_external_E_field\fP ()"
-.br
-.ti -1c
-.RI "static void \fBtest_external_B_field\fP ()"
-.br
-.ti -1c
-.RI "static void \fBtest_force_on_particle\fP ()"
-.br
-.ti -1c
-.RI "static void \fBtest_total_force_external\fP ()"
-.br
-.ti -1c
-.RI "static void \fBtest_total_force_particles\fP ()"
-.br
-.in -1c
-.SH "Detailed Description"
-.PP
-Definition at line \fB20\fP of file \fBtest_suite\&.cpp\fP\&.
-.SH "Member Function Documentation"
-.PP
-.SS "static void PenningTrapTest::test_external_B_field ()\fC [inline]\fP, \fC [static]\fP"
-
-.PP
-Definition at line \fB59\fP of file \fBtest_suite\&.cpp\fP\&.
-.SS "static void PenningTrapTest::test_external_E_field ()\fC [inline]\fP, \fC [static]\fP"
-
-.PP
-Definition at line \fB22\fP of file \fBtest_suite\&.cpp\fP\&.
-.SS "static void PenningTrapTest::test_force_on_particle ()\fC [inline]\fP, \fC [static]\fP"
-
-.PP
-Definition at line \fB70\fP of file \fBtest_suite\&.cpp\fP\&.
-.SS "static void PenningTrapTest::test_total_force_external ()\fC [inline]\fP, \fC [static]\fP"
-
-.PP
-Definition at line \fB95\fP of file \fBtest_suite\&.cpp\fP\&.
-.SS "static void PenningTrapTest::test_total_force_particles ()\fC [inline]\fP, \fC [static]\fP"
-
-.PP
-Definition at line \fB108\fP of file \fBtest_suite\&.cpp\fP\&.
-
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/bug.3 b/man_pages/man3/bug.3
deleted file mode 100644
index f93d6e3..0000000
--- a/man_pages/man3/bug.3
+++ /dev/null
@@ -1,27 +0,0 @@
-.TH "bug" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-bug \- Bug List
-.PP
-
-.IP "\fBFile \fBconstants\&.hpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fBmain\&.cpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fBParticle\&.cpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fBParticle\&.hpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fBPenningTrap\&.cpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fBPenningTrap\&.hpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fBtest_suite\&.cpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fButils\&.cpp\fP \fP" 1c
-No known bugs
-.IP "\fBFile \fButils\&.hpp\fP \fP" 1c
-No known bugs
-.PP
-
diff --git a/man_pages/man3/constants.hpp.3 b/man_pages/man3/constants.hpp.3
deleted file mode 100644
index ed6ff65..0000000
--- a/man_pages/man3/constants.hpp.3
+++ /dev/null
@@ -1,75 +0,0 @@
-.TH "include/constants.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-include/constants.hpp \- Library of constants\&.
-
-.SH SYNOPSIS
-.br
-.PP
-.SS "Macros"
-
-.in +1c
-.ti -1c
-.RI "#define \fBK_E\fP 138935\&.333"
-.br
-.RI "Coulomb constant\&. unit: $\frac{u(\mu m)^3}{(\mu s)^2 e^2}$\&. "
-.ti -1c
-.RI "#define \fBT\fP 96\&.4852558"
-.br
-.RI "1 Tesla\&. unit: $ \frac{u}{(\mu s) e} $ "
-.ti -1c
-.RI "#define \fBV\fP 96485255\&.8"
-.br
-.RI "1 Volt\&. unit: $ \frac{u (\mu m)^2}{(\mu s)^2 e} $ "
-.in -1c
-.SH "Detailed Description"
-.PP
-Library of constants\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-0\&.1
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fBconstants\&.hpp\fP\&.
-.SH "Macro Definition Documentation"
-.PP
-.SS "#define K_E 138935\&.333"
-
-.PP
-Coulomb constant\&. unit: $\frac{u(\mu m)^3}{(\mu s)^2 e^2}$\&.
-.PP
-Definition at line \fB15\fP of file \fBconstants\&.hpp\fP\&.
-.SS "#define T 96\&.4852558"
-
-.PP
-1 Tesla\&. unit: $ \frac{u}{(\mu s) e} $
-.PP
-Definition at line \fB17\fP of file \fBconstants\&.hpp\fP\&.
-.SS "#define V 96485255\&.8"
-
-.PP
-1 Volt\&. unit: $ \frac{u (\mu m)^2}{(\mu s)^2 e} $
-.PP
-Definition at line \fB19\fP of file \fBconstants\&.hpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/main.cpp.3 b/man_pages/man3/main.cpp.3
deleted file mode 100644
index e02bbe4..0000000
--- a/man_pages/man3/main.cpp.3
+++ /dev/null
@@ -1,102 +0,0 @@
-.TH "src/main.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-src/main.cpp \- The main program for this project\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-\fC#include 'PenningTrap\&.hpp'\fP
-.br
-
-.SS "Macros"
-
-.in +1c
-.ti -1c
-.RI "#define \fBPARTICLES\fP 100"
-.br
-.ti -1c
-.RI "#define \fBN\fP 10000"
-.br
-.ti -1c
-.RI "#define \fBCHARGE\fP 1\&."
-.br
-.ti -1c
-.RI "#define \fBMASS\fP 40\&."
-.br
-.in -1c
-.SS "Functions"
-
-.in +1c
-.ti -1c
-.RI "void \fBsimulate_100_particles\fP ()"
-.br
-.ti -1c
-.RI "int \fBmain\fP ()"
-.br
-.in -1c
-.SH "Detailed Description"
-.PP
-The main program for this project\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-0\&.1
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fBmain\&.cpp\fP\&.
-.SH "Macro Definition Documentation"
-.PP
-.SS "#define CHARGE 1\&."
-
-.PP
-Definition at line \fB21\fP of file \fBmain\&.cpp\fP\&.
-.SS "#define MASS 40\&."
-
-.PP
-Definition at line \fB22\fP of file \fBmain\&.cpp\fP\&.
-.SS "#define N 10000"
-
-.PP
-Definition at line \fB20\fP of file \fBmain\&.cpp\fP\&.
-.SS "#define PARTICLES 100"
-
-.PP
-Definition at line \fB19\fP of file \fBmain\&.cpp\fP\&.
-.SH "Function Documentation"
-.PP
-.SS "int main ()"
-
-.PP
-Definition at line \fB77\fP of file \fBmain\&.cpp\fP\&.
-.SS "void simulate_100_particles ()"
-
-.PP
-Definition at line \fB24\fP of file \fBmain\&.cpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/test_suite.cpp.3 b/man_pages/man3/test_suite.cpp.3
deleted file mode 100644
index fa522ef..0000000
--- a/man_pages/man3/test_suite.cpp.3
+++ /dev/null
@@ -1,70 +0,0 @@
-.TH "src/test_suite.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-src/test_suite.cpp \- The test suite for the project\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include 'PenningTrap\&.hpp'\fP
-.br
-\fC#include 'utils\&.hpp'\fP
-.br
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-
-.SS "Classes"
-
-.in +1c
-.ti -1c
-.RI "class \fBPenningTrapTest\fP"
-.br
-.in -1c
-.SS "Functions"
-
-.in +1c
-.ti -1c
-.RI "int \fBmain\fP ()"
-.br
-.in -1c
-.SH "Detailed Description"
-.PP
-The test suite for the project\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-0\&.1
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fBtest_suite\&.cpp\fP\&.
-.SH "Function Documentation"
-.PP
-.SS "int main ()"
-
-.PP
-Definition at line \fB135\fP of file \fBtest_suite\&.cpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/todo.3 b/man_pages/man3/todo.3
deleted file mode 100644
index a66e064..0000000
--- a/man_pages/man3/todo.3
+++ /dev/null
@@ -1,14 +0,0 @@
-.TH "todo" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-todo \- Todo List
-.PP
-
-.IP "\fBFile \fBPenningTrap\&.cpp\fP \fP" 1c
-Implement evolve_RK4
-.PP
-.PP
-Implement evolve_forward_euler
-.PP
-
diff --git a/man_pages/man3/utils.cpp.3 b/man_pages/man3/utils.cpp.3
deleted file mode 100644
index 3d60a86..0000000
--- a/man_pages/man3/utils.cpp.3
+++ /dev/null
@@ -1,153 +0,0 @@
-.TH "src/utils.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-src/utils.cpp \- Implementation of the utils\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include 'utils\&.hpp'\fP
-.br
-
-.SS "Functions"
-
-.in +1c
-.ti -1c
-.RI "std::string \fBscientific_format\fP (double d, int width, int prec)"
-.br
-.RI "Turns a double into a string written in scientific format\&. "
-.ti -1c
-.RI "std::string \fBscientific_format\fP (const std::vector< double > &v, int width, int prec)"
-.br
-.RI "Turns a vector of doubles into a string written in scientific format\&. "
-.ti -1c
-.RI "void \fBm_assert\fP (bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg)"
-.br
-.RI "Test an expression, confirm that test is ok, or abort execution\&. "
-.ti -1c
-.RI "bool \fBarma_vector_close_to\fP (arma::vec &a, arma::vec &b, double tol)"
-.br
-.RI "Test if two armadillo vectors are close to each other\&. "
-.in -1c
-.SH "Detailed Description"
-.PP
-Implementation of the utils\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-1\&.0
-.RE
-.PP
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fButils\&.cpp\fP\&.
-.SH "Function Documentation"
-.PP
-.SS "bool arma_vector_close_to (arma::vec & a, arma::vec & b, double tol = \fC1e\-8\fP)"
-
-.PP
-Test if two armadillo vectors are close to each other\&. This function takes in 2 vectors and checks if they are approximately equal to each other given a tolerance\&.
-.PP
-\fBParameters\fP
-.RS 4
-\fIa\fP Vector a
-.br
-\fIb\fP Vector b
-.br
-\fItol\fP The tolerance
-.RE
-.PP
-\fBReturns\fP
-.RS 4
-Boolean
-.RE
-.PP
-
-.PP
-Definition at line \fB59\fP of file \fButils\&.cpp\fP\&.
-.SS "void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)"
-
-.PP
-Test an expression, confirm that test is ok, or abort execution\&. This function takes in an expression and prints an OK message if it's true, or it prints a fail message and aborts execution if it fails\&.
-.PP
-\fBParameters\fP
-.RS 4
-\fIexpr\fP The expression to be evaluated
-.br
-\fIexpr_str\fP The stringified version of the expression
-.br
-\fIfunc\fP The function name of the caller
-.br
-\fIfile\fP The file of the caller
-.br
-\fIline\fP The line number where this function is called from
-.br
-\fImsg\fP The message to be displayed
-.RE
-.PP
-
-.PP
-Definition at line \fB40\fP of file \fButils\&.cpp\fP\&.
-.SS "std::string scientific_format (const std::vector< double > & v, int width = \fC20\fP, int prec = \fC10\fP)"
-
-.PP
-Turns a vector of doubles into a string written in scientific format\&.
-.PP
-\fBParameters\fP
-.RS 4
-\fIv\fP The vector to stringify
-.br
-\fIwidth\fP The reserved width of the string
-.br
-\fIprec\fP The precision of the stringified number
-.RE
-.PP
-\fBReturns\fP
-.RS 4
-String
-.RE
-.PP
-
-.PP
-Definition at line \fB21\fP of file \fButils\&.cpp\fP\&.
-.SS "std::string scientific_format (double d, int width = \fC20\fP, int prec = \fC10\fP)"
-
-.PP
-Turns a double into a string written in scientific format\&. Code stolen from https://github.com/anderkve/FYS3150 Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp
-.PP
-\fBParameters\fP
-.RS 4
-\fId\fP The number to stringify
-.br
-\fIwidth\fP The reserved width of the string
-.br
-\fIprec\fP The precision of the stringified number
-.RE
-.PP
-\fBReturns\fP
-.RS 4
-String
-.RE
-.PP
-
-.PP
-Definition at line \fB14\fP of file \fButils\&.cpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/man_pages/man3/utils.hpp.3 b/man_pages/man3/utils.hpp.3
deleted file mode 100644
index a67beb7..0000000
--- a/man_pages/man3/utils.hpp.3
+++ /dev/null
@@ -1,201 +0,0 @@
-.TH "include/utils.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*-
-.ad l
-.nh
-.SH NAME
-include/utils.hpp \- Function prototypes and macros that are useful\&.
-
-.SH SYNOPSIS
-.br
-.PP
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-\fC#include \fP
-.br
-
-.SS "Macros"
-
-.in +1c
-.ti -1c
-.RI "#define \fBDEBUG\fP(msg)"
-.br
-.RI "Writes a debug message\&. "
-.ti -1c
-.RI "#define \fBASSERT\fP(expr, msg)"
-.br
-.RI "A prettier assertion function\&. "
-.ti -1c
-.RI "#define \fB__METHOD_NAME__\fP methodName(__PRETTY_FUNCTION__)"
-.br
-.in -1c
-.SS "Functions"
-
-.in +1c
-.ti -1c
-.RI "std::string \fBscientific_format\fP (double d, int width=20, int prec=10)"
-.br
-.RI "Turns a double into a string written in scientific format\&. "
-.ti -1c
-.RI "std::string \fBscientific_format\fP (const std::vector< double > &v, int width=20, int prec=10)"
-.br
-.RI "Turns a vector of doubles into a string written in scientific format\&. "
-.ti -1c
-.RI "void \fBm_assert\fP (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)"
-.br
-.RI "Test an expression, confirm that test is ok, or abort execution\&. "
-.ti -1c
-.RI "bool \fBarma_vector_close_to\fP (arma::vec &a, arma::vec &b, double tol=1e\-8)"
-.br
-.RI "Test if two armadillo vectors are close to each other\&. "
-.in -1c
-.SH "Detailed Description"
-.PP
-Function prototypes and macros that are useful\&.
-
-
-.PP
-\fBAuthor\fP
-.RS 4
-Cory Alexander Balaton (coryab)
-.PP
-Janita Ovidie Sandtrøen Willumsen (janitaws)
-.RE
-.PP
-\fBVersion\fP
-.RS 4
-1\&.0
-.RE
-.PP
-.PP
-These utility function are mainly for convenience and aren't directly related to the project\&.
-.PP
-\fBBug\fP
-.RS 4
-No known bugs
-.RE
-.PP
-
-.PP
-Definition in file \fButils\&.hpp\fP\&.
-.SH "Macro Definition Documentation"
-.PP
-.SS "#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)"
-
-.PP
-Definition at line \fB48\fP of file \fButils\&.hpp\fP\&.
-.SS "#define ASSERT(expr, msg)"
-\fBValue:\fP.PP
-.nf
- m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \\
- __LINE__, msg)
-.fi
-
-.PP
-A prettier assertion function\&. This macro calls the m_assert function which is a more informative assertion function than the regular assert function from cassert\&.
-.PP
-Definition at line \fB45\fP of file \fButils\&.hpp\fP\&.
-.SS "#define DEBUG(msg)"
-
-.PP
-Writes a debug message\&. This macro writes a debug message that includes the filename, line number, and a custom message\&. The function is wrapped in an ifdef that checks if DBG is defined, so one can choose to display the debug messages by adding the -DDBG flag when compiling\&.
-.PP
-Definition at line \fB36\fP of file \fButils\&.hpp\fP\&.
-.SH "Function Documentation"
-.PP
-.SS "bool arma_vector_close_to (arma::vec & a, arma::vec & b, double tol = \fC1e\-8\fP)"
-
-.PP
-Test if two armadillo vectors are close to each other\&. This function takes in 2 vectors and checks if they are approximately equal to each other given a tolerance\&.
-.PP
-\fBParameters\fP
-.RS 4
-\fIa\fP Vector a
-.br
-\fIb\fP Vector b
-.br
-\fItol\fP The tolerance
-.RE
-.PP
-\fBReturns\fP
-.RS 4
-Boolean
-.RE
-.PP
-
-.PP
-Definition at line \fB59\fP of file \fButils\&.cpp\fP\&.
-.SS "void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)"
-
-.PP
-Test an expression, confirm that test is ok, or abort execution\&. This function takes in an expression and prints an OK message if it's true, or it prints a fail message and aborts execution if it fails\&.
-.PP
-\fBParameters\fP
-.RS 4
-\fIexpr\fP The expression to be evaluated
-.br
-\fIexpr_str\fP The stringified version of the expression
-.br
-\fIfunc\fP The function name of the caller
-.br
-\fIfile\fP The file of the caller
-.br
-\fIline\fP The line number where this function is called from
-.br
-\fImsg\fP The message to be displayed
-.RE
-.PP
-
-.PP
-Definition at line \fB40\fP of file \fButils\&.cpp\fP\&.
-.SS "std::string scientific_format (const std::vector< double > & v, int width = \fC20\fP, int prec = \fC10\fP)"
-
-.PP
-Turns a vector of doubles into a string written in scientific format\&.
-.PP
-\fBParameters\fP
-.RS 4
-\fIv\fP The vector to stringify
-.br
-\fIwidth\fP The reserved width of the string
-.br
-\fIprec\fP The precision of the stringified number
-.RE
-.PP
-\fBReturns\fP
-.RS 4
-String
-.RE
-.PP
-
-.PP
-Definition at line \fB21\fP of file \fButils\&.cpp\fP\&.
-.SS "std::string scientific_format (double d, int width = \fC20\fP, int prec = \fC10\fP)"
-
-.PP
-Turns a double into a string written in scientific format\&. Code stolen from https://github.com/anderkve/FYS3150 Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp
-.PP
-\fBParameters\fP
-.RS 4
-\fId\fP The number to stringify
-.br
-\fIwidth\fP The reserved width of the string
-.br
-\fIprec\fP The precision of the stringified number
-.RE
-.PP
-\fBReturns\fP
-.RS 4
-String
-.RE
-.PP
-
-.PP
-Definition at line \fB14\fP of file \fButils\&.cpp\fP\&.
-.SH "Author"
-.PP
-Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
diff --git a/src/Makefile b/src/Makefile
index 52c16b7..f678e43 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,7 +8,7 @@ CLASSOBJS=$(CLASSSRCS:.cpp=.o)
INCLUDE=../include
-CFLAGS=-larmadillo -llapack -std=c++11 -O2
+CFLAGS=-Wall -larmadillo -lblas -llapack -std=c++11 -O3
OPENMP=-fopenmp
# Add a debug flag when compiling (For the DEBUG macro in utils.hpp)
@@ -19,20 +19,27 @@ else
DBGFLAG=
endif
+PROFILE ?= 0
+ifeq ($(PROFILE), 1)
+ PROFFLAG=-pg
+else
+ PROFFLAG=
+endif
+
.PHONY: clean
all: test_suite main
# Rules for executables
main: main.o $(LIBOBJS) $(CLASSOBJS)
- $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP)
+ $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP)
test_suite: test_suite.o $(LIBOBJS) $(CLASSOBJS)
- $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP)
+ $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP)
# Rule for object files
%.o: %.cpp
- $(CC) -c $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP)
+ $(CC) -c $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP)
clean:
rm *.o
diff --git a/src/Particle.cpp b/src/Particle.cpp
index 0ff18e8..2caad68 100644
--- a/src/Particle.cpp
+++ b/src/Particle.cpp
@@ -8,7 +8,6 @@
* @brief The implementation of the Particle class.
*
* @bug No known bugs
- *
* */
#include "Particle.hpp"
diff --git a/src/PenningTrap.cpp b/src/PenningTrap.cpp
index 5d9a16b..d5a3b16 100644
--- a/src/PenningTrap.cpp
+++ b/src/PenningTrap.cpp
@@ -8,20 +8,75 @@
* @brief The implementation of the PenningTrap class.
*
* @bug No known bugs
- *
- * @todo Implement evolve_RK4
- * @todo Implement evolve_forward_euler
* */
#include "PenningTrap.hpp"
#include "constants.hpp"
+#include "typedefs.hpp"
#include "utils.hpp"
-PenningTrap::PenningTrap(double B_0, double V_0, double d)
+PenningTrap::PenningTrap(double B_0, std::function V_0,
+ double d, double t)
{
this->B_0 = B_0;
this->V_0 = V_0;
this->d = d;
+ this->t = t;
+}
+
+PenningTrap::PenningTrap(unsigned int i, double B_0,
+ std::function V_0, double d, double t)
+ : PenningTrap::PenningTrap(B_0, V_0, d)
+{
+ vec_3d r, v;
+ for (size_t j = 0; j < i; j++) {
+ r = vec_3d().randn() * .1 * this->d;
+ v = vec_3d().randn() * .1 * this->d;
+ this->add_particle(Particle(1., 40., r, v));
+ }
+}
+
+PenningTrap::PenningTrap(std::vector particles, double B_0,
+ std::function V_0, double d, double t)
+ : PenningTrap::PenningTrap(B_0, V_0, d)
+{
+ this->particles = particles;
+}
+
+vec_3d PenningTrap::v_func(unsigned int i, unsigned int j, double dt)
+{
+ switch (i) {
+ case 0:
+ return .5 * dt * this->k_v[0][j];
+ case 1:
+ return .5 * dt * this->k_v[1][j];
+ case 2:
+ return dt * this->k_v[2][j];
+ case 3:
+ return (dt / 6.) * (this->k_v[0][j] + 2. * this->k_v[1][j] +
+ 2. * this->k_v[2][j] + this->k_v[3][j]);
+ default:
+ std::cout << "Not valid!" << std::endl;
+ abort();
+ }
+}
+
+vec_3d PenningTrap::r_func(unsigned int i, unsigned int j, double dt)
+{
+ switch (i) {
+ case 0:
+ return .5 * dt * this->k_r[0][j];
+ case 1:
+ return .5 * dt * this->k_r[1][j];
+ case 2:
+ return dt * this->k_r[2][j];
+ case 3:
+ return (dt / 6.) * (this->k_r[0][j] + 2. * this->k_r[1][j] +
+ 2. * this->k_r[2][j] + this->k_r[3][j]);
+ default:
+ std::cout << "Not valid!" << std::endl;
+ abort();
+ }
}
void PenningTrap::add_particle(Particle particle)
@@ -29,61 +84,53 @@ void PenningTrap::add_particle(Particle particle)
this->particles.push_back(particle);
}
-arma::vec PenningTrap::external_E_field(arma::vec r)
+vec_3d PenningTrap::external_E_field(vec_3d r)
{
- arma::vec::fixed<3> res;
- double f = this->V_0 / (this->d * this->d);
- res(0) = r(0);
- res(1) = r(1);
- res(2) = -2. * r(2);
+ r(2) *= -2.;
+ double f = this->V_0(this->t) / (this->d * this->d);
- return f * res;
+ return f * r;
}
-arma::vec PenningTrap::external_B_field(arma::vec r)
+vec_3d PenningTrap::external_B_field(vec_3d r)
{
- arma::vec::fixed<3> res{0., 0., this->B_0};
-
- return res;
+ return vec_3d{0., 0., this->B_0};
}
-arma::vec PenningTrap::force_on_particle(int i, int j)
+vec_3d PenningTrap::force_on_particle(unsigned int i, unsigned int j)
{
+ Particle p_j = this->particles[j];
// Calculate the difference between the particles' position
- arma::vec::fixed<3> res =
- this->particles.at(i).r_vec - this->particles.at(j).r_vec;
+ vec_3d res = this->particles[i].r_vec - p_j.r_vec;
// Get the distance between the particles
- double norm = arma::norm(res);
+ double norm = arma::norm(res, 2);
- // Multiply res with p_j's charge divided by the norm cubed
- res *= this->particles.at(j).q / (norm * norm * norm);
-
- return res;
+ return vec_3d(res * p_j.q / (norm * norm * norm));
}
-arma::vec PenningTrap::total_force_external(int i)
+vec_3d PenningTrap::total_force_external(unsigned int i)
{
- Particle p = this->particles.at(i);
+ Particle p = this->particles[i];
- arma::vec::fixed<3> B = this->external_B_field(p.r_vec);
+ if (arma::norm(p.r_vec) > this->d) {
+ return vec_3d{0., 0., 0.};
+ }
- arma::vec::fixed<3> v_cross_B{p.v_vec(1) * B(2) - p.v_vec(2) * B(1),
- p.v_vec(2) * B(0) - p.v_vec(0) * B(2),
- p.v_vec(0) * B(1) - p.v_vec(1) * B(0)};
-
- arma::vec force = p.q * (this->external_E_field(p.r_vec) + v_cross_B);
+ vec_3d force =
+ p.q * (this->external_E_field(p.r_vec) +
+ arma::cross(p.v_vec, this->external_B_field(p.r_vec)));
return force;
}
-arma::vec PenningTrap::total_force_particles(int i)
+vec_3d PenningTrap::total_force_particles(unsigned int i)
{
- Particle p = this->particles.at(i);
+ Particle p = this->particles[i];
- arma::vec res(3);
+ vec_3d res;
- for (int j = 0; j < this->particles.size(); j++) {
+ for (size_t j = 0; j < this->particles.size(); j++) {
if (i == j) {
continue;
}
@@ -91,101 +138,171 @@ arma::vec PenningTrap::total_force_particles(int i)
res += this->force_on_particle(i, j);
}
- res *= K_E * (p.q / p.m);
-
- return res;
+ return vec_3d(res * K_E * (p.q / p.m));
}
-arma::vec PenningTrap::total_force(int i)
+vec_3d PenningTrap::total_force(unsigned int i)
{
return this->total_force_external(i) - this->total_force_particles(i);
}
-void PenningTrap::evolve_RK4(double dt)
+void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
{
+
+ std::vector original_particles = this->particles;
std::vector tmp_particles = this->particles;
-
- arma::vec::fixed<3> *k_v = new arma::vec::fixed<3>[this->particles.size()*4];
- arma::vec::fixed<3> *k_r = new arma::vec::fixed<3>[this->particles.size()*4];
- int size = this->particles.size();
-
- for (int i=0; itotal_force(i)/this->particles.at(i).m;
- k_r[i] = this->particles.at(i).v_vec;
+ vec_3d (PenningTrap::*force)(unsigned int);
+ if (particle_interaction) {
+ force = &PenningTrap::total_force;
+ }
+ else {
+ force = &PenningTrap::total_force_external;
}
- for (int i=0; iparticles.at(i);
+ size_t size = this->particles.size();
- p->v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[i];
- p->r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[i];
+ this->k_v = sim_arr(4, sim_cols(size));
+ this->k_r = sim_arr(4, sim_cols(size));
+
+ for (size_t i = 0; i < 4; i++) {
+#pragma omp parallel for
+ for (size_t j = 0; j < this->particles.size(); j++) {
+ this->k_v[i][j] = (this->*force)(j) / this->particles[j].m;
+ this->k_r[i][j] = this->particles[j].v_vec;
+
+ Particle *p = &tmp_particles[j];
+
+ p->v_vec = original_particles[j].v_vec + this->v_func(i, j, dt);
+ p->r_vec = original_particles[j].r_vec + this->r_func(i, j, dt);
+ }
+ this->particles.swap(tmp_particles);
}
-
-
- for (int i=0; itotal_force(i)/this->particles.at(i).m;
- k_r[1*size + i] = this->particles.at(i).v_vec;
- }
-
- for (int i=0; iparticles.at(i);
-
- p->v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[1*size + i];
- p->r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[1*size + i];
- }
-
- for (int i=0; itotal_force(i)/this->particles.at(i).m;
- k_r[2*size + i] = this->particles.at(i).v_vec;
- }
-
- for (int i=0; iparticles.at(i);
-
- p->v_vec = tmp_particles.at(i).v_vec + dt*k_v[2*size + i];
- p->r_vec = tmp_particles.at(i).r_vec + dt*k_r[2*size + i];
- }
-
-
- for (int i=0; itotal_force(i)/this->particles.at(i).m;
- k_r[3*size + i] = this->particles.at(i).v_vec;
- }
-
- for (int i=0; iparticles.at(i);
-
- p->v_vec = tmp_particles.at(i).v_vec + dt*(k_v[i] + k_v[size + i] + k_v[2*size + i] + k_v[3*size + i])/6;
- p->r_vec = tmp_particles.at(i).r_vec + dt*(k_r[i] + k_r[size + i] + k_r[2*size + i] + k_r[3*size + i])/6;
- }
-
- delete [] k_v;
- delete [] k_r;
+ this->t += dt;
}
-void PenningTrap::evolve_forward_euler(double dt)
+void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction)
{
- std::vector new_state = this->particles;
-
+ size_t size = this->particles.size();
+ vec_3d force_res[size];
Particle *p;
-#pragma omp parallel for private(p)
- for (int i = 0; i < this->particles.size(); i++) {
- p = &new_state.at(i);
- p->v_vec += dt * this->total_force(i) / new_state.at(i).m;
- p->r_vec += dt * this->particles.at(i).v_vec;
+ vec_3d (PenningTrap::*force)(unsigned int);
+ if (particle_interaction) {
+ force = &PenningTrap::total_force;
+ }
+ else {
+ force = &PenningTrap::total_force_external;
}
- this->particles = new_state;
+#pragma omp parallel for
+ for (size_t i = 0; i < size; i++) {
+ force_res[i] = (this->*force)(i);
+ }
+
+#pragma omp parallel for private(p)
+ for (size_t i = 0; i < size; i++) {
+ p = &this->particles[i];
+ p->r_vec += dt * p->v_vec;
+ p->v_vec += dt * force_res[i] / p->m;
+ }
+
+ this->t += dt;
}
-arma::vec PenningTrap::get_particle(int i)
+simulation_t PenningTrap::simulate(double time, unsigned int steps,
+ std::string method,
+ bool particle_interaction)
{
- return this->particles.at(i).r_vec;
+ double dt = time / (double)steps;
+
+ unsigned int size = this->particles.size();
+ // sim_arr res(this->particles.size(), sim_cols(steps));
+ simulation_t res{sim_arr(size, sim_cols(steps)),
+ sim_arr(size, sim_cols(steps))};
+
+ void (PenningTrap::*func)(double, bool);
+ if (method == "rk4") {
+ func = &PenningTrap::evolve_RK4;
+ }
+ else if (method == "euler") {
+ func = &PenningTrap::evolve_forward_euler;
+ }
+ else {
+ std::cout << "Not a valid method!" << std::endl;
+ abort();
+ }
+
+ for (size_t j = 0; j < steps; j++) {
+ for (size_t i = 0; i < size; i++) {
+ res.r_vecs[i][j] = this->particles[i].r_vec;
+ res.v_vecs[i][j] = this->particles[i].v_vec;
+ }
+ (this->*func)(dt, particle_interaction);
+ }
+
+ return res;
}
-double PenningTrap::get_d()
+void PenningTrap::write_simulation_to_dir(std::string path, double time,
+ unsigned int steps,
+ std::string method,
+ bool particle_interaction)
{
- return this->d;
+ if (path.back() != '/') {
+ path += '/';
+ }
+ if (mkpath(path, 0777) != 0) {
+ std::cout << "Hello" << std::endl;
+ return;
+ }
+
+ simulation_t res =
+ this->simulate(time, steps, method, particle_interaction);
+
+ std::ofstream ofile;
+
+#pragma omp parallel for private(ofile)
+ for (size_t i = 0; i < this->particles.size(); i++) {
+ ofile.open(path + "particle_" + std::to_string(i) + "_r.txt");
+ for (vec_3d &vec : res.r_vecs[i]) {
+ ofile << vec(0) << "," << vec(1) << "," << vec(2) << "\n";
+ }
+ ofile.close();
+ ofile.open(path + "particle_" + std::to_string(i) + "_v.txt");
+ for (vec_3d &vec : res.v_vecs[i]) {
+ ofile << scientific_format(vec(0), 10, 8) << ","
+ << scientific_format(vec(1), 8, 10) << ","
+ << scientific_format(vec(2), 8, 10) << "\n";
+ }
+ ofile.close();
+ }
+}
+
+double PenningTrap::fraction_of_particles_left(double time, unsigned int steps,
+ std::string method,
+ bool particle_interaction)
+{
+ simulation_t res =
+ this->simulate(time, steps, method, particle_interaction);
+
+ int particles_left = 0;
+
+ for (Particle p : this->particles) {
+ if (arma::norm(p.r_vec) < this->d) {
+ particles_left++;
+ }
+ }
+
+ return (double)particles_left / (double)this->particles.size();
+}
+
+vec_3d PenningTrap::get_r(int i)
+{
+ return this->particles[i].r_vec;
+}
+
+double PenningTrap::get_t()
+{
+ return this->t;
}
diff --git a/src/main.cpp b/src/main.cpp
index 1c55279..19ef8fd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,79 +10,181 @@
* @bug No known bugs
* */
+#include
+#include
#include
+#include
#include
+#include
#include
+#include
#include "PenningTrap.hpp"
+#include "utils.hpp"
#define PARTICLES 100
-#define N 10000
+#define N 40000
#define CHARGE 1.
#define MASS 40. // unit: amu
-void simulate_100_particles()
-{
- PenningTrap trap;
+Particle p1(CHARGE, MASS, vec_3d{20., 0., 20.}, vec_3d{0., 25., 0.});
+Particle p2(CHARGE, MASS, vec_3d{25., 25., 0.}, vec_3d{0., 40., 5.});
- // Add particles inside trap
- for (int i = 0; i < PARTICLES; i++) {
- arma::vec r = arma::vec(3).randn() * 0.1 *
- trap.get_d(); // random initial position
- arma::vec v = arma::vec(3).randn() * 0.1 *
- trap.get_d(); // random initial velocity
- trap.add_particle(Particle(CHARGE, MASS, r, v));
- }
+vec_3d analytical_solution_particle_1(double t)
+{
+ double w_0 = T / MASS;
+ double w_z2 = (50. * V / 1000.) / (MASS * 500. * 500.);
+ double w_p = (w_0 + std::sqrt(w_0 * w_0 - 2. * w_z2)) / 2.;
+ double w_n = (w_0 - std::sqrt(w_0 * w_0 - 2. * w_z2)) / 2.;
+ double A_p = (25. + w_n * 20.) / (w_n - w_p);
+ double A_n = -(25. + w_p * 20.) / (w_n - w_p);
+ std::complex f = A_p * std::exp(std::complex(0., -w_p * t)) +
+ A_n * std::exp(std::complex(0., -w_n * t));
+ vec_3d res{std::real(f), std::imag(f), 20. * std::cos(std::sqrt(w_z2) * t)};
+ return res;
+}
+
+void simulate_single_particle()
+{
+ DEBUG("Inside single particle sim");
+ PenningTrap trap(std::vector{p1});
double time = 50.; // microseconds
- double dt = time / (double)N;
- auto res = new arma::vec::fixed<3>[PARTICLES][N];
+ DEBUG("Write to dir");
+ trap.write_simulation_to_dir("output/simulate_single_particle", time, N,
+ "rk4", false);
+}
- int counter = 0;
+void simulate_two_particles()
+{
+ PenningTrap trap_no_interaction(std::vector{p1, p2});
+ PenningTrap trap_with_interaction(std::vector{p1, p2});
- // Get the path of all particles
- for (int j = 0; j < N; j++) {
-#pragma omp parallel for
- for (int i = 0; i < PARTICLES; i++) {
- res[i][j] = trap.get_particle(i);
- }
- trap.evolve_RK4(dt);
- }
+ double time = 50.; // microseconds
- std::cout << counter << std::endl;
+ trap_no_interaction.write_simulation_to_dir(
+ "output/simulate_2_particles/no_interaction", time, N, "rk4", false);
+ trap_with_interaction.write_simulation_to_dir(
+ "output/simulate_2_particles/with_interaction", time, N);
+}
- arma::vec::fixed<3> *cur_row;
- arma::vec::fixed<3> cur_elem;
+void simulate_single_particle_with_different_steps()
+{
- mkdir("output", 0777);
- mkdir("output/simulate_100_particles", 0777);
+ double time = 50.; // microseconds
std::ofstream ofile;
-// Write particle paths to file
-#pragma omp parallel for private(cur_row, cur_elem, ofile)
- for (int i = 0; i < PARTICLES; i++) {
- cur_row = res[i];
- ofile.open("output/simulate_100_particles/p" + std::to_string(i) + ".txt");
- for (int j = 0; j < N; j++) {
- cur_elem = cur_row[j];
- ofile << cur_elem(0) << "," << cur_elem(1) << "," << cur_elem(2)
+ for (int i = 0; i < 4; i++) {
+ int steps = 4000 * std::pow(2, i);
+ double dt = time / (double)steps;
+ std::string path = "output/relative_error/RK4/";
+ mkpath(path);
+ ofile.open(path + std::to_string(steps) + "_steps.txt");
+ PenningTrap trap(std::vector{p1});
+ for (int i = 0; i < steps; i++) {
+ trap.evolve_RK4(dt);
+ ofile << arma::norm(trap.get_r(0) -
+ analytical_solution_particle_1(trap.get_t()))
+ << "\n";
+ }
+ ofile.close();
+ }
+
+ for (int i = 0; i < 4; i++) {
+ int steps = 4000 * std::pow(2, i);
+ double dt = time / (double)steps;
+ std::string path = "output/relative_error/euler/";
+ mkpath(path);
+ ofile.open(path + std::to_string(steps) + "_steps.txt");
+ PenningTrap trap(std::vector{p1});
+ for (int i = 0; i < steps; i++) {
+ trap.evolve_forward_euler(dt);
+ ofile << arma::norm(trap.get_r(0) -
+ analytical_solution_particle_1(trap.get_t()))
<< "\n";
}
ofile.close();
}
}
+void simulate_100_particles()
+{
+ PenningTrap trap((unsigned)100, T,
+ [](double t) {
+ return 25. * V / 1000. * (1. + .4 * std::cos(1.5 * t));
+ },
+ 500., 0);
+
+ double time = 500.; // microseconds
+
+ trap.write_simulation_to_dir("output/simulate_100_particles", time, N * 4);
+}
+
+void simulate_100_particles_with_time_potential()
+{
+ double amplitudes[]{.1, .4, .7};
+
+ double freq_start = .2;
+ double freq_end = 2.5;
+ double freq_increment = .02;
+ size_t freq_iterations = (size_t)((freq_end - freq_start) / freq_increment);
+
+ double res[4][freq_iterations];
+
+ std::string path = "output/time_dependent_potential/";
+ mkpath(path);
+
+ std::ofstream ofile;
+
+ double freq = freq_start;
+ for (size_t i = 0; i < freq_iterations; i++) {
+ res[0][i] = freq;
+ freq += freq_increment;
+ }
+
+#pragma omp parallel for collapse(2) num_threads(4)
+ for (size_t i = 0; i < 3; i++) {
+ for (size_t j = 0; j < freq_iterations; j++) {
+ PenningTrap trap(
+ (unsigned)100, T,
+ std::bind(
+ [](double f, double r, double t) {
+ return (25. * V / 1000.) * (1. + f * std::cos(r * t));
+ },
+ amplitudes[i], res[0][j], std::placeholders::_1),
+ 500., 0.);
+ res[i + 1][j] =
+ trap.fraction_of_particles_left(500., 40000, "rk4", false);
+ }
+ }
+
+ ofile.open(path + "res.txt");
+ for (size_t i = 0; i < freq_iterations; i++) {
+ ofile << res[0][i] << "," << res[1][i] << "," << res[2][i] << ","
+ << res[3][i] << "\n";
+ }
+ ofile.close();
+}
+
int main()
{
double start = omp_get_wtime();
- simulate_100_particles();
+ simulate_single_particle();
+
+ simulate_two_particles();
+
+ simulate_single_particle_with_different_steps();
+
+ // simulate_100_particles();
+
+ // simulate_100_particles_with_time_potential();
double end = omp_get_wtime();
- std::cout << "Time: " << end - start << " seconds" << std::endl;
+ std::cout << "Time: " << (end - start) << " seconds" << std::endl;
return 0;
}
diff --git a/src/animate_100_particles.py b/src/scripts/animate_100_particles.py
similarity index 88%
rename from src/animate_100_particles.py
rename to src/scripts/animate_100_particles.py
index 19f10ca..0fc0083 100644
--- a/src/animate_100_particles.py
+++ b/src/scripts/animate_100_particles.py
@@ -32,7 +32,7 @@ def animate():
fig = plt.figure()
ax = fig.add_subplot(projection="3d")
- arr = get_data([f"output/simulate_100_particles/p{i}.txt" for i in range(100)])
+ arr = get_data([f"output/simulate_100_particles/particle_{i}.txt" for i in range(100)])
arr = arr[:, :, ::10]
@@ -63,8 +63,8 @@ def animate():
fig, update, N, fargs=(lines, arr), interval=1, blit=False
)
- ani.save("../images/100_particles.gif", writer=animation.FFMpegFileWriter(fps=50))
- # plt.show()
+ # ani.save("../images/100_particles.gif", writer=animation.FFMpegFileWriter(fps=50))
+ plt.show()
if __name__ == "__main__":
diff --git a/src/scripts/plot_2_particles.py b/src/scripts/plot_2_particles.py
new file mode 100644
index 0000000..17f327c
--- /dev/null
+++ b/src/scripts/plot_2_particles.py
@@ -0,0 +1,39 @@
+import matplotlib.pyplot as plt
+import numpy as np
+
+def main():
+ files = [
+ "output/simulate_2_particles/no_interaction/particle_0_r.txt",
+ "output/simulate_2_particles/no_interaction/particle_1_r.txt",
+ "output/simulate_2_particles/with_interaction/particle_0_r.txt",
+ "output/simulate_2_particles/with_interaction/particle_1_r.txt"
+ ]
+ labels = [
+ "particle 1 no interaction",
+ "particle 2 no interaction",
+ "particle 1 with interaction",
+ "particle 2 with interaction",
+ ]
+ colors = [
+ "lightskyblue",
+ "lightskyblue",
+ "salmon",
+ "salmon"
+ ]
+ for label, color, file in zip(labels, colors, files):
+ with open(file) as f:
+ lines = f.readlines()
+ t = np.linspace(0, 50, len(lines))
+ r = np.array([list(map(float, line.strip().split(","))) for line in lines])
+ plt.plot(r[:,0], r[:,1], label=label, color=color)
+
+ plt.xlabel(r"x $(\mu m)$")
+ plt.ylabel(r"y $(\mu m)$")
+ plt.title(r"2 particles with and without interactions.")
+ # plt.legend()
+ # plt.show()
+ plt.savefig("../latex/images/plot_2_particles_xy.pdf")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/scripts/plot_3d.py b/src/scripts/plot_3d.py
new file mode 100644
index 0000000..811bf6a
--- /dev/null
+++ b/src/scripts/plot_3d.py
@@ -0,0 +1,40 @@
+import matplotlib.pyplot as plt
+import numpy as np
+
+def main():
+ files = [
+ "output/simulate_2_particles/no_interaction/particle_0_r.txt",
+ "output/simulate_2_particles/no_interaction/particle_1_r.txt",
+ "output/simulate_2_particles/with_interaction/particle_0_r.txt",
+ "output/simulate_2_particles/with_interaction/particle_1_r.txt"
+ ]
+ labels = [
+ "particle 1 no interaction",
+ "particle 2 no interaction",
+ "particle 1 with interaction",
+ "particle 2 with interaction",
+ ]
+ colors = [
+ "lightskyblue",
+ "deepskyblue",
+ "salmon",
+ "darkred"
+ ]
+ ax = plt.figure().add_subplot(projection="3d")
+ for label, color, file in zip(labels, colors, files):
+ with open(file) as f:
+ lines = f.readlines()
+ t = np.linspace(0, 50, len(lines))
+ r = np.array([list(map(float, line.strip().split(","))) for line in lines])
+ ax.plot(r[:,0], r[:,1], r[:,2], label=label, color=color)
+
+ ax.set_xlabel(r"x $(\mu m)$")
+ ax.set_ylabel(r"y $(\mu m)$")
+ ax.set_zlabel(r"z $(\mu m)$")
+ plt.title(r"2 particles with and without interactions.")
+ plt.legend()
+ plt.savefig("../latex/images/3d_plot.pdf")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/scripts/plot_particles_left.py b/src/scripts/plot_particles_left.py
new file mode 100644
index 0000000..85bfd78
--- /dev/null
+++ b/src/scripts/plot_particles_left.py
@@ -0,0 +1,30 @@
+import matplotlib.pyplot as plt
+
+def main():
+ with open("output/time_dependent_potential/res.txt") as f:
+ lines = f.readlines()
+ x = []
+ y1 = []
+ y2 = []
+ y3 = []
+ for line in lines:
+ l = line.strip().split(",")
+ x.append(float(l[0]))
+ y1.append(float(l[1]))
+ y2.append(float(l[2]))
+ y3.append(float(l[3]))
+
+ plt.plot(x,y1,label=f"amplitude: 0.1")
+ plt.plot(x,y2,label=f"amplitude: 0.4")
+ plt.plot(x,y3,label=f"amplitude: 0.7")
+
+ plt.xlabel(r"$\omega_V$ (MHz)")
+ plt.ylabel(r"Fraction of particles left")
+ plt.title(r"The fraction of particles left in the Penning trap "
+ "after 500 microseconds for different amplitudes and frequencies")
+ plt.legend()
+ # plt.show()
+ plt.savefig("../latex/images/particles_left.pdf")
+
+if __name__ == "__main__":
+ main()
diff --git a/src/scripts/plot_phase_space.py b/src/scripts/plot_phase_space.py
new file mode 100644
index 0000000..5a4c3ac
--- /dev/null
+++ b/src/scripts/plot_phase_space.py
@@ -0,0 +1,53 @@
+import matplotlib.pyplot as plt
+import numpy as np
+
+def main():
+ directories = {
+ "output/simulate_2_particles/no_interaction/",
+ "output/simulate_2_particles/with_interaction/",
+ }
+ titles = {
+ "particles without interaction",
+ "particles with interaction"
+ }
+ files = [
+ "particle_0_r.txt",
+ "particle_0_v.txt",
+ "particle_1_r.txt",
+ "particle_1_v.txt",
+ ]
+ labels = [
+ r"particle 1 r",
+ r"particle 1 v",
+ r"particle 2 r",
+ r"particle 2 v",
+ ]
+ colors = [
+ "lightskyblue",
+ "deepskyblue",
+ "salmon",
+ "tomato",
+ ]
+ fig1, axs1 = plt.subplots(2,1)
+ fig2, axs2 = plt.subplots(2,1)
+ for i, (dir, title) in enumerate(zip(directories, titles)):
+ for label, color, file in zip(labels, colors, files):
+ with open(dir+file) as f:
+ lines = f.readlines()
+ t = np.linspace(0, 50, len(lines))
+ r = np.array([list(map(float, line.strip().split(","))) for line in lines])
+ axs1[i].plot(t, r[:,0], label=label, color=color)
+ axs2[i].plot(t, r[:,2], label=label, color=color)
+
+ axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"z $(\mu m)$")
+
+ axs1[i].legend()
+ axs1[i].set_title(title)
+
+ # plt.show()
+ fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
+ fig2.savefig("../latex/images/phase_space_2_particles_z.pdf")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/scripts/plot_relative_error.py b/src/scripts/plot_relative_error.py
new file mode 100644
index 0000000..54214c8
--- /dev/null
+++ b/src/scripts/plot_relative_error.py
@@ -0,0 +1,50 @@
+import matplotlib.pyplot as plt
+import numpy as np
+
+def main():
+ directories = {
+ "output/relative_error/RK4/",
+ "output/relative_error/euler/",
+ }
+ files = [
+ "4000_steps.txt",
+ "8000_steps.txt",
+ "16000_steps.txt",
+ "32000_steps.txt",
+ ]
+ labels = [
+ r"4000 steps",
+ r"8000 steps",
+ r"16000 steps",
+ r"32000 steps",
+ ]
+ titles = [
+ "Relative error for the RK4 method",
+ "Relative error for the forward Euler method"
+ ]
+ fig1, axs1 = plt.subplots(2,1)
+ for i, (dir, title) in enumerate(zip(directories, titles)):
+ max_err = []
+ for label, file in zip(labels, files):
+ with open(dir+file) as f:
+ lines = f.readlines()
+ t = np.linspace(0, 50, len(lines))
+ r = np.array([float(line.strip()) for line in lines])
+ max_err.append(max(r))
+ axs1[i].plot(t, r, label=label)
+
+ axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"relative_error $(\mu m)$")
+
+
+ axs1[i].legend()
+ axs1[i].set_title(title)
+
+ conv_rate = 1/3 * sum([np.log10(max_err[i+1]/max_err[i])/np.log10(.5) for i in range(3)])
+ print(conv_rate)
+
+ plt.show()
+ # fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/scripts/plot_single_particle.py b/src/scripts/plot_single_particle.py
new file mode 100644
index 0000000..f4bdc6a
--- /dev/null
+++ b/src/scripts/plot_single_particle.py
@@ -0,0 +1,30 @@
+import matplotlib.pyplot as plt
+import numpy as np
+
+def z(t):
+ V_0 = 25.*9.64852558 * 10**4
+ m = 40.
+ d = 500.
+ w_z = np.sqrt((2.*V_0)/(m*d*d))
+ return 20.*np.cos(w_z*t)
+
+def main():
+ filename = "output/simulate_single_particle/particle_0_r.txt"
+ r = t = []
+ with open(filename) as f:
+ lines = f.readlines()
+ t = np.linspace(0, 50, len(lines))
+ r = np.array([list(map(float, line.strip().split(","))) for line in lines])
+
+ plt.plot(t, r[:, 2], label="approximation")
+ plt.plot(t, z(t), label="analytical")
+ plt.xlabel(r"time $(\mu s)$")
+ plt.ylabel(r"z $(\mu m)$")
+ plt.title(r"Movement of a single particle in the x direction")
+ plt.legend()
+ # plt.savefig("../latex/images/single_particle.pdf")
+ plt.show()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/test_suite.cpp b/src/test_suite.cpp
index 81ea5c1..cd422c5 100644
--- a/src/test_suite.cpp
+++ b/src/test_suite.cpp
@@ -44,7 +44,7 @@ public:
arma::vec result;
arma::vec v;
std::stringstream msg;
- for (int i = 0; i < tests.size(); i++) {
+ for (size_t i = 0; i < tests.size(); i++) {
v = tests.at(i).first;
result = trap.external_E_field(v);
diff --git a/src/utils.cpp b/src/utils.cpp
index b55fa34..14670f0 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -9,6 +9,9 @@
*
* @bug No known bugs
* */
+
+#include
+
#include "utils.hpp"
std::string scientific_format(double d, int width, int prec)
@@ -62,10 +65,35 @@ bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol)
return false;
}
- for (int i = 0; i < a.n_elem; i++) {
+ for (size_t i = 0; i < a.n_elem; i++) {
if (std::abs(a(i) - b(i)) >= tol) {
return false;
}
}
return true;
}
+
+bool mkpath(std::string path, int mode)
+{
+ std::string cur_dir;
+ std::string::size_type pos = -1;
+ struct stat buf;
+
+ if (path.back() != '/') {
+ path += '/';
+ }
+ while (true) {
+ pos++;
+ pos = path.find('/', pos);
+ if (pos != std::string::npos) {
+ cur_dir = path.substr(0, pos);
+ if (mkdir(cur_dir.c_str(), mode) != 0 && stat(cur_dir.c_str(), &buf) != 0) {
+ return -1;
+ }
+ }
+ else {
+ break;
+ }
+ }
+ return 0;
+}