diff --git a/.clang-format b/.clang-format index d4d13ad..faa7019 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,44 @@ +# Set the language to C++ +Language: Cpp + +# Set the language standard to C++11 +Standard: Cpp11 + +# Never use tab for indentation UseTab: Never + +# Set the indent width to be 4 columns IndentWidth: 4 + +# Set tab width to be 4 columns TabWidth: 4 + +# Set access modifier (public, private, protected) offset to indent left AccessModifierOffset: -4 + +# Stop indentation of access modifiers IndentAccessModifiers: false + +# Don't allow a function to be defined on a single line AllowShortFunctionsOnASingleLine: false -BreakBeforeBraces: Custom -BraceWrapping: - AfterFunction: true - BeforeElse: true + +# Set the column limit to 80 characters +ColumnLimit: 80 + +# If an expression has to be split, then split before binary operators unless +# it's an assignment operator. +BreakBeforeBinaryOperators: NonAssignment + +# Use a Linux style brace break. +# Break before braces on function, namespace and class definitions. +BreakBeforeBraces: Linux + + +# If true, spaces will be inserted after ( and before ). +SpacesInParentheses: false + +# If true, spaces will be inserted after [ and before ]. +SpacesInSquareBrackets: false + +# Separate definition blocks (classes, functions, structs, enums) +SeparateDefinitionBlocks: Always diff --git a/.gitignore b/.gitignore index 7549ca4..2cdfb30 100644 --- a/.gitignore +++ b/.gitignore @@ -35,9 +35,11 @@ *.aux *.log *.out -*.bib *.synctex.gz *.bbl +*.blg +latex/mainNotes.bib + # C++ specifics src/* @@ -46,3 +48,7 @@ src/* !src/*.hpp !src/*.py !src/Doxyfile +!src/scripts + +# Job +!src/job.script diff --git a/Doxyfile b/Doxyfile index eeba27f..61d59dd 100644 --- a/Doxyfile +++ b/Doxyfile @@ -917,7 +917,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = include src README.md +INPUT = include src src/scripts README.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -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/README.md b/README.md index 254c153..e6614ba 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,140 @@ ![](./images/100_particles.gif) +[Repo](https://github.uio.no/FYS3150-G2-2023/Project-3) + +[Documentation](https://pages.github.uio.no/FYS3150-G2-2023/Project-3/) + +## Requirements + +### Operating systems + +- Linux + - Has been tested on [Fedora 38](https://fedoraproject.org/) + - Will most likely work on other Linux distributions +- MacOS + - Might work, but hasn't been tested +- Windows + - Will most likely not work + +### Tools + +- Profiling + - [gprof](https://ftp.gnu.org/old-gnu/Manuals/gprof-2.9.1/html_mono/gprof.html) + - [scalasca](https://www.scalasca.org/) + - [score-p](https://www.vi-hps.org/projects/score-p) + +### Libraries + +- Python + - [matplotlib](https://matplotlib.org/) + - [numpy](https://numpy.org/) + +- C++ + - [openmp](https://www.openmp.org/) + - [armadillo](https://arma.sourceforge.net/) + + +## Compiling + +Compiling is as easy as running this command while being inside the src directory: + +```shell + make +``` + +## Running programs + +### C++ binaries + +To run **main** or **test_suite**, just run this command while being inside src: + +```shell + ./ +``` + +### Python scripts + +#### Install libraries + +Before running the scripts, make sure that all libraries are installed. +Using pip, you can install all requirements like this: + +```shell + pip install -r requirements.txt +``` + +This recursively install all the packages that are listed in **requirements.txt**. + +#### Running scripts + +For the Python scripts, run them from the src directory like this: + +```shell + python scripts/ +``` + +If you have any problems running the scripts, you might have to run this instead: + +```shell + python3 scripts/ +``` + +### Batch system + +For the **frequency_narrow_sweeps_long** program, the is a script called +**job.script** that comes along with it. This is to be able to run it on a +batch system using Slurm if you have access to one. +This is the recommended way to use this program as it takes approximately 90 +minutes to complete when using 16 cores. + +If you happen to have such a system available to you, then you should clone +this repo on that system, then compile it by running: + +```shell + make frequency_narrow_sweeps_long +``` + +You might have to load the Armadillo library before compiling. + +After compiling, you can schedule it by running: + +```shell + sbatch job.script +``` + +## Performance + +This section aims to give an idea to the time it takes for the program to +run so that you know a bit what to expect if you decide to run it for +yourself. + +### CPU + +The times mentioned here are times achieved on a computer with these +specifications: + +- CPU model + - Intel i7-9850H +- Threads + - 12 +- Clock speed + - 4.6GHz + +### Times + +All times mentioned use the **evolve_RK4** method. + +Running a simulation with 100 particles without particle interactions over +40000 steps takes around 1.8 seconds. With particle interactions, it takes +around 4.8 seconds. + +**potential_resonance_wide_sweep** takes around 56 seconds to complete. + +**potential_resonance_narrow_sweep** takes around 172 seconds to complete. + +**potential_resonance_narrow_sweep_interaction** takes around 936 seconds to +complete. ## Credits diff --git a/docs/100_particles.gif b/docs/100_particles.gif index 337c6e5..ba16c67 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 b3fd0e9..d825cb9 100644 --- a/docs/Particle_8cpp.html +++ b/docs/Particle_8cpp.html @@ -112,8 +112,8 @@ $(document).ready(function(){initNavTree('Particle_8cpp.html',''); initResizable
Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Version
0.1
-
Bug:
No known bugs
+
Version
1.0
+
Bug:
No known bugs

Definition in file Particle.cpp.

diff --git a/docs/Particle_8cpp_source.html b/docs/Particle_8cpp_source.html index 13c1950..c9574ba 100644 --- a/docs/Particle_8cpp_source.html +++ b/docs/Particle_8cpp_source.html @@ -104,22 +104,21 @@ $(document).ready(function(){initNavTree('Particle_8cpp_source.html',''); initRe Go to the documentation of this file.
1
13#include "Particle.hpp"
14
-
15Particle::Particle(double q, double m,
-
16 arma::vec::fixed<3> r_vec,
-
17 arma::vec::fixed<3> v_vec)
-
18{
-
19 // Giving the particle its properties
+
15Particle::Particle(vec3 r_vec, vec3 v_vec, double q, double m)
+
16{
+
17 // Giving the particle its properties
+
18 this->r_vec = r_vec;
+
19 this->v_vec = v_vec;
20 this->q = q;
21 this->m = m;
-
22 this->r_vec = r_vec;
-
23 this->v_vec = v_vec;
-
24}
+
22}
A class that holds the properties of a particle.
-
double q
Charge.
Definition: Particle.hpp:23
-
Particle(double q, double m, vec_3d r_vec, vec_3d v_vec)
Initialize the particle.
Definition: Particle.cpp:15
-
vec_3d v_vec
velocity
Definition: Particle.hpp:26
-
double m
Mass.
Definition: Particle.hpp:24
-
vec_3d r_vec
position
Definition: Particle.hpp:25
+
vec3 r_vec
position
Definition: Particle.hpp:25
+
vec3 v_vec
velocity
Definition: Particle.hpp:26
+
double q
Charge.
Definition: Particle.hpp:27
+
double m
Mass.
Definition: Particle.hpp:28
+
Particle(vec3 r_vec, vec3 v_vec, double q=CA_CHARGE, double m=CA_MASS)
Initialize the particle.
Definition: Particle.cpp:15
+
arma::vec::fixed< 3 > vec3
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:23
diff --git a/docs/Particle_8hpp.html b/docs/Particle_8hpp.html index 00fc0e2..050ccb9 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 "constants.hpp"
#include "typedefs.hpp"

Go to the source code of this file.

@@ -122,7 +123,7 @@ Classes
Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Version
0.1
+
Version
1.0
Bug:
No known bugs

Definition in file Particle.hpp.

diff --git a/docs/Particle_8hpp_source.html b/docs/Particle_8hpp_source.html index f3339f5..bf09331 100644 --- a/docs/Particle_8hpp_source.html +++ b/docs/Particle_8hpp_source.html @@ -107,30 +107,35 @@ $(document).ready(function(){initNavTree('Particle_8hpp_source.html',''); initRe
14
15#include <armadillo>
16
-
17#include "typedefs.hpp"
-
18
-
21class Particle {
-
22private:
-
23 double q;
-
24 double m;
- - -
27
-
28public:
-
39 Particle(double q, double m, vec_3d r_vec, vec_3d v_vec);
-
40
-
43 friend class PenningTrap;
-
44};
-
45
-
46#endif
-
A class that holds attributes of a particle.
Definition: Particle.hpp:21
-
double q
Charge.
Definition: Particle.hpp:23
-
vec_3d v_vec
velocity
Definition: Particle.hpp:26
-
double m
Mass.
Definition: Particle.hpp:24
-
vec_3d r_vec
position
Definition: Particle.hpp:25
-
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:30
+
17#include "constants.hpp"
+
18#include "typedefs.hpp"
+
19
+ +
23{
+
24private:
+ + +
27 double q;
+
28 double m;
+
29
+
30public:
+
41 Particle(vec3 r_vec, vec3 v_vec, double q = CA_CHARGE, double m = CA_MASS);
+
42
+
45 friend class PenningTrap;
+
46};
+
47
+
48#endif
+
A class that holds attributes of a particle.
Definition: Particle.hpp:23
+
vec3 r_vec
position
Definition: Particle.hpp:25
+
vec3 v_vec
velocity
Definition: Particle.hpp:26
+
double q
Charge.
Definition: Particle.hpp:27
+
double m
Mass.
Definition: Particle.hpp:28
+
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:32
+
Library of constants.
+
#define CA_MASS
Mass of a single calcium ion. unit: amu.
Definition: constants.hpp:29
+
#define CA_CHARGE
Charge of a singly charged calcium ion. unit: e.
Definition: constants.hpp:33
Useful typedefs for cleaner code.
-
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:36
+
arma::vec::fixed< 3 > vec3
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:23
diff --git a/docs/PenningTrap_8cpp.html b/docs/PenningTrap_8cpp.html index 5817ff6..9ca258f 100644 --- a/docs/PenningTrap_8cpp.html +++ b/docs/PenningTrap_8cpp.html @@ -104,10 +104,12 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp.html',''); initResiza

The implementation of the PenningTrap class. More...

-
#include "PenningTrap.hpp"
-#include "constants.hpp"
+
#include <algorithm>
+#include <functional>
+#include <sys/types.h>
+#include <vector>
+#include "PenningTrap.hpp"
#include "typedefs.hpp"
-#include "utils.hpp"

Go to the source code of this file.

Detailed Description

@@ -115,8 +117,8 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp.html',''); initResiza
Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Version
0.1
-
Bug:
No known bugs
+
Version
1.0
+
Bug:
No known bugs

Definition in file PenningTrap.cpp.

diff --git a/docs/PenningTrap_8cpp_source.html b/docs/PenningTrap_8cpp_source.html index 282e5c2..eff147a 100644 --- a/docs/PenningTrap_8cpp_source.html +++ b/docs/PenningTrap_8cpp_source.html @@ -102,311 +102,377 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp_source.html',''); ini
Go to the documentation of this file.
1
-
13#include "PenningTrap.hpp"
-
14#include "constants.hpp"
-
15#include "typedefs.hpp"
-
16#include "utils.hpp"
+
13#include <algorithm>
+
14#include <functional>
+
15#include <sys/types.h>
+
16#include <vector>
17
-
18PenningTrap::PenningTrap(double B_0, std::function<double(double)> V_0,
-
19 double d, double t)
-
20{
-
21 this->B_0 = B_0;
-
22 this->V_0 = V_0;
-
23 this->d = d;
-
24 this->t = t;
-
25}
-
26
-
27PenningTrap::PenningTrap(unsigned int i, double B_0,
-
28 std::function<double(double)> V_0, double d, double t)
-
29 : PenningTrap::PenningTrap(B_0, V_0, d)
-
30{
-
31 vec_3d r, v;
-
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;
-
35 this->add_particle(Particle(1., 40., r, v));
-
36 }
-
37}
-
38
-
39PenningTrap::PenningTrap(std::vector<Particle> particles, double B_0,
-
40 std::function<double(double)> V_0, double d, double t)
-
41 : PenningTrap::PenningTrap(B_0, V_0, d)
-
42{
-
43 this->particles = particles;
-
44}
-
45
-
46vec_3d PenningTrap::v_func(unsigned int i, unsigned int j, double dt)
-
47{
-
48 switch (i) {
-
49 case 0:
-
50 return .5 * dt * this->k_v[0][j];
-
51 case 1:
-
52 return .5 * dt * this->k_v[1][j];
-
53 case 2:
-
54 return dt * this->k_v[2][j];
-
55 case 3:
-
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());
-
58 default:
-
59 std::cout << "Not valid!" << std::endl;
-
60 abort();
-
61 }
-
62}
-
63
-
64vec_3d PenningTrap::r_func(unsigned int i, unsigned int j, double dt)
-
65{
-
66 switch (i) {
-
67 case 0:
-
68 return .5 * dt * this->k_r[0][j];
-
69 case 1:
-
70 return .5 * dt * this->k_r[1][j];
-
71 case 2:
-
72 return dt * this->k_r[2][j];
-
73 case 3:
-
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());
-
76 default:
-
77 std::cout << "Not valid!" << std::endl;
-
78 abort();
-
79 }
-
80}
-
81
- -
83{
-
84 this->particles.push_back(particle);
-
85}
+
18#include "PenningTrap.hpp"
+
19#include "typedefs.hpp"
+
20
+
21vec3 PenningTrap::v_func(uint i, uint j, double dt)
+
22{
+
23 switch (i) {
+
24 case 0:
+
25 return .5 * dt * this->k_v[0][j];
+
26 case 1:
+
27 return .5 * dt * this->k_v[1][j];
+
28 case 2:
+
29 return dt * this->k_v[2][j];
+
30 case 3:
+
31 return vec3((dt / 6.)
+
32 * (this->k_v[0][j] + 2. * this->k_v[1][j]
+
33 + 2. * this->k_v[2][j] + this->k_v[3][j]));
+
34 default:
+
35 std::cout << "Not valid!" << std::endl;
+
36 abort();
+
37 }
+
38}
+
39
+
40vec3 PenningTrap::r_func(uint i, uint j, double dt)
+
41{
+
42 switch (i) {
+
43 case 0:
+
44 return .5 * dt * this->k_r[0][j];
+
45 case 1:
+
46 return .5 * dt * this->k_r[1][j];
+
47 case 2:
+
48 return dt * this->k_r[2][j];
+
49 case 3:
+
50 return vec3((dt / 6.)
+
51 * (this->k_r[0][j] + 2. * this->k_r[1][j]
+
52 + 2. * this->k_r[2][j] + this->k_r[3][j]));
+
53 default:
+
54 std::cout << "Not valid!" << std::endl;
+
55 abort();
+
56 }
+
57}
+
58
+ +
60{
+
61 r(2) *= -2.;
+
62
+
63 return vec3(
+
64 ((this->V_0 * this->perturbation(this->t)) / (this->d * this->d)) * r);
+
65}
+
66
+ +
68{
+
69 return vec3{0., 0., this->B_0};
+
70}
+
71
+ +
73{
+
74 // Calculate the difference between the particles' position
+
75 vec3 res = this->particles[i].r_vec - this->particles[j].r_vec;
+
76
+
77 // Get the distance between the particles
+
78 double norm = arma::norm(res, 2);
+
79
+
80 return vec3((this->particles[j].q / (norm * norm * norm)) * res);
+
81}
+
82
+ +
84{
+
85 Particle *p = &this->particles[i];
86
- -
88{
-
89 r(2) *= -2.;
-
90 double f = this->V_0(this->t) / (this->d * this->d);
+
87 return vec3(p->q
+
88 * (this->external_E_field(p->r_vec)
+
89 + arma::cross(p->v_vec, this->external_B_field(p->r_vec))));
+
90}
91
-
92 return f * r;
-
93}
-
94
- -
96{
-
97 return vec_3d{0., 0., this->B_0};
-
98}
-
99
-
100vec_3d PenningTrap::force_on_particle(unsigned int i, unsigned int j)
-
101{
-
102 Particle p_j = this->particles[j];
-
103 // Calculate the difference between the particles' position
-
104 vec_3d res = this->particles[i].r_vec - p_j.r_vec;
-
105
-
106 // Get the distance between the particles
-
107 double norm = arma::norm(res, 2);
-
108
-
109 // Multiply res with p_j's charge divided by the norm cubed
-
110
-
111 return vec_3d(res * p_j.q / (norm * norm * norm));
-
112}
-
113
- -
115{
-
116 Particle p = this->particles[i];
-
117
-
118 if (arma::norm(p.r_vec) > this->d) {
-
119 return vec_3d{0., 0., 0.};
-
120 }
-
121
-
122 vec_3d force =
-
123 p.q * (this->external_E_field(p.r_vec) +
-
124 arma::cross(p.v_vec, this->external_B_field(p.r_vec)));
-
125
-
126 return force;
+ +
93{
+
94 vec3 res;
+
95
+
96 for (size_t j = 0; j < this->particles.size(); j++) {
+
97 if (i != j)
+
98 res += this->force_on_particle(i, j);
+
99 }
+
100
+
101 return vec3(res * (K_E * this->particles[i].q));
+
102}
+
103
+ +
105{
+
106 if (arma::norm(this->particles[i].r_vec) > this->d) {
+
107 return vec3{0., 0., 0.};
+
108 }
+
109 return vec3(this->total_force_external(i) - this->total_force_particles(i));
+
110}
+
111
+ +
113{
+
114 if (arma::norm(this->particles[i].r_vec) > this->d) {
+
115 return vec3{0., 0., 0.};
+
116 }
+
117 return vec3(this->total_force_external(i));
+
118}
+
119
+
120PenningTrap::PenningTrap(double B_0, double V_0, double d, double t)
+
121{
+
122 this->B_0 = B_0;
+
123 this->V_0 = V_0;
+
124 this->d = d;
+
125 this->t = t;
+
126 this->perturbation = [](double t) { return 1.; };
127}
128
- -
130{
-
131 Particle p = this->particles[i];
-
132
-
133 vec_3d res;
-
134
-
135 for (size_t j = 0; j < this->particles.size(); j++) {
-
136 if (i == j) {
-
137 continue;
-
138 }
-
139
-
140 res += this->force_on_particle(i, j);
-
141 }
-
142
-
143 return vec_3d(res * K_E * (p.q / p.m));
+
129PenningTrap::PenningTrap(uint i, double B_0, double V_0, double d, double t)
+
130 : PenningTrap::PenningTrap(B_0, V_0, d)
+
131{
+
132 for (size_t j = 0; j < i; j++) {
+
133 this->particles.push_back(
+
134 Particle(vec3(vec3().randn() * .1 * this->d),
+
135 vec3(vec3().randn() * .1 * this->d)));
+
136 }
+
137}
+
138
+
139PenningTrap::PenningTrap(std::vector<Particle> particles, double B_0,
+
140 double V_0, double d, double t)
+
141 : PenningTrap::PenningTrap(B_0, V_0, d)
+
142{
+
143 this->particles = particles;
144}
145
- +
146void PenningTrap::set_pertubation(double f, double omega_V)
147{
-
148 return this->total_force_external(i) - this->total_force_particles(i);
-
149}
-
150
-
151void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
-
152{
-
153
-
154 std::vector<Particle> original_particles = this->particles;
-
155 std::vector<Particle> tmp_particles = this->particles;
-
156
-
157 vec_3d (PenningTrap::*force)(unsigned int);
-
158 if (particle_interaction) {
- -
160 }
-
161 else {
- +
148 this->perturbation = [f, omega_V](double t) {
+
149 return 1 + f * std::cos(omega_V * t);
+
150 };
+
151}
+
152
+
153void PenningTrap::reinitialize(double f, double omega_V, double t)
+
154{
+
155 this->t = t;
+
156 this->set_pertubation(f, omega_V);
+
157 Particle *p;
+
158
+
159 for (size_t i = 0; i < this->particles.size(); i++) {
+
160 p = &this->particles[i];
+
161 p->r_vec = vec3().randn() * .1 * this->d;
+
162 p->v_vec = vec3().randn() * .1 * this->d;
163 }
-
164
-
165 size_t size = this->particles.size();
-
166
-
167 this->k_v = sim_arr(4, sim_cols(size));
-
168 this->k_r = sim_arr(4, sim_cols(size));
-
169
-
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;
-
175
-
176 Particle *p = &tmp_particles[j];
-
177
-
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);
-
180 }
-
181 this->particles = tmp_particles;
-
182 }
-
183 this->t += dt;
-
184}
-
185
-
186void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction)
-
187{
-
188 std::vector<Particle> new_state = this->particles;
-
189
-
190 Particle *p;
+
164}
+
165
+ +
167{
+
168 this->particles.push_back(particle);
+
169}
+
170
+
171void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
+
172{
+
173 Particle *p;
+
174
+
175 // Keep original particles
+
176 std::vector<Particle> original_particles = this->particles;
+
177 std::vector<Particle> tmp_particles = this->particles;
+
178
+
179 vec3 (PenningTrap::*force)(uint) =
+
180 particle_interaction ? &PenningTrap::total_force
+ +
182
+
183 size_t size = this->particles.size();
+
184
+
185 // Allocating takes a long time, so reuse sim_arr if possible
+
186 if (this->k_v.size() != 4 || this->k_r.size() != 4
+
187 || this->k_v[0].size() != size || this->k_r[0].size() != size) {
+
188 this->k_v = sim_arr(4, sim_cols(size));
+
189 this->k_r = sim_arr(4, sim_cols(size));
+
190 }
191
-
192 vec_3d (PenningTrap::*force)(unsigned int);
-
193 if (particle_interaction) {
- -
195 }
-
196 else {
- -
198 }
+
192 // Each k_{i+1} is dependent on k_i, so outer loop is not parallelizable
+
193 for (size_t i = 0; i < 4; i++) {
+
194 // Inner loop is able to be parallelized
+
195#pragma omp parallel for private(p)
+
196 for (size_t j = 0; j < size; j++) {
+
197 this->k_v[i][j] = (this->*force)(j) / this->particles[j].m;
+
198 this->k_r[i][j] = this->particles[j].v_vec;
199
-
200#pragma omp parallel for private(p)
-
201 for (size_t i = 0; i < this->particles.size(); i++) {
-
202 p = &new_state[i];
-
203 p->v_vec += dt * (this->*force)(i) / p->m;
-
204 p->r_vec += dt * this->particles[i].v_vec;
-
205 }
-
206
-
207 this->particles = new_state;
+
200 p = &tmp_particles[j];
+
201
+
202 p->v_vec = original_particles[j].v_vec + this->v_func(i, j, dt);
+
203 p->r_vec = original_particles[j].r_vec + this->r_func(i, j, dt);
+
204 }
+
205 this->particles = tmp_particles;
+
206 }
+
207
208 this->t += dt;
209}
210
-
211sim_arr PenningTrap::simulate(double time, unsigned int steps,
-
212 std::string method, bool particle_interaction)
-
213{
-
214 double dt = time / (double)steps;
-
215
-
216 sim_arr res(this->particles.size(), sim_cols(steps));
-
217
-
218 void (PenningTrap::*func)(double, bool);
-
219 if (method == "rk4") {
- -
221 }
-
222 else if (method == "euler") {
- -
224 }
-
225 else {
-
226 std::cout << "Not a valid method!" << std::endl;
-
227 abort();
-
228 }
-
229
-
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;
-
233 }
-
234 (this->*func)(dt, particle_interaction);
+
211void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction)
+
212{
+
213 size_t size = this->particles.size();
+
214 vec3 force_res[size];
+
215 Particle *p;
+
216
+
217 vec3 (PenningTrap::*force)(uint) =
+
218 particle_interaction ? &PenningTrap::total_force
+ +
220
+
221 // Calculating the force for each particle is independent and therefore
+
222 // a good candidate for parallel execution
+
223#pragma omp parallel for
+
224 for (size_t i = 0; i < size; i++) {
+
225 force_res[i] = (this->*force)(i);
+
226 }
+
227
+
228 // Updating the particles is also independent, so we can parallelize
+
229 // this as well
+
230#pragma omp parallel for
+
231 for (size_t i = 0; i < size; i++) {
+
232 p = &this->particles[i];
+
233 p->r_vec += dt * p->v_vec;
+
234 p->v_vec += dt * force_res[i] / p->m;
235 }
236
-
237 return res;
+
237 this->t += dt;
238}
239
-
240void PenningTrap::write_simulation_to_dir(std::string path, double time,
-
241 int steps, std::string method,
-
242 bool particle_interaction)
-
243{
-
244 if (path.back() != '/') {
-
245 path += '/';
-
246 }
-
247 if (mkpath(path, 0777) != 0) {
-
248 std::cout << "Hello" << std::endl;
-
249 return;
-
250 }
-
251
-
252 sim_arr res = this->simulate(time, steps, method, particle_interaction);
-
253
-
254 std::ofstream ofile;
-
255
-
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";
-
261 }
-
262 ofile.close();
-
263 }
-
264}
-
265
-
266double PenningTrap::fraction_of_particles_left(double time, unsigned int steps, std::string method, bool particle_interaction)
-
267{
-
268 sim_arr res = this->simulate(time, steps, method, particle_interaction);
+
240simulation_t PenningTrap::simulate(double time, uint steps, std::string method,
+
241 bool particle_interaction)
+
242{
+
243 Particle *p;
+
244 double dt = time / (double)steps;
+
245
+
246 uint size = this->particles.size();
+
247
+
248 simulation_t res{sim_arr(size, sim_cols(steps)),
+
249 sim_arr(size, sim_cols(steps))};
+
250
+
251 void (PenningTrap::*func)(double, bool);
+
252 if (method == "rk4") {
+ +
254 } else if (method == "euler") {
+ +
256 } else {
+
257 std::cout << "Not a valid method!" << std::endl;
+
258 abort();
+
259 }
+
260
+
261 for (size_t j = 0; j < steps; j++) {
+
262 for (size_t i = 0; i < size; i++) {
+
263 p = &this->particles[i];
+
264 res.r_vecs[i][j] = p->r_vec;
+
265 res.v_vecs[i][j] = p->v_vec;
+
266 }
+
267 (this->*func)(dt, particle_interaction);
+
268 }
269
-
270 int particles_left = 0;
-
271
-
272 for (Particle p : this->particles) {
-
273 if (arma::norm(p.r_vec) < this->d) {
-
274 particles_left++;
-
275 }
-
276 }
-
277
-
278 return (double) particles_left / (double) this->particles.size();
-
279}
-
280
+
270 return res;
+
271}
+
272
+
273void PenningTrap::write_simulation_to_dir(std::string path, double time,
+
274 uint steps, std::string method,
+
275 bool particle_interaction)
+
276{
+
277 if (path.back() != '/') {
+
278 path += '/';
+
279 }
+
280 if (mkpath(path, 0777) != 0) {
+
281 std::cout << "Failed to make path" << std::endl;
+
282 abort();
+
283 }
+
284
+
285 simulation_t res =
+
286 this->simulate(time, steps, method, particle_interaction);
+
287
+
288 std::ofstream ofile;
+
289
+
290 // Writing each particle to its own file is independent and can be run in
+
291 // parallel.
+
292#pragma omp parallel for private(ofile)
+
293 for (size_t i = 0; i < this->particles.size(); i++) {
+
294 ofile.open(path + "particle_" + std::to_string(i) + "_r.txt");
+
295 for (vec3 &vec : res.r_vecs[i]) {
+
296 ofile << scientific_format(vec(0), 10, 8) << ','
+
297 << scientific_format(vec(1), 10, 8) << ','
+
298 << scientific_format(vec(2), 10, 8) << '\n';
+
299 }
+
300 ofile.close();
+
301 ofile.open(path + "particle_" + std::to_string(i) + "_v.txt");
+
302 for (vec3 &vec : res.v_vecs[i]) {
+
303 ofile << scientific_format(vec(0), 10, 8) << ','
+
304 << scientific_format(vec(1), 10, 8) << ','
+
305 << scientific_format(vec(2), 10, 8) << '\n';
+
306 }
+
307 ofile.close();
+
308 }
+
309}
+
310
+
311double PenningTrap::fraction_of_particles_left(double time, uint steps,
+
312 std::string method,
+
313 bool particle_interaction)
+
314{
+
315 double dt = time / (double)steps;
+
316
+
317 void (PenningTrap::*func)(double, bool);
+
318 if (method == "rk4") {
+ +
320 } else if (method == "euler") {
+ +
322 } else {
+
323 std::cout << "Not a valid method!" << std::endl;
+
324 abort();
+
325 }
+
326
+
327 for (size_t j = 0; j < steps; j++) {
+
328 (this->*func)(dt, particle_interaction);
+
329 }
+
330
+
331 int particles_left = 0;
+
332
+
333 // A reduction is perfect here
+
334#pragma omp parallel for reduction(+ : particles_left)
+
335 for (size_t i = 0; i < this->particles.size(); i++) {
+
336 if (arma::norm(this->particles[i].r_vec) < this->d) {
+
337 particles_left++;
+
338 }
+
339 }
+
340
+
341 return (double)particles_left / (double)this->particles.size();
+
342}
A class for simulating a Penning trap.
-
A class that holds attributes of a particle.
Definition: Particle.hpp:21
-
double q
Charge.
Definition: Particle.hpp:23
-
vec_3d v_vec
velocity
Definition: Particle.hpp:26
-
double m
Mass.
Definition: Particle.hpp:24
-
vec_3d r_vec
position
Definition: Particle.hpp:25
-
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:30
-
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:36
-
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.
Definition: PenningTrap.hpp:32
-
vec_3d external_E_field(vec_3d r)
Calculate E at point r.
Definition: PenningTrap.cpp:87
-
vec_3d total_force(unsigned int i)
calculate the total force on a particle p_i.
-
sim_arr k_r
Definition: PenningTrap.hpp:39
-
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.
Definition: PenningTrap.cpp:64
-
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.
Definition: PenningTrap.hpp:34
-
void add_particle(Particle particle)
Add a particle to the system.
Definition: PenningTrap.cpp:82
-
double t
Current time.
Definition: PenningTrap.hpp:35
-
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.
Definition: PenningTrap.hpp:33
-
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.
Definition: PenningTrap.cpp:95
-
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.
Definition: PenningTrap.cpp:18
-
vec_3d total_force_external(unsigned int i)
Calculate the total external force on a particle.
-
sim_arr k_v
Definition: PenningTrap.hpp:37
-
vec_3d v_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:46
-
Library of constants.
-
#define K_E
Coulomb constant. unit: .
Definition: constants.hpp:15
+
A class that holds attributes of a particle.
Definition: Particle.hpp:23
+
vec3 r_vec
position
Definition: Particle.hpp:25
+
vec3 v_vec
velocity
Definition: Particle.hpp:26
+
double q
Charge.
Definition: Particle.hpp:27
+
double m
Mass.
Definition: Particle.hpp:28
+
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:32
+
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:42
+
double B_0
Magnetic field strength.
Definition: PenningTrap.hpp:37
+
vec3 total_force_external(uint i)
Calculate the total external force on a particle.
Definition: PenningTrap.cpp:83
+
sim_arr k_r
A 2D vector containing all where is the index of a particle.
Definition: PenningTrap.hpp:52
+
vec3 total_force_particles(uint i)
Calculate the total force on a particle p_i from other particles.
Definition: PenningTrap.cpp:92
+
vec3 external_B_field(vec3 r)
Calculate B at point r.
Definition: PenningTrap.cpp:67
+
void evolve_RK4(double dt, bool particle_interaction=true)
Go forward one timestep using the RK4 method.
+
vec3 v_func(uint i, uint j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:21
+
vec3 external_E_field(vec3 r)
Calculate E at point r.
Definition: PenningTrap.cpp:59
+
PenningTrap(double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)
Constructor for the PenningTrap class.
+
vec3 total_force_no_interaction(uint i)
calculate the total force on a particle p_i without interaction
+
double d
Characteristic dimension.
Definition: PenningTrap.hpp:40
+
void add_particle(Particle particle)
Add a particle to the system.
+
double V_0
Applied potential.
Definition: PenningTrap.hpp:38
+
simulation_t simulate(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate the particle system inside the Penning trap over a certain amount of time.
+
vec3 force_on_particle(uint i, uint j)
Calculate the force between 2 particles.
Definition: PenningTrap.cpp:72
+
vec3 r_func(uint i, uint j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:40
+
double t
Current time.
Definition: PenningTrap.hpp:41
+
vec3 total_force(uint i)
calculate the total force on a particle p_i.
+
void set_pertubation(double f, double omega_V)
Time dependent perturbation to V_0.
+
void reinitialize(double f, double omega_V, double t=0.)
Give all particles new positions and velocities, and change t and V_0.
+
void evolve_forward_euler(double dt, bool particle_interaction=true)
Go forward one timestep using the forward Euler method.
+
double fraction_of_particles_left(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
+
void write_simulation_to_dir(std::string path, double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate and write the displacement of all particles to files.
+
std::function< double(double)> perturbation
Time-dependent perturbation.
Definition: PenningTrap.hpp:39
+
sim_arr k_v
A 2D vector containing all where is the index of a particle.
Definition: PenningTrap.hpp:47
+
#define K_E
Coulomb constant. unit: .
Definition: constants.hpp:17
+
Typedef for PenningTrap::simulation return value.
Definition: typedefs.hpp:40
Useful typedefs for cleaner code.
-
std::vector< arma::vec::fixed< 3 > > sim_cols
Typedef for the column of the result vector from simulating particles.
Definition: typedefs.hpp:24
-
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:36
-
std::vector< sim_cols > sim_arr
Typedef for the result of the simulate method.
Definition: typedefs.hpp:32
-
Function prototypes and macros that are useful.
-
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:76
+
arma::vec::fixed< 3 > vec3
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:23
+
std::vector< vec3 > sim_cols
Typedef for the column of the result vector from simulating particles.
Definition: typedefs.hpp:28
+
std::vector< sim_cols > sim_arr
Typedef for the result of the simulate method.
Definition: typedefs.hpp:36
+
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:72
+
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
Definition: utils.cpp:15
diff --git a/docs/PenningTrap_8hpp.html b/docs/PenningTrap_8hpp.html index 5f6ee45..e0d2a31 100644 --- a/docs/PenningTrap_8hpp.html +++ b/docs/PenningTrap_8hpp.html @@ -111,6 +111,7 @@ $(document).ready(function(){initNavTree('PenningTrap_8hpp.html',''); initResiza #include "Particle.hpp"
#include "constants.hpp"
#include "typedefs.hpp"
+#include "utils.hpp"

Go to the source code of this file.

@@ -125,7 +126,7 @@ Classes
Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Version
0.1
+
Version
1.0
Bug:
No known bugs

Definition in file PenningTrap.hpp.

diff --git a/docs/PenningTrap_8hpp_source.html b/docs/PenningTrap_8hpp_source.html index dfdddbe..9c94007 100644 --- a/docs/PenningTrap_8hpp_source.html +++ b/docs/PenningTrap_8hpp_source.html @@ -111,105 +111,115 @@ $(document).ready(function(){initNavTree('PenningTrap_8hpp_source.html',''); ini
18#include "Particle.hpp"
19#include "constants.hpp"
20#include "typedefs.hpp"
-
21
-
22#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
-
23 initializer(omp_priv = omp_orig)
-
24
- -
31private:
-
32 double B_0;
-
33 std::function<double(double)> V_0;
-
34 double d;
-
35 double t;
-
36 std::vector<Particle> particles;
- - -
41
-
52 vec_3d v_func(unsigned int i, unsigned int j, double dt);
+
21#include "utils.hpp"
+
22
+
23#pragma omp declare reduction(+ : vec3 : omp_out += omp_in) \
+
24 initializer(omp_priv = omp_orig)
+
25
+ +
32{
+
35 friend class PenningTrapTest;
+
36private:
+
37 double B_0;
+
38 double V_0;
+
39 std::function<double(double)> perturbation;
+
40 double d;
+
41 double t;
+
42 std::vector<Particle> particles;
+
43
+ +
48
+
53
-
64 vec_3d r_func(unsigned int i, unsigned int j, double dt);
+
64 vec3 v_func(uint i, uint j, double dt);
65
-
66public:
- -
75 double B_0 = T,
-
76 std::function<double(double)> V_0 =
-
77 [](double t) { return 25. * V / 1000.; },
-
78 double d = 500., double t = 0.);
-
79
- -
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.);
+
76 vec3 r_func(uint i, uint j, double dt);
+
77
+ +
85
+
93
- -
103 std::vector<Particle> particles, double B_0 = T,
-
104 std::function<double(double)> V_0 =
-
105 [](double t) { return 25. * V / 1000.; },
-
106 double d = 500., double t = 0.);
-
107
-
112 void add_particle(Particle particle);
-
113
- -
121
- -
129
-
140 vec_3d force_on_particle(unsigned int i, unsigned int j);
+
104 vec3 force_on_particle(uint i, uint j);
+
105
+ +
116
+ +
125
+
132 vec3 total_force(uint i);
+
133
+
141
-
151 vec_3d total_force_external(unsigned int i);
+
142public:
+
150 PenningTrap(double B_0 = T, double V_0 = (25. * V) / 1000., double d = 500.,
+
151 double t = 0.);
152
-
159 vec_3d total_force_particles(unsigned int i);
-
160
-
167 vec_3d total_force(unsigned int i);
-
168
-
174 void evolve_RK4(double dt, bool particle_interaction = true);
-
175
-
181 void evolve_forward_euler(double dt, bool particle_interaction = true);
-
182
-
191 sim_arr simulate(double time, unsigned int steps,
-
192 std::string method = "rk4",
-
193 bool particle_interaction = true);
-
194
-
203 void write_simulation_to_dir(std::string path, double time,
-
204 unsigned int steps, std::string method = "rk4",
-
205 bool particle_interaction = true);
-
206
-
217 double fraction_of_particles_left(double time, unsigned int steps,
-
218 std::string method = "rk4",
-
219 bool particle_interaction = true);
-
220};
-
221
-
222#endif
+
161 PenningTrap(uint i, double B_0 = T, double V_0 = (25. * V) / 1000.,
+
162 double d = 500., double t = 0.);
+
163
+
172 PenningTrap(std::vector<Particle> particles, double B_0 = T,
+
173 double V_0 = (25. * V) / 1000., double d = 500., double t = 0.);
+
174
+
180 void set_pertubation(double f, double omega_V);
+
181
+
188 void reinitialize(double f, double omega_V, double t = 0.);
+
189
+
194 void add_particle(Particle particle);
+
195
+
201 void evolve_RK4(double dt, bool particle_interaction = true);
+
202
+
208 void evolve_forward_euler(double dt, bool particle_interaction = true);
+
209
+
220 simulation_t simulate(double time, uint steps, std::string method = "rk4",
+
221 bool particle_interaction = true);
+
222
+
231 void write_simulation_to_dir(std::string path, double time, uint steps,
+
232 std::string method = "rk4",
+
233 bool particle_interaction = true);
+
234
+
245 double fraction_of_particles_left(double time, uint steps,
+
246 std::string method = "rk4",
+
247 bool particle_interaction = true);
+
248
+
249};
+
250
+
251#endif
A class that holds the properties of a particle.
-
A class that holds attributes of a particle.
Definition: Particle.hpp:21
-
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:30
-
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:36
-
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.
Definition: PenningTrap.hpp:32
-
vec_3d external_E_field(vec_3d r)
Calculate E at point r.
Definition: PenningTrap.cpp:87
-
vec_3d total_force(unsigned int i)
calculate the total force on a particle p_i.
-
sim_arr k_r
Definition: PenningTrap.hpp:39
-
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.
Definition: PenningTrap.cpp:64
-
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.
Definition: PenningTrap.hpp:34
-
void add_particle(Particle particle)
Add a particle to the system.
Definition: PenningTrap.cpp:82
-
double t
Current time.
Definition: PenningTrap.hpp:35
-
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.
Definition: PenningTrap.hpp:33
-
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.
Definition: PenningTrap.cpp:95
-
vec_3d total_force_external(unsigned int i)
Calculate the total external force on a particle.
-
sim_arr k_v
Definition: PenningTrap.hpp:37
-
vec_3d v_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:46
+
A class that holds attributes of a particle.
Definition: Particle.hpp:23
+
Test class for the Penning trap.
Definition: test_suite.cpp:24
+
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:32
+
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:42
+
double B_0
Magnetic field strength.
Definition: PenningTrap.hpp:37
+
vec3 total_force_external(uint i)
Calculate the total external force on a particle.
Definition: PenningTrap.cpp:83
+
sim_arr k_r
A 2D vector containing all where is the index of a particle.
Definition: PenningTrap.hpp:52
+
vec3 total_force_particles(uint i)
Calculate the total force on a particle p_i from other particles.
Definition: PenningTrap.cpp:92
+
vec3 external_B_field(vec3 r)
Calculate B at point r.
Definition: PenningTrap.cpp:67
+
void evolve_RK4(double dt, bool particle_interaction=true)
Go forward one timestep using the RK4 method.
+
vec3 v_func(uint i, uint j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:21
+
vec3 external_E_field(vec3 r)
Calculate E at point r.
Definition: PenningTrap.cpp:59
+
vec3 total_force_no_interaction(uint i)
calculate the total force on a particle p_i without interaction
+
double d
Characteristic dimension.
Definition: PenningTrap.hpp:40
+
void add_particle(Particle particle)
Add a particle to the system.
+
double V_0
Applied potential.
Definition: PenningTrap.hpp:38
+
simulation_t simulate(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate the particle system inside the Penning trap over a certain amount of time.
+
vec3 force_on_particle(uint i, uint j)
Calculate the force between 2 particles.
Definition: PenningTrap.cpp:72
+
vec3 r_func(uint i, uint j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:40
+
double t
Current time.
Definition: PenningTrap.hpp:41
+
vec3 total_force(uint i)
calculate the total force on a particle p_i.
+
void set_pertubation(double f, double omega_V)
Time dependent perturbation to V_0.
+
void reinitialize(double f, double omega_V, double t=0.)
Give all particles new positions and velocities, and change t and V_0.
+
void evolve_forward_euler(double dt, bool particle_interaction=true)
Go forward one timestep using the forward Euler method.
+
double fraction_of_particles_left(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
+
void write_simulation_to_dir(std::string path, double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate and write the displacement of all particles to files.
+
std::function< double(double)> perturbation
Time-dependent perturbation.
Definition: PenningTrap.hpp:39
+
sim_arr k_v
A 2D vector containing all where is the index of a particle.
Definition: PenningTrap.hpp:47
Library of constants.
-
#define T
1 Tesla. unit:
Definition: constants.hpp:17
-
#define V
1 Volt. unit:
Definition: constants.hpp:19
+
#define T
1 Tesla. unit:
Definition: constants.hpp:21
+
#define V
1 Volt. unit:
Definition: constants.hpp:25
+
Typedef for PenningTrap::simulation return value.
Definition: typedefs.hpp:40
Useful typedefs for cleaner code.
-
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:36
-
std::vector< sim_cols > sim_arr
Typedef for the result of the simulate method.
Definition: typedefs.hpp:32
+
arma::vec::fixed< 3 > vec3
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:23
+
std::vector< sim_cols > sim_arr
Typedef for the result of the simulate method.
Definition: typedefs.hpp:36
+
Function prototypes and macros that are useful.
diff --git a/docs/animate__100__particles_8py.html b/docs/animate__100__particles_8py.html new file mode 100644 index 0000000..dc312cc --- /dev/null +++ b/docs/animate__100__particles_8py.html @@ -0,0 +1,216 @@ + + + + + + + +Penning Trap Simulation: src/scripts/animate_100_particles.py File Reference + + + + + + + + + + + + + + + + +
+
+
+ + + + + +
+
Penning Trap Simulation +
+
Simulate particle behavior inside a Penning Trap
+
+ + + + + + + + + +
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
animate_100_particles.py File Reference
+
+
+ +

Animate 100 particles. +More...

+ +

Go to the source code of this file.

+ + + + + + + + +

+Functions

def animate_100_particles.get_data (files)
 
def animate_100_particles.update (num, lines, arr)
 
def animate_100_particles.animate ()
 
+

Detailed Description

+

Animate 100 particles.

+
Author
Cory Alexander Balaton (coryab)
+
+Janita Ovidie Sandtrøen Willumsen (janitaws)
+
Version
1.0
+
Bug:
No known bugs
+ +

Definition in file animate_100_particles.py.

+

Function Documentation

+ +

◆ animate()

+ +
+
+ + + + + + + +
def animate_100_particles.animate ()
+
+ +

Definition at line 41 of file animate_100_particles.py.

+ +
+
+ +

◆ get_data()

+ +
+
+ + + + + + + + +
def animate_100_particles.get_data ( files)
+
+ +

Definition at line 18 of file animate_100_particles.py.

+ +
+
+ +

◆ update()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
def animate_100_particles.update ( num,
 lines,
 arr 
)
+
+ +

Definition at line 35 of file animate_100_particles.py.

+ +
+
+
+
+ + + + diff --git a/docs/animate__100__particles_8py_source.html b/docs/animate__100__particles_8py_source.html index af734ca..d99bdbd 100644 --- a/docs/animate__100__particles_8py_source.html +++ b/docs/animate__100__particles_8py_source.html @@ -5,7 +5,7 @@ -Penning Trap Simulation: src/animate_100_particles.py Source File +Penning Trap Simulation: src/scripts/animate_100_particles.py Source File @@ -101,83 +101,84 @@ $(document).ready(function(){initNavTree('animate__100__particles_8py_source.htm
animate_100_particles.py
-
1import matplotlib.pyplot as plt
-
2import numpy as np
-
3from matplotlib import animation
-
4from mpl_toolkits.mplot3d import Axes3D
-
5
-
6
-
7def get_data(files):
-
8 res = []
-
9 for file in files:
-
10 arr = [[], [], []]
-
11 with open(file, encoding="utf8") as f:
-
12 lines = f.readlines()
-
13
-
14 for line in lines:
-
15 xi, yi, zi = map(float, line.strip().split(","))
-
16 arr[0].append(xi)
-
17 arr[1].append(yi)
-
18 arr[2].append(zi)
-
19 res.append(arr)
-
20
-
21 return np.array(res)
-
22
-
23
-
24def 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])
-
28
-
29
-
30def animate():
-
31 plt.style.use("dark_background")
-
32 fig = plt.figure()
-
33 ax = fig.add_subplot(projection="3d")
+Go to the documentation of this file.
1
+
11
+
12import matplotlib.pyplot as plt
+
13import numpy as np
+
14from matplotlib import animation
+
15from mpl_toolkits.mplot3d import Axes3D
+
16
+
17
+
18def get_data(files):
+
19 res = []
+
20 for file in files:
+
21 arr = [[], [], []]
+
22 with open(file, encoding="utf8") as f:
+
23 lines = f.readlines()
+
24
+
25 for line in lines:
+
26 xi, yi, zi = map(float, line.strip().split(","))
+
27 arr[0].append(xi)
+
28 arr[1].append(yi)
+
29 arr[2].append(zi)
+
30 res.append(arr)
+
31
+
32 return np.array(res)
+
33
34
-
35 arr = get_data([f"output/simulate_100_particles/particle_{i}.txt" for i in range(100)])
-
36
-
37 arr = arr[:, :, ::10]
-
38
-
39 N = len(arr[0][0])
+
35def update(num, lines, arr):
+
36 for line, a in zip(lines, arr):
+
37 line.set_data(a[:2, num - 1 : num])
+
38 line.set_3d_properties(a[2, num])
+
39
40
-
41 lines = [ax.plot(*a[:, 1], "o")[0] for a in arr]
-
42
-
43 ax.set_title("100 particles inside a Penning trap")
-
44 plt.figtext(
-
45 0.5,
-
46 0.01,
-
47 "100 randomly generated particles "
-
48 "evolving over a time of 50 microseconds.",
-
49 fontsize=12,
-
50 horizontalalignment="center",
-
51 )
-
52
-
53 ax.set_xlim3d([-500.0, 500.0])
-
54 ax.set_xlabel("X (micrometers)")
-
55
-
56 ax.set_ylim3d([-500.0, 500.0])
-
57 ax.set_ylabel("Y (micrometers)")
-
58
-
59 ax.set_zlim3d([-500.0, 500.0])
-
60 ax.set_zlabel("Z (micrometers)")
-
61
-
62 ani = animation.FuncAnimation(
-
63 fig, update, N, fargs=(lines, arr), interval=1, blit=False
-
64 )
-
65
-
66 # ani.save("../images/100_particles.gif", writer=animation.FFMpegFileWriter(fps=50))
-
67 plt.show()
-
68
+
41def animate():
+
42 plt.style.use("dark_background")
+
43 fig = plt.figure()
+
44 ax = fig.add_subplot(projection="3d")
+
45
+
46 arr = get_data([f"output/simulate_100_particles/particle_{i}_r.txt" for i in range(100)])
+
47
+
48 arr = arr[:, :, ::40]
+
49
+
50 N = len(arr[0][0])
+
51
+
52 lines = [ax.plot(*a[:, 1], "o")[0] for a in arr]
+
53
+
54 ax.set_title("100 particles inside a Penning trap")
+
55 plt.figtext(
+
56 0.5,
+
57 0.01,
+
58 "100 randomly generated particles "
+
59 "evolving over a time of 50 microseconds.",
+
60 fontsize=12,
+
61 horizontalalignment="center",
+
62 )
+
63
+
64 ax.set_xlim3d([-500.0, 500.0])
+
65 ax.set_xlabel("X (micrometers)")
+
66
+
67 ax.set_ylim3d([-500.0, 500.0])
+
68 ax.set_ylabel("Y (micrometers)")
69
-
70if __name__ == "__main__":
-
71 animate()
+
70 ax.set_zlim3d([-500.0, 500.0])
+
71 ax.set_zlabel("Z (micrometers)")
+
72
+
73 ani = animation.FuncAnimation(
+
74 fig, update, N, fargs=(lines, arr), interval=1, blit=False
+
75 )
+
76
+
77 ani.save("../images/100_particles.gif", writer=animation.FFMpegFileWriter(fps=50))
+
78
+
79
+
80if __name__ == "__main__":
+
81 animate()
diff --git a/docs/annotated.html b/docs/annotated.html index fdee9b2..323b2f9 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -105,7 +105,8 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable(); - + +
 CParticleA class that holds attributes of a particle
 CPenningTrapA class that simulates a Penning trap
 CPenningTrapTest
 CPenningTrapTestTest class for the Penning trap
 CsimulationTypedef for PenningTrap::simulation return value
diff --git a/docs/annotated_dup.js b/docs/annotated_dup.js index 574cc6b..37a2cab 100644 --- a/docs/annotated_dup.js +++ b/docs/annotated_dup.js @@ -2,5 +2,6 @@ var annotated_dup = [ [ "Particle", "classParticle.html", "classParticle" ], [ "PenningTrap", "classPenningTrap.html", "classPenningTrap" ], - [ "PenningTrapTest", "classPenningTrapTest.html", null ] + [ "PenningTrapTest", "classPenningTrapTest.html", "classPenningTrapTest" ], + [ "simulation", "structsimulation.html", null ] ]; \ No newline at end of file diff --git a/docs/bug.html b/docs/bug.html index 8ed5241..4d780bc 100644 --- a/docs/bug.html +++ b/docs/bug.html @@ -102,24 +102,40 @@ $(document).ready(function(){initNavTree('bug.html',''); initResizable(); });
+
File animate_100_particles.py
+
No known bugs
File constants.hpp
No known bugs
-
File main.cpp
+
File frequency_narrow_sweeps_long.cpp
No known bugs
-
File Particle.cpp
+
File main.cpp
No known bugs
+
File Particle.cpp
+
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 plot_2_particles.py
+
No known bugs
+
File plot_3d.py
+
No known bugs
+
File plot_particles_left.py
+
No known bugs
+
File plot_phase_space.py
+
No known bugs
+
File plot_relative_error.py
+
No known bugs
+
File plot_single_particle.py
+
No known bugs
File test_suite.cpp
-
No known bugs
+
No known bugs
File typedefs.hpp
No known bugs
File utils.cpp
-
No known bugs
+
No known bugs
File utils.hpp
No known bugs
diff --git a/docs/classParticle-members.html b/docs/classParticle-members.html index b3fc92b..2bb47b5 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.

- + - - + +
mParticleprivate
Particle(double q, double m, vec_3d r_vec, vec_3d v_vec)Particle
Particle(vec3 r_vec, vec3 v_vec, double q=CA_CHARGE, double m=CA_MASS)Particle
PenningTrapParticlefriend
qParticleprivate
r_vecParticleprivate
v_vecParticleprivate
r_vecParticleprivate
v_vecParticleprivate
diff --git a/docs/classParticle.html b/docs/classParticle.html index 271a213..c413211 100644 --- a/docs/classParticle.html +++ b/docs/classParticle.html @@ -114,24 +114,24 @@ $(document).ready(function(){initNavTree('classParticle.html',''); initResizable - - - + + +

Public Member Functions

 Particle (double q, double m, vec_3d r_vec, vec_3d v_vec)
 Initialize the particle.
 
 Particle (vec3 r_vec, vec3 v_vec, double q=CA_CHARGE, double m=CA_MASS)
 Initialize the particle.
 
+ + + + + + - - - - - -

Private Attributes

vec3 r_vec
 position
 
vec3 v_vec
 velocity
 
double q
 Charge.
 
double m
 Mass.
 
vec_3d r_vec
 position
 
vec_3d v_vec
 velocity
 
@@ -142,10 +142,10 @@ Friends

Detailed Description

A class that holds attributes of a particle.

-

Definition at line 21 of file Particle.hpp.

+

Definition at line 22 of file Particle.hpp.

Constructor & Destructor Documentation

- -

◆ Particle()

+ +

◆ Particle()

@@ -153,26 +153,26 @@ Friends
- - - - - - - - - - - - - + - - + + + + + + + + + + + + + + @@ -221,7 +221,7 @@ Friends

Make private attributes available for PenningTrap.

-

Definition at line 43 of file Particle.hpp.

+

Definition at line 45 of file Particle.hpp.

@@ -248,7 +248,7 @@ Friends

Mass.

-

Definition at line 24 of file Particle.hpp.

+

Definition at line 28 of file Particle.hpp.

@@ -274,12 +274,12 @@ Friends

Charge.

-

Definition at line 23 of file Particle.hpp.

+

Definition at line 27 of file Particle.hpp.

- -

◆ r_vec

+ +

◆ r_vec

@@ -288,7 +288,7 @@ Friends
@@ -304,8 +304,8 @@ Friends - -

◆ v_vec

+ +

◆ v_vec

@@ -314,7 +314,7 @@ Friends
diff --git a/docs/classParticle.js b/docs/classParticle.js index 71255c1..9ffef17 100644 --- a/docs/classParticle.js +++ b/docs/classParticle.js @@ -1,9 +1,9 @@ var classParticle = [ - [ "Particle", "classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4", null ], + [ "Particle", "classParticle.html#af1d7535fb8311eaa77d2b7b345882ec4", null ], [ "PenningTrap", "classParticle.html#aa797d319549dc2a0beb06cdbfd430232", null ], [ "m", "classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563", null ], [ "q", "classParticle.html#a566dcc1de4bdc01251776948798ea8e1", null ], - [ "r_vec", "classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6", null ], - [ "v_vec", "classParticle.html#a879692772803d6ab65fa4993b54aea6e", null ] + [ "r_vec", "classParticle.html#a1c59101411db43624828b766f87ad460", null ], + [ "v_vec", "classParticle.html#a3a10400add8dd22b8031330c2aafb6fe", null ] ]; \ No newline at end of file diff --git a/docs/classPenningTrap-members.html b/docs/classPenningTrap-members.html index 859c052..7e5d5c4 100644 --- a/docs/classPenningTrap-members.html +++ b/docs/classPenningTrap-members.html @@ -109,25 +109,30 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza - - - - + + + + - - - - - + + + + + + + + + - - - - - - + + + + + + +

Friends

Particle::Particle (double q,
double m,
vec_3d vec3  r_vec,
vec_3d v_vec vec3 v_vec,
double q = CA_CHARGE,
double m = CA_MASS 
- +
vec_3d Particle::r_vecvec3 Particle::r_vec
- +
vec_3d Particle::v_vecvec3 Particle::v_vec
dPenningTrapprivate
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
external_B_field(vec3 r)PenningTrapprivate
external_E_field(vec3 r)PenningTrapprivate
force_on_particle(uint i, uint j)PenningTrapprivate
fraction_of_particles_left(double time, uint steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
k_rPenningTrapprivate
k_vPenningTrapprivate
particlesPenningTrapprivate
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)PenningTrapprivate
simulate(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
PenningTrap(double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)PenningTrap
PenningTrap(uint i, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)PenningTrap
PenningTrap(std::vector< Particle > particles, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)PenningTrap
PenningTrapTestPenningTrapfriend
perturbationPenningTrapprivate
r_func(uint i, uint j, double dt)PenningTrapprivate
reinitialize(double f, double omega_V, double t=0.)PenningTrap
set_pertubation(double f, double omega_V)PenningTrap
simulate(double time, uint steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
tPenningTrapprivate
total_force(unsigned int i)PenningTrap
total_force_external(unsigned int i)PenningTrap
total_force_particles(unsigned int i)PenningTrap
V_0PenningTrapprivate
v_func(unsigned int i, unsigned int j, double dt)PenningTrapprivate
write_simulation_to_dir(std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
total_force(uint i)PenningTrapprivate
total_force_external(uint i)PenningTrapprivate
total_force_no_interaction(uint i)PenningTrapprivate
total_force_particles(uint i)PenningTrapprivate
V_0PenningTrapprivate
v_func(uint i, uint j, double dt)PenningTrapprivate
write_simulation_to_dir(std::string path, double time, uint steps, std::string method="rk4", bool particle_interaction=true)PenningTrap
diff --git a/docs/classPenningTrap.html b/docs/classPenningTrap.html index 9afb617..8879bd4 100644 --- a/docs/classPenningTrap.html +++ b/docs/classPenningTrap.html @@ -102,6 +102,7 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza Public Member Functions | Private Member Functions | Private Attributes | +Friends | List of all members
PenningTrap Class Reference
@@ -114,69 +115,81 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + +

Public Member Functions

 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.
 
 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.
 
 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.
 
 PenningTrap (double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)
 Constructor for the PenningTrap class.
 
 PenningTrap (uint i, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)
 Constructor for the PenningTrap class.
 
 PenningTrap (std::vector< Particle > particles, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)
 Constructor for the PenningTrap class.
 
void set_pertubation (double f, double omega_V)
 Time dependent perturbation to V_0.
 
void reinitialize (double f, double omega_V, double t=0.)
 Give all particles new positions and velocities, and change t and V_0.
 
void add_particle (Particle particle)
 Add a particle to the system.
 
vec_3d external_E_field (vec_3d r)
 Calculate E at point r.
 
vec_3d external_B_field (vec_3d r)
 Calculate B at point r.
 
vec_3d force_on_particle (unsigned int i, unsigned int j)
 Calculate the force between 2 particles.
 
vec_3d total_force_external (unsigned int i)
 Calculate the total external force on a particle.
 
vec_3d total_force_particles (unsigned int i)
 Calculate the total force on a particle p_i from other particles.
 
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.
 
void evolve_forward_euler (double dt, bool particle_interaction=true)
 Go forward one timestep using the forward Euler method.
 
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.
 
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.
 
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 simulation.
 
simulation_t simulate (double time, uint steps, std::string method="rk4", bool particle_interaction=true)
 Simulate the particle system inside the Penning trap over a certain amount of time.
 
void write_simulation_to_dir (std::string path, double time, uint steps, std::string method="rk4", bool particle_interaction=true)
 Simulate and write the displacement of all particles to files.
 
double fraction_of_particles_left (double time, uint steps, std::string method="rk4", bool particle_interaction=true)
 Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation.
 
- - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + +

Private Member Functions

vec_3d v_func (unsigned int i, unsigned int j, double dt)
 Helper for evolve_RK4 when calculating \(k_{v,i,j}\) values.
 
vec_3d r_func (unsigned int i, unsigned int j, double dt)
 Helper for evolve_RK4 when calculating \(k_{r,i,j}\) values.
 
vec3 v_func (uint i, uint j, double dt)
 Helper for evolve_RK4 when calculating \(k_{v,i,j}\) values.
 
vec3 r_func (uint i, uint j, double dt)
 Helper for evolve_RK4 when calculating \(k_{r,i,j}\) values.
 
vec3 external_E_field (vec3 r)
 Calculate E at point r.
 
vec3 external_B_field (vec3 r)
 Calculate B at point r.
 
vec3 force_on_particle (uint i, uint j)
 Calculate the force between 2 particles.
 
vec3 total_force_external (uint i)
 Calculate the total external force on a particle.
 
vec3 total_force_particles (uint i)
 Calculate the total force on a particle p_i from other particles.
 
vec3 total_force (uint i)
 calculate the total force on a particle p_i.
 
vec3 total_force_no_interaction (uint i)
 calculate the total force on a particle p_i without interaction
 
- - - + + + + + + @@ -187,18 +200,26 @@ Private Attributes + + +

Private Attributes

double B_0
 Magnetic field strength.
 
std::function< double(double)> V_0
 Applied potential.
 
double V_0
 Applied potential.
 
std::function< double(double)> perturbation
 Time-dependent perturbation.
 
double d
 Characteristic dimension.
 
 The particles in the Penning trap.
 
sim_arr k_v
 A 2D vector containing all \(k_{v,i,j}\) where \(j\) is the index of a particle.
 
sim_arr k_r
 A 2D vector containing all \(k_{r,i,j}\) where \(j\) is the index of a particle.
 
+ + + +

+Friends

class PenningTrapTest
 Make PenningTrapTest a friend of PenningTrap.
 

Detailed Description

A class that simulates a Penning trap.

This class simulates a Penning trap. It can take in a number of particles and simulate how they would behave inside a Penning trap.

-

Definition at line 30 of file PenningTrap.hpp.

+

Definition at line 31 of file PenningTrap.hpp.

Constructor & Destructor Documentation

- -

◆ PenningTrap() [1/3]

+ +

◆ PenningTrap() [1/3]

@@ -212,8 +233,8 @@ Private Attributes - std::function< double(double)>  - V_0 = [](double t) { return 25. * V / 1000.; }, + double  + V_0 = (25. * V) / 1000., @@ -246,12 +267,12 @@ Private Attributes -

Definition at line 18 of file PenningTrap.cpp.

+

Definition at line 120 of file PenningTrap.cpp.

- -

◆ PenningTrap() [2/3]

+ +

◆ PenningTrap() [2/3]

@@ -259,7 +280,7 @@ Private Attributes PenningTrap::PenningTrap ( - unsigned int  + uint  i, @@ -271,8 +292,8 @@ Private Attributes - std::function< double(double)>  - V_0 = [](double t) { return 25. * V / 1000.; }, + double  + V_0 = (25. * V) / 1000., @@ -306,12 +327,12 @@ Private Attributes -

Definition at line 27 of file PenningTrap.cpp.

+

Definition at line 129 of file PenningTrap.cpp.

- -

◆ PenningTrap() [3/3]

+ +

◆ PenningTrap() [3/3]

@@ -331,8 +352,8 @@ Private Attributes - std::function< double(double)>  - V_0 = [](double t) { return 25. * V / 1000.; }, + double  + V_0 = (25. * V) / 1000., @@ -366,7 +387,7 @@ Private Attributes -

Definition at line 39 of file PenningTrap.cpp.

+

Definition at line 139 of file PenningTrap.cpp.

@@ -395,7 +416,7 @@ Private Attributes -

Definition at line 82 of file PenningTrap.cpp.

+

Definition at line 166 of file PenningTrap.cpp.

@@ -434,7 +455,7 @@ Private Attributes -

Definition at line 186 of file PenningTrap.cpp.

+

Definition at line 211 of file PenningTrap.cpp.

@@ -473,24 +494,32 @@ Private Attributes -

Definition at line 151 of file PenningTrap.cpp.

+

Definition at line 171 of file PenningTrap.cpp.

- -

◆ external_B_field()

+ +

◆ external_B_field()

+ + + + + +
- + - +
vec_3d PenningTrap::external_B_field vec3 PenningTrap::external_B_field (vec_3d vec3  r)
+
+private

Calculate B at point r.

@@ -500,26 +529,34 @@ Private Attributes -
Returns
vec_3d
+
Returns
vec3
-

Definition at line 95 of file PenningTrap.cpp.

+

Definition at line 67 of file PenningTrap.cpp.

- -

◆ external_E_field()

+ +

◆ external_E_field()

+ + + + + +
- + - +
vec_3d PenningTrap::external_E_field vec3 PenningTrap::external_E_field (vec_3d vec3  r)
+
+private

Calculate E at point r.

@@ -529,28 +566,31 @@ Private Attributes -
Returns
vec_3d
+
Returns
vec3
-

Definition at line 87 of file PenningTrap.cpp.

+

Definition at line 59 of file PenningTrap.cpp.

- -

◆ force_on_particle()

+ +

◆ force_on_particle()

+ + + + + +
- + - + - + @@ -559,6 +599,11 @@ Private Attributes
vec_3d PenningTrap::force_on_particle vec3 PenningTrap::force_on_particle (unsigned int uint  i,
unsigned int uint  j 
+
+private

Calculate the force between 2 particles.

@@ -570,14 +615,14 @@ Private Attributes -
Returns
vec_3d
+
Returns
vec3
-

Definition at line 100 of file PenningTrap.cpp.

+

Definition at line 72 of file PenningTrap.cpp.

- -

◆ fraction_of_particles_left()

+ +

◆ fraction_of_particles_left()

@@ -591,7 +636,7 @@ Private Attributes - unsigned int  + uint  steps, @@ -626,12 +671,12 @@ Private Attributes
Returns
double
-

Definition at line 266 of file PenningTrap.cpp.

+

Definition at line 311 of file PenningTrap.cpp.

- -

◆ r_func()

+ +

◆ r_func()

@@ -640,15 +685,15 @@ Private Attributes - + - + - + @@ -676,24 +721,107 @@ Private Attributes
vec_3d PenningTrap::r_func vec3 PenningTrap::r_func (unsigned int uint  i,
unsigned int uint  j,
- +
iIndex i for \(k_{r,i,j}\)
jIndex j for \(k_{r,i,j}\)
dtthe step length (delta time)
dtThe step length (delta time)
-
Returns
vec_3d
+
Returns
vec3
-

Definition at line 64 of file PenningTrap.cpp.

+

Definition at line 40 of file PenningTrap.cpp.

- -

◆ simulate()

+ +

◆ reinitialize()

- + + + + + + + + + + + + + + + + + + + + + + +
sim_arr PenningTrap::simulate void PenningTrap::reinitialize (double f,
double omega_V,
double t = 0. 
)
+
+ +

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

+
Parameters
+ + + +
V_0The tiome dependent applied potential
tThe starting time
+
+
+ +

Definition at line 153 of file PenningTrap.cpp.

+ +
+
+ +

◆ set_pertubation()

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

Time dependent perturbation to V_0.

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

Definition at line 146 of file PenningTrap.cpp.

+ +
+
+ +

◆ simulate()

+ +
+
+ + + @@ -701,7 +829,7 @@ Private Attributes - + @@ -730,29 +858,38 @@ Private Attributes - +
simulation_t PenningTrap::simulate ( double  time,
unsigned int uint  steps,
timeThe time to simulate in microseconds
stepsThe amount of steps for the whole simulation
methodThe method to use when moving forward a timestep
particle_interactionTurn particle interactions on/off
particle_interactionTurn particle interactions on/off
+
Returns
simulation_t
-

Definition at line 211 of file PenningTrap.cpp.

+

Definition at line 240 of file PenningTrap.cpp.

- -

◆ total_force()

+ +

◆ total_force()

+ + + + + +
- + - +
vec_3d PenningTrap::total_force vec3 PenningTrap::total_force (unsigned int uint  i)
+
+private

calculate the total force on a particle p_i.

@@ -762,26 +899,34 @@ Private Attributes -
Returns
vec_3d
+
Returns
vec3
-

Definition at line 146 of file PenningTrap.cpp.

+

Definition at line 104 of file PenningTrap.cpp.

- -

◆ total_force_external()

+ +

◆ total_force_external()

+ + + + + +
- + - +
vec_3d PenningTrap::total_force_external vec3 PenningTrap::total_force_external (unsigned int uint  i)
+
+private

Calculate the total external force on a particle.

@@ -792,26 +937,71 @@ Private Attributes -
Returns
vec_3d
+
Returns
vec3
-

Definition at line 114 of file PenningTrap.cpp.

+

Definition at line 83 of file PenningTrap.cpp.

- -

◆ total_force_particles()

+ +

◆ total_force_no_interaction()

+ + + + + +
- + - +
vec_3d PenningTrap::total_force_particles vec3 PenningTrap::total_force_no_interaction (unsigned int uint  i)
+
+private
+
+ +

calculate the total force on a particle p_i without interaction

+
Parameters
+ + +
iThe index of particle p_i
+
+
+
Returns
vec3
+ +

Definition at line 112 of file PenningTrap.cpp.

+ +
+
+ +

◆ total_force_particles()

+ +
+
+ + + + + +
+ + + + + + + + +
vec3 PenningTrap::total_force_particles (uint i)
+
+private

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

@@ -821,14 +1011,14 @@ Private Attributes -
Returns
vec_3d
+
Returns
vec3
-

Definition at line 129 of file PenningTrap.cpp.

+

Definition at line 92 of file PenningTrap.cpp.

- -

◆ v_func()

+ +

◆ v_func()

@@ -837,15 +1027,15 @@ Private Attributes - + - + - + @@ -877,14 +1067,14 @@ Private Attributes
vec_3d PenningTrap::v_func vec3 PenningTrap::v_func (unsigned int uint  i,
unsigned int uint  j,
-
Returns
vec_3d
+
Returns
vec3
-

Definition at line 46 of file PenningTrap.cpp.

+

Definition at line 21 of file PenningTrap.cpp.

- -

◆ write_simulation_to_dir()

+ +

◆ write_simulation_to_dir()

@@ -904,7 +1094,7 @@ Private Attributes - unsigned int  + uint  steps, @@ -939,7 +1129,34 @@ Private Attributes -

Definition at line 240 of file PenningTrap.cpp.

+

Definition at line 273 of file PenningTrap.cpp.

+ +
+
+

Friends And Related Function Documentation

+ +

◆ PenningTrapTest

+ +
+
+ + + + + +
+ + + + +
friend class PenningTrapTest
+
+friend
+
+ +

Make PenningTrapTest a friend of PenningTrap.

+ +

Definition at line 35 of file PenningTrap.hpp.

@@ -966,7 +1183,7 @@ Private Attributes

Magnetic field strength.

-

Definition at line 32 of file PenningTrap.hpp.

+

Definition at line 37 of file PenningTrap.hpp.

@@ -992,7 +1209,7 @@ Private Attributes

Characteristic dimension.

-

Definition at line 34 of file PenningTrap.hpp.

+

Definition at line 40 of file PenningTrap.hpp.

@@ -1015,9 +1232,10 @@ Private Attributes
-

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

-

Definition at line 39 of file PenningTrap.hpp.

+

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

+ +

Definition at line 52 of file PenningTrap.hpp.

@@ -1040,9 +1258,10 @@ Private Attributes
-

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

-

Definition at line 37 of file PenningTrap.hpp.

+

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

+ +

Definition at line 47 of file PenningTrap.hpp.

@@ -1068,7 +1287,33 @@ Private Attributes

The particles in the Penning trap.

-

Definition at line 36 of file PenningTrap.hpp.

+

Definition at line 42 of file PenningTrap.hpp.

+ + + + +

◆ perturbation

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

Time-dependent perturbation.

+ +

Definition at line 39 of file PenningTrap.hpp.

@@ -1094,12 +1339,12 @@ Private Attributes

Current time.

-

Definition at line 35 of file PenningTrap.hpp.

+

Definition at line 41 of file PenningTrap.hpp.

- -

◆ V_0

+ +

◆ V_0

@@ -1108,7 +1353,7 @@ Private Attributes - +
std::function<double(double)> PenningTrap::V_0double PenningTrap::V_0
@@ -1120,7 +1365,7 @@ Private Attributes

Applied potential.

-

Definition at line 33 of file PenningTrap.hpp.

+

Definition at line 38 of file PenningTrap.hpp.

diff --git a/docs/classPenningTrap.js b/docs/classPenningTrap.js index 0fd7f36..38310ad 100644 --- a/docs/classPenningTrap.js +++ b/docs/classPenningTrap.js @@ -1,27 +1,32 @@ var classPenningTrap = [ - [ "PenningTrap", "classPenningTrap.html#ae670d7de621acdb343b01af098086f63", null ], - [ "PenningTrap", "classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1", null ], - [ "PenningTrap", "classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73", null ], + [ "PenningTrap", "classPenningTrap.html#a5b6c6d4636f3a6e279ccde59d4a345e8", null ], + [ "PenningTrap", "classPenningTrap.html#a830be1b8cbf59664e060b6edbeaa302f", null ], + [ "PenningTrap", "classPenningTrap.html#addc96789dcfec07b75156e19fee82f4f", null ], [ "add_particle", "classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8", 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 ], + [ "external_B_field", "classPenningTrap.html#a361f2c4862c90b5e8e2a2f50c6a95655", null ], + [ "external_E_field", "classPenningTrap.html#a5846c8f75cdc543fd9cf0b2185a3ef22", null ], + [ "force_on_particle", "classPenningTrap.html#a7f210bb2768a5d79ced4b0df0df97598", null ], + [ "fraction_of_particles_left", "classPenningTrap.html#ac529aa26c288f34eae184a67e6bac41f", null ], + [ "r_func", "classPenningTrap.html#a826b7fa8e709d481eb1dee7d0c2cdc08", null ], + [ "reinitialize", "classPenningTrap.html#aaee129f177657455348d0c8ae1441dea", null ], + [ "set_pertubation", "classPenningTrap.html#a9d1d8e90ca839b928aee1ad0cd4aff43", null ], + [ "simulate", "classPenningTrap.html#a7a1d9f0528a12308de25bc30718da20a", null ], + [ "total_force", "classPenningTrap.html#a9a301b0540078c36697880ef204afdf3", null ], + [ "total_force_external", "classPenningTrap.html#a2c01108b52c8e2a003cf9170da9e7682", null ], + [ "total_force_no_interaction", "classPenningTrap.html#a6069f82d8dbc7cadaebd228dbcd95018", null ], + [ "total_force_particles", "classPenningTrap.html#a2fe1cefbae18fa5808155ee0d2df713c", null ], + [ "v_func", "classPenningTrap.html#a3c0a44e4e0a94366ff609e81fe463fa2", null ], + [ "write_simulation_to_dir", "classPenningTrap.html#ad8bc4df7ab3eed53b16cfdff38e7760b", null ], + [ "PenningTrapTest", "classPenningTrap.html#a869f032f37d0569ed16f224b4c4356ae", 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 ], + [ "perturbation", "classPenningTrap.html#ae915f6ad0eef1fb46530e836b6e071e5", null ], [ "t", "classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e", null ], - [ "V_0", "classPenningTrap.html#aaf105828121c4a33cc2b217453c20317", null ] + [ "V_0", "classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89", null ] ]; \ No newline at end of file diff --git a/docs/classPenningTrapTest-members.html b/docs/classPenningTrapTest-members.html index 1b1f2e1..a1728e4 100644 --- a/docs/classPenningTrapTest-members.html +++ b/docs/classPenningTrapTest-members.html @@ -104,11 +104,11 @@ $(document).ready(function(){initNavTree('classPenningTrapTest.html',''); initRe

This is the complete list of members for PenningTrapTest, including all inherited members.

- - - - - + + + + +
test_external_B_field() (defined in PenningTrapTest)PenningTrapTestinlinestatic
test_external_E_field() (defined in PenningTrapTest)PenningTrapTestinlinestatic
test_force_on_particle() (defined in PenningTrapTest)PenningTrapTestinlinestatic
test_total_force_external() (defined in PenningTrapTest)PenningTrapTestinlinestatic
test_total_force_particles() (defined in PenningTrapTest)PenningTrapTestinlinestatic
test_external_B_field()PenningTrapTestinline
test_external_E_field()PenningTrapTestinline
test_force_on_particle()PenningTrapTestinline
test_total_force_external()PenningTrapTestinline
test_total_force_particles()PenningTrapTestinline
diff --git a/docs/classPenningTrapTest.html b/docs/classPenningTrapTest.html index 8eda947..e679696 100644 --- a/docs/classPenningTrapTest.html +++ b/docs/classPenningTrapTest.html @@ -99,31 +99,40 @@ $(document).ready(function(){initNavTree('classPenningTrapTest.html',''); initRe
+ +

Test class for the Penning trap. + More...

- - - - - - - - - - - + + + + + + + + + + + + + + + +

-Static Public Member Functions

static void test_external_E_field ()
 
static void test_external_B_field ()
 
static void test_force_on_particle ()
 
static void test_total_force_external ()
 
static void test_total_force_particles ()
 

+Public Member Functions

void test_external_E_field ()
 Test that the external E field gives correct values.
 
void test_external_B_field ()
 Test that the external B field gives correct values.
 
void test_force_on_particle ()
 Test that the force between particles gives expected results.
 
void test_total_force_external ()
 Test that the total external force returns expected results.
 
void test_total_force_particles ()
 Test that the total force of all particles on a single particle returns expected results.
 

Detailed Description

-
-

Definition at line 20 of file test_suite.cpp.

+

Test class for the Penning trap.

+ +

Definition at line 23 of file test_suite.cpp.

Member Function Documentation

- -

◆ test_external_B_field()

+ +

◆ test_external_B_field()

@@ -132,7 +141,7 @@ Static Public Member Functions - + @@ -140,17 +149,19 @@ Static Public Member Functions
static void PenningTrapTest::test_external_B_field void PenningTrapTest::test_external_B_field ( )
-inlinestatic +inline
-

Definition at line 59 of file test_suite.cpp.

+

Test that the external B field gives correct values.

+ +

Definition at line 66 of file test_suite.cpp.

- -

◆ test_external_E_field()

+ +

◆ test_external_E_field()

@@ -159,7 +170,7 @@ Static Public Member Functions - + @@ -167,17 +178,19 @@ Static Public Member Functions
static void PenningTrapTest::test_external_E_field void PenningTrapTest::test_external_E_field ( )
-inlinestatic +inline
-

Definition at line 22 of file test_suite.cpp.

+

Test that the external E field gives correct values.

+ +

Definition at line 28 of file test_suite.cpp.

- -

◆ test_force_on_particle()

+ +

◆ test_force_on_particle()

@@ -186,7 +199,7 @@ Static Public Member Functions - + @@ -194,17 +207,19 @@ Static Public Member Functions
static void PenningTrapTest::test_force_on_particle void PenningTrapTest::test_force_on_particle ( )
-inlinestatic +inline
-

Definition at line 70 of file test_suite.cpp.

+

Test that the force between particles gives expected results.

+ +

Definition at line 80 of file test_suite.cpp.

- -

◆ test_total_force_external()

+ +

◆ test_total_force_external()

@@ -213,7 +228,7 @@ Static Public Member Functions - + @@ -221,17 +236,19 @@ Static Public Member Functions
static void PenningTrapTest::test_total_force_external void PenningTrapTest::test_total_force_external ( )
-inlinestatic +inline
-

Definition at line 95 of file test_suite.cpp.

+

Test that the total external force returns expected results.

+ +

Definition at line 107 of file test_suite.cpp.

- -

◆ test_total_force_particles()

+ +

◆ test_total_force_particles()

@@ -240,7 +257,7 @@ Static Public Member Functions - + @@ -248,12 +265,14 @@ Static Public Member Functions
static void PenningTrapTest::test_total_force_particles void PenningTrapTest::test_total_force_particles ( )
-inlinestatic +inline
-

Definition at line 108 of file test_suite.cpp.

+

Test that the total force of all particles on a single particle returns expected results.

+ +

Definition at line 122 of file test_suite.cpp.

diff --git a/docs/classPenningTrapTest.js b/docs/classPenningTrapTest.js new file mode 100644 index 0000000..54d09ee --- /dev/null +++ b/docs/classPenningTrapTest.js @@ -0,0 +1,8 @@ +var classPenningTrapTest = +[ + [ "test_external_B_field", "classPenningTrapTest.html#ad668d7d875bdc1909a42426bf9dead9e", null ], + [ "test_external_E_field", "classPenningTrapTest.html#a6a303be62039ca2ecccd8252744d4dc8", null ], + [ "test_force_on_particle", "classPenningTrapTest.html#a5f4f0b150e54ce463bb29f76d49883f9", null ], + [ "test_total_force_external", "classPenningTrapTest.html#ae6d0c8e0d80338fb7c7edefc97331046", null ], + [ "test_total_force_particles", "classPenningTrapTest.html#a68449d508e66205bc8b27fa5f60db508", null ] +]; \ No newline at end of file diff --git a/docs/classes.html b/docs/classes.html index 7b8f02e..11e3ca3 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -101,11 +101,14 @@ $(document).ready(function(){initNavTree('classes.html',''); initResizable(); })
Class Index
diff --git a/docs/constants_8hpp.html b/docs/constants_8hpp.html index 8c5aceb..8119c18 100644 --- a/docs/constants_8hpp.html +++ b/docs/constants_8hpp.html @@ -111,26 +111,68 @@ $(document).ready(function(){initNavTree('constants_8hpp.html',''); initResizabl - + - + - + + + + + + +

Macros

#define K_E   138935.333
#define K_E   1.38935333 * 1e5
 Coulomb constant. unit: \(\frac{u(\mu m)^3}{(\mu s)^2 e^2}\).
 
#define T   96.4852558
#define T   9.64852558 * 1e1
 1 Tesla. unit: \( \frac{u}{(\mu s) e} \)
 
#define V   96485255.8
#define V   9.64852558 * 1e7
 1 Volt. unit: \( \frac{u (\mu m)^2}{(\mu s)^2 e} \)
 
#define CA_MASS   40.078
 Mass of a single calcium ion. unit: amu.
 
#define CA_CHARGE   1.
 Charge of a singly charged calcium ion. unit: e.
 

Detailed Description

Library of constants.

Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
-
Version
0.1
+
Version
1.0
Bug:
No known bugs

Definition in file constants.hpp.

Macro Definition Documentation

+ +

◆ CA_CHARGE

+ +
+
+ + + + +
#define CA_CHARGE   1.
+
+ +

Charge of a singly charged calcium ion. unit: e.

+ +

Definition at line 33 of file constants.hpp.

+ +
+
+ +

◆ CA_MASS

+ +
+
+ + + + +
#define CA_MASS   40.078
+
+ +

Mass of a single calcium ion. unit: amu.

+ +

Definition at line 29 of file constants.hpp.

+ +
+

◆ K_E

@@ -138,14 +180,14 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
- +
#define K_E   138935.333#define K_E   1.38935333 * 1e5

Coulomb constant. unit: \(\frac{u(\mu m)^3}{(\mu s)^2 e^2}\).

-

Definition at line 15 of file constants.hpp.

+

Definition at line 17 of file constants.hpp.

@@ -156,14 +198,14 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
- +
#define T   96.4852558#define T   9.64852558 * 1e1

1 Tesla. unit: \( \frac{u}{(\mu s) e} \)

-

Definition at line 17 of file constants.hpp.

+

Definition at line 21 of file constants.hpp.

@@ -174,14 +216,14 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
- +
#define V   96485255.8#define V   9.64852558 * 1e7

1 Volt. unit: \( \frac{u (\mu m)^2}{(\mu s)^2 e} \)

-

Definition at line 19 of file constants.hpp.

+

Definition at line 25 of file constants.hpp.

diff --git a/docs/constants_8hpp.js b/docs/constants_8hpp.js index a4eb8d0..10edb33 100644 --- a/docs/constants_8hpp.js +++ b/docs/constants_8hpp.js @@ -1,5 +1,7 @@ var constants_8hpp = [ + [ "CA_CHARGE", "constants_8hpp.html#af7602a3a314957137ad1cd719aa23789", null ], + [ "CA_MASS", "constants_8hpp.html#a2ff491cc7958ffd5e749c518a4a60ec8", null ], [ "K_E", "constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb", null ], [ "T", "constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5", null ], [ "V", "constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb", null ] diff --git a/docs/constants_8hpp_source.html b/docs/constants_8hpp_source.html index a9f3f8b..a2f06fc 100644 --- a/docs/constants_8hpp_source.html +++ b/docs/constants_8hpp_source.html @@ -105,13 +105,17 @@ $(document).ready(function(){initNavTree('constants_8hpp_source.html',''); initR
12#ifndef __CONST__
13#define __CONST__
14
-
15#define K_E 138935.333
-
16
-
17#define T 96.4852558
+
17#define K_E 1.38935333 * 1e5
18
-
19#define V 96485255.8
-
20
-
21#endif
+
21#define T 9.64852558 * 1e1
+
22
+
25#define V 9.64852558 * 1e7
+
26
+
29#define CA_MASS 40.078
+
30
+
33#define CA_CHARGE 1.
+
34
+
35#endif
diff --git a/docs/dir_634e799a3947388232110823971192a8.html b/docs/dir_634e799a3947388232110823971192a8.html new file mode 100644 index 0000000..6e5a151 --- /dev/null +++ b/docs/dir_634e799a3947388232110823971192a8.html @@ -0,0 +1,139 @@ + + + + + + + +Penning Trap Simulation: src/scripts Directory Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Penning Trap Simulation +
+
Simulate particle behavior inside a Penning Trap
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
scripts Directory Reference
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +

+Files

file  animate_100_particles.py [code]
 Animate 100 particles.
 
file  plot_2_particles.py [code]
 Plot 2 particles with and without particle interactions in the xy-plane.
 
file  plot_3d.py [code]
 Plot 2 particles with and without particle interactions in 3D.
 
file  plot_particles_left.py [code]
 Plot how many particles are left after 500 microseconds using different angular frequencies.
 
file  plot_phase_space.py [code]
 Plot the phase space for 2 particles in the x and z direction, with and without particle interactions.
 
file  plot_relative_error.py [code]
 Plot the relative error for forward Euler and RK4 method.
 
file  plot_single_particle.py [code]
 Plot the approximation and analytical solution for one particle in the z axis.
 
+
+
+ + + + diff --git a/docs/dir_634e799a3947388232110823971192a8.js b/docs/dir_634e799a3947388232110823971192a8.js new file mode 100644 index 0000000..e1f93d8 --- /dev/null +++ b/docs/dir_634e799a3947388232110823971192a8.js @@ -0,0 +1,10 @@ +var dir_634e799a3947388232110823971192a8 = +[ + [ "animate_100_particles.py", "animate__100__particles_8py.html", null ], + [ "plot_2_particles.py", "plot__2__particles_8py.html", null ], + [ "plot_3d.py", "plot__3d_8py.html", null ], + [ "plot_particles_left.py", "plot__particles__left_8py.html", null ], + [ "plot_phase_space.py", "plot__phase__space_8py.html", null ], + [ "plot_relative_error.py", "plot__relative__error_8py.html", null ], + [ "plot_single_particle.py", "plot__single__particle_8py.html", null ] +]; \ No newline at end of file diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 4313bbd..ef64c5f 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -102,9 +102,15 @@ $(document).ready(function(){initNavTree('dir_68267d1309a1af8e8297ef4c3efbcdba.h
+ + + +

+Directories

directory  scripts
 
- + + @@ -115,8 +121,6 @@ Files - - diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js index 64ce7a5..702a957 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js @@ -1,10 +1,10 @@ var dir_68267d1309a1af8e8297ef4c3efbcdba = [ - [ "animate_100_particles.py", "animate__100__particles_8py_source.html", null ], - [ "main.cpp", "main_8cpp.html", null ], + [ "scripts", "dir_634e799a3947388232110823971192a8.html", "dir_634e799a3947388232110823971192a8" ], + [ "frequency_narrow_sweeps_long.cpp", "frequency__narrow__sweeps__long_8cpp.html", "frequency__narrow__sweeps__long_8cpp" ], + [ "main.cpp", "main_8cpp.html", "main_8cpp" ], [ "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/files.html b/docs/files.html index e842a47..e40fb96 100644 --- a/docs/files.html +++ b/docs/files.html @@ -102,7 +102,7 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); });
Here is a list of all documented files with brief descriptions:
-
[detail level 12]

Files

file  animate_100_particles.py [code]
file  frequency_narrow_sweeps_long.cpp [code]
 Sweep of the frequencies from 1.1 to 1.7 using a small time step.
 
file  main.cpp [code]
 The main program for this project.
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.
 
+
[detail level 123]
@@ -110,13 +110,20 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); }); - - - - - - - + + + + + + + + + + + + + +
  include
 constants.hppLibrary of constants
 Particle.hppA class that holds the properties of a particle
 typedefs.hppUseful typedefs for cleaner code
 utils.hppFunction prototypes and macros that are useful
  src
 animate_100_particles.py
 main.cppThe main program for this project
 Particle.cppThe implementation of the Particle class
 PenningTrap.cppThe implementation of the PenningTrap class
 plot_particles_left.py
 test_suite.cppThe test suite for the project
 utils.cppImplementation of the utils
  scripts
 animate_100_particles.pyAnimate 100 particles
 plot_2_particles.pyPlot 2 particles with and without particle interactions in the xy-plane
 plot_3d.pyPlot 2 particles with and without particle interactions in 3D
 plot_particles_left.pyPlot how many particles are left after 500 microseconds using different angular frequencies
 plot_phase_space.pyPlot the phase space for 2 particles in the x and z direction, with and without particle interactions
 plot_relative_error.pyPlot the relative error for forward Euler and RK4 method
 plot_single_particle.pyPlot the approximation and analytical solution for one particle in the z axis
 frequency_narrow_sweeps_long.cppSweep of the frequencies from 1.1 to 1.7 using a small time step
 main.cppThe main program for this project
 Particle.cppThe implementation of the Particle class
 PenningTrap.cppThe implementation of the PenningTrap class
 test_suite.cppThe test suite for the project
 utils.cppImplementation of the utils
diff --git a/docs/frequency__narrow__sweeps__long_8cpp.html b/docs/frequency__narrow__sweeps__long_8cpp.html new file mode 100644 index 0000000..be73962 --- /dev/null +++ b/docs/frequency__narrow__sweeps__long_8cpp.html @@ -0,0 +1,256 @@ + + + + + + + +Penning Trap Simulation: src/frequency_narrow_sweeps_long.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Penning Trap Simulation +
+
Simulate particle behavior inside a Penning Trap
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
frequency_narrow_sweeps_long.cpp File Reference
+
+
+ +

Sweep of the frequencies from 1.1 to 1.7 using a small time step. +More...

+
#include <cmath>
+#include <complex>
+#include <fstream>
+#include <omp.h>
+#include <string>
+#include <vector>
+#include "PenningTrap.hpp"
+#include "constants.hpp"
+#include "utils.hpp"
+
+

Go to the source code of this file.

+ + + + + + +

+Macros

#define PARTICLES   100
 
#define N   40000
 
+ + + + + + + + + +

+Functions

void potential_resonance_narrow_sweep ()
 Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.
 
void potential_resonance_narrow_sweep_interaction ()
 Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.
 
int main ()
 
+

Detailed Description

+

Sweep of the frequencies from 1.1 to 1.7 using a small time step.

+
Author
Cory Alexander Balaton (coryab)
+
+Janita Ovidie Sandtrøen Willumsen (janitaws)
+
Version
1.0
+
Bug:
No known bugs
+ +

Definition in file frequency_narrow_sweeps_long.cpp.

+

Macro Definition Documentation

+ +

◆ N

+ +
+
+ + + + +
#define N   40000
+
+ +

Definition at line 25 of file frequency_narrow_sweeps_long.cpp.

+ +
+
+ +

◆ PARTICLES

+ +
+
+ + + + +
#define PARTICLES   100
+
+ +

Definition at line 24 of file frequency_narrow_sweeps_long.cpp.

+ +
+
+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + +
int main ()
+
+ +

Definition at line 139 of file frequency_narrow_sweeps_long.cpp.

+ +
+
+ +

◆ potential_resonance_narrow_sweep()

+ +
+
+ + + + + + + +
void potential_resonance_narrow_sweep ()
+
+ +

Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.

+

The simulation sweeps over different frequencies in [1., 1.7] MHz.

+ +

Definition at line 34 of file frequency_narrow_sweeps_long.cpp.

+ +
+
+ +

◆ potential_resonance_narrow_sweep_interaction()

+ +
+
+ + + + + + + +
void potential_resonance_narrow_sweep_interaction ()
+
+ +

Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.

+

The simulation sweeps over different frequencies in [1., 1.7] MHz.

+ +

Definition at line 91 of file frequency_narrow_sweeps_long.cpp.

+ +
+
+
+
+ + + + diff --git a/docs/frequency__narrow__sweeps__long_8cpp.js b/docs/frequency__narrow__sweeps__long_8cpp.js new file mode 100644 index 0000000..c5b9bb8 --- /dev/null +++ b/docs/frequency__narrow__sweeps__long_8cpp.js @@ -0,0 +1,5 @@ +var frequency__narrow__sweeps__long_8cpp = +[ + [ "potential_resonance_narrow_sweep", "frequency__narrow__sweeps__long_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea", null ], + [ "potential_resonance_narrow_sweep_interaction", "frequency__narrow__sweeps__long_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb", null ] +]; \ No newline at end of file diff --git a/docs/frequency__narrow__sweeps__long_8cpp_source.html b/docs/frequency__narrow__sweeps__long_8cpp_source.html new file mode 100644 index 0000000..983bcdf --- /dev/null +++ b/docs/frequency__narrow__sweeps__long_8cpp_source.html @@ -0,0 +1,252 @@ + + + + + + + +Penning Trap Simulation: src/frequency_narrow_sweeps_long.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Penning Trap Simulation +
+
Simulate particle behavior inside a Penning Trap
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
frequency_narrow_sweeps_long.cpp
+
+
+Go to the documentation of this file.
1
+
13#include <cmath>
+
14#include <complex>
+
15#include <fstream>
+
16#include <omp.h>
+
17#include <string>
+
18#include <vector>
+
19
+
20#include "PenningTrap.hpp"
+
21#include "constants.hpp"
+
22#include "utils.hpp"
+
23
+
24#define PARTICLES 100
+
25#define N 40000
+
26
+ +
35{
+
36 double time = 500.;
+
37
+
38 double amplitudes[]{.1, .4, .7};
+
39
+
40 double freq_start = 1.1;
+
41 double freq_end = 1.7;
+
42 double freq_increment = .0005;
+
43 size_t freq_iterations =
+
44 (size_t)((freq_end - freq_start) / freq_increment) + 1;
+
45
+
46 double res[4][freq_iterations];
+
47
+
48 std::string path = "output/time_dependent_potential/";
+
49 mkpath(path);
+
50
+
51 std::ofstream ofile;
+
52
+
53#pragma omp parallel for
+
54 // Insert frequencies
+
55 for (size_t i = 0; i < freq_iterations; i++) {
+
56 res[0][i] = freq_start + freq_increment * i;
+
57 }
+
58
+
59#pragma omp parallel
+
60 {
+
61 // Each thread creates a PenningTrap instance and reuses it throughout
+
62 // the sweep.
+
63 PenningTrap trap((uint)PARTICLES);
+
64#pragma omp for collapse(2)
+
65 for (size_t i = 0; i < 3; i++) {
+
66 for (size_t j = 0; j < freq_iterations; j++) {
+
67 // Reset particles and give new time dependent potential.
+
68 trap.reinitialize(amplitudes[i], res[0][j]);
+
69 res[i + 1][j] =
+
70 trap.fraction_of_particles_left(time, N, "rk4", false);
+
71 }
+
72 }
+
73 }
+
74
+
75 // Write results to file
+
76 ofile.open(path + "narrow_sweep_fine.txt");
+
77 for (size_t i = 0; i < freq_iterations; i++) {
+
78 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
+
79 << res[3][i] << '\n';
+
80 }
+
81 ofile.close();
+
82}
+
83
+ +
92{
+
93 double time = 500.;
+
94
+
95 double amplitudes[]{.1, .4, .7};
+
96
+
97 double freq_start = 1.1;
+
98 double freq_end = 1.7;
+
99 double freq_increment = .0005;
+
100 size_t freq_iterations =
+
101 (size_t)((freq_end - freq_start) / freq_increment) + 1;
+
102
+
103 double res[4][freq_iterations];
+
104
+
105 std::string path = "output/time_dependent_potential/";
+
106 mkpath(path);
+
107
+
108 std::ofstream ofile;
+
109
+
110#pragma omp parallel for
+
111 for (size_t i = 0; i < freq_iterations; i++) {
+
112 res[0][i] = freq_start + freq_increment * i;
+
113 }
+
114
+
115#pragma omp parallel
+
116 {
+
117 // Each thread creates a PenningTrap instance and reuses it throughout
+
118 // the sweep.
+
119 PenningTrap trap((uint)PARTICLES);
+
120#pragma omp for collapse(2)
+
121 for (size_t i = 0; i < 3; i++) {
+
122 for (size_t j = 0; j < freq_iterations; j++) {
+
123 // Reset particles and give new time dependent potential.
+
124 trap.reinitialize(amplitudes[i], res[0][j]);
+
125 res[i + 1][j] = trap.fraction_of_particles_left(time, N);
+
126 }
+
127 }
+
128 }
+
129
+
130 // Write results to file
+
131 ofile.open(path + "narrow_sweep_interactions_fine.txt");
+
132 for (size_t i = 0; i < freq_iterations; i++) {
+
133 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
+
134 << res[3][i] << '\n';
+
135 }
+
136 ofile.close();
+
137}
+
138
+
139int main()
+
140{
+
141 double start, end;
+
142
+
143 start = omp_get_wtime();
+
144
+ +
146
+ +
148
+
149 end = omp_get_wtime();
+
150
+
151 std::cout << "Time: " << end - start << " seconds" << std::endl;
+
152
+
153 return 0;
+
154}
+
A class for simulating a Penning trap.
+
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:32
+
void reinitialize(double f, double omega_V, double t=0.)
Give all particles new positions and velocities, and change t and V_0.
+
double fraction_of_particles_left(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
+
Library of constants.
+
void potential_resonance_narrow_sweep()
Simulate 100 particles over 500 using a time dependent potential.
+
void potential_resonance_narrow_sweep_interaction()
Simulate 100 particles over 500 using a time dependent potential.
+
Function prototypes and macros that are useful.
+
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:72
+
+
+ + + + diff --git a/docs/functions.html b/docs/functions.html index a2f04ea..ff9a215 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -98,34 +98,98 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable();
-
Here is a list of all documented class members with links to the class documentation for each member:
diff --git a/docs/functions_func.html b/docs/functions_func.html index 1182b1d..e821456 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -102,19 +102,27 @@ $(document).ready(function(){initNavTree('functions_func.html',''); initResizabl
  • add_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
  • -
  • Particle() : Particle
  • -
  • PenningTrap() : PenningTrap
  • -
  • r_func() : PenningTrap
  • -
  • simulate() : PenningTrap
  • -
  • total_force() : PenningTrap
  • -
  • total_force_external() : PenningTrap
  • -
  • total_force_particles() : PenningTrap
  • -
  • v_func() : PenningTrap
  • -
  • write_simulation_to_dir() : PenningTrap
  • +
  • external_B_field() : PenningTrap
  • +
  • external_E_field() : PenningTrap
  • +
  • force_on_particle() : PenningTrap
  • +
  • fraction_of_particles_left() : PenningTrap
  • +
  • Particle() : Particle
  • +
  • PenningTrap() : PenningTrap
  • +
  • r_func() : PenningTrap
  • +
  • reinitialize() : PenningTrap
  • +
  • set_pertubation() : PenningTrap
  • +
  • simulate() : PenningTrap
  • +
  • test_external_B_field() : PenningTrapTest
  • +
  • test_external_E_field() : PenningTrapTest
  • +
  • test_force_on_particle() : PenningTrapTest
  • +
  • test_total_force_external() : PenningTrapTest
  • +
  • test_total_force_particles() : PenningTrapTest
  • +
  • total_force() : PenningTrap
  • +
  • total_force_external() : PenningTrap
  • +
  • total_force_no_interaction() : PenningTrap
  • +
  • total_force_particles() : PenningTrap
  • +
  • v_func() : PenningTrap
  • +
  • write_simulation_to_dir() : PenningTrap
  • diff --git a/docs/functions_rela.html b/docs/functions_rela.html index 81a1c72..ab3c3e5 100644 --- a/docs/functions_rela.html +++ b/docs/functions_rela.html @@ -100,6 +100,7 @@ $(document).ready(function(){initNavTree('functions_rela.html',''); initResizabl
     
    diff --git a/docs/functions_vars.html b/docs/functions_vars.html index 3ca2e5b..81cb4af 100644 --- a/docs/functions_vars.html +++ b/docs/functions_vars.html @@ -105,11 +105,12 @@ $(document).ready(function(){initNavTree('functions_vars.html',''); initResizabl
  • k_v : PenningTrap
  • m : Particle
  • particles : PenningTrap
  • +
  • perturbation : PenningTrap
  • q : Particle
  • -
  • r_vec : Particle
  • +
  • r_vec : Particle
  • t : PenningTrap
  • -
  • V_0 : PenningTrap
  • -
  • v_vec : Particle
  • +
  • V_0 : PenningTrap
  • +
  • v_vec : Particle
  • diff --git a/docs/globals.html b/docs/globals.html index 19a9638..98cafee 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -98,21 +98,72 @@ $(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 c7eb483..b7d9886 100644 --- a/docs/globals_defs.html +++ b/docs/globals_defs.html @@ -101,6 +101,8 @@ $(document).ready(function(){initNavTree('globals_defs.html',''); initResizable(  
    • __METHOD_NAME__ : utils.hpp
    • ASSERT : utils.hpp
    • +
    • CA_CHARGE : constants.hpp
    • +
    • CA_MASS : constants.hpp
    • DEBUG : utils.hpp
    • K_E : constants.hpp
    • T : constants.hpp
    • diff --git a/docs/globals_func.html b/docs/globals_func.html index c73a436..5d664cd 100644 --- a/docs/globals_func.html +++ b/docs/globals_func.html @@ -99,10 +99,18 @@ $(document).ready(function(){initNavTree('globals_func.html',''); initResizable(
       
      diff --git a/docs/globals_type.html b/docs/globals_type.html index b7735cc..9d20f34 100644 --- a/docs/globals_type.html +++ b/docs/globals_type.html @@ -100,9 +100,10 @@ $(document).ready(function(){initNavTree('globals_type.html',''); initResizable(
       
      diff --git a/docs/globals_vars.html b/docs/globals_vars.html new file mode 100644 index 0000000..4cbef9c --- /dev/null +++ b/docs/globals_vars.html @@ -0,0 +1,114 @@ + + + + + + + +Penning Trap Simulation: File Members + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      +
      + + + + diff --git a/docs/index.html b/docs/index.html index 29ac7fb..4015ebb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -104,7 +104,110 @@ $(document).ready(function(){initNavTree('index.html',''); initResizable(); });

      -

      +

      Repo

      +

      Documentation

      +

      +Requirements

      +

      +Operating systems

      +
        +
      • Linux
          +
        • Has been tested on Fedora 38
        • +
        • Will most likely work on other Linux distributions
        • +
        +
      • +
      • MacOS
          +
        • Might work, but hasn't been tested
        • +
        +
      • +
      • Windows
          +
        • Will most likely not work
        • +
        +
      • +
      +

      +Tools

      + +

      +Libraries

      + +

      +Compiling

      +

      Compiling is as easy as running this command while being inside the src directory:

      +
      make
      +

      +Running programs

      +

      +C++ binaries

      +

      To run main or test_suite, just run this command while being inside src:

      +
      ./<program-name>
      +

      +Python scripts

      +

      +Install libraries

      +

      Before running the scripts, make sure that all libraries are installed. Using pip, you can install all requirements like this:

      +
      pip install -r requirements.txt
      +

      This recursively install all the packages that are listed in requirements.txt.

      +

      +Running scripts

      +

      For the Python scripts, run them from the src directory like this:

      +
      python scripts/<script-name>
      +

      If you have any problems running the scripts, you might have to run this instead:

      +
      python3 scripts/<script-name>
      +

      +Batch system

      +

      For the frequency_narrow_sweeps_long program, the is a script called job.script that comes along with it. This is to be able to run it on a batch system using Slurm if you have access to one. This is the recommended way to use this program as it takes approximately 90 minutes to complete when using 16 cores.

      +

      If you happen to have such a system available to you, then you should clone this repo on that system, then compile it by running:

      +
      make frequency_narrow_sweeps_long
      +

      You might have to load the Armadillo library before compiling.

      +

      After compiling, you can schedule it by running:

      +
      sbatch job.script
      +

      +Performance

      +

      This section aims to give an idea to the time it takes for the program to run so that you know a bit what to expect if you decide to run it for yourself.

      +

      +CPU

      +

      The times mentioned here are times achieved on a computer with these specifications:

      +
        +
      • CPU model
          +
        • Intel i7-9850H
        • +
        +
      • +
      • Threads
          +
        • 12
        • +
        +
      • +
      • Clock speed
          +
        • 4.6GHz
        • +
        +
      • +
      +

      +Times

      +

      All times mentioned use the evolve_RK4 method.

      +

      Running a simulation with 100 particles without particle interactions over 40000 steps takes around 1.8 seconds. With particle interactions, it takes around 4.8 seconds.

      +

      potential_resonance_wide_sweep takes around 56 seconds to complete.

      +

      potential_resonance_narrow_sweep takes around 172 seconds to complete.

      +

      potential_resonance_narrow_sweep_interaction takes around 936 seconds to complete.

      +

      Credits

      The Doxygen theme used here is doxygen-awesome-css.

      diff --git a/docs/main_8cpp.html b/docs/main_8cpp.html index b83f224..dab738a 100644 --- a/docs/main_8cpp.html +++ b/docs/main_8cpp.html @@ -109,12 +109,13 @@ $(document).ready(function(){initNavTree('main_8cpp.html',''); initResizable();

      The main program for this project. More...

      #include <cmath>
      +#include <complex>
      #include <fstream>
      #include <omp.h>
      #include <string>
      -#include <sys/stat.h>
      #include <vector>
      #include "PenningTrap.hpp"
      +#include "constants.hpp"
      #include "utils.hpp"

      Go to the source code of this file.

      @@ -123,79 +124,59 @@ $(document).ready(function(){initNavTree('main_8cpp.html',''); initResizable(); Macros #define PARTICLES   100   -#define N   10000 +#define N   40000   -#define CHARGE   1. -  -#define MASS   40. -  + + + + + + + - - + + + + + + + + +

      Functions

      vec3 analytical_solution_particle_1 (double t)
       The analytical solution for particle p1.
       
      void simulate_single_particle ()
       Simulate a single particle over the period of 50 \( \mu s \).
       
      void simulate_two_particles ()
       Simulate 2 particles over the period of 50 \( \mu s \) with and without particle interactions.
       
      void simulate_single_particle_with_different_steps ()
       Simulate a single particle over 50 \( \mu s \) using different amount of steps and different methods.
       
      void simulate_100_particles ()
       Simulate 100 particles over 50 \( \mu s \).
       
      void simulate_100_particles_with_time_potential ()
       
      void potential_resonance_wide_sweep ()
       Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.
       
      void potential_resonance_narrow_sweep ()
       Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.
       
      void potential_resonance_narrow_sweep_interaction ()
       Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.
       
      int main ()
       
      - - - - + + + + + +

      Variables

      -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.})
       
      +Particle p1 (vec3{20., 0., 20.}, vec3{0., 25., 0.})
       Particle 1.
       
      +Particle p2 (vec3{25., 25., 0.}, vec3{0., 40., 5.})
       Particle 2.
       

      Detailed Description

      The main program for this project.

      Author
      Cory Alexander Balaton (coryab)
      Janita Ovidie Sandtrøen Willumsen (janitaws)
      -
      Version
      0.1
      -
      Bug:
      No known bugs
      +
      Version
      1.0
      +
      Bug:
      No known bugs

      Definition in file main.cpp.

      Macro Definition Documentation

      - -

      ◆ CHARGE

      - -
      -
      - - - - -
      #define CHARGE   1.
      -
      - -

      Definition at line 25 of file main.cpp.

      - -
      -
      - -

      ◆ MASS

      - -
      -
      - - - - -
      #define MASS   40.
      -
      - -

      Definition at line 26 of file main.cpp.

      - -
      -

      ◆ N

      @@ -203,12 +184,12 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      - +
      #define N   10000#define N   40000
      -

      Definition at line 24 of file main.cpp.

      +

      Definition at line 25 of file main.cpp.

      @@ -224,11 +205,40 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      -

      Definition at line 23 of file main.cpp.

      +

      Definition at line 24 of file main.cpp.

      Function Documentation

      + +

      ◆ analytical_solution_particle_1()

      + +
      +
      + + + + + + + + +
      vec3 analytical_solution_particle_1 (double t)
      +
      + +

      The analytical solution for particle p1.

      +
      Parameters
      + + +
      tTime
      +
      +
      +
      Returns
      vec3
      + +

      Definition at line 37 of file main.cpp.

      + +
      +

      ◆ main()

      @@ -244,7 +254,73 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      -

      Definition at line 124 of file main.cpp.

      +

      Definition at line 314 of file main.cpp.

      + +
      + + +

      ◆ potential_resonance_narrow_sweep()

      + +
      +
      + + + + + + + +
      void potential_resonance_narrow_sweep ()
      +
      + +

      Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.

      +

      The simulation sweeps over different frequencies in [1., 1.7] MHz.

      + +

      Definition at line 209 of file main.cpp.

      + +
      +
      + +

      ◆ potential_resonance_narrow_sweep_interaction()

      + +
      +
      + + + + + + + +
      void potential_resonance_narrow_sweep_interaction ()
      +
      + +

      Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.

      +

      The simulation sweeps over different frequencies in [1., 1.7] MHz.

      + +

      Definition at line 266 of file main.cpp.

      + +
      +
      + +

      ◆ potential_resonance_wide_sweep()

      + +
      +
      + + + + + + + +
      void potential_resonance_wide_sweep ()
      +
      + +

      Simulate 100 particles over 500 \( \mu s \) using a time dependent potential.

      +

      The simulation sweeps over different frequencies in [0.2, 2.5] MHz.

      + +

      Definition at line 152 of file main.cpp.

      @@ -263,26 +339,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      -

      Definition at line 77 of file main.cpp.

      +

      Simulate 100 particles over 50 \( \mu s \).

      -
      - - -

      ◆ simulate_100_particles_with_time_potential()

      - -
      -
      - - - - - - - -
      void simulate_100_particles_with_time_potential ()
      -
      - -

      Definition at line 91 of file main.cpp.

      +

      Definition at line 134 of file main.cpp.

      @@ -301,7 +360,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      -

      Definition at line 31 of file main.cpp.

      +

      Simulate a single particle over the period of 50 \( \mu s \).

      + +

      Definition at line 55 of file main.cpp.

      @@ -320,7 +381,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      -

      Definition at line 55 of file main.cpp.

      +

      Simulate a single particle over 50 \( \mu s \) using different amount of steps and different methods.

      + +

      Definition at line 88 of file main.cpp.

      @@ -339,7 +402,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      -

      Definition at line 42 of file main.cpp.

      +

      Simulate 2 particles over the period of 50 \( \mu s \) with and without particle interactions.

      + +

      Definition at line 70 of file main.cpp.

      diff --git a/docs/main_8cpp.js b/docs/main_8cpp.js new file mode 100644 index 0000000..fad5ed2 --- /dev/null +++ b/docs/main_8cpp.js @@ -0,0 +1,13 @@ +var main_8cpp = +[ + [ "analytical_solution_particle_1", "main_8cpp.html#a8d92fb2ad085065fbd14718647551657", null ], + [ "potential_resonance_narrow_sweep", "main_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea", null ], + [ "potential_resonance_narrow_sweep_interaction", "main_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb", null ], + [ "potential_resonance_wide_sweep", "main_8cpp.html#a6b38b477c18e2f4268779751a88edab1", null ], + [ "simulate_100_particles", "main_8cpp.html#a213713d6ecc02a32b588ffd179dc7513", null ], + [ "simulate_single_particle", "main_8cpp.html#a8fdbe2d5a872e50ef5ec1263243589d6", null ], + [ "simulate_single_particle_with_different_steps", "main_8cpp.html#ac67e0d59227856c4d42e7d01c75e0ad2", null ], + [ "simulate_two_particles", "main_8cpp.html#a783789519f97c6430081171cacb0ffb1", null ], + [ "p1", "main_8cpp.html#a2efa69bb9d93049429ce4637075f1d30", null ], + [ "p2", "main_8cpp.html#ac70b61df65f4336f57ea9b4c35250df7", null ] +]; \ No newline at end of file diff --git a/docs/main_8cpp_source.html b/docs/main_8cpp_source.html index d437689..22654cb 100644 --- a/docs/main_8cpp_source.html +++ b/docs/main_8cpp_source.html @@ -103,148 +103,397 @@ $(document).ready(function(){initNavTree('main_8cpp_source.html',''); initResiza
      Go to the documentation of this file.
      1
      13#include <cmath>
      -
      14#include <fstream>
      -
      15#include <omp.h>
      -
      16#include <string>
      -
      17#include <sys/stat.h>
      +
      14#include <complex>
      +
      15#include <fstream>
      +
      16#include <omp.h>
      +
      17#include <string>
      18#include <vector>
      19
      20#include "PenningTrap.hpp"
      -
      21#include "utils.hpp"
      -
      22
      -
      23#define PARTICLES 100
      -
      24#define N 10000
      -
      25#define CHARGE 1.
      -
      26#define MASS 40. // unit: amu
      -
      27
      -
      28Particle p1(CHARGE, MASS, vec_3d{20., 0., 20.}, vec_3d{0., 25., 0.});
      -
      29Particle p2(CHARGE, MASS, vec_3d{25., 25., 0.}, vec_3d{0., 40., 5.});
      +
      21#include "constants.hpp"
      +
      22#include "utils.hpp"
      +
      23
      +
      24#define PARTICLES 100
      +
      25#define N 40000
      +
      26
      +
      27// Particles used for testing
      +
      28Particle p1(vec3{20., 0., 20.}, vec3{0., 25., 0.});
      +
      29Particle p2(vec3{25., 25., 0.}, vec3{0., 40., 5.});
      30
      -
      31void simulate_single_particle()
      -
      32{
      -
      33 DEBUG("Inside single particle sim");
      -
      34 PenningTrap trap(std::vector<Particle>{p1});
      -
      35
      -
      36 double time = 50.; // microseconds
      -
      37
      -
      38 DEBUG("Write to dir");
      -
      39 trap.write_simulation_to_dir("output/simulate_single_particle", time, N);
      -
      40}
      -
      41
      -
      42void simulate_two_particles()
      -
      43{
      -
      44 PenningTrap trap_no_interaction(std::vector<Particle>{p1, p2});
      -
      45 PenningTrap trap_with_interaction(std::vector<Particle>{p1, p2});
      -
      46
      -
      47 double time = 50.; // microseconds
      -
      48
      -
      49 trap_no_interaction.write_simulation_to_dir(
      -
      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);
      -
      53}
      -
      54
      -
      55void simulate_single_particle_with_different_steps()
      + +
      38{
      +
      39 double w_0 = T / CA_MASS;
      +
      40 double w_z2 = (50. * V / 1000.) / (CA_MASS * 500. * 500.);
      +
      41 double w_p = (w_0 + std::sqrt(w_0 * w_0 - 2. * w_z2)) / 2.;
      +
      42 double w_n = (w_0 - std::sqrt(w_0 * w_0 - 2. * w_z2)) / 2.;
      +
      43 double A_p = (25. + w_n * 20.) / (w_n - w_p);
      +
      44 double A_n = -(25. + w_p * 20.) / (w_n - w_p);
      +
      45 std::cout << A_p << "," << A_n << std::endl;
      +
      46 std::complex<double> f =
      +
      47 A_p * std::exp(std::complex<double>(0., -w_p * t))
      +
      48 + A_n * std::exp(std::complex<double>(0., -w_n * t));
      +
      49 vec3 res{std::real(f), std::imag(f), 20. * std::cos(std::sqrt(w_z2) * t)};
      +
      50 return res;
      +
      51}
      +
      52
      +
      56{
      -
      57
      -
      58 double time = 50; // microseconds
      +
      57 // Initialize trap with particle 1
      +
      58 PenningTrap trap(std::vector<Particle>{p1});
      59
      -
      60 for (int i = 0; i < 4; i++) {
      -
      61 int steps = 4000 * (i + 1);
      -
      62 PenningTrap trap(std::vector<Particle>{p1});
      -
      63 trap.write_simulation_to_dir("output/N_steps/RK4/" +
      -
      64 std::to_string(steps) + "_steps",
      -
      65 time, steps, "rk4", false);
      -
      66 }
      -
      67
      -
      68 for (int i = 0; i < 4; i++) {
      -
      69 int steps = 4000 * (i + 1);
      -
      70 PenningTrap trap(std::vector<Particle>{p1});
      -
      71 trap.write_simulation_to_dir("output/N_steps/euler/" +
      -
      72 std::to_string(steps) + "_steps",
      -
      73 time, steps, "euler", false);
      -
      74 }
      -
      75}
      -
      76
      -
      77void simulate_100_particles()
      -
      78{
      -
      79 PenningTrap trap((unsigned)100, T,
      -
      80 [](double t) {
      -
      81 return 25. * V / 1000. *
      -
      82 (1. + .4 * std::cos(1.5 * t));
      -
      83 },
      -
      84 500., 0);
      -
      85
      -
      86 double time = 500.; // microseconds
      -
      87
      -
      88 trap.write_simulation_to_dir("output/simulate_100_particles", time, N*5);
      -
      89}
      -
      90
      -
      91void simulate_100_particles_with_time_potential()
      -
      92{
      -
      93 double amplitudes[]{.1, .4, .7};
      -
      94
      -
      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);
      -
      99
      -
      100 std::string path = "output/time_dependent_potential/";
      -
      101 mkpath(path);
      -
      102
      -
      103 std::ofstream ofile;
      -
      104
      -
      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;
      -
      110 PenningTrap trap((unsigned)100, T,
      -
      111 [f, freq](double t) {
      -
      112 return (25. * V / 1000.) *
      -
      113 (1. + f * std::cos(freq * t));
      -
      114 },
      -
      115 500., 0.);
      -
      116 double res = trap.fraction_of_particles_left(500., 40000, "rk4", true);
      -
      117 #pragma omp ordered
      -
      118 ofile << freq << "," << res << "\n";
      -
      119 }
      -
      120 ofile.close();
      -
      121 }
      -
      122}
      -
      123
      -
      124int main()
      -
      125{
      -
      126
      -
      127 simulate_single_particle();
      -
      128
      -
      129 simulate_two_particles();
      -
      130
      -
      131 simulate_single_particle_with_different_steps();
      -
      132
      -
      133 double start = omp_get_wtime();
      -
      134
      -
      135 //simulate_100_particles();
      -
      136
      -
      137 simulate_100_particles_with_time_potential();
      -
      138
      -
      139 double end = omp_get_wtime();
      -
      140
      -
      141 std::cout << "Time: " << end - start << " seconds" << std::endl;
      -
      142
      -
      143 return 0;
      -
      144}
      +
      60 double time = 50.; // microseconds
      +
      61
      +
      62 // Simulate and write results to file
      +
      63 trap.write_simulation_to_dir("output/simulate_single_particle", time, N,
      +
      64 "rk4", false);
      +
      65}
      +
      66
      + +
      71{
      +
      72 // Initialize traps with particles
      +
      73 PenningTrap trap_no_interaction(std::vector<Particle>{p1, p2});
      +
      74 PenningTrap trap_with_interaction(std::vector<Particle>{p1, p2});
      +
      75
      +
      76 double time = 50.; // microseconds
      +
      77
      +
      78 // Simulate and write results to files
      +
      79 trap_no_interaction.write_simulation_to_dir(
      +
      80 "output/simulate_2_particles/no_interaction", time, N, "rk4", false);
      +
      81 trap_with_interaction.write_simulation_to_dir(
      +
      82 "output/simulate_2_particles/with_interaction", time, N);
      +
      83}
      +
      84
      + +
      89{
      +
      90 double time = 50.; // microseconds
      +
      91
      +
      92 std::ofstream ofile;
      +
      93
      +
      94 // Calculate relative error for RK4
      +
      95 std::string path = "output/relative_error/RK4/";
      +
      96 mkpath(path);
      +
      97#pragma omp parallel for private(ofile)
      +
      98 for (int i = 0; i < 4; i++) {
      +
      99 int steps = 4000 * std::pow(2, i);
      +
      100 std::cout << steps << std::endl;
      +
      101 double dt = time / (double)steps;
      +
      102 ofile.open(path + std::to_string(steps) + "_steps.txt");
      +
      103 PenningTrap trap(std::vector<Particle>{p1});
      +
      104 simulation_t res = trap.simulate(time, steps, "rk4", false);
      +
      105 for (int i = 0; i < steps; i++) {
      +
      106 ofile << arma::norm(res.r_vecs[0][i]
      + +
      108 << '\n';
      +
      109 }
      +
      110 ofile.close();
      +
      111 }
      +
      112
      +
      113 // Calculate relative error for forward Euler
      +
      114 path = "output/relative_error/euler/";
      +
      115 mkpath(path);
      +
      116#pragma omp parallel for private(ofile)
      +
      117 for (int i = 0; i < 4; i++) {
      +
      118 int steps = 4000 * std::pow(2, i);
      +
      119 double dt = time / (double)steps;
      +
      120 ofile.open(path + std::to_string(steps) + "_steps.txt");
      +
      121 PenningTrap trap(std::vector<Particle>{p1});
      +
      122 simulation_t res = trap.simulate(time, steps, "euler", false);
      +
      123 for (int i = 0; i < steps; i++) {
      +
      124 ofile << arma::norm(res.r_vecs[0][i]
      + +
      126 << '\n';
      +
      127 }
      +
      128 ofile.close();
      +
      129 }
      +
      130}
      +
      131
      + +
      135{
      +
      136 PenningTrap trap((unsigned)100);
      +
      137
      +
      138 double time = 50.; // microseconds
      +
      139
      +
      140 // trap.write_simulation_to_dir("output/simulate_100_particles", time, N,
      +
      141 //"rk4", false);
      +
      142 trap.simulate(time, N, "rk4", true);
      +
      143}
      +
      144
      + +
      153{
      +
      154 double time = 500.;
      +
      155
      +
      156 double amplitudes[]{.1, .4, .7};
      +
      157
      +
      158 double freq_start = .2;
      +
      159 double freq_end = 2.5;
      +
      160 double freq_increment = .02;
      +
      161 size_t freq_iterations =
      +
      162 (size_t)((freq_end - freq_start) / freq_increment) + 1;
      +
      163
      +
      164 double res[4][freq_iterations];
      +
      165
      +
      166 std::string path = "output/time_dependent_potential/";
      +
      167 mkpath(path);
      +
      168
      +
      169 std::ofstream ofile;
      +
      170
      +
      171#pragma omp parallel for
      +
      172 // Insert frequencies
      +
      173 for (size_t i = 0; i < freq_iterations; i++) {
      +
      174 res[0][i] = freq_start + freq_increment * i;
      +
      175 }
      +
      176
      +
      177#pragma omp parallel
      +
      178 {
      +
      179 // Each thread creates a PenningTrap instance and reuses it throughout
      +
      180 // the sweep.
      +
      181 PenningTrap trap((uint)100);
      +
      182#pragma omp for collapse(2)
      +
      183 for (size_t i = 0; i < 3; i++) {
      +
      184 for (size_t j = 0; j < freq_iterations; j++) {
      +
      185 // Reset particles and give new time dependent potential.
      +
      186 trap.reinitialize(amplitudes[i], res[0][j]);
      +
      187 res[i + 1][j] =
      +
      188 trap.fraction_of_particles_left(time, N, "rk4", false);
      +
      189 }
      +
      190 }
      +
      191 }
      +
      192
      +
      193 // Write results to file
      +
      194 ofile.open(path + "wide_sweep.txt");
      +
      195 for (size_t i = 0; i < freq_iterations; i++) {
      +
      196 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
      +
      197 << res[3][i] << '\n';
      +
      198 }
      +
      199 ofile.close();
      +
      200}
      +
      201
      + +
      210{
      +
      211 double time = 500.;
      +
      212
      +
      213 double amplitudes[]{.1, .4, .7};
      +
      214
      +
      215 double freq_start = 1.1;
      +
      216 double freq_end = 1.7;
      +
      217 double freq_increment = .002;
      +
      218 size_t freq_iterations =
      +
      219 (size_t)((freq_end - freq_start) / freq_increment) + 1;
      +
      220
      +
      221 double res[4][freq_iterations];
      +
      222
      +
      223 std::string path = "output/time_dependent_potential/";
      +
      224 mkpath(path);
      +
      225
      +
      226 std::ofstream ofile;
      +
      227
      +
      228#pragma omp parallel for
      +
      229 // Insert frequencies
      +
      230 for (size_t i = 0; i < freq_iterations; i++) {
      +
      231 res[0][i] = freq_start + freq_increment * i;
      +
      232 }
      +
      233
      +
      234#pragma omp parallel
      +
      235 {
      +
      236 // Each thread creates a PenningTrap instance and reuses it throughout
      +
      237 // the sweep.
      +
      238 PenningTrap trap((uint)100);
      +
      239#pragma omp for collapse(2)
      +
      240 for (size_t i = 0; i < 3; i++) {
      +
      241 for (size_t j = 0; j < freq_iterations; j++) {
      +
      242 // Reset particles and give new time dependent potential.
      +
      243 trap.reinitialize(amplitudes[i], res[0][j]);
      +
      244 res[i + 1][j] =
      +
      245 trap.fraction_of_particles_left(time, N, "rk4", false);
      +
      246 }
      +
      247 }
      +
      248 }
      +
      249
      +
      250 // Write results to file
      +
      251 ofile.open(path + "narrow_sweep.txt");
      +
      252 for (size_t i = 0; i < freq_iterations; i++) {
      +
      253 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
      +
      254 << res[3][i] << '\n';
      +
      255 }
      +
      256 ofile.close();
      +
      257}
      +
      258
      + +
      267{
      +
      268 double time = 500.;
      +
      269
      +
      270 double amplitudes[]{.1, .4, .7};
      +
      271
      +
      272 double freq_start = 1.1;
      +
      273 double freq_end = 1.7;
      +
      274 double freq_increment = .002;
      +
      275 size_t freq_iterations =
      +
      276 (size_t)((freq_end - freq_start) / freq_increment) + 1;
      +
      277
      +
      278 double res[4][freq_iterations];
      +
      279
      +
      280 std::string path = "output/time_dependent_potential/";
      +
      281 mkpath(path);
      +
      282
      +
      283 std::ofstream ofile;
      +
      284
      +
      285#pragma omp parallel for
      +
      286 for (size_t i = 0; i < freq_iterations; i++) {
      +
      287 res[0][i] = freq_start + freq_increment * i;
      +
      288 }
      +
      289
      +
      290#pragma omp parallel
      +
      291 {
      +
      292 // Each thread creates a PenningTrap instance and reuses it throughout
      +
      293 // the sweep.
      +
      294 PenningTrap trap((uint)100);
      +
      295#pragma omp for collapse(2)
      +
      296 for (size_t i = 0; i < 3; i++) {
      +
      297 for (size_t j = 0; j < freq_iterations; j++) {
      +
      298 // Reset particles and give new time dependent potential.
      +
      299 trap.reinitialize(amplitudes[i], res[0][j]);
      +
      300 res[i + 1][j] = trap.fraction_of_particles_left(time, N);
      +
      301 }
      +
      302 }
      +
      303 }
      +
      304
      +
      305 // Write results to file
      +
      306 ofile.open(path + "narrow_sweep_interactions.txt");
      +
      307 for (size_t i = 0; i < freq_iterations; i++) {
      +
      308 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
      +
      309 << res[3][i] << '\n';
      +
      310 }
      +
      311 ofile.close();
      +
      312}
      +
      313
      +
      314int main()
      +
      315{
      +
      316 int option = 1;
      +
      317 bool chosen = false;
      +
      318
      +
      319 system("clear");
      +
      320 std::cout << "(1) All (default)\n"
      +
      321 << "(2) Simulate single particle\n"
      +
      322 << "(3) simulate 2 particles\n"
      +
      323 << "(4) Simulate single particle with different time steps\n"
      +
      324 << "(5) Simulate 100 particles\n"
      +
      325 << "(6) Potential resonance wide sweep\n"
      +
      326 << "(7) Potential resonance narrow sweep without particle "
      +
      327 "interactions\n"
      +
      328 << "(8) Potential resonance narrow sweep with particle "
      +
      329 "interaction\n"
      +
      330 << "Select what to run: ";
      +
      331 std::cin >> std::noskipws;
      +
      332 do {
      +
      333 if (!(std::cin >> option) || option < 1 || option > 8) {
      +
      334 std::cin.clear();
      +
      335 std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
      +
      336 system("clear");
      +
      337 std::cout
      +
      338 << "(1) All (default)\n"
      +
      339 << "(2) Simulate single particle\n"
      +
      340 << "(3) simulate 2 particles\n"
      +
      341 << "(4) Simulate single particle with different time steps\n"
      +
      342 << "(5) Simulate 100 particles\n"
      +
      343 << "(6) Potential resonance wide sweep\n"
      +
      344 << "(7) Potential resonance narrow sweep without particle "
      +
      345 "interactions\n"
      +
      346 << "(8) Potential resonance narrow sweep with particle "
      +
      347 "interaction\n"
      +
      348 << "Not a valid option, please enter a valid number: ";
      +
      349 } else {
      +
      350 chosen = true;
      +
      351 }
      +
      352 } while (!chosen);
      +
      353
      +
      354 double start, end;
      +
      355
      +
      356 system("clear");
      +
      357
      +
      358 start = omp_get_wtime();
      +
      359 switch (option) {
      +
      360 case 1:
      +
      361 std::cout << "Running simulate_single_particle\n";
      + +
      363
      +
      364 std::cout << "Running simulate_two_particles\n";
      + +
      366
      +
      367 std::cout << "Running simulate_single_particle_with_different_steps\n";
      + +
      369
      +
      370 std::cout << "Running simulate_100_particles\n";
      + +
      372
      +
      373 std::cout << "Running potential_resonance_wide_sweep\n";
      + +
      375
      +
      376 std::cout << "Running potential_resonance_narrow_sweep\n";
      + +
      378
      +
      379 std::cout << "Running potential_resonance_narrow_sweep_interaction\n";
      + +
      381 break;
      +
      382 case 2:
      +
      383 std::cout << "Running simulate_single_particle\n";
      + +
      385 break;
      +
      386 case 3:
      +
      387 std::cout << "Running simulate_two_particles\n";
      + +
      389 break;
      +
      390 case 4:
      +
      391 std::cout << "Running simulate_single_particle_with_different_steps\n";
      + +
      393 break;
      +
      394 case 5:
      +
      395 std::cout << "Running simulate_100_particles\n";
      + +
      397 break;
      +
      398 case 6:
      +
      399 std::cout << "Running potential_resonance_wide_sweep\n";
      + +
      401 break;
      +
      402 case 7:
      +
      403 std::cout << "Running potential_resonance_narrow_sweep\n";
      + +
      405 break;
      +
      406 case 8:
      +
      407 std::cout << "Running potential_resonance_narrow_sweep_interaction\n";
      + +
      409 break;
      +
      410 }
      +
      411 end = omp_get_wtime();
      +
      412
      +
      413 std::cout << "Time: " << end - start << " seconds" << std::endl;
      +
      414
      +
      415 return 0;
      +
      416}
      A class for simulating a Penning trap.
      -
      A class that holds attributes of a particle.
      Definition: Particle.hpp:21
      -
      A class that simulates a Penning trap.
      Definition: PenningTrap.hpp:30
      -
      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.
      -
      #define T
      1 Tesla. unit:
      Definition: constants.hpp:17
      -
      #define V
      1 Volt. unit:
      Definition: constants.hpp:19
      -
      arma::vec::fixed< 3 > vec_3d
      Typedef for a fixed 3d arma vector.
      Definition: typedefs.hpp:36
      +
      A class that holds attributes of a particle.
      Definition: Particle.hpp:23
      +
      A class that simulates a Penning trap.
      Definition: PenningTrap.hpp:32
      +
      simulation_t simulate(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
      Simulate the particle system inside the Penning trap over a certain amount of time.
      +
      void reinitialize(double f, double omega_V, double t=0.)
      Give all particles new positions and velocities, and change t and V_0.
      +
      double fraction_of_particles_left(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
      Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
      +
      void write_simulation_to_dir(std::string path, double time, uint steps, std::string method="rk4", bool particle_interaction=true)
      Simulate and write the displacement of all particles to files.
      +
      Library of constants.
      +
      #define T
      1 Tesla. unit:
      Definition: constants.hpp:21
      +
      #define CA_MASS
      Mass of a single calcium ion. unit: amu.
      Definition: constants.hpp:29
      +
      #define V
      1 Volt. unit:
      Definition: constants.hpp:25
      +
      void simulate_100_particles()
      Simulate 100 particles over 50 .
      Definition: main.cpp:134
      +
      Particle p1(vec3{20., 0., 20.}, vec3{0., 25., 0.})
      Particle 1.
      +
      void potential_resonance_narrow_sweep()
      Simulate 100 particles over 500 using a time dependent potential.
      Definition: main.cpp:209
      +
      void potential_resonance_wide_sweep()
      Simulate 100 particles over 500 using a time dependent potential.
      Definition: main.cpp:152
      +
      void simulate_two_particles()
      Simulate 2 particles over the period of 50 with and without particle interactions.
      Definition: main.cpp:70
      +
      vec3 analytical_solution_particle_1(double t)
      The analytical solution for particle p1.
      Definition: main.cpp:37
      +
      void simulate_single_particle()
      Simulate a single particle over the period of 50 .
      Definition: main.cpp:55
      +
      void potential_resonance_narrow_sweep_interaction()
      Simulate 100 particles over 500 using a time dependent potential.
      Definition: main.cpp:266
      +
      void simulate_single_particle_with_different_steps()
      Simulate a single particle over 50 using different amount of steps and different methods.
      Definition: main.cpp:88
      +
      Particle p2(vec3{25., 25., 0.}, vec3{0., 40., 5.})
      Particle 2.
      +
      Typedef for PenningTrap::simulation return value.
      Definition: typedefs.hpp:40
      +
      arma::vec::fixed< 3 > vec3
      Typedef for a fixed 3d arma vector.
      Definition: typedefs.hpp:23
      Function prototypes and macros that are useful.
      -
      bool mkpath(std::string path, int mode=0777)
      Make path given.
      Definition: utils.cpp:76
      -
      #define DEBUG(msg)
      Writes a debug message.
      Definition: utils.hpp:36
      +
      bool mkpath(std::string path, int mode=0777)
      Make path given.
      Definition: utils.cpp:72
      diff --git a/docs/menudata.js b/docs/menudata.js index 74c1d7b..51a28c4 100644 --- a/docs/menudata.js +++ b/docs/menudata.js @@ -29,14 +29,39 @@ var menudata={children:[ {text:"Class List",url:"annotated.html"}, {text:"Class Index",url:"classes.html"}, {text:"Class Members",url:"functions.html",children:[ -{text:"All",url:"functions.html"}, +{text:"All",url:"functions.html",children:[ +{text:"a",url:"functions.html#index_a"}, +{text:"b",url:"functions.html#index_b"}, +{text:"d",url:"functions.html#index_d"}, +{text:"e",url:"functions.html#index_e"}, +{text:"f",url:"functions.html#index_f"}, +{text:"k",url:"functions.html#index_k"}, +{text:"m",url:"functions.html#index_m"}, +{text:"p",url:"functions.html#index_p"}, +{text:"q",url:"functions.html#index_q"}, +{text:"r",url:"functions.html#index_r"}, +{text:"s",url:"functions.html#index_s"}, +{text:"t",url:"functions.html#index_t"}, +{text:"v",url:"functions.html#index_v"}, +{text:"w",url:"functions.html#index_w"}]}, {text:"Functions",url:"functions_func.html"}, {text:"Variables",url:"functions_vars.html"}, {text:"Related Functions",url:"functions_rela.html"}]}]}, {text:"Files",url:"files.html",children:[ {text:"File List",url:"files.html"}, {text:"File Members",url:"globals.html",children:[ -{text:"All",url:"globals.html"}, +{text:"All",url:"globals.html",children:[ +{text:"_",url:"globals.html#index__5F"}, +{text:"a",url:"globals.html#index_a"}, +{text:"c",url:"globals.html#index_c"}, +{text:"d",url:"globals.html#index_d"}, +{text:"k",url:"globals.html#index_k"}, +{text:"m",url:"globals.html#index_m"}, +{text:"p",url:"globals.html#index_p"}, +{text:"s",url:"globals.html#index_s"}, +{text:"t",url:"globals.html#index_t"}, +{text:"v",url:"globals.html#index_v"}]}, {text:"Functions",url:"globals_func.html"}, +{text:"Variables",url:"globals_vars.html"}, {text:"Typedefs",url:"globals_type.html"}, {text:"Macros",url:"globals_defs.html"}]}]}]} diff --git a/docs/namespaceplot__3d.html b/docs/namespaceplot__3d.html new file mode 100644 index 0000000..508e8b0 --- /dev/null +++ b/docs/namespaceplot__3d.html @@ -0,0 +1,177 @@ + + + + + + + +Penning Trap Simulation: plot_3d Namespace Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      plot_3d Namespace Reference
      +
      +
      + + + + +

      +Functions

      def main ()
       
      + + + +

      +Variables

      dict params
       
      +

      Detailed Description

      +
       @package plot_3d

      Function Documentation

      + +

      ◆ main()

      + +
      +
      + + + + + + + +
      def plot_3d.main ()
      +
      + +

      Definition at line 22 of file plot_3d.py.

      + +
      +
      +

      Variable Documentation

      + +

      ◆ params

      + +
      +
      + + + + +
      dict plot_3d.params
      +
      +Initial value:
      1= {
      +
      2 "font.family": "Serif",
      +
      3 "font.serif": "Roman",
      +
      4 "text.usetex": True,
      +
      5 "axes.titlesize": "large",
      +
      6 "axes.labelsize": "large",
      +
      7 "xtick.labelsize": "large",
      +
      8 "ytick.labelsize": "large",
      +
      9 "legend.fontsize": "medium",
      +
      10 "figure.autolayout": True
      +
      11}
      +
      +

      Definition at line 9 of file plot_3d.py.

      + +
      +
      +
      +
      + + + + diff --git a/docs/namespaces.html b/docs/namespaces.html new file mode 100644 index 0000000..82851f0 --- /dev/null +++ b/docs/namespaces.html @@ -0,0 +1,118 @@ + + + + + + + +Penning Trap Simulation: Namespace List + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      Namespace List
      +
      +
      +
      Here is a list of all documented namespaces with brief descriptions:
      + + +
       Nplot_3d
      +
      +
      +
      + + + + diff --git a/docs/namespaces_dup.js b/docs/namespaces_dup.js new file mode 100644 index 0000000..6787057 --- /dev/null +++ b/docs/namespaces_dup.js @@ -0,0 +1,4 @@ +var namespaces_dup = +[ + [ "plot_3d", "namespaceplot__3d.html", null ] +]; \ No newline at end of file diff --git a/docs/navtreedata.js b/docs/navtreedata.js index 9640812..681af00 100644 --- a/docs/navtreedata.js +++ b/docs/navtreedata.js @@ -25,7 +25,25 @@ var NAVTREE = [ [ "Penning Trap Simulation", "index.html", [ - [ "Credits", "index.html#autotoc_md1", null ], + [ "Requirements", "index.html#autotoc_md1", [ + [ "Operating systems", "index.html#autotoc_md2", null ], + [ "Tools", "index.html#autotoc_md3", null ], + [ "Libraries", "index.html#autotoc_md4", null ] + ] ], + [ "Compiling", "index.html#autotoc_md5", null ], + [ "Running programs", "index.html#autotoc_md6", [ + [ "C++ binaries", "index.html#autotoc_md7", null ], + [ "Python scripts", "index.html#autotoc_md8", [ + [ "Install libraries", "index.html#autotoc_md9", null ], + [ "Running scripts", "index.html#autotoc_md10", null ] + ] ], + [ "Batch system", "index.html#autotoc_md11", null ] + ] ], + [ "Performance", "index.html#autotoc_md12", [ + [ "CPU", "index.html#autotoc_md13", null ], + [ "Times", "index.html#autotoc_md14", null ] + ] ], + [ "Credits", "index.html#autotoc_md15", null ], [ "Bug List", "bug.html", null ], [ "Classes", "annotated.html", [ [ "Class List", "annotated.html", "annotated_dup" ], @@ -42,6 +60,7 @@ var NAVTREE = [ "File Members", "globals.html", [ [ "All", "globals.html", null ], [ "Functions", "globals_func.html", null ], + [ "Variables", "globals_vars.html", null ], [ "Typedefs", "globals_type.html", null ], [ "Macros", "globals_defs.html", null ] ] ] diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js index 16caa0e..e8420ad 100644 --- a/docs/navtreeindex0.js +++ b/docs/navtreeindex0.js @@ -1,95 +1,151 @@ var NAVTREEINDEX0 = { -"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":[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], +"Particle_8cpp.html":[7,0,1,3], +"Particle_8cpp_source.html":[7,0,1,3], +"Particle_8hpp.html":[7,0,0,1], +"Particle_8hpp_source.html":[7,0,0,1], +"PenningTrap_8cpp.html":[7,0,1,4], +"PenningTrap_8cpp_source.html":[7,0,1,4], +"PenningTrap_8hpp.html":[7,0,0,2], +"PenningTrap_8hpp_source.html":[7,0,0,2], +"animate__100__particles_8py.html":[7,0,1,0,0], +"animate__100__particles_8py_source.html":[7,0,1,0,0], +"annotated.html":[6,0], +"bug.html":[5], +"classParticle.html":[6,0,0], +"classParticle.html#a1c59101411db43624828b766f87ad460":[6,0,0,4], +"classParticle.html#a3a10400add8dd22b8031330c2aafb6fe":[6,0,0,5], +"classParticle.html#a566dcc1de4bdc01251776948798ea8e1":[6,0,0,3], +"classParticle.html#aa797d319549dc2a0beb06cdbfd430232":[6,0,0,1], +"classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563":[6,0,0,2], +"classParticle.html#af1d7535fb8311eaa77d2b7b345882ec4":[6,0,0,0], +"classPenningTrap.html":[6,0,1], +"classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f":[6,0,1,25], +"classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716":[6,0,1,21], +"classPenningTrap.html#a2c01108b52c8e2a003cf9170da9e7682":[6,0,1,15], +"classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640":[6,0,1,23], +"classPenningTrap.html#a2fe1cefbae18fa5808155ee0d2df713c":[6,0,1,17], +"classPenningTrap.html#a361f2c4862c90b5e8e2a2f50c6a95655":[6,0,1,6], +"classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e":[6,0,1,5], +"classPenningTrap.html#a3c0a44e4e0a94366ff609e81fe463fa2":[6,0,1,18], +"classPenningTrap.html#a5846c8f75cdc543fd9cf0b2185a3ef22":[6,0,1,7], +"classPenningTrap.html#a5b6c6d4636f3a6e279ccde59d4a345e8":[6,0,1,0], +"classPenningTrap.html#a6069f82d8dbc7cadaebd228dbcd95018":[6,0,1,16], +"classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2":[6,0,1,22], +"classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8":[6,0,1,3], +"classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89":[6,0,1,28], +"classPenningTrap.html#a7a1d9f0528a12308de25bc30718da20a":[6,0,1,13], +"classPenningTrap.html#a7f210bb2768a5d79ced4b0df0df97598":[6,0,1,8], +"classPenningTrap.html#a826b7fa8e709d481eb1dee7d0c2cdc08":[6,0,1,10], +"classPenningTrap.html#a830be1b8cbf59664e060b6edbeaa302f":[6,0,1,1], +"classPenningTrap.html#a869f032f37d0569ed16f224b4c4356ae":[6,0,1,20], +"classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e":[6,0,1,27], +"classPenningTrap.html#a9a301b0540078c36697880ef204afdf3":[6,0,1,14], +"classPenningTrap.html#a9d1d8e90ca839b928aee1ad0cd4aff43":[6,0,1,12], +"classPenningTrap.html#aaee129f177657455348d0c8ae1441dea":[6,0,1,11], +"classPenningTrap.html#ab9ea97a406534bbe621a95215144875e":[6,0,1,4], +"classPenningTrap.html#ac529aa26c288f34eae184a67e6bac41f":[6,0,1,9], +"classPenningTrap.html#ad8bc4df7ab3eed53b16cfdff38e7760b":[6,0,1,19], +"classPenningTrap.html#addc96789dcfec07b75156e19fee82f4f":[6,0,1,2], +"classPenningTrap.html#ae915f6ad0eef1fb46530e836b6e071e5":[6,0,1,26], +"classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4":[6,0,1,24], +"classPenningTrapTest.html":[6,0,2], +"classPenningTrapTest.html#a5f4f0b150e54ce463bb29f76d49883f9":[6,0,2,2], +"classPenningTrapTest.html#a68449d508e66205bc8b27fa5f60db508":[6,0,2,4], +"classPenningTrapTest.html#a6a303be62039ca2ecccd8252744d4dc8":[6,0,2,1], +"classPenningTrapTest.html#ad668d7d875bdc1909a42426bf9dead9e":[6,0,2,0], +"classPenningTrapTest.html#ae6d0c8e0d80338fb7c7edefc97331046":[6,0,2,3], +"classes.html":[6,1], +"constants_8hpp.html":[7,0,0,0], +"constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5":[7,0,0,0,3], +"constants_8hpp.html#a2ff491cc7958ffd5e749c518a4a60ec8":[7,0,0,0,1], +"constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb":[7,0,0,0,2], +"constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb":[7,0,0,0,4], +"constants_8hpp.html#af7602a3a314957137ad1cd719aa23789":[7,0,0,0,0], +"constants_8hpp_source.html":[7,0,0,0], +"dir_634e799a3947388232110823971192a8.html":[7,0,1,0], +"dir_68267d1309a1af8e8297ef4c3efbcdba.html":[7,0,1], +"dir_d44c64559bbebec7f509842c48db8b23.html":[7,0,0], +"files.html":[7,0], +"frequency__narrow__sweeps__long_8cpp.html":[7,0,1,1], +"frequency__narrow__sweeps__long_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea":[7,0,1,1,0], +"frequency__narrow__sweeps__long_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb":[7,0,1,1,1], +"frequency__narrow__sweeps__long_8cpp_source.html":[7,0,1,1], +"functions.html":[6,2,0], +"functions_func.html":[6,2,1], +"functions_rela.html":[6,2,3], +"functions_vars.html":[6,2,2], +"globals.html":[7,1,0], +"globals_defs.html":[7,1,4], +"globals_func.html":[7,1,1], +"globals_type.html":[7,1,3], +"globals_vars.html":[7,1,2], "index.html":[], "index.html#autotoc_md1":[0], -"main_8cpp.html":[3,0,1,1], -"main_8cpp_source.html":[3,0,1,1], +"index.html#autotoc_md10":[2,1,1], +"index.html#autotoc_md11":[2,2], +"index.html#autotoc_md12":[3], +"index.html#autotoc_md13":[3,0], +"index.html#autotoc_md14":[3,1], +"index.html#autotoc_md15":[4], +"index.html#autotoc_md2":[0,0], +"index.html#autotoc_md3":[0,1], +"index.html#autotoc_md4":[0,2], +"index.html#autotoc_md5":[1], +"index.html#autotoc_md6":[2], +"index.html#autotoc_md7":[2,0], +"index.html#autotoc_md8":[2,1], +"index.html#autotoc_md9":[2,1,0], +"main_8cpp.html":[7,0,1,2], +"main_8cpp.html#a213713d6ecc02a32b588ffd179dc7513":[7,0,1,2,4], +"main_8cpp.html#a2efa69bb9d93049429ce4637075f1d30":[7,0,1,2,8], +"main_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea":[7,0,1,2,1], +"main_8cpp.html#a6b38b477c18e2f4268779751a88edab1":[7,0,1,2,3], +"main_8cpp.html#a783789519f97c6430081171cacb0ffb1":[7,0,1,2,7], +"main_8cpp.html#a8d92fb2ad085065fbd14718647551657":[7,0,1,2,0], +"main_8cpp.html#a8fdbe2d5a872e50ef5ec1263243589d6":[7,0,1,2,5], +"main_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb":[7,0,1,2,2], +"main_8cpp.html#ac67e0d59227856c4d42e7d01c75e0ad2":[7,0,1,2,6], +"main_8cpp.html#ac70b61df65f4336f57ea9b4c35250df7":[7,0,1,2,9], +"main_8cpp_source.html":[7,0,1,2], "pages.html":[], -"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] +"plot__2__particles_8py.html":[7,0,1,0,1], +"plot__2__particles_8py_source.html":[7,0,1,0,1], +"plot__3d_8py.html":[7,0,1,0,2], +"plot__3d_8py_source.html":[7,0,1,0,2], +"plot__particles__left_8py.html":[7,0,1,0,3], +"plot__particles__left_8py_source.html":[7,0,1,0,3], +"plot__phase__space_8py.html":[7,0,1,0,4], +"plot__phase__space_8py_source.html":[7,0,1,0,4], +"plot__relative__error_8py.html":[7,0,1,0,5], +"plot__relative__error_8py_source.html":[7,0,1,0,5], +"plot__single__particle_8py.html":[7,0,1,0,6], +"plot__single__particle_8py_source.html":[7,0,1,0,6], +"structsimulation.html":[6,0,3], +"test__suite_8cpp.html":[7,0,1,5], +"test__suite_8cpp_source.html":[7,0,1,5], +"typedefs_8hpp.html":[7,0,0,3], +"typedefs_8hpp.html#a33418f31f28663b8414c8f7182998c22":[7,0,0,3,3], +"typedefs_8hpp.html#a3bdfb73a02f88ae32b6128ef747c4aea":[7,0,0,3,5], +"typedefs_8hpp.html#a46482a2697556c00556c9d73f461784f":[7,0,0,3,2], +"typedefs_8hpp.html#a784799c37b5e4fb8bf4f6368e004dec6":[7,0,0,3,4], +"typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af":[7,0,0,3,1], +"typedefs_8hpp_source.html":[7,0,0,3], +"utils_8cpp.html":[7,0,1,6], +"utils_8cpp.html#a58565270b643b24e3132f38c653e0199":[7,0,1,6,3], +"utils_8cpp.html#a6be6f938bcbb235ebb6a2ed9d08411b2":[7,0,1,6,0], +"utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746":[7,0,1,6,4], +"utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de":[7,0,1,6,2], +"utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b":[7,0,1,6,1], +"utils_8cpp_source.html":[7,0,1,6], +"utils_8hpp.html":[7,0,0,4], +"utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38":[7,0,0,4,4], +"utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168":[7,0,0,4,0], +"utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa":[7,0,0,4,5], +"utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[7,0,0,4,1], +"utils_8hpp.html#ab3e0cf669bddc59bd53998490ffb68b9":[7,0,0,4,3], +"utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d":[7,0,0,4,6], +"utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384":[7,0,0,4,7], +"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[7,0,0,4,2], +"utils_8hpp_source.html":[7,0,0,4] }; diff --git a/docs/plot__2__particles_8py.html b/docs/plot__2__particles_8py.html new file mode 100644 index 0000000..48c34d9 --- /dev/null +++ b/docs/plot__2__particles_8py.html @@ -0,0 +1,189 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_2_particles.py File Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      plot_2_particles.py File Reference
      +
      +
      + +

      Plot 2 particles with and without particle interactions in the xy-plane. +More...

      + +

      Go to the source code of this file.

      + + + + +

      +Functions

      def plot_2_particles.main ()
       
      + + + +

      +Variables

      dict plot_2_particles.params
       
      +

      Detailed Description

      +

      Plot 2 particles with and without particle interactions in the xy-plane.

      +
      Author
      Cory Alexander Balaton (coryab)
      +
      +Janita Ovidie Sandtrøen Willumsen (janitaws)
      +
      Version
      1.0
      +
      Bug:
      No known bugs
      + +

      Definition in file plot_2_particles.py.

      +

      Function Documentation

      + +

      ◆ main()

      + +
      +
      + + + + + + + +
      def plot_2_particles.main ()
      +
      + +

      Definition at line 30 of file plot_2_particles.py.

      + +
      +
      +

      Variable Documentation

      + +

      ◆ params

      + +
      +
      + + + + +
      dict plot_2_particles.params
      +
      +Initial value:
      1= {
      +
      2 "font.family": "Serif",
      +
      3 "font.serif": "Roman",
      +
      4 "text.usetex": True,
      +
      5 "axes.titlesize": "large",
      +
      6 "axes.labelsize": "large",
      +
      7 "xtick.labelsize": "large",
      +
      8 "ytick.labelsize": "large",
      +
      9 "legend.fontsize": "medium"
      +
      10}
      +
      +

      Definition at line 18 of file plot_2_particles.py.

      + +
      +
      +
      +
      + + + + diff --git a/docs/plot__2__particles_8py_source.html b/docs/plot__2__particles_8py_source.html new file mode 100644 index 0000000..f248e58 --- /dev/null +++ b/docs/plot__2__particles_8py_source.html @@ -0,0 +1,179 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_2_particles.py Source File + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      plot_2_particles.py
      +
      +
      +Go to the documentation of this file.
      1
      +
      12
      +
      13import matplotlib.pyplot as plt
      +
      14import numpy as np
      +
      15import seaborn as sns
      +
      16
      +
      17sns.set_theme()
      +
      18params = {
      +
      19 "font.family": "Serif",
      +
      20 "font.serif": "Roman",
      +
      21 "text.usetex": True,
      +
      22 "axes.titlesize": "large",
      +
      23 "axes.labelsize": "large",
      +
      24 "xtick.labelsize": "large",
      +
      25 "ytick.labelsize": "large",
      +
      26 "legend.fontsize": "medium"
      +
      27}
      +
      28plt.rcParams.update(params)
      +
      29
      +
      30def main():
      +
      31 directories = {
      +
      32 "output/simulate_2_particles/no_interaction/",
      +
      33 "output/simulate_2_particles/with_interaction/",
      +
      34 }
      +
      35 files = [
      +
      36 "particle_0_r.txt",
      +
      37 "particle_1_r.txt",
      +
      38 ]
      +
      39 outputs = [
      +
      40 "../latex/images/simulate_2_particles_no_interaction_xy.pdf",
      +
      41 "../latex/images/simulate_2_particles_interaction_xy.pdf",
      +
      42 ]
      +
      43 labels = [
      +
      44 r"$p_1$",
      +
      45 r"$p_2$",
      +
      46 r"$\hat{p}_1$",
      +
      47 r"$\hat{p}_2$",
      +
      48 ]
      +
      49 colors = [
      +
      50 "seagreen",
      +
      51 "darkred"
      +
      52 ]
      +
      53 start_pos = set()
      +
      54 for dir, output in zip(directories, outputs):
      +
      55 fig, ax = plt.subplots()
      +
      56 for label, color, file in zip(labels, colors, files):
      +
      57 with open(dir+file) as f:
      +
      58 lines = f.readlines()
      +
      59 t = np.linspace(0, 50, len(lines))
      +
      60 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
      +
      61 ax.plot(r[:,0], r[:,1], label=label, color=color)
      +
      62 start_pos.add((r[0,0],r[0,1]))
      +
      63
      +
      64 for pos in start_pos:
      +
      65 ax.plot(*pos, "o", color="black")
      +
      66
      +
      67 ax.set_xlabel(r"x $(\mu m)$")
      +
      68 ax.set_ylabel(r"y $(\mu m)$")
      +
      69 ax.legend(loc="upper right")
      +
      70 ax.axis("equal")
      +
      71 fig.savefig(output, bbox_inches="tight")
      +
      72
      +
      73
      +
      74if __name__ == "__main__":
      +
      75 main()
      +
      +
      + + + + diff --git a/docs/plot__3d_8py.html b/docs/plot__3d_8py.html new file mode 100644 index 0000000..a26c163 --- /dev/null +++ b/docs/plot__3d_8py.html @@ -0,0 +1,190 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_3d.py File Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      plot_3d.py File Reference
      +
      +
      + +

      Plot 2 particles with and without particle interactions in 3D. +More...

      + +

      Go to the source code of this file.

      + + + + +

      +Functions

      def plot_3d.main ()
       
      + + + +

      +Variables

      dict plot_3d.params
       
      +

      Detailed Description

      +

      Plot 2 particles with and without particle interactions in 3D.

      +
      Author
      Cory Alexander Balaton (coryab)
      +
      +Janita Ovidie Sandtrøen Willumsen (janitaws)
      +
      Version
      1.0
      +
      Bug:
      No known bugs
      + +

      Definition in file plot_3d.py.

      +

      Function Documentation

      + +

      ◆ main()

      + +
      +
      + + + + + + + +
      def plot_3d.main ()
      +
      + +

      Definition at line 30 of file plot_3d.py.

      + +
      +
      +

      Variable Documentation

      + +

      ◆ params

      + +
      +
      + + + + +
      dict plot_3d.params
      +
      +Initial value:
      1= {
      +
      2 "font.family": "Serif",
      +
      3 "font.serif": "Roman",
      +
      4 "text.usetex": True,
      +
      5 "axes.titlesize": "large",
      +
      6 "axes.labelsize": "large",
      +
      7 "xtick.labelsize": "large",
      +
      8 "ytick.labelsize": "large",
      +
      9 "legend.fontsize": "medium",
      +
      10 "figure.autolayout": True
      +
      11}
      +
      +

      Definition at line 17 of file plot_3d.py.

      + +
      +
      +
      +
      + + + + diff --git a/docs/plot__3d_8py_source.html b/docs/plot__3d_8py_source.html new file mode 100644 index 0000000..039e889 --- /dev/null +++ b/docs/plot__3d_8py_source.html @@ -0,0 +1,172 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_3d.py Source File + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      plot_3d.py
      +
      +
      +Go to the documentation of this file.
      1
      +
      11
      +
      12import matplotlib.pyplot as plt
      +
      13import numpy as np
      +
      14import seaborn as sns
      +
      15
      +
      16sns.set_theme()
      +
      17params = {
      +
      18 "font.family": "Serif",
      +
      19 "font.serif": "Roman",
      +
      20 "text.usetex": True,
      +
      21 "axes.titlesize": "large",
      +
      22 "axes.labelsize": "large",
      +
      23 "xtick.labelsize": "large",
      +
      24 "ytick.labelsize": "large",
      +
      25 "legend.fontsize": "medium",
      +
      26 "figure.autolayout": True
      +
      27}
      +
      28plt.rcParams.update(params)
      +
      29
      +
      30def main():
      +
      31 files = [
      +
      32 "output/simulate_2_particles/no_interaction/particle_0_r.txt",
      +
      33 "output/simulate_2_particles/no_interaction/particle_1_r.txt",
      +
      34 "output/simulate_2_particles/with_interaction/particle_0_r.txt",
      +
      35 "output/simulate_2_particles/with_interaction/particle_1_r.txt"
      +
      36 ]
      +
      37 labels = [
      +
      38 r"$p_1$",
      +
      39 r"$p_2$",
      +
      40 r"$\hat{p}_1$",
      +
      41 r"$\hat{p}_2$",
      +
      42 ]
      +
      43 colors = [
      +
      44 "mediumaquamarine",
      +
      45 "salmon",
      +
      46 "seagreen",
      +
      47 "darkred"
      +
      48 ]
      +
      49 ax = plt.figure().add_subplot(projection="3d")
      +
      50 for label, color, file in zip(labels, colors, files):
      +
      51 with open(file) as f:
      +
      52 lines = f.readlines()
      +
      53 t = np.linspace(0, 50, len(lines))
      +
      54 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
      +
      55 ax.plot(r[:,0], r[:,1], r[:,2], label=label, color=color)
      +
      56
      +
      57 ax.set_xlabel(r"x $(\mu m)$")
      +
      58 ax.set_ylabel(r"y $(\mu m)$")
      +
      59 ax.set_zlabel(r"z $(\mu m)$")
      +
      60 ax.view_init(10,-35)
      +
      61
      +
      62 plt.legend()
      +
      63 plt.savefig("../latex/images/3d_plot.pdf")
      +
      64
      +
      65
      +
      66if __name__ == "__main__":
      +
      67 main()
      +
      +
      + + + + diff --git a/docs/plot__particles__left_8py.html b/docs/plot__particles__left_8py.html new file mode 100644 index 0000000..93cc53c --- /dev/null +++ b/docs/plot__particles__left_8py.html @@ -0,0 +1,189 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_particles_left.py File Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      plot_particles_left.py File Reference
      +
      +
      + +

      Plot how many particles are left after 500 microseconds using different angular frequencies. +More...

      + +

      Go to the source code of this file.

      + + + + +

      +Functions

      def plot_particles_left.main ()
       
      + + + +

      +Variables

      dict plot_particles_left.params
       
      +

      Detailed Description

      +

      Plot how many particles are left after 500 microseconds using different angular frequencies.

      +
      Author
      Cory Alexander Balaton (coryab)
      +
      +Janita Ovidie Sandtrøen Willumsen (janitaws)
      +
      Version
      1.0
      +
      Bug:
      No known bugs
      + +

      Definition in file plot_particles_left.py.

      +

      Function Documentation

      + +

      ◆ main()

      + +
      +
      + + + + + + + +
      def plot_particles_left.main ()
      +
      + +

      Definition at line 29 of file plot_particles_left.py.

      + +
      +
      +

      Variable Documentation

      + +

      ◆ params

      + +
      +
      + + + + +
      dict plot_particles_left.params
      +
      +Initial value:
      1= {
      +
      2 "font.family": "Serif",
      +
      3 "font.serif": "Roman",
      +
      4 "text.usetex": True,
      +
      5 "axes.titlesize": "large",
      +
      6 "axes.labelsize": "large",
      +
      7 "xtick.labelsize": "large",
      +
      8 "ytick.labelsize": "large",
      +
      9 "legend.fontsize": "medium"
      +
      10}
      +
      +

      Definition at line 17 of file plot_particles_left.py.

      + +
      +
      +
      +
      + + + + diff --git a/docs/plot__particles__left_8py_source.html b/docs/plot__particles__left_8py_source.html index c9ab258..9de8c42 100644 --- a/docs/plot__particles__left_8py_source.html +++ b/docs/plot__particles__left_8py_source.html @@ -5,7 +5,7 @@ -Penning Trap Simulation: src/plot_particles_left.py Source File +Penning Trap Simulation: src/scripts/plot_particles_left.py Source File @@ -101,45 +101,83 @@ $(document).ready(function(){initNavTree('plot__particles__left_8py_source.html'
      plot_particles_left.py
      -
      1import matplotlib.pyplot as plt
      -
      2
      -
      3def main():
      -
      4 files = [
      -
      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",
      -
      8 ]
      -
      9 vals = [
      -
      10 .1,
      -
      11 .4,
      -
      12 .7
      -
      13 ]
      -
      14 for i in range(3):
      -
      15 with open(files[i]) as f:
      -
      16 lines = f.readlines()
      -
      17 x = []
      -
      18 y = []
      -
      19 for line in lines:
      -
      20 a,b = line.strip().split(",")
      -
      21 x.append(float(a))
      -
      22 y.append(float(b))
      -
      23 plt.plot(x,y,label=f"amplitude: {vals[i]}")
      -
      24
      -
      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")
      -
      29 plt.legend()
      -
      30 plt.show()
      -
      31
      -
      32if __name__ == "__main__":
      -
      33 main()
      +Go to the documentation of this file.
      1
      +
      12
      +
      13import matplotlib.pyplot as plt
      +
      14import seaborn as sns
      +
      15
      +
      16sns.set_theme()
      +
      17params = {
      +
      18 "font.family": "Serif",
      +
      19 "font.serif": "Roman",
      +
      20 "text.usetex": True,
      +
      21 "axes.titlesize": "large",
      +
      22 "axes.labelsize": "large",
      +
      23 "xtick.labelsize": "large",
      +
      24 "ytick.labelsize": "large",
      +
      25 "legend.fontsize": "medium"
      +
      26}
      +
      27plt.rcParams.update(params)
      +
      28
      +
      29def main():
      +
      30 colors = [
      +
      31 "mediumseagreen",
      +
      32 "darkred",
      +
      33 "darkgoldenrod"
      +
      34 ]
      +
      35 files = [
      +
      36 "output/time_dependent_potential/wide_sweep.txt",
      +
      37 "output/time_dependent_potential/narrow_sweep.txt",
      +
      38 "output/time_dependent_potential/narrow_sweep_fine.txt",
      +
      39 "output/time_dependent_potential/narrow_sweep_interactions.txt",
      +
      40 "output/time_dependent_potential/narrow_sweep_interactions_fine.txt",
      +
      41 ]
      +
      42 outputs = [
      +
      43 "../latex/images/particles_left_wide_sweep.pdf",
      +
      44 "../latex/images/particles_left_narrow_sweep.pdf",
      +
      45 "../latex/images/particles_left_narrow_sweep_fine.pdf",
      +
      46 "../latex/images/particles_left_narrow_sweep_interactions.pdf",
      +
      47 "../latex/images/particles_left_narrow_sweep_interactions_fine.pdf",
      +
      48 ]
      +
      49 for file, output in zip(files, outputs):
      +
      50 with open(file) as f:
      +
      51 lines = f.readlines()
      +
      52 x = []
      +
      53 y1 = []
      +
      54 y2 = []
      +
      55 y3 = []
      +
      56 for line in lines:
      +
      57 l = line.strip().split(",")
      +
      58 x.append(float(l[0]))
      +
      59 y1.append(float(l[1]))
      +
      60 y2.append(float(l[2]))
      +
      61 y3.append(float(l[3]))
      +
      62
      +
      63 fig, ax = plt.subplots()
      +
      64 ax.plot(x, y1, label=r"$f_{1} = 0.1$", color=colors[0])
      +
      65 ax.plot(x, y2, label=r"$f_{2} = 0.4$", color=colors[1])
      +
      66 ax.plot(x, y3, label=r"$f_{3} = 0.7$", color=colors[2])
      +
      67
      +
      68 ax.set_xlabel(r"Angular frequency $\omega_V$ (MHz)")
      +
      69 # ax.set_xlim((0, 2.8))
      +
      70 ax.set_ylabel(r"Fraction of particles left")
      +
      71 # ax.set_ylim((-0.1, 1.1))
      +
      72 # plt.title(r"The fraction of particles left in the Penning trap "
      +
      73 # "after 500 microseconds for different amplitudes and frequencies")
      +
      74
      +
      75 ax.legend(loc="upper right")
      +
      76
      +
      77 # plt.show()
      +
      78 fig.savefig(output, bbox_inches="tight")
      +
      79
      +
      80if __name__ == "__main__":
      +
      81 main()
      diff --git a/docs/plot__phase__space_8py.html b/docs/plot__phase__space_8py.html new file mode 100644 index 0000000..4900d42 --- /dev/null +++ b/docs/plot__phase__space_8py.html @@ -0,0 +1,189 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_phase_space.py File Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      plot_phase_space.py File Reference
      +
      +
      + +

      Plot the phase space for 2 particles in the x and z direction, with and without particle interactions. +More...

      + +

      Go to the source code of this file.

      + + + + +

      +Functions

      def plot_phase_space.main ()
       
      + + + +

      +Variables

      dict plot_phase_space.params
       
      +

      Detailed Description

      +

      Plot the phase space for 2 particles in the x and z direction, with and without particle interactions.

      +
      Author
      Cory Alexander Balaton (coryab)
      +
      +Janita Ovidie Sandtrøen Willumsen (janitaws)
      +
      Version
      1.0
      +
      Bug:
      No known bugs
      + +

      Definition in file plot_phase_space.py.

      +

      Function Documentation

      + +

      ◆ main()

      + +
      +
      + + + + + + + +
      def plot_phase_space.main ()
      +
      + +

      Definition at line 31 of file plot_phase_space.py.

      + +
      +
      +

      Variable Documentation

      + +

      ◆ params

      + +
      +
      + + + + +
      dict plot_phase_space.params
      +
      +Initial value:
      1= {
      +
      2 "font.family": "Serif",
      +
      3 "font.serif": "Roman",
      +
      4 "text.usetex": True,
      +
      5 "axes.titlesize": "large",
      +
      6 "axes.labelsize": "large",
      +
      7 "xtick.labelsize": "large",
      +
      8 "ytick.labelsize": "large",
      +
      9 "legend.fontsize": "medium",
      +
      10}
      +
      +

      Definition at line 18 of file plot_phase_space.py.

      + +
      +
      +
      +
      + + + + diff --git a/docs/plot__phase__space_8py_source.html b/docs/plot__phase__space_8py_source.html new file mode 100644 index 0000000..8bb2bfc --- /dev/null +++ b/docs/plot__phase__space_8py_source.html @@ -0,0 +1,190 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_phase_space.py Source File + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      plot_phase_space.py
      +
      +
      +Go to the documentation of this file.
      1
      +
      12
      +
      13import matplotlib.pyplot as plt
      +
      14import numpy as np
      +
      15import seaborn as sns
      +
      16
      +
      17sns.set_theme()
      +
      18params = {
      +
      19 "font.family": "Serif",
      +
      20 "font.serif": "Roman",
      +
      21 "text.usetex": True,
      +
      22 "axes.titlesize": "large",
      +
      23 "axes.labelsize": "large",
      +
      24 "xtick.labelsize": "large",
      +
      25 "ytick.labelsize": "large",
      +
      26 "legend.fontsize": "medium",
      +
      27}
      +
      28plt.rcParams.update(params)
      +
      29
      +
      30
      +
      31def main():
      +
      32 directories = [
      +
      33 "output/simulate_2_particles/no_interaction/",
      +
      34 "output/simulate_2_particles/with_interaction/",
      +
      35 ]
      +
      36 files = [
      +
      37 "particle_0",
      +
      38 "particle_1",
      +
      39 ]
      +
      40 labels = [r"$p_1$", r"$p_2$"]
      +
      41 output = [
      +
      42 "../latex/images/phase_space_no_interaction",
      +
      43 "../latex/images/phase_space_interaction",
      +
      44 ]
      +
      45 colors = [
      +
      46 "seagreen",
      +
      47 "darkred",
      +
      48 ]
      +
      49
      +
      50 for i, dir in enumerate(directories):
      +
      51 fig1, axs1 = plt.subplots(sharex=True)
      +
      52 fig2, axs2 = plt.subplots(sharex=True)
      +
      53 for j, (file, label, color) in enumerate(zip(files, labels, colors)):
      +
      54 r = []
      +
      55 v = []
      +
      56 with open(dir + file + "_r.txt") as f:
      +
      57 lines = f.readlines()
      +
      58 r = np.array(
      +
      59 [list(map(float, line.strip().split(","))) for line in lines]
      +
      60 )
      +
      61
      +
      62 with open(dir + file + "_v.txt") as f:
      +
      63 lines = f.readlines()
      +
      64 v = np.array(
      +
      65 [list(map(float, line.strip().split(","))) for line in lines]
      +
      66 )
      +
      67 axs1.plot(r[:, 0], v[:, 0], label=label, color=color)
      +
      68 axs1.plot(r[0,0], v[0,0], "ko")
      +
      69 axs2.plot(r[:, 2], v[:, 2], label=label, color=color)
      +
      70 axs2.plot(r[0,2], v[0,2], "ko")
      +
      71 axs1.axis("equal")
      +
      72 axs2.axis("equal")
      +
      73
      +
      74 axs1.set(xlabel=r"$x (\mu m)$", ylabel=r"$v_x (\mu m / \mu s)$")
      +
      75 axs2.set(xlabel=r"$z (\mu m)$", ylabel=r"$v_z (\mu m / \mu s)$")
      +
      76
      +
      77 axs1.legend(loc="upper right")
      +
      78 axs2.legend(loc="upper right")
      +
      79
      +
      80 fig1.savefig(f"{output[i]}_x.pdf", bbox_inches="tight")
      +
      81 fig2.savefig(f"{output[i]}_z.pdf", bbox_inches="tight")
      +
      82 # plt.show()
      +
      83
      +
      84
      +
      85if __name__ == "__main__":
      +
      86 main()
      +
      +
      + + + + diff --git a/docs/plot__relative__error_8py.html b/docs/plot__relative__error_8py.html new file mode 100644 index 0000000..e0a886d --- /dev/null +++ b/docs/plot__relative__error_8py.html @@ -0,0 +1,189 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_relative_error.py File Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      plot_relative_error.py File Reference
      +
      +
      + +

      Plot the relative error for forward Euler and RK4 method. +More...

      + +

      Go to the source code of this file.

      + + + + +

      +Functions

      def plot_relative_error.main ()
       
      + + + +

      +Variables

      dict plot_relative_error.params
       
      +

      Detailed Description

      +

      Plot the relative error for forward Euler and RK4 method.

      +
      Author
      Cory Alexander Balaton (coryab)
      +
      +Janita Ovidie Sandtrøen Willumsen (janitaws)
      +
      Version
      1.0
      +
      Bug:
      No known bugs
      + +

      Definition in file plot_relative_error.py.

      +

      Function Documentation

      + +

      ◆ main()

      + +
      +
      + + + + + + + +
      def plot_relative_error.main ()
      +
      + +

      Definition at line 29 of file plot_relative_error.py.

      + +
      +
      +

      Variable Documentation

      + +

      ◆ params

      + +
      +
      + + + + +
      dict plot_relative_error.params
      +
      +Initial value:
      1= {
      +
      2 "font.family": "Serif",
      +
      3 "font.serif": "Roman",
      +
      4 "text.usetex": True,
      +
      5 "axes.titlesize": "large",
      +
      6 "axes.labelsize": "large",
      +
      7 "xtick.labelsize": "large",
      +
      8 "ytick.labelsize": "large",
      +
      9 "legend.fontsize": "medium"
      +
      10}
      +
      +

      Definition at line 17 of file plot_relative_error.py.

      + +
      +
      +
      +
      + + + + diff --git a/docs/plot__relative__error_8py_source.html b/docs/plot__relative__error_8py_source.html new file mode 100644 index 0000000..f37bb78 --- /dev/null +++ b/docs/plot__relative__error_8py_source.html @@ -0,0 +1,188 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_relative_error.py Source File + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      plot_relative_error.py
      +
      +
      +Go to the documentation of this file.
      1
      +
      11
      +
      12import matplotlib.pyplot as plt
      +
      13import numpy as np
      +
      14import seaborn as sns
      +
      15
      +
      16sns.set_theme()
      +
      17params = {
      +
      18 "font.family": "Serif",
      +
      19 "font.serif": "Roman",
      +
      20 "text.usetex": True,
      +
      21 "axes.titlesize": "large",
      +
      22 "axes.labelsize": "large",
      +
      23 "xtick.labelsize": "large",
      +
      24 "ytick.labelsize": "large",
      +
      25 "legend.fontsize": "medium"
      +
      26}
      +
      27plt.rcParams.update(params)
      +
      28
      +
      29def main():
      +
      30 directories = [
      +
      31 "output/relative_error/RK4/",
      +
      32 "output/relative_error/euler/",
      +
      33 ]
      +
      34 files = [
      +
      35 "4000_steps.txt",
      +
      36 "8000_steps.txt",
      +
      37 "16000_steps.txt",
      +
      38 "32000_steps.txt",
      +
      39 ]
      +
      40 labels = [
      +
      41 r"$n_1$",
      +
      42 r"$n_2$",
      +
      43 r"$n_3$",
      +
      44 r"$n_4$",
      +
      45 ]
      +
      46 titles = [
      +
      47 "(a)",
      +
      48 "(b)"
      +
      49 ]
      +
      50 methods = [
      +
      51 "rk4",
      +
      52 "euler"
      +
      53 ]
      +
      54 colors = [
      +
      55 "seagreen",
      +
      56 "darkred",
      +
      57 "darkgoldenrod",
      +
      58 "steelblue"
      +
      59 ]
      +
      60 fig1, axs1 = plt.subplots(2,1)
      +
      61 for i, (dir, title) in enumerate(list(zip(directories, titles))):
      +
      62 max_err = []
      +
      63 for label, file, color in zip(labels, files, colors):
      +
      64 with open(dir+file) as f:
      +
      65 lines = f.readlines()
      +
      66 t = np.linspace(0, 50, len(lines))
      +
      67 r = np.array([float(line.strip()) for line in lines])
      +
      68 max_err.append(max(r))
      +
      69 axs1[i].plot(t, r, label=label, color=color)
      +
      70
      +
      71 axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"relative error $(\mu m)$")
      +
      72 axs1[i].legend()
      +
      73 axs1[i].set_title(title)
      +
      74
      +
      75 conv_rate = 1/3 * sum([np.log2(max_err[i+1]/max_err[i])/np.log2(.5) for i in range(3)])
      +
      76 print(f"{methods[i]}: {conv_rate}")
      +
      77
      +
      78 plt.tight_layout()
      +
      79 fig1.savefig("../latex/images/relative_error.pdf", bbox_inches="tight")
      +
      80
      +
      81
      +
      82if __name__ == "__main__":
      +
      83 main()
      +
      +
      + + + + diff --git a/docs/plot__single__particle_8py.html b/docs/plot__single__particle_8py.html new file mode 100644 index 0000000..52b2617 --- /dev/null +++ b/docs/plot__single__particle_8py.html @@ -0,0 +1,211 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_single_particle.py File Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      plot_single_particle.py File Reference
      +
      +
      + +

      Plot the approximation and analytical solution for one particle in the z axis. +More...

      + +

      Go to the source code of this file.

      + + + + + + +

      +Functions

      def plot_single_particle.z (t)
       
      def plot_single_particle.main ()
       
      + + + +

      +Variables

      dict plot_single_particle.params
       
      +

      Detailed Description

      +

      Plot the approximation and analytical solution for one particle in the z axis.

      +
      Author
      Cory Alexander Balaton (coryab)
      +
      +Janita Ovidie Sandtrøen Willumsen (janitaws)
      +
      Version
      1.0
      +
      Bug:
      No known bugs
      + +

      Definition in file plot_single_particle.py.

      +

      Function Documentation

      + +

      ◆ main()

      + +
      +
      + + + + + + + +
      def plot_single_particle.main ()
      +
      + +

      Definition at line 37 of file plot_single_particle.py.

      + +
      +
      + +

      ◆ z()

      + +
      +
      + + + + + + + + +
      def plot_single_particle.z ( t)
      +
      + +

      Definition at line 30 of file plot_single_particle.py.

      + +
      +
      +

      Variable Documentation

      + +

      ◆ params

      + +
      +
      + + + + +
      dict plot_single_particle.params
      +
      +Initial value:
      1= {
      +
      2 "font.family": "Serif",
      +
      3 "font.serif": "Roman",
      +
      4 "text.usetex": True,
      +
      5 "axes.titlesize": "large",
      +
      6 "axes.labelsize": "large",
      +
      7 "xtick.labelsize": "large",
      +
      8 "ytick.labelsize": "large",
      +
      9 "legend.fontsize": "medium"
      +
      10}
      +
      +

      Definition at line 18 of file plot_single_particle.py.

      + +
      +
      +
      +
      + + + + diff --git a/docs/plot__single__particle_8py_source.html b/docs/plot__single__particle_8py_source.html new file mode 100644 index 0000000..376227f --- /dev/null +++ b/docs/plot__single__particle_8py_source.html @@ -0,0 +1,163 @@ + + + + + + + +Penning Trap Simulation: src/scripts/plot_single_particle.py Source File + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      plot_single_particle.py
      +
      +
      +Go to the documentation of this file.
      1
      +
      12
      +
      13import matplotlib.pyplot as plt
      +
      14import numpy as np
      +
      15import seaborn as sns
      +
      16
      +
      17sns.set_theme()
      +
      18params = {
      +
      19 "font.family": "Serif",
      +
      20 "font.serif": "Roman",
      +
      21 "text.usetex": True,
      +
      22 "axes.titlesize": "large",
      +
      23 "axes.labelsize": "large",
      +
      24 "xtick.labelsize": "large",
      +
      25 "ytick.labelsize": "large",
      +
      26 "legend.fontsize": "medium"
      +
      27}
      +
      28plt.rcParams.update(params)
      +
      29
      +
      30def z(t):
      +
      31 V_0 = 25.*9.64852558 * 10**4
      +
      32 m = 40.
      +
      33 d = 500.
      +
      34 w_z = np.sqrt((2.*V_0)/(m*d*d))
      +
      35 return 20.*np.cos(w_z*t)
      +
      36
      +
      37def main():
      +
      38 filename = "output/simulate_single_particle/particle_0_r.txt"
      +
      39 r = t = []
      +
      40 with open(filename) as f:
      +
      41 lines = f.readlines()
      +
      42 t = np.linspace(0, 50, len(lines))
      +
      43 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
      +
      44
      +
      45 fig, ax = plt.subplots()
      +
      46 ax.plot(t, r[:, 2], label="approximation", color="mediumseagreen")
      +
      47 ax.plot(t, z(t), label="analytical", color="black", linestyle="dotted")
      +
      48 ax.set_xlabel(r"t $(\mu s)$")
      +
      49 ax.set_xlim((-5, 55))
      +
      50 ax.set_ylabel(r"z $(\mu m)$")
      +
      51 ax.set_ylim((-25, 25))
      +
      52 # plt.title(r"Movement of a single particle in the x direction")
      +
      53 ax.legend(loc="upper right")
      +
      54 fig.savefig("../latex/images/single_particle.pdf", bbox_inches="tight")
      +
      55 # plt.show()
      +
      56
      +
      57
      +
      58if __name__ == "__main__":
      +
      59 main()
      +
      +
      + + + + diff --git a/docs/search/all_1.js b/docs/search/all_1.js index 4fc815a..737ed4a 100644 --- a/docs/search/all_1.js +++ b/docs/search/all_1.js @@ -1,6 +1,7 @@ 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']]] + ['analytical_5fsolution_5fparticle_5f1_1',['analytical_solution_particle_1',['../main_8cpp.html#a8d92fb2ad085065fbd14718647551657',1,'main.cpp']]], + ['animate_5f100_5fparticles_2epy_2',['animate_100_particles.py',['../animate__100__particles_8py.html',1,'']]], + ['assert_3',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]] ]; diff --git a/docs/search/all_10.js b/docs/search/all_10.js index 1b9fc74..209042a 100644 --- a/docs/search/all_10.js +++ b/docs/search/all_10.js @@ -1,4 +1,4 @@ var searchData= [ - ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57',1,'PenningTrap']]] + ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#ad8bc4df7ab3eed53b16cfdff38e7760b',1,'PenningTrap']]] ]; diff --git a/docs/search/all_3.js b/docs/search/all_3.js index 0648f09..ecb5965 100644 --- a/docs/search/all_3.js +++ b/docs/search/all_3.js @@ -1,4 +1,7 @@ var searchData= [ - ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]] + ['ca_5fcharge_0',['CA_CHARGE',['../constants_8hpp.html#af7602a3a314957137ad1cd719aa23789',1,'constants.hpp']]], + ['ca_5fmass_1',['CA_MASS',['../constants_8hpp.html#a2ff491cc7958ffd5e749c518a4a60ec8',1,'constants.hpp']]], + ['close_5fto_2',['close_to',['../utils_8hpp.html#ab3e0cf669bddc59bd53998490ffb68b9',1,'close_to(arma::vec &a, arma::vec &b, double tol=1e-8): utils.cpp'],['../utils_8cpp.html#a6be6f938bcbb235ebb6a2ed9d08411b2',1,'close_to(arma::vec &a, arma::vec &b, double tol): utils.cpp']]], + ['constants_2ehpp_3',['constants.hpp',['../constants_8hpp.html',1,'']]] ]; diff --git a/docs/search/all_5.js b/docs/search/all_5.js index c4c479f..e8152c7 100644 --- a/docs/search/all_5.js +++ b/docs/search/all_5.js @@ -2,6 +2,6 @@ var searchData= [ ['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']]] + ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#a361f2c4862c90b5e8e2a2f50c6a95655',1,'PenningTrap']]], + ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a5846c8f75cdc543fd9cf0b2185a3ef22',1,'PenningTrap']]] ]; diff --git a/docs/search/all_6.js b/docs/search/all_6.js index d1d9acc..074618b 100644 --- a/docs/search/all_6.js +++ b/docs/search/all_6.js @@ -1,5 +1,6 @@ var searchData= [ - ['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']]] + ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a7f210bb2768a5d79ced4b0df0df97598',1,'PenningTrap']]], + ['fraction_5fof_5fparticles_5fleft_1',['fraction_of_particles_left',['../classPenningTrap.html#ac529aa26c288f34eae184a67e6bac41f',1,'PenningTrap']]], + ['frequency_5fnarrow_5fsweeps_5flong_2ecpp_2',['frequency_narrow_sweeps_long.cpp',['../frequency__narrow__sweeps__long_8cpp.html',1,'']]] ]; diff --git a/docs/search/all_9.js b/docs/search/all_9.js index 962dfef..70494b2 100644 --- a/docs/search/all_9.js +++ b/docs/search/all_9.js @@ -1,12 +1,24 @@ var searchData= [ - ['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,'']]] + ['p1_0',['p1',['../main_8cpp.html#a2efa69bb9d93049429ce4637075f1d30',1,'main.cpp']]], + ['p2_1',['p2',['../main_8cpp.html#ac70b61df65f4336f57ea9b4c35250df7',1,'main.cpp']]], + ['particle_2',['Particle',['../classParticle.html',1,'Particle'],['../classParticle.html#af1d7535fb8311eaa77d2b7b345882ec4',1,'Particle::Particle()']]], + ['particle_2ecpp_3',['Particle.cpp',['../Particle_8cpp.html',1,'']]], + ['particle_2ehpp_4',['Particle.hpp',['../Particle_8hpp.html',1,'']]], + ['particles_5',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]], + ['penning_20trap_20simulation_6',['Penning trap simulation',['../index.html',1,'']]], + ['penningtrap_7',['PenningTrap',['../classPenningTrap.html#addc96789dcfec07b75156e19fee82f4f',1,'PenningTrap::PenningTrap()'],['../classPenningTrap.html',1,'PenningTrap'],['../classPenningTrap.html#a830be1b8cbf59664e060b6edbeaa302f',1,'PenningTrap::PenningTrap(uint i, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)'],['../classPenningTrap.html#a5b6c6d4636f3a6e279ccde59d4a345e8',1,'PenningTrap::PenningTrap(double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)'],['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle::PenningTrap()']]], + ['penningtrap_2ecpp_8',['PenningTrap.cpp',['../PenningTrap_8cpp.html',1,'']]], + ['penningtrap_2ehpp_9',['PenningTrap.hpp',['../PenningTrap_8hpp.html',1,'']]], + ['penningtraptest_10',['PenningTrapTest',['../classPenningTrap.html#a869f032f37d0569ed16f224b4c4356ae',1,'PenningTrap::PenningTrapTest()'],['../classPenningTrapTest.html',1,'PenningTrapTest']]], + ['perturbation_11',['perturbation',['../classPenningTrap.html#ae915f6ad0eef1fb46530e836b6e071e5',1,'PenningTrap']]], + ['plot_5f2_5fparticles_2epy_12',['plot_2_particles.py',['../plot__2__particles_8py.html',1,'']]], + ['plot_5f3d_2epy_13',['plot_3d.py',['../plot__3d_8py.html',1,'']]], + ['plot_5fparticles_5fleft_2epy_14',['plot_particles_left.py',['../plot__particles__left_8py.html',1,'']]], + ['plot_5fphase_5fspace_2epy_15',['plot_phase_space.py',['../plot__phase__space_8py.html',1,'']]], + ['plot_5frelative_5ferror_2epy_16',['plot_relative_error.py',['../plot__relative__error_8py.html',1,'']]], + ['plot_5fsingle_5fparticle_2epy_17',['plot_single_particle.py',['../plot__single__particle_8py.html',1,'']]], + ['potential_5fresonance_5fnarrow_5fsweep_18',['potential_resonance_narrow_sweep',['../frequency__narrow__sweeps__long_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea',1,'potential_resonance_narrow_sweep(): frequency_narrow_sweeps_long.cpp'],['../main_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea',1,'potential_resonance_narrow_sweep(): main.cpp']]], + ['potential_5fresonance_5fnarrow_5fsweep_5finteraction_19',['potential_resonance_narrow_sweep_interaction',['../frequency__narrow__sweeps__long_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb',1,'potential_resonance_narrow_sweep_interaction(): frequency_narrow_sweeps_long.cpp'],['../main_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb',1,'potential_resonance_narrow_sweep_interaction(): main.cpp']]], + ['potential_5fresonance_5fwide_5fsweep_20',['potential_resonance_wide_sweep',['../main_8cpp.html#a6b38b477c18e2f4268779751a88edab1',1,'main.cpp']]] ]; diff --git a/docs/search/all_b.js b/docs/search/all_b.js index fb8b113..3d33231 100644 --- a/docs/search/all_b.js +++ b/docs/search/all_b.js @@ -1,5 +1,6 @@ var searchData= [ - ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648',1,'PenningTrap']]], - ['r_5fvec_1',['r_vec',['../classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6',1,'Particle']]] + ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a826b7fa8e709d481eb1dee7d0c2cdc08',1,'PenningTrap']]], + ['r_5fvec_1',['r_vec',['../classParticle.html#a1c59101411db43624828b766f87ad460',1,'Particle']]], + ['reinitialize_2',['reinitialize',['../classPenningTrap.html#aaee129f177657455348d0c8ae1441dea',1,'PenningTrap']]] ]; diff --git a/docs/search/all_c.js b/docs/search/all_c.js index f0c09d2..e3fbf37 100644 --- a/docs/search/all_c.js +++ b/docs/search/all_c.js @@ -1,8 +1,15 @@ 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']]], - ['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']]] + ['set_5fpertubation_1',['set_pertubation',['../classPenningTrap.html#a9d1d8e90ca839b928aee1ad0cd4aff43',1,'PenningTrap']]], + ['sim_5farr_2',['sim_arr',['../typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af',1,'typedefs.hpp']]], + ['sim_5fcols_3',['sim_cols',['../typedefs_8hpp.html#a46482a2697556c00556c9d73f461784f',1,'typedefs.hpp']]], + ['sim_5frows_4',['sim_rows',['../typedefs_8hpp.html#a33418f31f28663b8414c8f7182998c22',1,'typedefs.hpp']]], + ['simulate_5',['simulate',['../classPenningTrap.html#a7a1d9f0528a12308de25bc30718da20a',1,'PenningTrap']]], + ['simulate_5f100_5fparticles_6',['simulate_100_particles',['../main_8cpp.html#a213713d6ecc02a32b588ffd179dc7513',1,'main.cpp']]], + ['simulate_5fsingle_5fparticle_7',['simulate_single_particle',['../main_8cpp.html#a8fdbe2d5a872e50ef5ec1263243589d6',1,'main.cpp']]], + ['simulate_5fsingle_5fparticle_5fwith_5fdifferent_5fsteps_8',['simulate_single_particle_with_different_steps',['../main_8cpp.html#ac67e0d59227856c4d42e7d01c75e0ad2',1,'main.cpp']]], + ['simulate_5ftwo_5fparticles_9',['simulate_two_particles',['../main_8cpp.html#a783789519f97c6430081171cacb0ffb1',1,'main.cpp']]], + ['simulation_10',['simulation',['../structsimulation.html',1,'']]], + ['simulation_5ft_11',['simulation_t',['../typedefs_8hpp.html#a784799c37b5e4fb8bf4f6368e004dec6',1,'typedefs.hpp']]] ]; diff --git a/docs/search/all_d.js b/docs/search/all_d.js index c04457d..80bb0f1 100644 --- a/docs/search/all_d.js +++ b/docs/search/all_d.js @@ -2,9 +2,15 @@ var searchData= [ ['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,'']]] + ['test_5fexternal_5fb_5ffield_2',['test_external_B_field',['../classPenningTrapTest.html#ad668d7d875bdc1909a42426bf9dead9e',1,'PenningTrapTest']]], + ['test_5fexternal_5fe_5ffield_3',['test_external_E_field',['../classPenningTrapTest.html#a6a303be62039ca2ecccd8252744d4dc8',1,'PenningTrapTest']]], + ['test_5fforce_5fon_5fparticle_4',['test_force_on_particle',['../classPenningTrapTest.html#a5f4f0b150e54ce463bb29f76d49883f9',1,'PenningTrapTest']]], + ['test_5fsuite_2ecpp_5',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], + ['test_5ftotal_5fforce_5fexternal_6',['test_total_force_external',['../classPenningTrapTest.html#ae6d0c8e0d80338fb7c7edefc97331046',1,'PenningTrapTest']]], + ['test_5ftotal_5fforce_5fparticles_7',['test_total_force_particles',['../classPenningTrapTest.html#a68449d508e66205bc8b27fa5f60db508',1,'PenningTrapTest']]], + ['total_5fforce_8',['total_force',['../classPenningTrap.html#a9a301b0540078c36697880ef204afdf3',1,'PenningTrap']]], + ['total_5fforce_5fexternal_9',['total_force_external',['../classPenningTrap.html#a2c01108b52c8e2a003cf9170da9e7682',1,'PenningTrap']]], + ['total_5fforce_5fno_5finteraction_10',['total_force_no_interaction',['../classPenningTrap.html#a6069f82d8dbc7cadaebd228dbcd95018',1,'PenningTrap']]], + ['total_5fforce_5fparticles_11',['total_force_particles',['../classPenningTrap.html#a2fe1cefbae18fa5808155ee0d2df713c',1,'PenningTrap']]], + ['typedefs_2ehpp_12',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]] ]; diff --git a/docs/search/all_f.js b/docs/search/all_f.js index bb9c0eb..d989494 100644 --- a/docs/search/all_f.js +++ b/docs/search/all_f.js @@ -1,8 +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']]] + ['v_5f0_1',['V_0',['../classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89',1,'PenningTrap']]], + ['v_5ffunc_2',['v_func',['../classPenningTrap.html#a3c0a44e4e0a94366ff609e81fe463fa2',1,'PenningTrap']]], + ['v_5fvec_3',['v_vec',['../classParticle.html#a3a10400add8dd22b8031330c2aafb6fe',1,'Particle']]], + ['vec3_4',['vec3',['../typedefs_8hpp.html#a3bdfb73a02f88ae32b6128ef747c4aea',1,'typedefs.hpp']]] ]; diff --git a/docs/search/classes_1.js b/docs/search/classes_1.js new file mode 100644 index 0000000..0a5cda5 --- /dev/null +++ b/docs/search/classes_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['simulation_0',['simulation',['../structsimulation.html',1,'']]] +]; diff --git a/docs/search/defines_2.js b/docs/search/defines_2.js index c6466cb..835b733 100644 --- a/docs/search/defines_2.js +++ b/docs/search/defines_2.js @@ -1,4 +1,5 @@ var searchData= [ - ['debug_0',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]] + ['ca_5fcharge_0',['CA_CHARGE',['../constants_8hpp.html#af7602a3a314957137ad1cd719aa23789',1,'constants.hpp']]], + ['ca_5fmass_1',['CA_MASS',['../constants_8hpp.html#a2ff491cc7958ffd5e749c518a4a60ec8',1,'constants.hpp']]] ]; diff --git a/docs/search/defines_3.js b/docs/search/defines_3.js index cb8673f..c6466cb 100644 --- a/docs/search/defines_3.js +++ b/docs/search/defines_3.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_4.js b/docs/search/defines_4.js index 6eef01f..cb8673f 100644 --- a/docs/search/defines_4.js +++ b/docs/search/defines_4.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_5.js b/docs/search/defines_5.js index 06f433f..6eef01f 100644 --- a/docs/search/defines_5.js +++ b/docs/search/defines_5.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_6.js b/docs/search/defines_6.js new file mode 100644 index 0000000..06f433f --- /dev/null +++ b/docs/search/defines_6.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]] +]; diff --git a/docs/search/files_0.js b/docs/search/files_0.js index 0648f09..bb49631 100644 --- a/docs/search/files_0.js +++ b/docs/search/files_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]] + ['animate_5f100_5fparticles_2epy_0',['animate_100_particles.py',['../animate__100__particles_8py.html',1,'']]] ]; diff --git a/docs/search/files_1.js b/docs/search/files_1.js index 695b4fd..0648f09 100644 --- a/docs/search/files_1.js +++ b/docs/search/files_1.js @@ -1,4 +1,4 @@ var searchData= [ - ['main_2ecpp_0',['main.cpp',['../main_8cpp.html',1,'']]] + ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]] ]; diff --git a/docs/search/files_2.js b/docs/search/files_2.js index 8fae0fa..9000051 100644 --- a/docs/search/files_2.js +++ b/docs/search/files_2.js @@ -1,7 +1,4 @@ var searchData= [ - ['particle_2ecpp_0',['Particle.cpp',['../Particle_8cpp.html',1,'']]], - ['particle_2ehpp_1',['Particle.hpp',['../Particle_8hpp.html',1,'']]], - ['penningtrap_2ecpp_2',['PenningTrap.cpp',['../PenningTrap_8cpp.html',1,'']]], - ['penningtrap_2ehpp_3',['PenningTrap.hpp',['../PenningTrap_8hpp.html',1,'']]] + ['frequency_5fnarrow_5fsweeps_5flong_2ecpp_0',['frequency_narrow_sweeps_long.cpp',['../frequency__narrow__sweeps__long_8cpp.html',1,'']]] ]; diff --git a/docs/search/files_3.js b/docs/search/files_3.js index 5e3fea9..695b4fd 100644 --- a/docs/search/files_3.js +++ b/docs/search/files_3.js @@ -1,5 +1,4 @@ var searchData= [ - ['test_5fsuite_2ecpp_0',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], - ['typedefs_2ehpp_1',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]] + ['main_2ecpp_0',['main.cpp',['../main_8cpp.html',1,'']]] ]; diff --git a/docs/search/files_4.js b/docs/search/files_4.js index cd921db..a3c3ac1 100644 --- a/docs/search/files_4.js +++ b/docs/search/files_4.js @@ -1,5 +1,13 @@ var searchData= [ - ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]], - ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]] + ['particle_2ecpp_0',['Particle.cpp',['../Particle_8cpp.html',1,'']]], + ['particle_2ehpp_1',['Particle.hpp',['../Particle_8hpp.html',1,'']]], + ['penningtrap_2ecpp_2',['PenningTrap.cpp',['../PenningTrap_8cpp.html',1,'']]], + ['penningtrap_2ehpp_3',['PenningTrap.hpp',['../PenningTrap_8hpp.html',1,'']]], + ['plot_5f2_5fparticles_2epy_4',['plot_2_particles.py',['../plot__2__particles_8py.html',1,'']]], + ['plot_5f3d_2epy_5',['plot_3d.py',['../plot__3d_8py.html',1,'']]], + ['plot_5fparticles_5fleft_2epy_6',['plot_particles_left.py',['../plot__particles__left_8py.html',1,'']]], + ['plot_5fphase_5fspace_2epy_7',['plot_phase_space.py',['../plot__phase__space_8py.html',1,'']]], + ['plot_5frelative_5ferror_2epy_8',['plot_relative_error.py',['../plot__relative__error_8py.html',1,'']]], + ['plot_5fsingle_5fparticle_2epy_9',['plot_single_particle.py',['../plot__single__particle_8py.html',1,'']]] ]; diff --git a/docs/search/files_5.js b/docs/search/files_5.js new file mode 100644 index 0000000..5e3fea9 --- /dev/null +++ b/docs/search/files_5.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['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/files_6.js b/docs/search/files_6.js new file mode 100644 index 0000000..cd921db --- /dev/null +++ b/docs/search/files_6.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]], + ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]] +]; diff --git a/docs/search/functions_0.js b/docs/search/functions_0.js index 72dba03..693aa36 100644 --- a/docs/search/functions_0.js +++ b/docs/search/functions_0.js @@ -1,5 +1,5 @@ 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']]] + ['analytical_5fsolution_5fparticle_5f1_1',['analytical_solution_particle_1',['../main_8cpp.html#a8d92fb2ad085065fbd14718647551657',1,'main.cpp']]] ]; diff --git a/docs/search/functions_1.js b/docs/search/functions_1.js index c4c479f..ff2dfc6 100644 --- a/docs/search/functions_1.js +++ b/docs/search/functions_1.js @@ -1,7 +1,4 @@ var searchData= [ - ['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']]] + ['close_5fto_0',['close_to',['../utils_8hpp.html#ab3e0cf669bddc59bd53998490ffb68b9',1,'close_to(arma::vec &a, arma::vec &b, double tol=1e-8): utils.cpp'],['../utils_8cpp.html#a6be6f938bcbb235ebb6a2ed9d08411b2',1,'close_to(arma::vec &a, arma::vec &b, double tol): utils.cpp']]] ]; diff --git a/docs/search/functions_2.js b/docs/search/functions_2.js index d1d9acc..e8152c7 100644 --- a/docs/search/functions_2.js +++ b/docs/search/functions_2.js @@ -1,5 +1,7 @@ var searchData= [ - ['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']]] + ['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#a361f2c4862c90b5e8e2a2f50c6a95655',1,'PenningTrap']]], + ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a5846c8f75cdc543fd9cf0b2185a3ef22',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_3.js b/docs/search/functions_3.js index ffb26d6..e6919eb 100644 --- a/docs/search/functions_3.js +++ b/docs/search/functions_3.js @@ -1,5 +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']]], - ['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']]] + ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a7f210bb2768a5d79ced4b0df0df97598',1,'PenningTrap']]], + ['fraction_5fof_5fparticles_5fleft_1',['fraction_of_particles_left',['../classPenningTrap.html#ac529aa26c288f34eae184a67e6bac41f',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_4.js b/docs/search/functions_4.js index 852716e..ffb26d6 100644 --- a/docs/search/functions_4.js +++ b/docs/search/functions_4.js @@ -1,5 +1,5 @@ var searchData= [ - ['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.)']]] + ['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_5.js b/docs/search/functions_5.js index 07b3041..ae92b61 100644 --- a/docs/search/functions_5.js +++ b/docs/search/functions_5.js @@ -1,4 +1,8 @@ var searchData= [ - ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648',1,'PenningTrap']]] + ['particle_0',['Particle',['../classParticle.html#af1d7535fb8311eaa77d2b7b345882ec4',1,'Particle']]], + ['penningtrap_1',['PenningTrap',['../classPenningTrap.html#a5b6c6d4636f3a6e279ccde59d4a345e8',1,'PenningTrap::PenningTrap(double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)'],['../classPenningTrap.html#a830be1b8cbf59664e060b6edbeaa302f',1,'PenningTrap::PenningTrap(uint i, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)'],['../classPenningTrap.html#addc96789dcfec07b75156e19fee82f4f',1,'PenningTrap::PenningTrap(std::vector< Particle > particles, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)']]], + ['potential_5fresonance_5fnarrow_5fsweep_2',['potential_resonance_narrow_sweep',['../frequency__narrow__sweeps__long_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea',1,'potential_resonance_narrow_sweep(): frequency_narrow_sweeps_long.cpp'],['../main_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea',1,'potential_resonance_narrow_sweep(): main.cpp']]], + ['potential_5fresonance_5fnarrow_5fsweep_5finteraction_3',['potential_resonance_narrow_sweep_interaction',['../frequency__narrow__sweeps__long_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb',1,'potential_resonance_narrow_sweep_interaction(): frequency_narrow_sweeps_long.cpp'],['../main_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb',1,'potential_resonance_narrow_sweep_interaction(): main.cpp']]], + ['potential_5fresonance_5fwide_5fsweep_4',['potential_resonance_wide_sweep',['../main_8cpp.html#a6b38b477c18e2f4268779751a88edab1',1,'main.cpp']]] ]; diff --git a/docs/search/functions_6.js b/docs/search/functions_6.js index a7b65b4..f9fecdd 100644 --- a/docs/search/functions_6.js +++ b/docs/search/functions_6.js @@ -1,5 +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']]], - ['simulate_1',['simulate',['../classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854',1,'PenningTrap']]] + ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a826b7fa8e709d481eb1dee7d0c2cdc08',1,'PenningTrap']]], + ['reinitialize_1',['reinitialize',['../classPenningTrap.html#aaee129f177657455348d0c8ae1441dea',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_7.js b/docs/search/functions_7.js index 73e1881..eb77e26 100644 --- a/docs/search/functions_7.js +++ b/docs/search/functions_7.js @@ -1,6 +1,10 @@ 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']]] + ['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']]], + ['set_5fpertubation_1',['set_pertubation',['../classPenningTrap.html#a9d1d8e90ca839b928aee1ad0cd4aff43',1,'PenningTrap']]], + ['simulate_2',['simulate',['../classPenningTrap.html#a7a1d9f0528a12308de25bc30718da20a',1,'PenningTrap']]], + ['simulate_5f100_5fparticles_3',['simulate_100_particles',['../main_8cpp.html#a213713d6ecc02a32b588ffd179dc7513',1,'main.cpp']]], + ['simulate_5fsingle_5fparticle_4',['simulate_single_particle',['../main_8cpp.html#a8fdbe2d5a872e50ef5ec1263243589d6',1,'main.cpp']]], + ['simulate_5fsingle_5fparticle_5fwith_5fdifferent_5fsteps_5',['simulate_single_particle_with_different_steps',['../main_8cpp.html#ac67e0d59227856c4d42e7d01c75e0ad2',1,'main.cpp']]], + ['simulate_5ftwo_5fparticles_6',['simulate_two_particles',['../main_8cpp.html#a783789519f97c6430081171cacb0ffb1',1,'main.cpp']]] ]; diff --git a/docs/search/functions_8.js b/docs/search/functions_8.js index 8d7b6ff..14193ad 100644 --- a/docs/search/functions_8.js +++ b/docs/search/functions_8.js @@ -1,4 +1,12 @@ var searchData= [ - ['v_5ffunc_0',['v_func',['../classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e',1,'PenningTrap']]] + ['test_5fexternal_5fb_5ffield_0',['test_external_B_field',['../classPenningTrapTest.html#ad668d7d875bdc1909a42426bf9dead9e',1,'PenningTrapTest']]], + ['test_5fexternal_5fe_5ffield_1',['test_external_E_field',['../classPenningTrapTest.html#a6a303be62039ca2ecccd8252744d4dc8',1,'PenningTrapTest']]], + ['test_5fforce_5fon_5fparticle_2',['test_force_on_particle',['../classPenningTrapTest.html#a5f4f0b150e54ce463bb29f76d49883f9',1,'PenningTrapTest']]], + ['test_5ftotal_5fforce_5fexternal_3',['test_total_force_external',['../classPenningTrapTest.html#ae6d0c8e0d80338fb7c7edefc97331046',1,'PenningTrapTest']]], + ['test_5ftotal_5fforce_5fparticles_4',['test_total_force_particles',['../classPenningTrapTest.html#a68449d508e66205bc8b27fa5f60db508',1,'PenningTrapTest']]], + ['total_5fforce_5',['total_force',['../classPenningTrap.html#a9a301b0540078c36697880ef204afdf3',1,'PenningTrap']]], + ['total_5fforce_5fexternal_6',['total_force_external',['../classPenningTrap.html#a2c01108b52c8e2a003cf9170da9e7682',1,'PenningTrap']]], + ['total_5fforce_5fno_5finteraction_7',['total_force_no_interaction',['../classPenningTrap.html#a6069f82d8dbc7cadaebd228dbcd95018',1,'PenningTrap']]], + ['total_5fforce_5fparticles_8',['total_force_particles',['../classPenningTrap.html#a2fe1cefbae18fa5808155ee0d2df713c',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_9.js b/docs/search/functions_9.js index 1b9fc74..df5f413 100644 --- a/docs/search/functions_9.js +++ b/docs/search/functions_9.js @@ -1,4 +1,4 @@ var searchData= [ - ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57',1,'PenningTrap']]] + ['v_5ffunc_0',['v_func',['../classPenningTrap.html#a3c0a44e4e0a94366ff609e81fe463fa2',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_a.js b/docs/search/functions_a.js new file mode 100644 index 0000000..209042a --- /dev/null +++ b/docs/search/functions_a.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#ad8bc4df7ab3eed53b16cfdff38e7760b',1,'PenningTrap']]] +]; diff --git a/docs/search/namespaces_0.js b/docs/search/namespaces_0.js new file mode 100644 index 0000000..0f7354f --- /dev/null +++ b/docs/search/namespaces_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['plot_5f3d_0',['plot_3d',['../namespaceplot__3d.html',1,'']]] +]; diff --git a/docs/search/related_0.js b/docs/search/related_0.js index 0d3bc2c..3f7af5a 100644 --- a/docs/search/related_0.js +++ b/docs/search/related_0.js @@ -1,4 +1,5 @@ var searchData= [ - ['penningtrap_0',['PenningTrap',['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle']]] + ['penningtrap_0',['PenningTrap',['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle']]], + ['penningtraptest_1',['PenningTrapTest',['../classPenningTrap.html#a869f032f37d0569ed16f224b4c4356ae',1,'PenningTrap']]] ]; diff --git a/docs/search/searchdata.js b/docs/search/searchdata.js index 4d47bbf..bd9004d 100644 --- a/docs/search/searchdata.js +++ b/docs/search/searchdata.js @@ -1,13 +1,13 @@ var indexSectionsWithContent = { 0: "_abcdefkmpqrstuvw", - 1: "p", - 2: "cmptu", - 3: "aefmprstvw", + 1: "ps", + 2: "acfmptu", + 3: "acefmprstvw", 4: "bdkmpqrtv", 5: "sv", 6: "p", - 7: "_adktv", + 7: "_acdktv", 8: "bp" }; diff --git a/docs/search/typedefs_0.js b/docs/search/typedefs_0.js index e79ff95..39ee307 100644 --- a/docs/search/typedefs_0.js +++ b/docs/search/typedefs_0.js @@ -1,6 +1,7 @@ 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']]] + ['sim_5fcols_1',['sim_cols',['../typedefs_8hpp.html#a46482a2697556c00556c9d73f461784f',1,'typedefs.hpp']]], + ['sim_5frows_2',['sim_rows',['../typedefs_8hpp.html#a33418f31f28663b8414c8f7182998c22',1,'typedefs.hpp']]], + ['simulation_5ft_3',['simulation_t',['../typedefs_8hpp.html#a784799c37b5e4fb8bf4f6368e004dec6',1,'typedefs.hpp']]] ]; diff --git a/docs/search/typedefs_1.js b/docs/search/typedefs_1.js index fe88abf..d34d7e2 100644 --- a/docs/search/typedefs_1.js +++ b/docs/search/typedefs_1.js @@ -1,4 +1,4 @@ var searchData= [ - ['vec_5f3d_0',['vec_3d',['../typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df',1,'typedefs.hpp']]] + ['vec3_0',['vec3',['../typedefs_8hpp.html#a3bdfb73a02f88ae32b6128ef747c4aea',1,'typedefs.hpp']]] ]; diff --git a/docs/search/variables_4.js b/docs/search/variables_4.js index c9f603d..081d653 100644 --- a/docs/search/variables_4.js +++ b/docs/search/variables_4.js @@ -1,4 +1,7 @@ var searchData= [ - ['particles_0',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]] + ['p1_0',['p1',['../main_8cpp.html#a2efa69bb9d93049429ce4637075f1d30',1,'main.cpp']]], + ['p2_1',['p2',['../main_8cpp.html#ac70b61df65f4336f57ea9b4c35250df7',1,'main.cpp']]], + ['particles_2',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]], + ['perturbation_3',['perturbation',['../classPenningTrap.html#ae915f6ad0eef1fb46530e836b6e071e5',1,'PenningTrap']]] ]; diff --git a/docs/search/variables_6.js b/docs/search/variables_6.js index fa44d82..d549400 100644 --- a/docs/search/variables_6.js +++ b/docs/search/variables_6.js @@ -1,4 +1,4 @@ var searchData= [ - ['r_5fvec_0',['r_vec',['../classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6',1,'Particle']]] + ['r_5fvec_0',['r_vec',['../classParticle.html#a1c59101411db43624828b766f87ad460',1,'Particle']]] ]; diff --git a/docs/search/variables_8.js b/docs/search/variables_8.js index 601b41d..d107c7d 100644 --- a/docs/search/variables_8.js +++ b/docs/search/variables_8.js @@ -1,5 +1,5 @@ var searchData= [ - ['v_5f0_0',['V_0',['../classPenningTrap.html#aaf105828121c4a33cc2b217453c20317',1,'PenningTrap']]], - ['v_5fvec_1',['v_vec',['../classParticle.html#a879692772803d6ab65fa4993b54aea6e',1,'Particle']]] + ['v_5f0_0',['V_0',['../classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89',1,'PenningTrap']]], + ['v_5fvec_1',['v_vec',['../classParticle.html#a3a10400add8dd22b8031330c2aafb6fe',1,'Particle']]] ]; diff --git a/docs/structsimulation-members.html b/docs/structsimulation-members.html new file mode 100644 index 0000000..e81bad3 --- /dev/null +++ b/docs/structsimulation-members.html @@ -0,0 +1,118 @@ + + + + + + + +Penning Trap Simulation: Member List + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      simulation Member List
      +
      +
      + +

      This is the complete list of members for simulation, including all inherited members.

      + + + +
      r_vecs (defined in simulation)simulation
      v_vecs (defined in simulation)simulation
      +
      + + + + diff --git a/docs/structsimulation.html b/docs/structsimulation.html new file mode 100644 index 0000000..ea17361 --- /dev/null +++ b/docs/structsimulation.html @@ -0,0 +1,170 @@ + + + + + + + +Penning Trap Simulation: simulation Struct Reference + + + + + + + + + + + + + + + + +
      +
      + + + + + + +
      +
      Penning Trap Simulation +
      +
      Simulate particle behavior inside a Penning Trap
      +
      +
      + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      + +
      simulation Struct Reference
      +
      +
      + +

      Typedef for PenningTrap::simulation return value. + More...

      + +

      #include <typedefs.hpp>

      + + + + + + +

      +Public Attributes

      sim_arr r_vecs
       
      sim_arr v_vecs
       
      +

      Detailed Description

      +

      Typedef for PenningTrap::simulation return value.

      + +

      Definition at line 40 of file typedefs.hpp.

      +

      Member Data Documentation

      + +

      ◆ r_vecs

      + +
      +
      + + + + +
      sim_arr simulation::r_vecs
      +
      + +

      Definition at line 41 of file typedefs.hpp.

      + +
      +
      + +

      ◆ v_vecs

      + +
      +
      + + + + +
      sim_arr simulation::v_vecs
      +
      + +

      Definition at line 42 of file typedefs.hpp.

      + +
      +
      +
      The documentation for this struct was generated from the following file: +
      +
      + + + + diff --git a/docs/test__suite_8cpp.html b/docs/test__suite_8cpp.html index 7c69921..bae411e 100644 --- a/docs/test__suite_8cpp.html +++ b/docs/test__suite_8cpp.html @@ -107,17 +107,19 @@ $(document).ready(function(){initNavTree('test__suite_8cpp.html',''); initResiza

      The test suite for the project. More...

      -
      #include "PenningTrap.hpp"
      -#include "utils.hpp"
      -#include <iomanip>
      +
      #include <iomanip>
      #include <sstream>
      #include <string>
      +#include "PenningTrap.hpp"
      +#include "constants.hpp"
      +#include "utils.hpp"

      Go to the source code of this file.

      +

      Classes

      class  PenningTrapTest
       Test class for the Penning trap. More...
       
      Author
      Cory Alexander Balaton (coryab)
      Janita Ovidie Sandtrøen Willumsen (janitaws)
      -
      Version
      0.1
      -
      Bug:
      No known bugs
      +
      Version
      1.0
      +
      Bug:
      No known bugs

      Definition in file test_suite.cpp.

      Function Documentation

      @@ -150,7 +152,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

      @@ -130,8 +132,8 @@ Functions

      -

      Definition at line 135 of file test_suite.cpp.

      +

      Definition at line 145 of file test_suite.cpp.

      diff --git a/docs/test__suite_8cpp.js b/docs/test__suite_8cpp.js index 5bace7d..0a487ff 100644 --- a/docs/test__suite_8cpp.js +++ b/docs/test__suite_8cpp.js @@ -1,4 +1,4 @@ var test__suite_8cpp = [ - [ "PenningTrapTest", "classPenningTrapTest.html", null ] + [ "PenningTrapTest", "classPenningTrapTest.html", "classPenningTrapTest" ] ]; \ No newline at end of file diff --git a/docs/test__suite_8cpp_source.html b/docs/test__suite_8cpp_source.html index b317c82..9247504 100644 --- a/docs/test__suite_8cpp_source.html +++ b/docs/test__suite_8cpp_source.html @@ -102,151 +102,155 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
      Go to the documentation of this file.
      1
      -
      13#include "PenningTrap.hpp"
      -
      14#include "utils.hpp"
      -
      15
      -
      16#include <iomanip>
      -
      17#include <sstream>
      -
      18#include <string>
      -
      19
      - -
      21public:
      -
      22 static void test_external_E_field()
      -
      23 {
      -
      24 PenningTrap trap;
      -
      25
      -
      26 // Vector containing inputs and expected results
      -
      27 std::vector<std::pair<arma::vec, arma::vec>> tests;
      -
      28
      -
      29 tests.push_back(
      -
      30 std::make_pair(arma::vec{0., 0., 0.}, arma::vec{0., 0., 0.}));
      +
      13#include <iomanip>
      +
      14#include <sstream>
      +
      15#include <string>
      +
      16
      +
      17#include "PenningTrap.hpp"
      +
      18#include "constants.hpp"
      +
      19#include "utils.hpp"
      +
      20
      + +
      24{
      +
      25public:
      + +
      29 {
      +
      30 PenningTrap trap;
      31
      -
      32 tests.push_back(std::make_pair(arma::vec{10., 0., 0.},
      -
      33 arma::vec{96.4852558, 0., 0.}));
      +
      32 // Vector containing inputs and expected results
      +
      33 std::vector<std::pair<vec3, vec3>> tests;
      34
      -
      35 tests.push_back(std::make_pair(arma::vec{10., 0., 0.},
      -
      36 arma::vec{96.4852558, 0., 0.}));
      -
      37
      -
      38 tests.push_back(std::make_pair(arma::vec{0., 10., 0.},
      -
      39 arma::vec{0., 96.4852558, 0.}));
      -
      40
      -
      41 tests.push_back(std::make_pair(arma::vec{0., 0., 10.},
      -
      42 arma::vec{0., 0., -192.9705116}));
      -
      43
      -
      44 arma::vec result;
      -
      45 arma::vec v;
      -
      46 std::stringstream msg;
      -
      47 for (size_t i = 0; i < tests.size(); i++) {
      -
      48 v = tests.at(i).first;
      -
      49 result = trap.external_E_field(v);
      -
      50
      -
      51 msg.str("");
      -
      52 msg << "Testing the external E field at (" << std::setprecision(2)
      -
      53 << v(0) << "," << v(1) << "," << v(2) << ").";
      -
      54
      -
      55 ASSERT(arma_vector_close_to(result, tests.at(i).second), msg.str());
      -
      56 }
      -
      57 }
      -
      58
      -
      59 static void test_external_B_field()
      -
      60 {
      -
      61 // No point in testing at different points since it's not dependent
      -
      62 // on position.
      -
      63 PenningTrap trap;
      -
      64 arma::vec expected{0., 0., T};
      -
      65 arma::vec result = trap.external_B_field(arma::vec{0., 0., 0.});
      -
      66 ASSERT(arma_vector_close_to(expected, result),
      -
      67 "Testing the external B field at (0,0,0)");
      -
      68 }
      -
      69
      -
      70 static void test_force_on_particle()
      -
      71 {
      -
      72 PenningTrap trap;
      -
      73 arma::vec v{0., 0., 0.};
      -
      74
      -
      75 // Add particles to test
      -
      76 trap.add_particle(Particle(1., 40., arma::vec{0., 0., 0.}, v));
      -
      77 trap.add_particle(Particle(1., 40., arma::vec{1., 0., 0.}, v));
      -
      78 trap.add_particle(Particle(1., 40., arma::vec{0., 3., 4.}, v));
      -
      79
      -
      80 // Test p0 and p1
      -
      81 arma::vec expected{-1., 0., 0.};
      -
      82 arma::vec result = trap.force_on_particle(0, 1);
      -
      83 ASSERT(arma_vector_close_to(expected, result),
      -
      84 "Testing the force on a particle at (0,0,0) from a "
      -
      85 "particle at (1,0,0).");
      -
      86
      -
      87 // Test p0 and p2
      -
      88 expected = arma::vec{0, -.024, -.032};
      -
      89 result = trap.force_on_particle(0, 2);
      -
      90 ASSERT(arma_vector_close_to(expected, result),
      -
      91 "Testing the force on a particle at (0,0,0) from a "
      -
      92 "particle at (0,3,4).");
      -
      93 }
      -
      94
      -
      95 static void test_total_force_external()
      -
      96 {
      -
      97 PenningTrap trap;
      -
      98 trap.add_particle(
      -
      99 Particle(1., 40., arma::vec{1., 2., 3.}, arma::vec{3., 4., 5.}));
      -
      100
      -
      101 arma::vec expected{395.58954878, -270.15871624, -57.89115348};
      -
      102 arma::vec result = trap.total_force_external(0);
      -
      103 ASSERT(arma_vector_close_to(expected, result),
      -
      104 "Testing the total external force on a particle at "
      -
      105 "(1,2,3) with velocity (3,4,5)");
      -
      106 }
      -
      107
      -
      108 static void test_total_force_particles()
      -
      109 {
      -
      110 PenningTrap trap;
      -
      111 trap.add_particle(
      -
      112 Particle(1., 40., arma::vec{0., 0., 0.}, arma::vec{0., 0., 0.}));
      -
      113
      -
      114 arma::vec expected{0., 0., 0.};
      -
      115 arma::vec result = trap.total_force_particles(0);
      -
      116 ASSERT(arma_vector_close_to(expected, result),
      -
      117 "Testing the total force of all particles on particle 0 "
      -
      118 "with only a single particle");
      -
      119
      -
      120 trap.add_particle(
      -
      121 Particle(1., 40., arma::vec{1., 0., 0.}, arma::vec{0., 0., 0.}));
      -
      122 trap.add_particle(
      -
      123 Particle(1., 40., arma::vec{0., 1., 0.}, arma::vec{0., 0., 0.}));
      -
      124 trap.add_particle(
      -
      125 Particle(1., 40., arma::vec{0., 0., 1.}, arma::vec{0., 0., 0.}));
      +
      35 tests.push_back(std::make_pair(vec3{0., 0., 0.}, vec3{0., 0., 0.}));
      +
      36
      +
      37 tests.push_back(
      +
      38 std::make_pair(vec3{10., 0., 0.}, vec3{96.4852558, 0., 0.}));
      +
      39
      +
      40 tests.push_back(
      +
      41 std::make_pair(vec3{10., 0., 0.}, vec3{96.4852558, 0., 0.}));
      +
      42
      +
      43 tests.push_back(
      +
      44 std::make_pair(vec3{0., 10., 0.}, vec3{0., 96.4852558, 0.}));
      +
      45
      +
      46 tests.push_back(
      +
      47 std::make_pair(vec3{0., 0., 10.}, vec3{0., 0., -192.9705116}));
      +
      48
      +
      49 vec3 result;
      +
      50 vec3 v;
      +
      51 std::stringstream msg;
      +
      52 for (size_t i = 0; i < tests.size(); i++) {
      +
      53 v = tests.at(i).first;
      +
      54 result = trap.external_E_field(v);
      +
      55
      +
      56 msg.str("");
      +
      57 msg << "Testing the external E field at (" << std::setprecision(2)
      +
      58 << v(0) << "," << v(1) << "," << v(2) << ").";
      +
      59
      +
      60 ASSERT(close_to(result, tests.at(i).second), msg.str());
      +
      61 }
      +
      62 }
      +
      63
      + +
      67 {
      +
      68 // No point in testing at different points since it's not dependent
      +
      69 // on position.
      +
      70 PenningTrap trap;
      +
      71 vec3 expected{0., 0., T};
      +
      72 vec3 result = trap.external_B_field(vec3{0., 0., 0.});
      +
      73 ASSERT(close_to(expected, result),
      +
      74 "Testing the external B field at (0,0,0)");
      +
      75 }
      +
      76
      + +
      81 {
      +
      82 PenningTrap trap;
      +
      83 vec3 v{0., 0., 0.};
      +
      84
      +
      85 // Add particles to test
      +
      86 trap.add_particle(Particle(vec3{0., 0., 0.}, v));
      +
      87 trap.add_particle(Particle(vec3{1., 0., 0.}, v));
      +
      88 trap.add_particle(Particle(vec3{0., 3., 4.}, v));
      +
      89
      +
      90 // Test p0 and p1
      +
      91 vec3 expected{-1., 0., 0.};
      +
      92 vec3 result = trap.force_on_particle(0, 1);
      +
      93 ASSERT(close_to(expected, result),
      +
      94 "Testing the force on a particle at (0,0,0) from a "
      +
      95 "particle at (1,0,0).");
      +
      96
      +
      97 // Test p0 and p2
      +
      98 expected = vec3{0, -.024, -.032};
      +
      99 result = trap.force_on_particle(0, 2);
      +
      100 ASSERT(close_to(expected, result),
      +
      101 "Testing the force on a particle at (0,0,0) from a "
      +
      102 "particle at (0,3,4).");
      +
      103 }
      +
      104
      + +
      108 {
      +
      109 PenningTrap trap;
      +
      110 trap.add_particle(Particle(vec3{1., 2., 3.}, vec3{3., 4., 5.}));
      +
      111
      +
      112 vec3 expected{395.58954878, -270.15871624, -57.89115348};
      +
      113 vec3 result = trap.total_force_external(0);
      +
      114 ASSERT(close_to(expected, result),
      +
      115 "Testing the total external force on a particle at "
      +
      116 "(1,2,3) with velocity (3,4,5)");
      +
      117 }
      +
      118
      + +
      123 {
      +
      124 PenningTrap trap;
      +
      125 trap.add_particle(Particle(vec3{0., 0., 0.}, vec3{0., 0., 0.}));
      126
      -
      127 expected = arma::vec(3, arma::fill::value(-3473.383325));
      -
      128 result = trap.total_force_particles(0);
      -
      129 ASSERT(arma_vector_close_to(expected, result),
      +
      127 vec3 expected{0., 0., 0.};
      +
      128 vec3 result = trap.total_force_particles(0);
      +
      129 ASSERT(close_to(expected, result),
      130 "Testing the total force of all particles on particle 0 "
      -
      131 "with 3 other particles.");
      -
      132 }
      -
      133};
      -
      134
      -
      135int main()
      -
      136{
      -
      137 PenningTrapTest::test_external_E_field();
      -
      138 PenningTrapTest::test_external_B_field();
      -
      139 PenningTrapTest::test_force_on_particle();
      -
      140 PenningTrapTest::test_total_force_external();
      -
      141 PenningTrapTest::test_total_force_particles();
      -
      142 return 0;
      -
      143}
      +
      131 "with only a single particle");
      +
      132
      +
      133 trap.add_particle(Particle(vec3{1., 0., 0.}, vec3{0., 0., 0.}));
      +
      134 trap.add_particle(Particle(vec3{0., 1., 0.}, vec3{0., 0., 0.}));
      +
      135 trap.add_particle(Particle(vec3{0., 0., 1.}, vec3{0., 0., 0.}));
      +
      136
      +
      137 expected = vec3().fill(-138935.333);
      +
      138 result = trap.total_force_particles(0);
      +
      139 ASSERT(close_to(expected, result),
      +
      140 "Testing the total force of all particles on particle 0 "
      +
      141 "with 3 other particles.");
      +
      142 }
      +
      143};
      +
      144
      +
      145int main()
      +
      146{
      +
      147 PenningTrapTest test;
      + + + + + +
      153 return 0;
      +
      154}
      A class for simulating a Penning trap.
      -
      A class that holds attributes of a particle.
      Definition: Particle.hpp:21
      - -
      A class that simulates a Penning trap.
      Definition: PenningTrap.hpp:30
      -
      vec_3d external_E_field(vec_3d r)
      Calculate E at point r.
      Definition: PenningTrap.cpp:87
      -
      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.
      Definition: PenningTrap.cpp:82
      -
      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.
      Definition: PenningTrap.cpp:95
      -
      vec_3d total_force_external(unsigned int i)
      Calculate the total external force on a particle.
      -
      #define T
      1 Tesla. unit:
      Definition: constants.hpp:17
      +
      A class that holds attributes of a particle.
      Definition: Particle.hpp:23
      +
      Test class for the Penning trap.
      Definition: test_suite.cpp:24
      +
      void test_force_on_particle()
      Test that the force between particles gives expected results.
      Definition: test_suite.cpp:80
      +
      void test_total_force_particles()
      Test that the total force of all particles on a single particle returns expected results.
      Definition: test_suite.cpp:122
      +
      void test_external_E_field()
      Test that the external E field gives correct values.
      Definition: test_suite.cpp:28
      +
      void test_external_B_field()
      Test that the external B field gives correct values.
      Definition: test_suite.cpp:66
      +
      void test_total_force_external()
      Test that the total external force returns expected results.
      Definition: test_suite.cpp:107
      +
      A class that simulates a Penning trap.
      Definition: PenningTrap.hpp:32
      +
      vec3 total_force_external(uint i)
      Calculate the total external force on a particle.
      Definition: PenningTrap.cpp:83
      +
      vec3 total_force_particles(uint i)
      Calculate the total force on a particle p_i from other particles.
      Definition: PenningTrap.cpp:92
      +
      vec3 external_B_field(vec3 r)
      Calculate B at point r.
      Definition: PenningTrap.cpp:67
      +
      vec3 external_E_field(vec3 r)
      Calculate E at point r.
      Definition: PenningTrap.cpp:59
      +
      void add_particle(Particle particle)
      Add a particle to the system.
      +
      vec3 force_on_particle(uint i, uint j)
      Calculate the force between 2 particles.
      Definition: PenningTrap.cpp:72
      +
      Library of constants.
      +
      #define T
      1 Tesla. unit:
      Definition: constants.hpp:21
      +
      arma::vec::fixed< 3 > vec3
      Typedef for a fixed 3d arma vector.
      Definition: typedefs.hpp:23
      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.
      Definition: utils.cpp:62
      -
      #define ASSERT(expr, msg)
      A prettier assertion function.
      Definition: utils.hpp:45
      +
      #define ASSERT(expr, msg)
      A prettier assertion function.
      Definition: utils.hpp:46
      +
      bool close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
      Test if two armadillo vectors are close to each other.
      Definition: utils.cpp:58
      diff --git a/docs/typedefs_8hpp.html b/docs/typedefs_8hpp.html index 1f2eedb..60e3c9c 100644 --- a/docs/typedefs_8hpp.html +++ b/docs/typedefs_8hpp.html @@ -99,6 +99,7 @@ $(document).ready(function(){initNavTree('typedefs_8hpp.html',''); initResizable
      typedefs.hpp File Reference
      @@ -106,25 +107,35 @@ $(document).ready(function(){initNavTree('typedefs_8hpp.html',''); initResizable

      Useful typedefs for cleaner code. More...

      -
      #include <vector>
      -#include <armadillo>
      +
      #include <armadillo>
      +#include <vector>

      Go to the source code of this file.

      + + + + +

      +Classes

      struct  simulation
       Typedef for PenningTrap::simulation return value. More...
       
      - - - - - - - + + + + + + + + + + - - - + + +

      Typedefs

      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_colssim_arr
      typedef arma::vec::fixed< 3 > vec3
       Typedef for a fixed 3d arma vector.
       
      typedef std::vector< vec3sim_cols
       Typedef for the column of the result vector from simulating particles.
       
      typedef std::vector< vec3sim_rows
       Typedef for the row of the result vector from simulating particles.
       
      typedef std::vector< sim_colssim_arr
       Typedef for the result of the simulate method.
       
      typedef arma::vec::fixed< 3 > vec_3d
       Typedef for a fixed 3d arma vector.
       
      +typedef struct simulation simulation_t
       Typedef for PenningTrap::simulation return value.
       

      Detailed Description

      Useful typedefs for cleaner code.

      @@ -144,68 +155,68 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      - +
      typedef std::vector<sim_cols> sim_arrtypedef std::vector<sim_cols> sim_arr

      Typedef for the result of the simulate method.

      -

      Definition at line 32 of file typedefs.hpp.

      +

      Definition at line 36 of file typedefs.hpp.

      - -

      ◆ sim_cols

      + +

      ◆ sim_cols

      - +
      typedef std::vector<arma::vec::fixed<3> > sim_colstypedef std::vector<vec3> sim_cols

      Typedef for the column of the result vector from simulating particles.

      -

      Definition at line 24 of file typedefs.hpp.

      +

      Definition at line 28 of file typedefs.hpp.

      - -

      ◆ sim_rows

      + +

      ◆ sim_rows

      - +
      typedef std::vector<arma::vec::fixed<3> > sim_rowstypedef std::vector<vec3> sim_rows

      Typedef for the row of the result vector from simulating particles.

      -

      Definition at line 28 of file typedefs.hpp.

      +

      Definition at line 32 of file typedefs.hpp.

      - -

      ◆ vec_3d

      + +

      ◆ vec3

      - +
      typedef arma::vec::fixed<3> vec_3dtypedef arma::vec::fixed<3> vec3

      Typedef for a fixed 3d arma vector.

      -

      Definition at line 36 of file typedefs.hpp.

      +

      Definition at line 23 of file typedefs.hpp.

      diff --git a/docs/typedefs_8hpp.js b/docs/typedefs_8hpp.js index d014844..3b3b8bd 100644 --- a/docs/typedefs_8hpp.js +++ b/docs/typedefs_8hpp.js @@ -1,7 +1,9 @@ var typedefs_8hpp = [ + [ "simulation", "structsimulation.html", null ], [ "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 ] + [ "sim_cols", "typedefs_8hpp.html#a46482a2697556c00556c9d73f461784f", null ], + [ "sim_rows", "typedefs_8hpp.html#a33418f31f28663b8414c8f7182998c22", null ], + [ "simulation_t", "typedefs_8hpp.html#a784799c37b5e4fb8bf4f6368e004dec6", null ], + [ "vec3", "typedefs_8hpp.html#a3bdfb73a02f88ae32b6128ef747c4aea", null ] ]; \ No newline at end of file diff --git a/docs/typedefs_8hpp_source.html b/docs/typedefs_8hpp_source.html index 475ff07..3cb6d86 100644 --- a/docs/typedefs_8hpp_source.html +++ b/docs/typedefs_8hpp_source.html @@ -105,22 +105,29 @@ $(document).ready(function(){initNavTree('typedefs_8hpp_source.html',''); initRe
      15#ifndef __TYPEDEFS__
      16#define __TYPEDEFS__
      17
      -
      18#include <vector>
      -
      19#include <armadillo>
      +
      18#include <armadillo>
      +
      19#include <vector>
      20
      -
      24typedef std::vector<arma::vec::fixed<3>> sim_cols;
      -
      25
      -
      28typedef std::vector<arma::vec::fixed<3>> sim_rows;
      +
      23typedef arma::vec::fixed<3> vec3;
      +
      24
      +
      28typedef std::vector<vec3> sim_cols;
      29
      -
      32typedef std::vector<sim_cols> sim_arr;
      +
      32typedef std::vector<vec3> sim_rows;
      33
      -
      36typedef arma::vec::fixed<3> vec_3d;
      +
      36typedef std::vector<sim_cols> sim_arr;
      37
      -
      38#endif
      -
      std::vector< arma::vec::fixed< 3 > > sim_cols
      Typedef for the column of the result vector from simulating particles.
      Definition: typedefs.hpp:24
      -
      std::vector< arma::vec::fixed< 3 > > sim_rows
      Typedef for the row of the result vector from simulating particles.
      Definition: typedefs.hpp:28
      -
      arma::vec::fixed< 3 > vec_3d
      Typedef for a fixed 3d arma vector.
      Definition: typedefs.hpp:36
      -
      std::vector< sim_cols > sim_arr
      Typedef for the result of the simulate method.
      Definition: typedefs.hpp:32
      +
      40typedef struct simulation {
      +
      41 sim_arr r_vecs;
      +
      42 sim_arr v_vecs;
      + +
      44
      +
      45#endif
      +
      Typedef for PenningTrap::simulation return value.
      Definition: typedefs.hpp:40
      +
      std::vector< vec3 > sim_rows
      Typedef for the row of the result vector from simulating particles.
      Definition: typedefs.hpp:32
      +
      arma::vec::fixed< 3 > vec3
      Typedef for a fixed 3d arma vector.
      Definition: typedefs.hpp:23
      +
      std::vector< vec3 > sim_cols
      Typedef for the column of the result vector from simulating particles.
      Definition: typedefs.hpp:28
      +
      struct simulation simulation_t
      Typedef for PenningTrap::simulation return value.
      +
      std::vector< sim_cols > sim_arr
      Typedef for the result of the simulate method.
      Definition: typedefs.hpp:36
      diff --git a/docs/utils_8cpp.html b/docs/utils_8cpp.html index 9401b51..89ca470 100644 --- a/docs/utils_8cpp.html +++ b/docs/utils_8cpp.html @@ -106,8 +106,7 @@ $(document).ready(function(){initNavTree('utils_8cpp.html',''); initResizable();

      Implementation of the utils. More...

      -
      #include <sys/stat.h>
      -#include "utils.hpp"
      +
      #include "utils.hpp"

      Go to the source code of this file.

      @@ -122,9 +121,9 @@ Functions - - - + + + @@ -135,18 +134,18 @@ Functions
      Janita Ovidie Sandtrøen Willumsen (janitaws)
      Version
      1.0
      -
      Bug:
      No known bugs
      +
      Bug:
      No known bugs

      Definition in file utils.cpp.

      Function Documentation

      - -

      ◆ arma_vector_close_to()

      + +

      ◆ close_to()

      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.
       
      bool arma_vector_close_to (arma::vec &a, arma::vec &b, double tol)
       Test if two armadillo vectors are close to each other.
       
      bool 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.
       
      - + @@ -183,7 +182,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      Returns
      bool
      -

      Definition at line 62 of file utils.cpp.

      +

      Definition at line 58 of file utils.cpp.

      @@ -251,7 +250,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) -

      Definition at line 43 of file utils.cpp.

      +

      Definition at line 40 of file utils.cpp.

      @@ -290,9 +289,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      bool arma_vector_close_to bool close_to ( arma::vec &  a,
      -
      Returns
      bool
      +
      Returns
      bool Success/Fail
      -

      Definition at line 76 of file utils.cpp.

      +

      Definition at line 72 of file utils.cpp.

      @@ -340,7 +339,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      Returns
      std::string
      -

      Definition at line 24 of file utils.cpp.

      +

      Definition at line 22 of file utils.cpp.

      @@ -388,7 +387,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      Returns
      std::string
      -

      Definition at line 17 of file utils.cpp.

      +

      Definition at line 15 of file utils.cpp.

      diff --git a/docs/utils_8cpp.js b/docs/utils_8cpp.js index 362b36a..a2d8610 100644 --- a/docs/utils_8cpp.js +++ b/docs/utils_8cpp.js @@ -1,6 +1,6 @@ var utils_8cpp = [ - [ "arma_vector_close_to", "utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a", null ], + [ "close_to", "utils_8cpp.html#a6be6f938bcbb235ebb6a2ed9d08411b2", null ], [ "m_assert", "utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b", null ], [ "mkpath", "utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de", null ], [ "scientific_format", "utils_8cpp.html#a58565270b643b24e3132f38c653e0199", null ], diff --git a/docs/utils_8cpp_source.html b/docs/utils_8cpp_source.html index 5ed9571..f124b46 100644 --- a/docs/utils_8cpp_source.html +++ b/docs/utils_8cpp_source.html @@ -102,97 +102,93 @@ $(document).ready(function(){initNavTree('utils_8cpp_source.html',''); initResiz
      Go to the documentation of this file.
      1
      -
      13#include <sys/stat.h>
      +
      13#include "utils.hpp"
      14
      -
      15#include "utils.hpp"
      -
      16
      -
      17std::string scientific_format(double d, int width, int prec)
      -
      18{
      -
      19 std::stringstream ss;
      -
      20 ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
      -
      21 return ss.str();
      -
      22}
      -
      23
      -
      24std::string scientific_format(const std::vector<double> &v, int width, int prec)
      -
      25{
      -
      26 std::stringstream ss;
      -
      27 for (double elem : v) {
      -
      28 ss << scientific_format(elem, width, prec);
      -
      29 }
      -
      30 return ss.str();
      -
      31}
      -
      32
      -
      33static void print_message(std::string msg)
      -
      34{
      -
      35 if (msg.size() > 0) {
      -
      36 std::cout << "message: " << msg << "\n\n";
      +
      15std::string scientific_format(double d, int width, int prec)
      +
      16{
      +
      17 std::stringstream ss;
      +
      18 ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
      +
      19 return ss.str();
      +
      20}
      +
      21
      +
      22std::string scientific_format(const std::vector<double> &v, int width, int prec)
      +
      23{
      +
      24 std::stringstream ss;
      +
      25 for (double elem : v) {
      +
      26 ss << scientific_format(elem, width, prec);
      +
      27 }
      +
      28 return ss.str();
      +
      29}
      +
      30
      +
      31static void print_message(std::string msg)
      +
      32{
      +
      33 if (msg.size() > 0) {
      +
      34 std::cout << "message: " << msg << "\n\n";
      +
      35 } else {
      +
      36 std::cout << "\n";
      37 }
      -
      38 else {
      -
      39 std::cout << "\n";
      -
      40 }
      -
      41}
      -
      42
      -
      43void m_assert(bool expr, std::string expr_str, std::string f, std::string file,
      -
      44 int line, std::string msg)
      -
      45{
      -
      46 std::string new_assert(f.size() + (expr ? 4 : 6), '-');
      -
      47 std::cout << "\x1B[36m" << new_assert << "\033[0m\n";
      -
      48 std::cout << f << ": ";
      -
      49 if (expr) {
      -
      50 std::cout << "\x1B[32mOK\033[0m\n";
      +
      38}
      +
      39
      +
      40void m_assert(bool expr, std::string expr_str, std::string f, std::string file,
      +
      41 int line, std::string msg)
      +
      42{
      +
      43 std::string new_assert(f.size() + (expr ? 4 : 6), '-');
      +
      44 std::cout << "\x1B[36m" << new_assert << "\033[0m\n";
      +
      45 std::cout << f << ": ";
      +
      46 if (expr) {
      +
      47 std::cout << "\x1B[32mOK\033[0m\n";
      +
      48 print_message(msg);
      +
      49 } else {
      +
      50 std::cout << "\x1B[31mFAIL\033[0m\n";
      51 print_message(msg);
      -
      52 }
      -
      53 else {
      -
      54 std::cout << "\x1B[31mFAIL\033[0m\n";
      -
      55 print_message(msg);
      -
      56 std::cout << file << " " << line << ": Assertion \"" << expr_str
      -
      57 << "\" Failed\n\n";
      -
      58 abort();
      -
      59 }
      -
      60}
      -
      61
      -
      62bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol)
      -
      63{
      -
      64 if (a.n_elem != b.n_elem) {
      -
      65 return false;
      -
      66 }
      -
      67
      -
      68 for (size_t i = 0; i < a.n_elem; i++) {
      -
      69 if (std::abs(a(i) - b(i)) >= tol) {
      -
      70 return false;
      -
      71 }
      -
      72 }
      -
      73 return true;
      -
      74}
      -
      75
      -
      76bool mkpath(std::string path, int mode)
      -
      77{
      -
      78 std::string cur_dir;
      -
      79 std::string::size_type pos = -1;
      -
      80 struct stat buf;
      -
      81
      -
      82 if (path.back() != '/') {
      -
      83 path += '/';
      -
      84 }
      -
      85 while (true) {
      -
      86 pos++;
      -
      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) {
      -
      91 return -1;
      -
      92 }
      -
      93 }
      -
      94 else {
      -
      95 break;
      -
      96 }
      -
      97 }
      -
      98 return 0;
      -
      99}
      -
      bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol)
      Test if two armadillo vectors are close to each other.
      Definition: utils.cpp:62
      -
      std::string scientific_format(double d, int width, int prec)
      Turns a double into a string written in scientific format.
      Definition: utils.cpp:17
      -
      bool mkpath(std::string path, int mode)
      Make path given.
      Definition: utils.cpp:76
      -
      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.
      Definition: utils.cpp:43
      +
      52 std::cout << file << " " << line << ": Assertion \"" << expr_str
      +
      53 << "\" Failed\n\n";
      +
      54 abort();
      +
      55 }
      +
      56}
      +
      57
      +
      58bool close_to(arma::vec &a, arma::vec &b, double tol)
      +
      59{
      +
      60 if (a.n_elem != b.n_elem) {
      +
      61 return false;
      +
      62 }
      +
      63
      +
      64 for (size_t i = 0; i < a.n_elem; i++) {
      +
      65 if (std::abs(a(i) - b(i)) >= tol) {
      +
      66 return false;
      +
      67 }
      +
      68 }
      +
      69 return true;
      +
      70}
      +
      71
      +
      72bool mkpath(std::string path, int mode)
      +
      73{
      +
      74 std::string cur_dir;
      +
      75 std::string::size_type pos = -1;
      +
      76 struct stat buf;
      +
      77
      +
      78 if (path.back() != '/') {
      +
      79 path += '/';
      +
      80 }
      +
      81 while (true) {
      +
      82 pos++;
      +
      83 pos = path.find('/', pos);
      +
      84 if (pos != std::string::npos) {
      +
      85 cur_dir = path.substr(0, pos);
      +
      86 if (mkdir(cur_dir.c_str(), mode) != 0
      +
      87 && stat(cur_dir.c_str(), &buf) != 0) {
      +
      88 return -1;
      +
      89 }
      +
      90 } else {
      +
      91 break;
      +
      92 }
      +
      93 }
      +
      94 return 0;
      +
      95}
      +
      bool close_to(arma::vec &a, arma::vec &b, double tol)
      Test if two armadillo vectors are close to each other.
      Definition: utils.cpp:58
      +
      std::string scientific_format(double d, int width, int prec)
      Turns a double into a string written in scientific format.
      Definition: utils.cpp:15
      +
      bool mkpath(std::string path, int mode)
      Make path given.
      Definition: utils.cpp:72
      +
      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.
      Definition: utils.cpp:40
      Function prototypes and macros that are useful.
      diff --git a/docs/utils_8hpp.html b/docs/utils_8hpp.html index 2866ae0..44e8275 100644 --- a/docs/utils_8hpp.html +++ b/docs/utils_8hpp.html @@ -111,6 +111,7 @@ $(document).ready(function(){initNavTree('utils_8hpp.html',''); initResizable(); #include <iomanip>
      #include <sstream>
      #include <string>
      +#include <sys/stat.h>
      #include <vector>

      Go to the source code of this file.

      @@ -120,11 +121,11 @@ Macros #define DEBUG(msg)  Writes a debug message.
        -#define ASSERT(expr, msg) +#define ASSERT(expr, msg)    m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg)  A prettier assertion function.
        #define __METHOD_NAME__   methodName(__PRETTY_FUNCTION__) - Get the name of the current method/function.
      + Get the name of the current method/function without the return type.
        - - - + + + @@ -168,9 +169,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

      @@ -138,9 +139,9 @@ Functions

      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 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 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.
       
      -

      Get the name of the current method/function.

      +

      Get the name of the current method/function without the return type.

      -

      Definition at line 51 of file utils.hpp.

      +

      Definition at line 52 of file utils.hpp.

      @@ -195,19 +196,15 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) ) - +     m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg)
      -Value:
      m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
      -
      __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.
      Definition: utils.cpp:43
      -
      #define __METHOD_NAME__
      Get the name of the current method/function.
      Definition: utils.hpp:51
      -
      +

      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.

      -

      Definition at line 45 of file utils.hpp.

      +

      Definition at line 46 of file utils.hpp.

      @@ -230,19 +227,19 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

      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.

      -

      Definition at line 36 of file utils.hpp.

      +

      Definition at line 37 of file utils.hpp.

      Function Documentation

      - -

      ◆ arma_vector_close_to()

      + +

      ◆ close_to()

      - + @@ -279,7 +276,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      Returns
      bool
      -

      Definition at line 62 of file utils.cpp.

      +

      Definition at line 58 of file utils.cpp.

      @@ -347,7 +344,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) -

      Definition at line 43 of file utils.cpp.

      +

      Definition at line 40 of file utils.cpp.

      @@ -386,9 +383,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      bool arma_vector_close_to bool close_to ( arma::vec &  a,
      -
      Returns
      bool
      +
      Returns
      bool Success/Fail
      -

      Definition at line 76 of file utils.cpp.

      +

      Definition at line 72 of file utils.cpp.

      @@ -436,7 +433,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      Returns
      std::string
      -

      Definition at line 24 of file utils.cpp.

      +

      Definition at line 22 of file utils.cpp.

      @@ -484,7 +481,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
      Returns
      std::string
      -

      Definition at line 17 of file utils.cpp.

      +

      Definition at line 15 of file utils.cpp.

      diff --git a/docs/utils_8hpp.js b/docs/utils_8hpp.js index 68951df..35bac4e 100644 --- a/docs/utils_8hpp.js +++ b/docs/utils_8hpp.js @@ -3,7 +3,7 @@ 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 ], + [ "close_to", "utils_8hpp.html#ab3e0cf669bddc59bd53998490ffb68b9", null ], [ "m_assert", "utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38", null ], [ "mkpath", "utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa", null ], [ "scientific_format", "utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d", null ], diff --git a/docs/utils_8hpp_source.html b/docs/utils_8hpp_source.html index 1c7052d..576b8d7 100644 --- a/docs/utils_8hpp_source.html +++ b/docs/utils_8hpp_source.html @@ -109,57 +109,47 @@ $(document).ready(function(){initNavTree('utils_8hpp_source.html',''); initResiz
      19#include <iomanip>
      20#include <sstream>
      21#include <string>
      -
      22#include <vector>
      -
      23
      -
      32#ifdef DBG
      -
      33 #define DEBUG(msg) std::cout << __FILE__ << " " << __LINE__ << ": " \
      -
      34 << msg << std::endl
      -
      35#else
      -
      36 #define DEBUG(msg)
      -
      37#endif
      -
      38
      -
      45#define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
      -
      46 __LINE__, msg)
      -
      47
      -
      51#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
      -
      52
      +
      22#include <sys/stat.h>
      +
      23#include <vector>
      +
      24
      +
      33#ifdef DBG
      +
      34#define DEBUG(msg) \
      +
      35 std::cout << __FILE__ << " " << __LINE__ << ": " << msg << std::endl
      +
      36#else
      +
      37#define DEBUG(msg)
      +
      38#endif
      +
      39
      +
      46#define ASSERT(expr, msg) \
      +
      47 m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg)
      +
      48
      +
      52#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
      53
      -
      64std::string scientific_format(double d, int width=20, int prec=10);
      +
      64std::string scientific_format(double d, int width = 20, int prec = 10);
      65
      -
      66
      -
      77std::string scientific_format(const std::vector<double>& v,
      -
      78 int width=20,
      -
      79 int prec=10);
      -
      80
      -
      81
      -
      94void m_assert(bool expr,
      -
      95 std::string expr_str,
      -
      96 std::string func,
      -
      97 std::string file,
      -
      98 int line,
      -
      99 std::string msg);
      -
      100
      -
      101
      -
      113bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
      -
      114
      -
      115
      -
      126static inline std::string methodName(const std::string& pretty_function)
      -
      127{
      -
      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;
      -
      131
      -
      132 return pretty_function.substr(begin,end) + "()";
      -
      133}
      -
      134
      -
      135
      -
      146bool mkpath(std::string path, int mode = 0777);
      -
      147
      -
      148#endif
      -
      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.
      Definition: utils.cpp:62
      -
      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.
      Definition: utils.cpp:43
      -
      bool mkpath(std::string path, int mode=0777)
      Make path given.
      Definition: utils.cpp:76
      -
      std::string scientific_format(double d, int width=20, int prec=10)
      Turns a double into a string written in scientific format.
      Definition: utils.cpp:17
      +
      77std::string scientific_format(const std::vector<double> &v, int width = 20,
      +
      78 int prec = 10);
      +
      79
      +
      92void m_assert(bool expr, std::string expr_str, std::string func,
      +
      93 std::string file, int line, std::string msg);
      +
      94
      +
      106bool close_to(arma::vec &a, arma::vec &b, double tol = 1e-8);
      +
      107
      +
      118static inline std::string methodName(const std::string &pretty_function)
      +
      119{
      +
      120 size_t colons = pretty_function.find("::");
      +
      121 size_t begin = pretty_function.substr(0, colons).rfind(" ") + 1;
      +
      122 size_t end = pretty_function.rfind("(") - begin;
      +
      123
      +
      124 return pretty_function.substr(begin, end) + "()";
      +
      125}
      +
      126
      +
      137bool mkpath(std::string path, int mode = 0777);
      +
      138
      +
      139#endif
      +
      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.
      Definition: utils.cpp:40
      +
      bool mkpath(std::string path, int mode=0777)
      Make path given.
      Definition: utils.cpp:72
      +
      bool close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
      Test if two armadillo vectors are close to each other.
      Definition: utils.cpp:58
      +
      std::string scientific_format(double d, int width=20, int prec=10)
      Turns a double into a string written in scientific format.
      Definition: utils.cpp:15
      diff --git a/images/100_particles.gif b/images/100_particles.gif index 53eb275..ba16c67 100644 Binary files a/images/100_particles.gif and b/images/100_particles.gif differ diff --git a/include/Particle.hpp b/include/Particle.hpp index 4b5e716..3f5d182 100644 --- a/include/Particle.hpp +++ b/include/Particle.hpp @@ -3,7 +3,7 @@ * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * - * @version 0.1 + * @version 1.0 * * @brief A class that holds the properties of a particle. * @@ -14,16 +14,18 @@ #include +#include "constants.hpp" #include "typedefs.hpp" /** @brief A class that holds attributes of a particle * */ -class Particle { +class Particle +{ private: - double q; ///< Charge - double m; ///< Mass - vec_3d r_vec; ///< position - vec_3d v_vec; ///< velocity + vec3 r_vec; ///< position + vec3 v_vec; ///< velocity + double q; ///< Charge + double m; ///< Mass public: /** @brief Initialize the particle. @@ -36,7 +38,7 @@ public: * @param r_vec The initial position of the particle * @param v_vec The initial velocity of the particle * */ - Particle(double q, double m, vec_3d r_vec, vec_3d v_vec); + Particle(vec3 r_vec, vec3 v_vec, double q = CA_CHARGE, double m = CA_MASS); /** @brief Make private attributes available for PenningTrap. * */ diff --git a/include/PenningTrap.hpp b/include/PenningTrap.hpp index f6cf2c0..587299a 100644 --- a/include/PenningTrap.hpp +++ b/include/PenningTrap.hpp @@ -3,7 +3,7 @@ * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * - * @version 0.1 + * @version 1.0 * * @brief A class for simulating a Penning trap. * @@ -18,8 +18,9 @@ #include "Particle.hpp" #include "constants.hpp" #include "typedefs.hpp" +#include "utils.hpp" -#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \ +#pragma omp declare reduction(+ : vec3 : omp_out += omp_in) \ initializer(omp_priv = omp_orig) /** @brief A class that simulates a Penning trap. @@ -27,17 +28,28 @@ * This class simulates a Penning trap. It can take in a number of particles * and simulate how they would behave inside a Penning trap. * */ -class PenningTrap { +class PenningTrap +{ + /** @brief Make PenningTrapTest a friend of PenningTrap. + * */ + friend class PenningTrapTest; private: - 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 + double B_0; ///< Magnetic field strength + double V_0; ///< Applied potential + std::function perturbation; ///< Time-dependent perturbation + double d; ///< Characteristic dimension + double t; ///< Current time + std::vector particles; ///< The particles in the Penning trap + + /** @brief A 2D vector containing all \f$k_{v,i,j}\f$ where \f$j\f$ is the + * index of a particle + * */ + sim_arr k_v; + + /** @brief A 2D vector containing all \f$k_{r,i,j}\f$ where \f$j\f$ is the + * index of a particle + * */ + sim_arr k_r; /** @brief Helper for evolve_RK4 when calculating \f$k_{v,i,j}\f$ values * @@ -47,9 +59,9 @@ private: * @param j Index j for \f$k_{v,i,j}\f$ * @param dt the step length (delta time) * - * @return vec_3d + * @return vec3 * */ - vec_3d v_func(unsigned int i, unsigned int j, double dt); + vec3 v_func(uint i, uint j, double dt); /** @brief Helper for evolve_RK4 when calculating \f$k_{r,i,j}\f$ values * @@ -57,75 +69,27 @@ private: * * @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) + * @param dt The step length (delta time) * - * @return vec_3d + * @return vec3 * */ - vec_3d r_func(unsigned int i, unsigned int j, double dt); - -public: - /** @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, - 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); + vec3 r_func(uint i, uint j, double dt); /** @brief Calculate E at point r * * @param r The position where we want to calculate the E field * - * @return vec_3d + * @return vec3 * */ - vec_3d external_E_field(vec_3d r); + vec3 external_E_field(vec3 r); /** @brief Calculate B at point r * * @param r The position where we want to calculate the B field * - * @return vec_3d + * @return vec3 * */ - vec_3d external_B_field(vec_3d r); + vec3 external_B_field(vec3 r); /** @brief Calculate the force between 2 particles. * @@ -135,9 +99,9 @@ public: * @param i The index of particle p_i * @param j The index of particle p_j * - * @return vec_3d + * @return vec3 * */ - vec_3d force_on_particle(unsigned int i, unsigned int j); + vec3 force_on_particle(uint i, uint j); /** @brief Calculate the total external force on a particle. * @@ -146,25 +110,88 @@ public: * * @param i The index of particle p_i * - * @return vec_3d + * @return vec3 * */ - vec_3d total_force_external(unsigned int i); + vec3 total_force_external(uint i); - /** @brief Calculate the total force on a particle p_i 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 + * @return vec3 * */ - vec_3d total_force_particles(unsigned int i); + vec3 total_force_particles(uint i); /** @brief calculate the total force on a particle p_i. * * @param i The index of particle p_i * - * @return vec_3d + * @return vec3 * */ - vec_3d total_force(unsigned int i); + vec3 total_force(uint i); + + /** @brief calculate the total force on a particle p_i without interaction + * + * @param i The index of particle p_i + * + * @return vec3 + * */ + vec3 total_force_no_interaction(uint i); + +public: + /** @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., + 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(uint i, double B_0 = T, double V_0 = (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, + double V_0 = (25. * V) / 1000., double d = 500., double t = 0.); + + /** @brief Time dependent perturbation to V_0 + * + * @param f The amplitude of the perturbation + * @parma omega_V the angular frequency of the perturbation + * */ + void set_pertubation(double f, double omega_V); + + /** @brief Give all particles new positions and velocities, and change t + * and V_0. + * + * @param V_0 The tiome dependent applied potential + * @param t The starting time + * */ + void reinitialize(double f, double omega_V, 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 Go forward one timestep using the RK4 method * @@ -187,10 +214,11 @@ public: * @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 simulation_t * */ - sim_arr simulate(double time, unsigned int steps, - std::string method = "rk4", - bool particle_interaction = true); + simulation_t simulate(double time, uint steps, std::string method = "rk4", + bool particle_interaction = true); /** @brief Simulate and write the displacement of all particles to files. * @@ -200,8 +228,8 @@ public: * @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", + void write_simulation_to_dir(std::string path, double time, uint steps, + std::string method = "rk4", bool particle_interaction = true); /** @brief Simulate and calculate what fraction of particles are still @@ -214,9 +242,10 @@ public: * * @return double * */ - double fraction_of_particles_left(double time, unsigned int steps, + double fraction_of_particles_left(double time, uint steps, std::string method = "rk4", bool particle_interaction = true); + }; #endif diff --git a/include/constants.hpp b/include/constants.hpp index 592b48a..85fc7d2 100644 --- a/include/constants.hpp +++ b/include/constants.hpp @@ -3,7 +3,7 @@ * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * - * @version 0.1 + * @version 1.0 * * @brief Library of constants * @@ -12,10 +12,24 @@ #ifndef __CONST__ #define __CONST__ -#define K_E 138935.333 ///< Coulomb constant. unit: \f$\frac{u(\mu m)^3}{(\mu s)^2 e^2}\f$ +/** @brief Coulomb constant. unit: \f$\frac{u(\mu m)^3}{(\mu s)^2 e^2}\f$ + * */ +#define K_E 1.38935333 * 1e5 -#define T 96.4852558 ///< 1 Tesla. unit: \f$ \frac{u}{(\mu s) e} \f$ +/** @brief 1 Tesla. unit: \f$ \frac{u}{(\mu s) e} \f$ + * */ +#define T 9.64852558 * 1e1 -#define V 96485255.8 ///< 1 Volt. unit: \f$ \frac{u (\mu m)^2}{(\mu s)^2 e} \f$ +/** @brief 1 Volt. unit: \f$ \frac{u (\mu m)^2}{(\mu s)^2 e} \f$ + * */ +#define V 9.64852558 * 1e7 + +/** @brief Mass of a single calcium ion. unit: amu + * */ +#define CA_MASS 40.078 + +/** @brief Charge of a singly charged calcium ion. unit: e + * */ +#define CA_CHARGE 1. #endif diff --git a/include/typedefs.hpp b/include/typedefs.hpp index f0ceca2..688e942 100644 --- a/include/typedefs.hpp +++ b/include/typedefs.hpp @@ -7,7 +7,7 @@ * * @brief Useful typedefs for cleaner code. * - * @details These typedefs make the code more readable and easy to follow + * @details These typedefs make the code more readable and easy to follow * along. * * @bug No known bugs @@ -15,24 +15,31 @@ #ifndef __TYPEDEFS__ #define __TYPEDEFS__ -#include #include +#include -/** @brief Typedef for the column of the result vector from simulating +/** @brief Typedef for a fixed 3d arma vector. + * */ +typedef arma::vec::fixed<3> vec3; + +/** @brief Typedef for the column of the result vector from simulating * particles. * */ -typedef std::vector> sim_cols; +typedef std::vector sim_cols; /** @brief Typedef for the row of the result vector from simulating particles. * */ -typedef std::vector> sim_rows; +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. +/** @brief Typedef for PenningTrap::simulation return value. * */ -typedef arma::vec::fixed<3> vec_3d; +typedef struct simulation { + sim_arr r_vecs; + sim_arr v_vecs; +} simulation_t; #endif diff --git a/include/utils.hpp b/include/utils.hpp index c9c9485..8816e8f 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include /** @def DEBUG(msg) @@ -26,14 +27,14 @@ * * 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 + * that checks if DBG is defined, so one can choose to display the debug * messages by adding the -DDBG flag when compiling. * */ #ifdef DBG - #define DEBUG(msg) std::cout << __FILE__ << " " << __LINE__ << ": " \ - << msg << std::endl +#define DEBUG(msg) \ + std::cout << __FILE__ << " " << __LINE__ << ": " << msg << std::endl #else - #define DEBUG(msg) +#define DEBUG(msg) #endif /** @def ASSERT(expr) @@ -42,15 +43,14 @@ * This macro calls the m_assert function which is a more informative * assertion function than the regular assert function from cassert. * */ -#define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \ - __LINE__, msg) +#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. + * @brief Get the name of the current method/function without the return type. * */ #define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__) - /** @brief Turns a double into a string written in scientific format. * * @details The code is stolen from https://github.com/anderkve/FYS3150. @@ -61,11 +61,11 @@ * * @return std::string * */ -std::string scientific_format(double d, int width=20, int prec=10); +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. - * +/** @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 @@ -74,14 +74,12 @@ std::string scientific_format(double d, int width=20, int prec=10); * * @return std::string * */ -std::string scientific_format(const std::vector& v, - int width=20, - int prec=10); - +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. * - * @details This function takes in an expression and prints an OK message if + * @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 @@ -91,17 +89,12 @@ std::string scientific_format(const std::vector& v, * @param line The line number where this function is called from * @param msg The message to be displayed * */ -void m_assert(bool expr, - std::string expr_str, - std::string func, - std::string file, - int line, - std::string msg); - +void m_assert(bool expr, std::string expr_str, std::string func, + std::string file, int line, std::string msg); /** @brief Test if two armadillo vectors are close to each other. * - * @details This function takes in 2 vectors and checks if they are + * @details This function takes in 2 vectors and checks if they are * approximately equal to each other given a tolerance. * * @param a Vector a @@ -110,8 +103,7 @@ void m_assert(bool expr, * * @return bool * */ -bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8); - +bool close_to(arma::vec &a, arma::vec &b, double tol = 1e-8); /** @brief Takes in the __PRETTY_FUNCTION__ string and removes the return type. * @@ -123,16 +115,15 @@ bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8); * * @return std::string * */ -static inline std::string methodName(const std::string& pretty_function) +static inline std::string methodName(const std::string &pretty_function) { size_t colons = pretty_function.find("::"); - size_t begin = pretty_function.substr(0,colons).rfind(" ") + 1; + size_t begin = pretty_function.substr(0, colons).rfind(" ") + 1; size_t end = pretty_function.rfind("(") - begin; - return pretty_function.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 @@ -141,7 +132,7 @@ static inline std::string methodName(const std::string& pretty_function) * @param path The path to be created * @param mode The mode/permissions for all the new directories * - * @return bool + * @return bool Success/Fail * */ bool mkpath(std::string path, int mode = 0777); diff --git a/latex/appendix.tex b/latex/appendix.tex new file mode 100644 index 0000000..315fbec --- /dev/null +++ b/latex/appendix.tex @@ -0,0 +1,266 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} +\section{Derivation of equations}\label{sec:derivations} +% Problem 1 +\subsection{Equations of motion}\label{sec:eq_motion} % +First, we need to define the velocity of the particle +\begin{align*} + \mathbf{v} \equiv \frac{d \mathbf{r}}{dt} &= \bigg( \frac{dx}{dt}, \frac{dy}{dt}, \frac{dz}{dt} \bigg). +\end{align*} % +% +We can rewrite the velocity as $\dot{r} = (\dot{x}, \dot{y}, \dot{z})$, and find the cross product +\begin{align*} + q \mathbf{v} \cross \mathbf{B} &= + q \begin{vmatrix} + \hat{e}_{x} & \hat{e}_{y} & \hat{e}_{z} \\ + \dot{x} & \dot{y} & \dot{z} \\ + 0 & 0 & B_{0} + \end{vmatrix} + = q \big( B_{0} \dot{y}, -B_{0} \dot{x}, 0 \big). +\end{align*} % +% +We are considering an ideal Penning traps, where we define the electric potential as +\begin{align*} + V(x, y, z) &= \frac{V_{0}}{2 d^{2}}(2z^{2} - x^{2} - y^{2}). +\end{align*} % +% +The relationship between the electric field $\mathbf{E}$ and the electric potential of the field is given by +\begin{align*} + \mathbf{E} &= - \nabla V \\ + &= - \bigg( \frac{dV}{dx}, \frac{dV}{dy} \frac{dV}{dz} \bigg) \\ + &= \frac{V_{0}}{d^{2}} \big( x, y, -2z \big). +\end{align*} % +% +We can now express the Lorentz force as +\begin{align*} + \mathbf{F} &= q \mathbf{E} + q \mathbf{v} \cross \mathbf{B} \\ + &= \frac{q V_{0}}{d^{2}} \big( x, y, -2z \big) + \big(q B_{0} \dot{y}, -q B_{0} \dot{x}, 0 \big), +\end{align*} % +% +and insert it into Newtons equation \eqref{eq:newton_second}. We get +\begin{align*} + \ddot{\mathbf{r}} &= \bigg( \frac{q V_{0}}{m d^{2}} x, \frac{q V_{0}}{m d^{2}} y, -\frac{2 q V_{0}}{m d^{2}} z \bigg) + \bigg(\frac{q B_{0}}{m} \dot{y}, -\frac{q B_{0}}{m} \dot{x}, 0 \bigg), +\end{align*} % +% +which can be written as +\begin{align*} + \ddot{x} &= \frac{q V_{0}}{m d^{2}} x + \frac{q B_{0}}{m} \dot{y}, \\ + \ddot{y} &= \frac{q V_{0}}{m d^{2}} y - \frac{q B_{0}}{m} \dot{x}, \\ + \ddot{z} &= -\frac{2 q V_{0}}{m d^{2}} z. +\end{align*} % +% +If we define +\begin{equation*} + \omega_{0} \equiv \frac{q B_{0}}{m}, \quad \omega_{z}^{2} \equiv \frac{2 q V_{0}}{m d^{2}}, +\end{equation*} % +% +the equations of motion can be written as +\begin{align*} + \ddot{x} &= \frac{1}{2} \omega_{z}^{2} x + \omega_{0} \dot{y}, \\ + \ddot{y} &= \frac{1}{2} \omega_{z}^{2} y - \omega_{0} \dot{x}, \\ + \ddot{z} &= -\omega_{z}^{2} z. \\ +\end{align*} % +% +\subsection{General solution}\label{sec:eq_general} +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}}. +\end{align*} % +The characteristic equation has two complex roots +\begin{equation*} + r_{1} = - i \omega_{z}, \quad r_{2} = i \omega_{z}, +\end{equation*} +which give us solutions in the general form +\begin{equation*} + z = c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t}. +\end{equation*} +In addition, 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 the general solution 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}) \\ + & \quad + c_{2} (\cos{\omega_{z} t} - i \sin{\omega_{z} t} \\ + &= E \cos{\omega_{z} t} + i F \sin{\omega_{z} t}. +\end{align*} % +% +\subsection{Complex function}\label{sec:eq_complex} % +In sec. \ref{sec:eq_motion} we found the differential equations for $\ddot{x}$ and $\ddot{y}$. To derive a single differential equation, we introduce the complex function $f(t) = x(t) + iy(t)$, which gives us +\begin{align*} + 0 &= \Big(\ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x \Big) + i \Big(\ddot{y} + \omega_{0} \dot{x} - \frac{1}{2} \omega_{z}^{2} y \Big) \\ + &= \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 \\ + &= \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. \\ +\end{align*} +Using the definition $i = \sqrt{-1}$, we can rewrite +\begin{equation*} + i \omega_{0} \dot{x} + (-1) \omega_{0} \dot{y} = i \omega_{0} \dot{x} + i^{2} \omega_{0} \dot{y}. +\end{equation*} +This gives us a single differential equation +\begin{align*} + 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 \\ + &= \ddot{f} + i \omega_{0} \dot{f} - \frac{1}{2} \omega_{z}^{2} f. +\end{align*} +% +\subsection{Physical coordinates}\label{sec:eq_coord} +We can rewrite eq. \eqref{eq:general_solution}, as +\begin{align*} + f(t) &= A_{+}e^{-i(\omega_{+} t + \phi_{+})} + A_{-}e^{-i(\omega_{-} t + \phi_{-})} \\ + &= A_{+}(\cos{(\omega_{+} t + \phi_{+})} - i \sin{(\omega_{+} t + \phi_{+})}) \\ + % \numberthis \label{eq:general_solution_trig} + & \quad + A_{-}(\cos{(\omega_{-} t + \phi_{-})} - i \sin{(\omega_{-} t + \phi_{-})}). +\end{align*} % +% +\subsection{Upper and lower bounds}\label{sec:upper_lower_bound} +To obtain the upper and lower bounds of the particle's distance from the origin, we first find an expression for the second norm defined as $|f(t)| = \sqrt{(x(t))^{2} + (y(t))^{2}}$. +\begin{align*} + (x(t))^{2} &= \big( A_{+}\cos(\omega_{+} t + \phi_{+}) + A_{-}\cos(\omega_{-} t + \phi_{-}) \big)^{2} \\ + &= A_{+}^{2} \cos^{2}(\omega_{+} t + \phi_{+}) \\ + & \quad + 2 A_{+}A_{-} \cos(\omega_{+} t + \phi_{+})\cos(\omega_{-} t + \phi_{-}) \\ + & \quad + A_{-}^{2}\cos^{2}(\omega_{-} t + \phi_{-}), \\ +\end{align*} % +\begin{align*} + (y(t))^{2} &= \big( - A_{+} \sin(\omega_{+} t + \phi_{+}) - A_{-} \sin(\omega_{-} t + \phi_{-}) \big)^{2} \\ + &= A_{+}^{2} \sin^{2}(\omega_{+} t + \phi_{+}) \\ + & \quad + 2 A_{+}A_{-} \sin(\omega_{+} t + \phi_{+})\sin(\omega_{-} t + \phi_{-}) \\ + & \quad + A_{-}^{2} \sin^{2}(\omega_{-} t + \phi_{-}). +\end{align*} % +We insert these expressions, and find +\begin{align*} + |f(t)| &= \sqrt{(x(t))^{2} + (y(t))^{2}} \\ + &= \sqrt{A_{+}^{2} + 2 A_{+} A_{-} \cos^{2}(\alpha) + A_{-}^{2}}, +\end{align*} % +where $\alpha = (\omega_{+} - \omega_{-}) t +( \phi_{+} - \phi_{-})$. If we set $\alpha = 0$ we get $\cos(0) = 1$, and obtain the upper bound +\begin{align*} + R_{+} &= \sqrt{A_{+}^{2} + 2 A_{+} A_{-} + A_{-}^{2}} \\ + &= \sqrt{(A_{+} + A_{-})^{2}} \\ + &= A_{+} + A_{-}. +\end{align*} +If $\alpha = \pi$ we get $\cos(\pi) = -1$, and find the lower bound +\begin{align*} + R_{-} &= \sqrt{A_{+}^{2} - 2 A_{+} A_{-} + A_{-}^{2}} \\ + &= \sqrt{(A_{+} - A_{-})^{2}} \\ + &= |A_{+} - A_{-}|. +\end{align*} % +% +\subsection{Bounded solution}\label{sec:bounded_solution} +To find a bounded solution, we need to consider the angular rate in eq. \eqref{eq:angular_rate}. Specifically the square-root expression +\begin{align*} + \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}. +\end{align*} +A bounded solution can be found when this expression is greater than zero. Meaning +\begin{align*} + \omega_{0}^{2} &> 2 \omega_{z}^{2}. +\end{align*} % +% +We can now use the definition of $\omega_{0}$ and $\omega_{z}^{2}$ to find an expression related to the Penning trap parameters, and the particle properties, to get +\begin{align*} + \Big( \frac{q B_{0}}{m} \Big)^{2} &> 2 \frac{2 q V_{0}}{m d^{2}} \\ + \frac{q^{2} B_{0}^{2}}{m^{2}} &> \frac{4 q V_{0}}{m d^{2}}. +\end{align*} % + +\section{Values used in simulation} +\subsection{Specific analytical solution}\label{sec:spec_analytical} +To compare our implementation of the Penning trap and particle, we have to specify initial conditions of the system to compare with the analytical solution. The initial conditions of a particle with a single positive charge, can be found in table \ref{tab:initial_particle_cond}. +\begin{table}[H] + \centering + \begin{tabular}[c]{ll} + $\mathbf{r}(0)$ & $\dot{\mathbf{r}}(0)$ \\ + \hline + $x(0)$ = $x_{0}$ & $\dot{x}(0)$ = $0$ \\ + $y(0)$ = $0$ & $\dot{y}(0)$ = $v_{0}$ \\ + $z(0)$ = $z_{0}$ & $\dot{z}(0)$ = $0$ \\ + \hline + \end{tabular} + \caption{Initial values of a particle with a single charge $q$, and mass $m$, confined in a Penning trap.} + \label{tab:initial_particle_cond} +\end{table} + +\begin{table}[H] + \centering + \begin{tabular}[c]{lll} + Property & Value \\ + \hline + $B_{0}$ & $1.00 T$ = $9.65 \cross 10^{1} \frac{u}{(\mu s) e}$ \\ + $V_{0}$ & $25.0 mV$ = $2.41 \cross 10^{6} \frac{u (\mu m)^{2}}{(\mu s)^{2} e}$ \\ + $d$ & $500 \ \mu m$ = \\ + \hline + \end{tabular} + \caption{Default configuration of the Penning trap, where the value of T and V can be found in table \ref{tab:constants}.} + \label{tab:penning_config} +\end{table} + +\begin{table}[H] + \centering + \begin{tabular}[c]{lll} + Property & Value \\ + \hline + $q$ & $1.00 T$ & $9.65 \cross 10^{1} \frac{u}{(\mu s) e}$ \\ + $m$ & $25.0 mV$ & $2.41 \cross 10^{6} \frac{u (\mu m)^{2}}{(\mu s)^{2} e}$ \\ + \hline + \end{tabular} + \caption{Default configuration of the Penning trap, where the value of T and V can be found in table \ref{tab:constants}.} + \label{tab:particle_config} +\end{table} + +\begin{table}[H] + \centering + \begin{tabular}[c]{lll} + $n_{k}$ & Time steps & Step size \\ + \hline + $n_{1}$ & $4000$ & $0.0125$ \\ + $n_{2}$ & $8000$ & $0.00625$ \\ + $n_{3}$ & $16000$ & $0.003125$ \\ + $n_{4}$ & $32000$ & $0.0015625$ \\ + \hline + \end{tabular} + \caption{Number of steps used in a given simulation $k$, where the step size corresponds to $h_{1} = 50 / n_{k} \mu s$.} + \label{tab:time_steps} +\end{table} + +\subsection{Numbers and units}\label{sec:numbers_units} +\begin{table}[H] + \centering + \begin{tabular}[c]{lll} + Constant & Value & Unit \\ + \hline + $k_{e}$ (Coulomb) & $1.38935333 \cross 10^{5}$ & $\frac{u (\mu m)^{3}}{(\mu s)^{2} e^{2}}$ \\ + T (Tesla) & $9.64852558 \cross 10^{1}$ & $\frac{u}{(\mu s) e}$ \\ + V (Volt) & $9.64852558 \cross 10^{7}$ & $\frac{u (\mu m)^{2}}{(\mu s)^{2} e}$ \\ + \hline + \end{tabular} + \caption{Value of the Coulomb constant ($k_{e}$), and the SI units for magnetic field strength ($T$) and electric potential ($V$). The base units are given by length in micrometre ($\mu m$), time in microseconds ($\mu s$), mass in ($u$), and charge in elementary charge ($e$).} + \label{tab:constants} +\end{table} + +\section{Algorithm implementation and testing}\label{sec:algo} +\subsection{Forward Euler}\label{sec:algo_euler} +For a particle $i$, at time step $j$, the forward Euler method for a coupled system can be expressed as +\begin{align*} + \mathbf{r}_{i,j+1} &= \mathbf{r}_{i,j} + h \frac{d \mathbf{r}_{i,j}}{dt} = \mathbf{r}_{i,j} + h \mathbf{v}_{i,j} \\ + \mathbf{v}_{i,j+1} &= \mathbf{v}_{i,j} + h \frac{\mathbf{v}_{i,j}}{dt} = \mathbf{v}_{i,j} + h \frac{\mathbf{F}(t_{j},\mathbf{v}_{i,j}, \mathbf{r}_{i,j} )}{m_{i}}, +\end{align*} +$m_{i}$ is the mass of the particle, and $h$ is the step length. + +\subsection{4th order Runge-Kutta}\label{sec:algo_rk4} +For a particle $i$, at time step $j$, the 4th order Runge-Kutta method for a coupled system can be expressed as +\begin{align*} + \mathbf{v}_{i,j+1} &= \mathbf{v}_{i,j} + \frac{h}{6} (\mathbf{k}_{\mathbf{v},1,i} + 2 \mathbf{k}_{\mathbf{v},2,i} + 2 \mathbf{k}_{\mathbf{v},3,i} + \mathbf{k}_{\mathbf{v},4,i} ), \\ + \mathbf{r}_{i,j+1} &= \mathbf{r}_{i,j} + \frac{h}{6} (\mathbf{k}_{\mathbf{r},1,i} + 2 \mathbf{k}_{\mathbf{r},2,i} + 2\mathbf{k}_{\mathbf{r},3,i} + \mathbf{k}_{\mathbf{r},4,i}), +\end{align*} +where +\begin{align*} + \mathbf{k}_{\mathbf{v},1,i} &= \frac{\mathbf{F}_{i}(t_{j}, \mathbf{v}_{i,j}, \mathbf{r}_{i,j})}{m_{i}}, \\ + \mathbf{k}_{\mathbf{r},1,i} &= \mathbf{v}_{i,j}, \\ + \mathbf{k}_{\mathbf{v},2,i} &= \frac{\mathbf{F}_{i}(t_{j}+\frac{h}{2}, \mathbf{v}_{i,j} + h \frac{\mathbf{k}_{\mathbf{v},1,i}}{2}, \mathbf{r}_{i,j} + h \frac{\mathbf{k}_{\mathbf{r},1,i}}{2})}{m_{i}}, \\ + \mathbf{k}_{\mathbf{r},2,i} &= \mathbf{v}_{i,j} + h \frac{\mathbf{k}_{\mathbf{v},1,i}}{2}, \\ + \mathbf{k}_{\mathbf{v},3,i} &= \frac{\mathbf{F}_{i}(t_{j}+\frac{h}{2}, \mathbf{v}_{i,j} + h \frac{\mathbf{k}_{\mathbf{v},2,i}}{2}, \mathbf{r}_{i,j} + h \frac{\mathbf{k}_{\mathbf{r},2,i}}{2})}{m_{i}}, \\ + \mathbf{k}_{\mathbf{r},3,i} &= \mathbf{v}_{i,j} + h \frac{\mathbf{k}_{\mathbf{v},2,i}}{2}, \\ + \mathbf{k}_{\mathbf{v},4,i} &= \frac{\mathbf{F}_{i}(t_{j}+h, \mathbf{v}_{i,j} + h \mathbf{k}_{\mathbf{v},3,i}, \mathbf{r}_{i,j} + h \mathbf{k}_{\mathbf{r},3,i})}{m_{i}} \\ + \mathbf{k}_{\mathbf{r},4,i} &= \mathbf{v}_{i,j} + h \frac{\mathbf{k}_{\mathbf{v},1,i}}{2}. +\end{align*} +In order to find each $\mathbf{k}_{\mathbf{r},i}$ and $\mathbf{k}_{\mathbf{v},i}$, we need to first compute all $\mathbf{k}_{\mathbf{r},i}$ and $\mathbf{k}_{\mathbf{v},i}$ for all particles, then update the particle values in order to compute $\mathbf{k}_{\mathbf{r},i+1}$ and $\mathbf{k}_{\mathbf{v},i+1}$. + +\subsection{Test of implementation}\label{sec:testing} +We implemented a test suite, to validate the implementation during code development. In addition, we have implemented functionality to get informative output while testing the code. Further instructions with code can be found in the github repo \cite{github:repo}. + +\end{document} \ No newline at end of file diff --git a/latex/appendix/appendix_a.tex b/latex/appendix/appendix_a.tex new file mode 100644 index 0000000..ccc0a85 --- /dev/null +++ b/latex/appendix/appendix_a.tex @@ -0,0 +1,29 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} + +\section{Equations of electrodynamics and classical mechanics}\label{sec:appendix_a} +Newton's second law +\begin{equation}\label{eq:newton_second} + m \ddot{\mathbf{r}} = \sum_{i} \mathbf{F}_{i} +\end{equation}% +% +Lorentz force +\begin{equation}\label{eq:lorentz_force} + \mathbf{F} = q \mathbf{E} + q \mathbf{v} \times \mathbf{B}, +\end{equation}% +% +Electric field +\begin{equation}\label{eq:e_field_potential} + \mathbf{E} = - \nabla V +\end{equation} % +% +Electric field at a point $\mathbf{r}$ +\begin{equation}\label{eq:e_field_point} + \mathbf{E} = k_{e} \sum_{j=1}^{n} q_j \frac{\mathbf{r} - \mathbf{r}_{j}}{|\mathbf{r} - \mathbf{r}_{j}|^{3}} +\end{equation} + + + +\end{document} \ No newline at end of file diff --git a/latex/appendix/appendix_b.tex b/latex/appendix/appendix_b.tex new file mode 100644 index 0000000..772f73e --- /dev/null +++ b/latex/appendix/appendix_b.tex @@ -0,0 +1,145 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} +\section{Derivation of equations}\label{sec:appendix_b} +% Problem 1 +\subsection{Equations of motion}\label{sec:eq_motion} % +First, we need to define the velocity of the particle +\begin{align*} + \mathbf{v} \equiv \frac{d \mathbf{r}}{dt} &= \bigg( \frac{dx}{dt}, \frac{dy}{dt}, \frac{dz}{dt} \bigg). +\end{align*} % +We can rewrite the velocity as $\dot{r} = (\dot{x}, \dot{y}, \dot{z})$, and find the cross product +\begin{align*} + q \mathbf{v} \cross \mathbf{B} &= + q \begin{vmatrix} + \hat{e}_{x} & \hat{e}_{y} & \hat{e}_{z} \\ + \dot{x} & \dot{y} & \dot{z} \\ + 0 & 0 & B_{0} + \end{vmatrix} + = q \big( B_{0} \dot{y}, -B_{0} \dot{x}, 0 \big). +\end{align*} % +We are considering an ideal Penning traps, where we define the electric potential as +\begin{align*} + V(x, y, z) &= \frac{V_{0}}{2 d^{2}}(2z^{2} - x^{2} - y^{2}). +\end{align*} % +The relationship between the electric field $\mathbf{E}$ and the electric potential of the field is given by +\begin{align*} + \mathbf{E} &= - \nabla V \\ + &= - \bigg( \frac{dV}{dx}, \frac{dV}{dy} \frac{dV}{dz} \bigg) \\ + &= \frac{V_{0}}{d^{2}} \big( x, y, -2z \big). +\end{align*} % +We can now express the Lorentz force as +\begin{align*} + \mathbf{F} &= q \mathbf{E} + q \mathbf{v} \cross \mathbf{B} \\ + &= \frac{q V_{0}}{d^{2}} \big( x, y, -2z \big) + \big(q B_{0} \dot{y}, -q B_{0} \dot{x}, 0 \big), +\end{align*} % +and insert it into Newtons equation \eqref{eq:newton_second}. We get +\begin{align*} + \ddot{\mathbf{r}} &= \bigg( \frac{q V_{0}}{m d^{2}} x, \frac{q V_{0}}{m d^{2}} y, -\frac{2 q V_{0}}{m d^{2}} z \bigg) + \bigg(\frac{q B_{0}}{m} \dot{y}, -\frac{q B_{0}}{m} \dot{x}, 0 \bigg), +\end{align*} % +which can be written as +\begin{align*} + \ddot{x} &= \frac{q V_{0}}{m d^{2}} x + \frac{q B_{0}}{m} \dot{y}, \\ + \ddot{y} &= \frac{q V_{0}}{m d^{2}} y - \frac{q B_{0}}{m} \dot{x}, \\ + \ddot{z} &= -\frac{2 q V_{0}}{m d^{2}} z. +\end{align*} +If we define +\begin{equation*} + \omega_{0} \equiv \frac{q B_{0}}{m}, \quad \omega_{z}^{2} \equiv \frac{2 q V_{0}}{m d^{2}}, +\end{equation*} +the equations of motion can be written as +\begin{align*} + \ddot{x} &= \frac{1}{2} \omega_{z}^{2} x + \omega_{0} \dot{y}, \\ + \ddot{y} &= \frac{1}{2} \omega_{z}^{2} y - \omega_{0} \dot{x}, \\ + \ddot{z} &= -\omega_{z}^{2} z. \\ +\end{align*} + +\subsection{General solution}\label{sec:eq_general} +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}}. +\end{align*} % +The characteristic equation has two complex roots +\begin{equation*} + r_{1} = - i \omega_{z}, \quad r_{2} = i \omega_{z}, +\end{equation*} +which give us solutions in the general form +\begin{equation*} + z = c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t}. +\end{equation*} +In addition, 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 the general solution 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}) \\ + & \quad + c_{2} (\cos{\omega_{z} t} - i \sin{\omega_{z} t} \\ + &= E \cos{\omega_{z} t} + i F \sin{\omega_{z} t}. +\end{align*} % +% +\subsection{Complex function}\label{sec:eq_complex} % +In sec. \ref{sec:eq_motion} we found the differential equations for $\ddot{x}$ and $\ddot{y}$. To derive a single differential equation, we introduce the complex function $f(t) = x(t) + iy(t)$, which gives us +\begin{align*} + 0 &= \Big(\ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x \Big) + i \Big(\ddot{y} + \omega_{0} \dot{x} - \frac{1}{2} \omega_{z}^{2} y \Big) \\ + &= \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 \\ + &= \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. \\ +\end{align*} +Using the definition $i = \sqrt{-1}$, we can rewrite +\begin{equation*} + i \omega_{0} \dot{x} + (-1) \omega_{0} \dot{y} = i \omega_{0} \dot{x} + i^{2} \omega_{0} \dot{y}. +\end{equation*} +This gives us a single differential equation +\begin{align*} + 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 \\ + &= \ddot{f} + i \omega_{0} \dot{f} - \frac{1}{2} \omega_{z}^{2} f. +\end{align*} +% +\subsection{Physical coordinates}\label{sec:eq_coord} +We can rewrite eq. \eqref{eq:general_solution}, as +\begin{align*} + f(t) &= A_{+}e^{-i(\omega_{+} t + \phi_{+})} + A_{-}e^{-i(\omega_{-} t + \phi_{-})} \\ + &= A_{+}(\cos{(\omega_{+} t + \phi_{+})} - i \sin{(\omega_{+} t + \phi_{+})}) \\ + % \numberthis \label{eq:general_solution_trig} + & \quad + A_{-}(\cos{(\omega_{-} t + \phi_{-})} - i \sin{(\omega_{-} t + \phi_{-})}). +\end{align*} % +% +\subsection{Upper and lower bounds}\label{sec:upper_lower_bound} +To obtain the upper and lower bounds of the particle's distance from the origin, we first find an expression for the second norm (?) defined as $|f(t)| = \sqrt{(x(t))^{2} + (y(t))^{2}}$. +\begin{align*} + (x(t))^{2} &= \big( A_{+}\cos(\omega_{+} t + \phi_{+}) + A_{-}\cos(\omega_{-} t + \phi_{-}) \big)^{2} \\ + &= A_{+}^{2} \cos^{2}(\omega_{+} t + \phi_{+}) \\ + & \quad + 2 A_{+}A_{-} \cos(\omega_{+} t + \phi_{+})\cos(\omega_{-} t + \phi_{-}) \\ + & \quad + A_{-}^{2}\cos^{2}(\omega_{-} t + \phi_{-}), \\ +\end{align*} % +\begin{align*} + (y(t))^{2} &= \big( - A_{+} \sin(\omega_{+} t + \phi_{+}) - A_{-} \sin(\omega_{-} t + \phi_{-}) \big)^{2} \\ + &= A_{+}^{2} \sin^{2}(\omega_{+} t + \phi_{+}) \\ + & \quad + 2 A_{+}A_{-} \sin(\omega_{+} t + \phi_{+})\sin(\omega_{-} t + \phi_{-}) \\ + & \quad + A_{-}^{2} \sin^{2}(\omega_{-} t + \phi_{-}). +\end{align*} % +We insert these expressions, and find +\begin{align*} + |f(t)| &= \sqrt{(x(t))^{2} + (y(t))^{2}} \\ + &= \sqrt{A_{+}^{2} + 2 A_{+} A_{-} \cos^{2}(\alpha) + A_{-}^{2}}, +\end{align*} % +where $\alpha = (\omega_{+} - \omega_{-}) t +( \phi_{+} - \phi_{-})$. If we set $\alpha = 0$ we get $\cos(0) = 1$, and obtain the upper bound +\begin{align*} + R_{+} &= \sqrt{A_{+}^{2} + 2 A_{+} A_{-} + A_{-}^{2}} \\ + &= \sqrt{(A_{+} + A_{-})^{2}} \\ + &= A_{+} + A_{-}. +\end{align*} +If $\alpha = \pi$ we get $\cos(\pi) = -1$, and find the lower bound +\begin{align*} + R_{-} &= \sqrt{A_{+}^{2} - 2 A_{+} A_{-} + A_{-}^{2}} \\ + &= \sqrt{(A_{+} - A_{-})^{2}} \\ + &= |A_{+} - A_{-}|. +\end{align*} % +% +\subsection{Bounded solution}\label{sec:bounded_solution} + + +\end{document} + +% \begin{align*} +% \omega_{+} - \omega_{-} &= \frac{\omega_{0} + \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}}{2} - \frac{\omega_{0} - \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}}{2} \\ +% &= +% \end{align*} \ No newline at end of file diff --git a/latex/appendix/appendix_c.tex b/latex/appendix/appendix_c.tex new file mode 100644 index 0000000..0a3edd7 --- /dev/null +++ b/latex/appendix/appendix_c.tex @@ -0,0 +1,21 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} + +\section{Numbers and units}\label{sec:appendix_c} +\begin{table}[H] + \centering + \begin{tabular}[c]{lll} + Constant & Value & Unit \\ + \hline + $k_{e}$ (Coulomb) & $1.38935333 \cross 10^{5}$ & $\frac{u (\mu m)^{3}}{(\mu s)^{2} e^{2}}$ \\ + T (Tesla) & $9.64852558 \cross 10^{1}$ & $\frac{u}{(\mu s) e}$ \\ + V (Volt) & $9.64852558 \cross 10^{7}$ & $\frac{u (\mu m)^{2}}{(\mu s)^{2} e}$ \\ + \hline + \end{tabular} + \caption{Value of the Coulomb constant ($k_{e}$), and the SI units for magnetic field strength ($T$) and electric potential ($V$). The base units are given by length in micrometre ($\mu m$), time in microseconds ($\mu s$), mass in ($u$), and charge in elementary charge ($e$).} + \label{tab:constants} +\end{table} + +\end{document} \ No newline at end of file diff --git a/latex/images/3d_plot.pdf b/latex/images/3d_plot.pdf new file mode 100644 index 0000000..e7f0a14 Binary files /dev/null and b/latex/images/3d_plot.pdf differ diff --git a/latex/images/particles_left_narrow_sweep.pdf b/latex/images/particles_left_narrow_sweep.pdf new file mode 100644 index 0000000..d5c2bbc Binary files /dev/null and b/latex/images/particles_left_narrow_sweep.pdf differ diff --git a/latex/images/particles_left_narrow_sweep_fine.pdf b/latex/images/particles_left_narrow_sweep_fine.pdf new file mode 100644 index 0000000..31da0eb Binary files /dev/null and b/latex/images/particles_left_narrow_sweep_fine.pdf differ diff --git a/latex/images/particles_left_narrow_sweep_interactions.pdf b/latex/images/particles_left_narrow_sweep_interactions.pdf new file mode 100644 index 0000000..f68274c Binary files /dev/null and b/latex/images/particles_left_narrow_sweep_interactions.pdf differ diff --git a/latex/images/particles_left_narrow_sweep_interactions_fine.pdf b/latex/images/particles_left_narrow_sweep_interactions_fine.pdf new file mode 100644 index 0000000..40d09e3 Binary files /dev/null and b/latex/images/particles_left_narrow_sweep_interactions_fine.pdf differ diff --git a/latex/images/particles_left_wide_sweep.pdf b/latex/images/particles_left_wide_sweep.pdf new file mode 100644 index 0000000..c757fc8 Binary files /dev/null and b/latex/images/particles_left_wide_sweep.pdf differ diff --git a/latex/images/penning_trap.pdf b/latex/images/penning_trap.pdf new file mode 100644 index 0000000..f6bd81b Binary files /dev/null and b/latex/images/penning_trap.pdf differ diff --git a/latex/images/phase_space_interaction_x.pdf b/latex/images/phase_space_interaction_x.pdf new file mode 100644 index 0000000..0cd0d92 Binary files /dev/null and b/latex/images/phase_space_interaction_x.pdf differ diff --git a/latex/images/phase_space_interaction_z.pdf b/latex/images/phase_space_interaction_z.pdf new file mode 100644 index 0000000..6628c96 Binary files /dev/null and b/latex/images/phase_space_interaction_z.pdf differ diff --git a/latex/images/phase_space_no_interaction_x.pdf b/latex/images/phase_space_no_interaction_x.pdf new file mode 100644 index 0000000..69906d5 Binary files /dev/null and b/latex/images/phase_space_no_interaction_x.pdf differ diff --git a/latex/images/phase_space_no_interaction_z.pdf b/latex/images/phase_space_no_interaction_z.pdf new file mode 100644 index 0000000..8a03d23 Binary files /dev/null and b/latex/images/phase_space_no_interaction_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..d705eef Binary files /dev/null and b/latex/images/plot_2_particles_xy.pdf differ diff --git a/latex/images/relative_error.pdf b/latex/images/relative_error.pdf new file mode 100644 index 0000000..fa2a357 Binary files /dev/null and b/latex/images/relative_error.pdf differ diff --git a/latex/images/simulate_2_particles_interaction_xy.pdf b/latex/images/simulate_2_particles_interaction_xy.pdf new file mode 100644 index 0000000..2a6474a Binary files /dev/null and b/latex/images/simulate_2_particles_interaction_xy.pdf differ diff --git a/latex/images/simulate_2_particles_no_interaction_xy.pdf b/latex/images/simulate_2_particles_no_interaction_xy.pdf new file mode 100644 index 0000000..bb23a19 Binary files /dev/null and b/latex/images/simulate_2_particles_no_interaction_xy.pdf differ diff --git a/latex/images/single_particle.pdf b/latex/images/single_particle.pdf new file mode 100644 index 0000000..4cf3a86 Binary files /dev/null and b/latex/images/single_particle.pdf differ diff --git a/latex/main.pdf b/latex/main.pdf new file mode 100644 index 0000000..962bca8 Binary files /dev/null and b/latex/main.pdf differ diff --git a/latex/main.tex b/latex/main.tex new file mode 100644 index 0000000..f73c54a --- /dev/null +++ b/latex/main.tex @@ -0,0 +1,90 @@ +\documentclass[english,notitlepage,reprint,nofootinbib]{revtex4-1} % defines the basic parameters of the document +% +% For preview: skriv i terminal: latexmk -pdf -pvc filnavn +% If you want a single-column, remove "reprint" + +% Silence warning of revtex4-1 +\usepackage{silence} +\WarningFilter{revtex4-1}{Repair the float} + +% Allows special characters (including æøå) +\usepackage[utf8]{inputenc} +\usepackage{fontawesome} +% \usepackage{tabularx} +% \usepackage[english]{babel} + +%% Note that you may need to download some of these packages manually, it depends on your setup. +%% I recommend downloading TeXMaker, because it includes a large library of the most common packages. + +\usepackage{physics,amssymb} % mathematical symbols (physics imports amsmath) + +\usepackage{graphicx} % include graphics such as plots +\graphicspath{{images/}} +\usepackage{xcolor} % set colors +\usepackage{hyperref} % automagic cross-referencing +\usepackage{listings} % display code +\usepackage{subfigure} % imports a lot of cool and useful figure commands +% \usepackage{float} +%\usepackage[section]{placeins} +\usepackage{algorithm} +\usepackage[noend]{algpseudocode} +\usepackage{subfigure} +\usepackage{tikz} +\usetikzlibrary{quantikz2} +% defines the color of hyperref objects +% Blending two colors: blue!80!black = 80% blue and 20% black +\hypersetup{ % this is just my personal choice, feel free to change things + colorlinks, + linkcolor={red!50!black}, + citecolor={blue!50!black}, + urlcolor={blue!80!black}} + +% Biblio stuff +% \def\biblio{\bibliographystyle{plain}\bibliography{../references/references}} +\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}} + +\usepackage{xr} +\usepackage{subfiles} +% \externaldocument[M-]{\subfix{main}} + +\begin{document} + +\title{Simulating Particles in an Ideal Penning Trap} +\author{Cory Alexander Balaton \& Janita Ovidie Sandtrøen Willumsen \\ \faGithub \, \url{https://github.uio.no/FYS3150-G2-2023/Project-3}} % self-explanatory +\date{\today} % self-explanatory +\noaffiliation % ignore this, but keep it. + +% Abstract +\subfile{sections/abstract} + + +\maketitle + + +% Introduction +\subfile{sections/introduction} + +% Methods +\subfile{sections/methods} + +% Results +\subfile{sections/results} + +% Conclusion +\subfile{sections/conclusion} + +\newpage + +\appendix +\subfile{appendix} +% \subfile{appendix/appendix_b} +% \subfile{appendix/appendix_c} +% \subfile{appendix/appendix_d} + +\onecolumngrid + +\bibliographystyle{unsrt} +\bibliography{references/references} + + +\end{document} diff --git a/latex/references/references.bib b/latex/references/references.bib new file mode 100644 index 0000000..b461fd7 --- /dev/null +++ b/latex/references/references.bib @@ -0,0 +1,128 @@ +@book{vogel:2018, + author = {Manuel Vogel}, + title = {Particle Confinement in Penning Traps}, + subtitle = {An Introduction}, + publisher = {Springer Cham}, + year = {2018}, + edition = {1}, + abstract = {An introduction to the field of Penning traps and related experimental techniques. The book is motivated by the observation that often a vast number of different resources have to be explored to gain a good overview of Penning trap principles. This is especially true for students who experience additional difficulty due to the different styles of presentation and notation.} +} + +@inbook{vogel:2018:ch5, + author = {Manuel Vogel}, + title = {Particle Confinement in Penning Traps}, + subtitle = {An Introduction}, + publisher = {Springer Cham}, + year = {2018}, + edition = {1}, + pages = {45--50} +} + +@inbook{vogel:2018:ch1, + author = {Manuel Vogel}, + title = {Particle Confinement in Penning Traps}, + subtitle = {An Introduction}, + publisher = {Springer Cham}, + year = {2018}, + edition ={1--6} +} + +@article{hunter:2007:matplotlib, + author = {Hunter, J. D.}, + title = {Matplotlib: A 2D graphics environment}, + journal = {Computing in Science \& Engineering}, + volume = {9}, + number = {3}, + pages = {90--95}, + abstract = {Matplotlib is a 2D graphics package used for Python for + application development, interactive scripting, and publication-quality + image generation across user interfaces and operating systems.}, + publisher = {IEEE COMPUTER SOC}, + doi = {10.1109/MCSE.2007.55}, + year = 2007 +} + +@inbook{lindstrom:2016:ch3, + author = {Tom Lindstrøm}, + title = {Kalkulus}, + publisher = {Universitetsforlaget}, + year = {2016}, + edition = {4}, + pages = {133--137} +} + +@inbook{lindstrom:2016:ch10:5, + author = {Tom Lindstrøm}, + title = {Kalkulus}, + publisher = {Universitetsforlaget}, + year = {2016}, + edition = {4}, + pages = {589--606} +} + +@online{britannica:2023:matter, + author = {The Editors of Encyclopaedia Britannica}, + title = {matter}, + year = {2023}, + url = {https://www.britannica.com/science/matter}, + urldate = {2023-10-17} +} + +@inbook{gjevik:2014:appendix, + author = {Bjørn Gjevik and Morten Wang Fagerland}, + title = {Feltteori og vektoranalyse}, + publisher = {Farleia Forlag}, + year = {2018}, + pages = {162--163} +} + +@article{waskom:2021:seaborn, + author = {Michael L. Waskom}, + title = {seaborn: statistical data visualization}, + journal = {Journal of Open Source Software}, + volume = {6}, + number = {60}, + publisher = {The Open Journal}, + year = {2021}, + doi = {10.21105/joss.03021}, + url = {https://doi.org/10.21105/joss.03021}, + pages = {3021} + } + +@online{openmp:2018, + author = {OpenMP}, + title = {OpenMP Application Programming Interface}, + year = {2018}, + url = {https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf}, + urldate = {2023-10-22} +} + +@online{penning:fig, + author = {Ludwig-Maximilians-Universität München}, + title = {Penning traps}, + url = {https://www.med.physik.uni-muenchen.de/research/nuclear-science/nuclear-masses/mlltrap/layout/traps/index.html}, + urldate = {2023-10-23}, + note = {Configuration of a Penning trap, figure a} +} + +@online{github:repo, + author = {Cory Alexander Balaton and Janita Ovidie Sandtrøen Willumsen}, + url = {https://github.uio.no/FYS3150-G2-2023/Project-3}, + urldate = {2023-10-24}, + note = {FYS3150 Project 3 repo} +} + +@online{scalasca, + author = {M. Geimer and F. Wolf and B.J.N. Wylie and E. Abraham and D. Becker and B. Mohr}, + title = {Scalasca}, + url = {https://www.scalasca.org/scalasca/about/about.html}, + urldate = {2023-10-24}, + note = {Tool to support performance optimization of parallel programs, measuring and analyzing runtime behavior.} +} + +@online{scorep, + title = {Score-P: the Scalable Performance Measurement Infrastructure for Parallel Codes}, + url = {https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/latest/html/}, + urldate = {2023-10-24}, + note = {Tool suite for profiling and event tracing.} +} diff --git a/latex/sections/abstract.tex b/latex/sections/abstract.tex new file mode 100644 index 0000000..cbd63f7 --- /dev/null +++ b/latex/sections/abstract.tex @@ -0,0 +1,10 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} + +\begin{abstract} + We have studied the behavior of singly-charged Calcium ions ($\text{Ca}^{+}$), inside an ideal Penning trap. With a numerical approach, we studied the equations of motion by implementing the forward Euler method \(FE\) and the 4th order Runge-Kutta \(RK4\). We found that RK4 approximates the solution with smaller relative error than the relative error of FE. In addition, we evaluated the methods by their rate of convergence. We found that RK4 has a higher convergence rate at approx. $4.0$, compared to FE at approx. $1.4$. For particles interacting we explored angular frequencies, and amplitudes, of the time-dependent potential applied to the particles. We found that angular frequency in the range $\omega_{V} \in (1.3, 1.4)$ MHz is effective in pushing out particles, even for amplitude $f = 0.1$. +\end{abstract} + +\end{document} \ No newline at end of file diff --git a/latex/sections/conclusion.tex b/latex/sections/conclusion.tex new file mode 100644 index 0000000..9469d4c --- /dev/null +++ b/latex/sections/conclusion.tex @@ -0,0 +1,11 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} +\section{Conclusion} +We studied the movement of particles confined by an ideal Penning trap, where we used iterative methods to simulate the particle behavior. We included the magnetic and electric field of the Penning trap, in addition to simulating the particles behavior when interaction with other each other. When we introduced the interaction, the movement in both radial direction and z-direction changed. From a circular path, to a more elliptical path, where the particles initial condition determine how it is affecting other particles path. + +We also compared iterative methods, with the analytical solution, and found that the forward Euler \(FE\) method result in an approximation with a large relative error compared to the relative error of the 4th order Runge-kutta \(RK4\) method. In addition, we also found that RK4 has a higher convergence rate at approx. $4.0$, compared to FE at approx. $1.4$. Which suggest RK4 reach the solution faster than what FE, however, when we increase the number of time steps both methods result in similar relative error. When the number of calculations increase, and the number of time steps is sufficient, FE can be the better choise to conserve computational resources. + +When we explored the particles behavior at angular frequencies $\omega_{V} \in (0.2, 2.5)$ MHz, we found that particles are pushed out of the Penning trap when the amplitude of the applied time-dependent potential increase. The amplitude $f = 0.7$ result in particles being pushed out at most of the range of angular frequencies, whereas an amplitude $f = 0.1$ result in particles being pushed in a more narrow range. Since particles are being pushed out when the amplitude is low, there is likely a resonance frequency at around $1.4$ MHz. +\end{document} \ No newline at end of file diff --git a/latex/sections/introduction.tex b/latex/sections/introduction.tex new file mode 100644 index 0000000..5a3cbfc --- /dev/null +++ b/latex/sections/introduction.tex @@ -0,0 +1,15 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} +% +\section{Introduction} +We are surrounded by matter, which are made up of elementary particles. In the field of physics we want to understand the properties of these particles, and measure their physical quantities. We want to describe the particles such that we can explain the origin of mass \cite{britannica:2023:matter}. + +However, to study a particle, it is necessary isolate and contain it over time. The Penning trap is a device, able to confine charged particles for a period of time. This concept was evolved from F. M. Penning's implementation of magnetic fields to a vaccuum gauge, and J. R. Pierce's work with electron beams, and put into practice by Hans Dehmelt. In 1973 Dehmelt and his group of researchers were able to confine a particle and store it over several months \cite{vogel:2018:ch1}. + +In practice, a Penning trap is not easy to obtain, and an experiment would be both time consuming and expensive. A numerical approach, allow us to study the effects of the Penning trap on a charged particle, without the equipment and material cost. With ordinary differential equations (ODE) we can model the movement of particles, confined within a Penning trap. + +We will study an ideal Penning trap, where an electrostatic field confines the particle in z-direction, and a magnetic field confines it in the radial direction. We will use numerical methods to model a single particle, and study the particle motion in radial direction. In addition, we will model a system of particles, and study their motion both with and without particle interaction. +% +\end{document} \ No newline at end of file diff --git a/latex/sections/methods.tex b/latex/sections/methods.tex new file mode 100644 index 0000000..1027824 --- /dev/null +++ b/latex/sections/methods.tex @@ -0,0 +1,257 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} +\section{Methods}\label{sec:methods} +\subsection{Theoretical background}\label{sec:theoretical_background} +In this experiment we study a particle with a charge $q$. To do so, we need to consider the forces acting on that particle. These forces are given by the Penning trap's electric field and magnetic field, an illustration can be found in fig. \ref{fig:penning_trap}. +\begin{figure} + \centering + \includegraphics[width=0.6\linewidth]{images/penning_trap.pdf} + \caption{The basic configuration of a hyperbolic Penning trap \cite{penning:fig}. Electric potential $V_{0}$ is applied to the electrodes in end caps (top and bottom), and in the ring (middle). The magnetic field is denoted as $\mathbf{B}$, the distance from the center to the end caps are denoted as $z_{0}$, and the radial distance as $r_{0}$.} + \label{fig:penning_trap} +\end{figure} +The electric field $\mathbf{E}$ in our model is related to the electric potential $V$ through +\begin{equation}\label{eq:electric_field_potential} + \mathbf{E} = - \nabla V, +\end{equation} % +% +where we define the electric potential as +\begin{equation}\label{eq:electric_potential} + V(x, y, z) = \frac{V_{0}}{2 d^{2}} (2z^{2} - x^{2} - y^{2}). +\end{equation} % +% +The characteristic dimension $d = \sqrt{z_{0}^{2} + r_{0}^{2} / 2}$ determine the scale of the region between the electrodes. The magnetic field is homogeneous and defined as +\begin{equation}\label{eq:magnetic_field} + \mathbf{B} = B_{0} \hat{e}_{z} = (0, 0, B), +\end{equation} % +% +where $B_{0} > 0$ determines the strength of the field. The electric potential $V_{0}$ is applied to the electrodes, where the end caps are positively charged and the ring is negatively charged. The particle is confined by the electric field in the z-direction, however, it is not confined in the radial direction (xy-plane). The magnetic field is necessary to ensure the particle is fully confined in the Penning trap, and will force the particle to move in a circular orbit. + +First, we consider Newton's second law \eqref{eq:newton_second}, to determine the position of the particle. +\begin{equation}\label{eq:newton_second} + m \ddot{\mathbf{r}} = \sum_{i} \mathbf{F}_{i} +\end{equation} % +% +In addition, we introduce the Lorentz force \eqref{eq:lorentz_force}, which describes the force acting on the particle. +\begin{equation}\label{eq:lorentz_force} + \mathbf{F} = q \mathbf{E} + q \mathbf{v} \times \mathbf{B}, +\end{equation} % +% +where $\ddot{\mathbf{r}} = d^{2} \mathbf{r} / dt^{2}$. We combine eq. \eqref{eq:newton_second} and eq. \eqref{eq:lorentz_force} in +\begin{equation}\label{eq:newton_lorentz} + m \ddot{\mathbf{r}} = (q \mathbf{E} + q \mathbf{v} \times \mathbf{B}), +\end{equation} % +% +and derive the differential equations in appendix \ref{sec:eq_motion}. We can rewrite and simplify these equations 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} % +% +where +\begin{equation*} + \omega_{0} \equiv \frac{q B_{0}}{m}, \quad \omega_{z}^{2} \equiv \frac{2 q V_{0}}{m d^{2}}. +\end{equation*} % +% +We find the general solution for eq. \eqref{eq:motion_z} +\begin{equation}\label{eq:eq_general} + z(t) = c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t}, +\end{equation} % +derived in appendix \ref{sec:eq_general}. Continuing, we will use a Calcium ion with a single positive charge. That is, we assume the charge of the particle is $q > 0$. + +Since eq. \eqref{eq:motion_x} and eq. \eqref{eq:motion_y} are coupled, we want to rewrite them as a single differential equation. We derive this in appendix \ref{sec:eq_complex}, and the resulting equation is given by +\begin{equation}\label{eq:single_differential} + \ddot{f} + i \omega_{0} \dot{f} - \frac{1}{2} \omega_{z}^{2} f = 0. +\end{equation} % +% +Eq. \eqref{eq:single_differential} has a general solution given by +\begin{equation}\label{eq:general_solution} + f(t) = A_{+}e^{-i(\omega_{+} t + \phi_{+})} + A_{-}e^{-i(\omega_{-} t + \phi_{-})}. +\end{equation} % +% +The amplitude $A_{+}$ and $A_{-}$ are positive, the phases $\phi_{+}$ and $\phi_{-}$ are constant, and the angular rate is given by +\begin{equation}\label{eq:angular_rate} + \omega_{\pm} = \frac{\omega_{0} \pm \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}}{2}. +\end{equation} +We find the physical coordinates at a given time $t$ using +\begin{equation*} + x(t) = \text{Re}f(t), \quad y(t) = \text{Im}f(t), +\end{equation*} % +and eq. \eqref{eq:general_solution}. We can rearrange the right hand side of the expression derived in \ref{sec:eq_coord}, to find the physical coordinates +\begin{align}\label{eq:physical_coord} + x(t) &= A_{+} \cos(\omega_{+} t + \phi_{+}) + A_{-} \cos(\omega_{-} t + \phi_{-}) \\ + y(t) &= - A_{+} \sin(\omega_{+} t + \phi_{+}) - A_{-} \sin(\omega_{-} t + \phi_{-}) +\end{align} % +% Problem 4 +However, to obtain a bound on the particle's movement in the radial direction, we have to ensure that +\begin{align*} + |f(t)| &= \sqrt{(x(t))^{2} + (y(t))^{2}}. \\ +\end{align*} % +Which means we have to put constraint on the values of $\omega_{0}$ and $\omega_{z}^{2}$ in order to find a bounded solution $|f(t)| < \infty$. We derive an expression for this in appendix \ref{sec:bounded_solution}. Since we have assumed the particle charge $q > 0$, and the mass $m > 0$, the constraints are +\begin{equation} + \frac{q}{m} > \frac{4 V_{0}}{d^{2} B_{0}^{2}}. +\end{equation} % +% +When $t \rightarrow \infty$, the upper and lower limits are +\begin{align} + \label{eq:upper_b} + R_{+} &= A_{+} + A_{-}, \\ + \label{eq:lower_b} + R_{-} &= |A_{+} - A_{-}|, +\end{align} +which we derive in appendix \ref{sec:upper_lower_bound}. + +In this experiment, we will use the initial conditions for the particle given in table \ref{tab:initial_particle_cond}. From eq. \eqref{eq:motion_z} and the initial conditions, we find the specific solution +\begin{equation*} + z(t) = z_{0} \cos (\omega_{z} t) +\end{equation*} +For the particle movement in the radial direction, we find the specific solution using eq. \eqref{eq:general_solution} with +\begin{align*} + A_{+} &= \frac{v_{0} + \omega_{-} x{0}}{\omega_{-} - \omega_{+}}, & A_{-} &= - \frac{v_{0} + \omega_{+} x{0}}{\omega_{-} - \omega_{+}}, \\ + \phi_{+} &= 0, & \phi_{-} &= 0. +\end{align*} + +We will also consider the numerical simulation of multiple particles, confined in a Penning trap. The particles will experience a repelling force from each other, giving the electric field +\begin{equation}\label{eq:electric_field_interaction} + \mathbf{E} = k_{e} \sum_{j = 1}^{n} q_j \frac{\mathbf{r} - \mathbf{r}_{j}}{|\mathbf{r}_{i} - \mathbf{r}_{j}|^{3}}. +\end{equation} % +The Coulomb constant $k_{e}$ value can be found in table \ref{tab:constants}. + +For multiple particles we have to modify the equations of motion, by adding a term for the force a given particle experience at a given point. When we scale eq. \eqref{eq:electric_field_interaction} by charge and mass, we get a new set of equations of motion +\begin{align} + \label{eq:coulomb_motion_x} + \ddot{x}_{i} - \omega_{0,i} \dot{y}_{i} - \frac{1}{2} \omega_{z,i}^{2} x_{i} - k_{e} \frac{q_{i}}{m_{i}}\sum_{j \neq i} q_j \frac{x_{i} - x_{j}}{|\mathbf{r}_{i} - \mathbf{r}_{j}|^{3}} &= 0, \\ + \label{eq:coulomb_motion_y} + \ddot{y}_{i} - \omega_{0,i} \dot{x}_{i} - \frac{1}{2} \omega_{z,i}^{2} y_{i} - k_{e} \frac{q_{i}}{m_{i}}\sum_{j \neq i} q_j \frac{y_{i} - y_{j}}{|\mathbf{r}_{i} - \mathbf{r}_{j}|^{3}} &= 0, \\ + \label{eq:coulomb_motion_z} + \ddot{z}_{i} + \omega_{z,i}^{2} z_{i} - k_{e} \frac{q_{i}}{m_{i}}\sum_{j \neq i} q_j \frac{z_{i} - z_{j}}{|\mathbf{r}_{i} - \mathbf{r}_{j}|^{3}} &= 0, +\end{align} % +where $i$ and $j$ denote the particle indices. When we include a time-dependence to the applied potential we make a replacement of the initial electric potential +\begin{equation}\label{eq:pertubation} + V_{0} \rightarrow V_{0} (1 + f \cos (\omega_{V} t)), +\end{equation} +where $f$ denotes the amplitude and $\omega_{V}$ the angular rate. + +\subsection{Algorithms and implementation}\label{sec:algo_implementation} +When we consider a multi-particle system, we adapt the notation in our derived equations. The force acting on a particle in the Penning trap, which experience particle interaction, can be written as +\begin{equation}\label{eq:lorentz_force_interaction} + \mathbf{F}_{i}(t, \mathbf{v}_{i}, \mathbf{r}_{i}) = q_{i} \mathbf{E}(t, \mathbf{r}_{i}) + q_{i} \mathbf{v}_{i} \cross \mathbf{B} - \mathbf{E}_{p}(t, \mathbf{r}_{i}), +\end{equation} +where $i$ and $j$ still denotes the particle indices, and $\mathbf{E}_{p}$ denotes the force exerted on particle $i$ by particle $j$. +\begin{equation}\label{eq:electric_force_interaction} + \mathbf{E}_{p}(t, \mathbf{r}_{i}) = k_{e} q_{i} \sum_{j \neq i} + q_{j} \frac{\mathbf{r}_{i} - \mathbf{r}_{j}}{| \mathbf{r}_{i} - \mathbf{r}_{j} |^{3}}. +\end{equation} % +In addition, we adapt the notation of \eqref{eq:newton_second}, and define the first derivative of the particle position as +\begin{align} + \label{eq:r_derivative} + \frac{d \mathbf{r}_{i}}{dt} = \dot{\mathbf{r}}_{i} &= \mathbf{v}_{i}, \\ + \label{eq:v_derivative} + \frac{d \mathbf{v}_{i}}{dt} = \dot{\mathbf{v}}_{i} &= \frac{\mathbf{F}_{i} (t, \mathbf{v}_{i}, \mathbf{r}_{i}}{m_{i}}, +\end{align} + +We first implemented the forward Euler method, using the expression for a coupled system given in appendix \ref{sec:algo_euler}. We define the forward Euler algorithm in \ref{algo:forward_euler}. +\begin{figure}[H] + \begin{algorithm}[H] + \caption{Forward Euler method} + \label{algo:forward_euler} + \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} + +We also implemented the 4th order Runge-Kutta (RK4) method, using the expression given in appendix \ref{sec:algo_rk4}. We define the RK4 algorithm in \ref{algo:rk4}. $\mathbf{F}$ does not take any arguments, however, the total force acting on the particle is calculated using the value of position and velocity within $particles$. +\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} + 2 \vb{k}_{\vb{r},2,i} + + 2 \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} + 2 \vb{k}_{\vb{v},2,i} + + 2 \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} +\end{figure} +For a system of particles, the positional value of one particle affects the rest of the particles. We calculated the next step for all particles, updated their values in a copy, and updated the positional value based on the original values. We simulated the movement of particles confined in a Penning trap. All simulations used the initial conditions for particle 1 and 2 given in table \ref{tab:initial_particle_cond}. + +\subsection{Testing and error analysis} +We implemented a test suite to validate our results, details can be found in appendix \ref{sec:testing}. To analyze our results, we compared the relative error of the analytical solution with the result from the implemented forward Euler method and RK4 method. We simulated four times using time steps given in table \ref{tab:time_steps}, and estimated the error convergence rate $r_{\text{err}}$ for both methods using +\begin{equation} + r_{\text{err}} = \frac{1}{3} \sum_{k=2}^{4} \frac{\log(\Delta_{\text{max},k} / \Delta_{\text{max}, k-1})}{\log(h_{k} / h_{k-1})}. +\end{equation} +The maximum error of a simulation $k$ with a step size $h_{k}$ is given by +\begin{equation*} + \Delta_{\text{max},k} = \max_{i} |\mathbf{r}_{i, \text{exact}} - \mathbf{r}_{i}|, +\end{equation*} +where $\mathbf{r}_{i, \text{exact}}$ is the analytical solution, and $\mathbf{r}_{i}$ is the computed result. + +\subsection{Tools} +The numerical methods are implemented in C++, and parallelized using \verb|OpenMP| \cite{openmp:2018}. In addition, we used the profiler \verb|Scalasca| \cite{scalasca} and \verb|Score-P| \cite{scorep} event tracking, during development. We used the Python library \verb|matplotlib| \cite{hunter:2007:matplotlib} to produce all the plots, and \verb|seaborn| \cite{waskom:2021:seaborn} to set the theme in the figures. +\end{document} diff --git a/latex/sections/results.tex b/latex/sections/results.tex new file mode 100644 index 0000000..8960f00 --- /dev/null +++ b/latex/sections/results.tex @@ -0,0 +1,123 @@ +\documentclass[../main.tex]{subfiles} +\graphicspath{{\subfix{../images/}}} + +\begin{document} +\section{Results and Discussion} +The simulations were performed using a constant configuration for the Penning trap, where the values of $B_{0}$, $V_{0}$, and $d$ can be found in table \ref{tab:penning_config}. We also used a constant configuration for the particles, found in table \ref{tab:particle_config}. Initial position of particle 1 $p_{1}$ was set to $(20, 0, 20) \mu m$ with velocity $(0, 25, 0) \mu m/ \mu s$, whereas the position of particle 2 $p_{2}$ was set to $(25, 25, 0) \mu m$ with velocity $(0, 40, 5) \mu m/ \mu s$. + +First, we simulated a single particle for $50 \mu s$, approximating the particle's motion using the RK4 method. In addition we compared the result with the analytical solution in figure \ref{fig:single_particle}. The approximated solution completely overlap the analytical, suggesting the implemented method is approximating the solution with minimal error. The angular frequency is +\begin{align*} + \omega_{z} &= \sqrt{\frac{2 q V_{0}}{m d^{2}}} = \sqrt{\frac{2 \cdot 1 \cdot 9.65}{40.078}} \approx 0.694 \text{ rad/\textmu s}, +\end{align*} +which result in a period (P) of +\begin{align*} + \text{P} &= \frac{2 \pi}{|\omega_{z}|} \approx 9.054 \text{\textmu s}. +\end{align*} +From figure \ref{fig:single_particle} we see that the period, the time it takes for the particle to reach the same position, is close to 9 \textmu s. This is what we would expect given the value of $\omega_{z}$. +% Figure: single_particle.pdf +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/single_particle.pdf} + \caption{Movement of a single particle in z-direction. Approximated using the 4th order Runge-Kutta method, compared to the analytical solution $z(t) = z_{0} \cos (\omega_{z} t)$.} + \label{fig:single_particle} +\end{figure} + +To evaluate the implemented methods we simulated the particle using both forward Euler (FE) and RK4, with different time steps given in \ref{tab:time_steps}. Again, we simulated the particle movement for $50$ \textmu s, and estimated the relative error of each method. The result can be found in figure \ref{fig:relative_error}. The relative error of FE is large compared to the relative error of RK4. The error convergence rate for FE is $r_{\text{err}} \approx 1.39652$, and RK4 $r_{\text{err}} \approx 3.99998$, which means RK4 converges faster compared to FE. +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/relative_error.pdf} + \caption{Relative error measured for 4th order Runge-Kutta \(a\) and foreward Euler \(b\). Important to notice when reading the plot, that the scale of measured relative error differ between the methods.} + \label{fig:relative_error} +\end{figure} +RK4 is a more complex method, which requires four times the calculations compared to FE. When the simulation is done with $n_{4} = 32000$ time steps, the difference in relative error decreases. The cost of calculation exceed the benefit of accuracy. That is, at a large number of time steps we could find a satisfying approximation to the solution using FE, with less calculations. + +Next, we simulated the movement of two particles in radial direction. In figure \ref{fig:two_particles_radial}, we see the path of both particles without interaction. The starting position of particle 1 $p_{1}$ is closer to the center of the Penning trap, than the starting position of $p_{}$. Both particles move in an orbital path arount the center, however, the starting velocity of each particles determine the minimum and maximum distance a particle moves from the center. We find these values bounds using eq. \ref{eq:upper_b} and eq. \ref{eq:lower_b} +\begin{align*} + R_{+} &= A_{+} + A_{-} \\ + &= -12.3232 \text{\textmu m} + 32.3232 \text{\textmu m} \\ + &= 20.00 \text{\textmu m}, +\end{align*} +and +\begin{align*} + R_{-} &= |A_{+} - A_{-}| \\ + &= |-12.3232 \text{\textmu m} - 32.3232 \text{\textmu m}| \\ + &= 44.6464 \text{\textmu m}. +\end{align*} +The distance is similar that in figure \ref{fig:two_particles_radial}. In addition, we can see from \ref{fig:phase_nointer_x} that the distance differ between $p_{1}$ and $p_{2}$. When we study the particle movement in z-direction, in figure \ref{fig:phase_nointer_z}, we see a circular movement. Again, the distance the particle moves from the center is determined by its initial conditions. + +In figure \ref{fig:two_particles_radial_interaction} we see the movement in radial direction, where particle interaction is included. The orbital path is similar to what we see without particle interaction. However, the additional force acting on the particle is affecting it's trajectory. The distance each particle is moving from the center, differs depending on the position. Which is also seen in figure \ref{fig:phase_inter_x}, where we see the trajectory of the particle at a given position. When we study the phase space plot, where particle interaction is included, in figure \ref{fig:phase_inter_z} a similar difference is observed. In figure \ref{fig:3d_particles} we see the movement of two particles in both the radial direction and z-direction. The figure include particle movement with and without interaction, where we can observe the change in movement.% Something about the trajectory related to the interaction? + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/simulate_2_particles_no_interaction_xy.pdf} + \caption{Path of two particles, $p_{1}$ and $p_{2}$, without interaction. The black dot marks the starting position of each particle.} + \label{fig:two_particles_radial} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/simulate_2_particles_interaction_xy.pdf} + \caption{Path of two particles, $p_{1}$ and $p_{2}$, with interaction. The black dot marks the starting position of each particle.} + \label{fig:two_particles_radial_interaction} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/phase_space_no_interaction_x.pdf} + \caption{Particle trajectory at a given position $x$, without particle interaction. The black dot marks the starting position of each particle.} + \label{fig:phase_nointer_x} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/phase_space_no_interaction_z.pdf} + \caption{Particle trajectory at a given position $z$, without particle interaction. The black dot marks the starting position of each particle.} + \label{fig:phase_nointer_z} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/phase_space_interaction_x.pdf} + \caption{Particle trajectory at a given position $x$, with particle interaction. The black dot marks the starting position of each particle.} + \label{fig:phase_inter_x} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/phase_space_interaction_z.pdf} + \caption{Particle trajectory at a given position $z$, with particle interaction. The black dot marks the starting position of each particle.} + \label{fig:phase_inter_z} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/3d_plot.pdf} + \caption{The movement of particles in a Penning trap. Where $p_{1}$ and $p_{2}$ is without interaction, $\hat{p}_{1}$ and $\hat{p}_{2}$ is without interaction.} + \label{fig:3d_particles} +\end{figure} + +Finally, by subjecting the system to a time-dependent field, making the replacement in \ref{eq:pertubation}, we study the fraction of particles left at different amplitudes $f$. We can see how the different amplitudes lead to loss of particles, at different angular frequencies $\omega_{V}$ in \ref{fig:wide_sweep}. We study frequencies in the range $\omega_{V} \in (0.2, 2.5)$ MHz, with steps of $0.02$ MHz, and find that angular frequencies in the range $(1.0, 2.5)$ is effective in pushing the particles out of the Penning trap. + +We explore the range $\omega_{V} \in (1.0, 1.7)$ MHz closer in figure \ref{fig:narrow_sweep}, and observe a loss of particles for amplitude $f_{1} = 0.1$ in the range $\omega_{V} \in (1.3, 1.5)$, for $f_{2} = 0.4$ in the range $\omega_{V} \in (1.2, 1.6)$, and $f_{3} = 0.7$ in the entire range explored. When we introduce particle interaction, we observe the amplitude with higher value will result in a larger bound for the particle movement, and particles are easily pushed out. When we add particle interaction the angular frequencies, which result in particles being pushed out, are similar as in no interaction. As we see in figure \ref{fig:narrow_sweep_interactions} the particle's behavior, when interactions are added, is disrupted and add to the force resulting in the particle being pushed out of the Penning trap. We see that fewer particles tend to be left in the Penning trap, than without any particle interactions. We also see that the fraction of particles left is more unpredictable with particle interactions. + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/particles_left_wide_sweep.pdf} + \caption{Exploring the behavior of particles, where the amplitude of time-dependent potential $f = [0.1, 0.4, 0.7]$, for angular frequency $\omega_{V} \in (0.2, 2.5)$ MHz.} + \label{fig:wide_sweep} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/particles_left_narrow_sweep.pdf} + \caption{Exploring the behavior of particles, where the amplitude of time-dependent potential $f = [0.1, 0.4, 0.7]$, for angular frequency $\omega_{V} \in (1.1, 1.7)$ MHz.} + \label{fig:narrow_sweep} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{images/particles_left_narrow_sweep_interactions.pdf} + \caption{Exploring the behavior of particles, where the amplitude of time-dependent potential $f = [0.1, 0.4, 0.7]$, for angular frequency $\omega_{V} \in (1.1, 1.7)$ MHz with particle interactions.} + \label{fig:narrow_sweep_interactions} +\end{figure} +\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 ebff781..0000000 --- a/man_pages/man3/Particle.3 +++ /dev/null @@ -1,111 +0,0 @@ -.TH "Particle" 3 "Sat Oct 14 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, \fBvec_3d\fP \fBr_vec\fP, \fBvec_3d\fP \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 "\fBvec_3d\fP \fBr_vec\fP" -.br -.RI "position " -.ti -1c -.RI "\fBvec_3d\fP \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 \fB21\fP of file \fBParticle\&.hpp\fP\&. -.SH "Constructor & Destructor Documentation" -.PP -.SS "Particle::Particle (double q, double m, \fBvec_3d\fP r_vec, \fBvec_3d\fP v_vec)" - -.PP -Initialize the particle\&. Initialize the particle with a charge, mass, position and velocity\&. -.PP -\fBParameters\fP -.RS 4 -\fIq\fP The charge of the particle -.br -\fIm\fP The mass of the particle -.br -\fIr_vec\fP The initial position of the particle -.br -\fIv_vec\fP The initial velocity of the particle -.RE -.PP - -.PP -Definition at line \fB15\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 \fB43\fP of file \fBParticle\&.hpp\fP\&. -.SH "Member Data Documentation" -.PP -.SS "double Particle::m\fC [private]\fP" - -.PP -Mass\&. -.PP -Definition at line \fB24\fP of file \fBParticle\&.hpp\fP\&. -.SS "double Particle::q\fC [private]\fP" - -.PP -Charge\&. -.PP -Definition at line \fB23\fP of file \fBParticle\&.hpp\fP\&. -.SS "\fBvec_3d\fP Particle::r_vec\fC [private]\fP" - -.PP -position -.PP -Definition at line \fB25\fP of file \fBParticle\&.hpp\fP\&. -.SS "\fBvec_3d\fP Particle::v_vec\fC [private]\fP" - -.PP -velocity -.PP -Definition at line \fB26\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 904c7a4..0000000 --- a/man_pages/man3/Particle.cpp.3 +++ /dev/null @@ -1,42 +0,0 @@ -.TH "src/Particle.cpp" 3 "Sat Oct 14 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 2033d14..0000000 --- a/man_pages/man3/Particle.hpp.3 +++ /dev/null @@ -1,52 +0,0 @@ -.TH "include/Particle.hpp" 3 "Sat Oct 14 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 -\fC#include 'typedefs\&.hpp'\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 51cca93..0000000 --- a/man_pages/man3/PenningTrap.3 +++ /dev/null @@ -1,494 +0,0 @@ -.TH "PenningTrap" 3 "Sat Oct 14 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, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)" -.br -.RI "Constructor for the \fBPenningTrap\fP class\&. " -.ti -1c -.RI "\fBPenningTrap\fP (unsigned int i, double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)" -.br -.RI "Constructor for the \fBPenningTrap\fP class\&. " -.ti -1c -.RI "\fBPenningTrap\fP (std::vector< \fBParticle\fP > \fBparticles\fP, double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)" -.br -.RI "Constructor for the \fBPenningTrap\fP class\&. " -.ti -1c -.RI "void \fBadd_particle\fP (\fBParticle\fP particle)" -.br -.RI "Add a particle to the system\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBexternal_E_field\fP (\fBvec_3d\fP r)" -.br -.RI "Calculate E at point r\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBexternal_B_field\fP (\fBvec_3d\fP r)" -.br -.RI "Calculate B at point r\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBforce_on_particle\fP (unsigned int i, unsigned int j)" -.br -.RI "Calculate the force between 2 particles\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBtotal_force_external\fP (unsigned int i)" -.br -.RI "Calculate the total external force on a particle\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBtotal_force_particles\fP (unsigned int i)" -.br -.RI "Calculate the total force on a particle p_i from other particles\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBtotal_force\fP (unsigned int i)" -.br -.RI "calculate the total force on a particle p_i\&. " -.ti -1c -.RI "void \fBevolve_RK4\fP (double dt, bool particle_interaction=true)" -.br -.RI "Go forward one timestep using the RK4 method\&. " -.ti -1c -.RI "void \fBevolve_forward_euler\fP (double dt, bool particle_interaction=true)" -.br -.RI "Go forward one timestep using the forward Euler method\&. " -.ti -1c -.RI "\fBsim_arr\fP \fBsimulate\fP (double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)" -.br -.RI "Simulate the particle system inside the Penning trap over a certain amount of time\&. " -.ti -1c -.RI "void \fBwrite_simulation_to_dir\fP (std::string path, double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)" -.br -.RI "Simulate and write the displacement of all particles to files\&. " -.ti -1c -.RI "double \fBfraction_of_particles_left\fP (double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)" -.br -.RI "Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation\&. " -.in -1c -.SS "Private Member Functions" - -.in +1c -.ti -1c -.RI "\fBvec_3d\fP \fBv_func\fP (unsigned int i, unsigned int j, double dt)" -.br -.RI "Helper for evolve_RK4 when calculating $k_{v,i,j}$ values\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBr_func\fP (unsigned int i, unsigned int j, double dt)" -.br -.RI "Helper for evolve_RK4 when calculating $k_{r,i,j}$ values\&. " -.in -1c -.SS "Private Attributes" - -.in +1c -.ti -1c -.RI "double \fBB_0\fP" -.br -.RI "Magnetic field strength\&. " -.ti -1c -.RI "std::function< double(double)> \fBV_0\fP" -.br -.RI "Applied potential\&. " -.ti -1c -.RI "double \fBd\fP" -.br -.RI "Characteristic dimension\&. " -.ti -1c -.RI "double \fBt\fP" -.br -.RI "Current time\&. " -.ti -1c -.RI "std::vector< \fBParticle\fP > \fBparticles\fP" -.br -.RI "The particles in the Penning trap\&. " -.ti -1c -.RI "\fBsim_arr\fP \fBk_v\fP" -.br -.ti -1c -.RI "\fBsim_arr\fP \fBk_r\fP" -.br -.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 \fB30\fP of file \fBPenningTrap\&.hpp\fP\&. -.SH "Constructor & Destructor Documentation" -.PP -.SS "PenningTrap::PenningTrap (double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)" - -.PP -Constructor for the \fBPenningTrap\fP class\&. -.PP -\fBParameters\fP -.RS 4 -\fIB_0\fP The magnetic field strength -.br -\fIV_0\fP The time dependent applied potential -.br -\fId\fP The characteristic dimension -.br -\fIt\fP The starting time -.RE -.PP - -.PP -Definition at line \fB18\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "PenningTrap::PenningTrap (unsigned int i, double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)" - -.PP -Constructor for the \fBPenningTrap\fP class\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The number of particles to generate -.br -\fIB_0\fP The magnetic field strength -.br -\fIV_0\fP The time dependent applied potential -.br -\fId\fP The characteristic dimension -.br -\fIt\fP The starting time -.RE -.PP - -.PP -Definition at line \fB27\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "PenningTrap::PenningTrap (std::vector< \fBParticle\fP > particles, double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)" - -.PP -Constructor for the \fBPenningTrap\fP class\&. -.PP -\fBParameters\fP -.RS 4 -\fIparticles\fP The starting particles -.br -\fIB_0\fP The magnetic field strength -.br -\fIV_0\fP The time dependent applied potential -.br -\fId\fP The characteristic dimension -.br -\fIt\fP The starting time -.RE -.PP - -.PP -Definition at line \fB39\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 -\fBParameters\fP -.RS 4 -\fIparticle\fP The particle to add to the Penning trap -.RE -.PP - -.PP -Definition at line \fB82\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "void PenningTrap::evolve_forward_euler (double dt, bool particle_interaction = \fCtrue\fP)" - -.PP -Go forward one timestep using the forward Euler method\&. -.PP -\fBParameters\fP -.RS 4 -\fIdt\fP The step length -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB186\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "void PenningTrap::evolve_RK4 (double dt, bool particle_interaction = \fCtrue\fP)" - -.PP -Go forward one timestep using the RK4 method\&. -.PP -\fBParameters\fP -.RS 4 -\fIdt\fP The step length -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB151\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::external_B_field (\fBvec_3d\fP r)" - -.PP -Calculate B at point r\&. -.PP -\fBParameters\fP -.RS 4 -\fIr\fP The position where we want to calculate the B field -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB95\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::external_E_field (\fBvec_3d\fP r)" - -.PP -Calculate E at point r\&. -.PP -\fBParameters\fP -.RS 4 -\fIr\fP The position where we want to calculate the E field -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB87\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::force_on_particle (unsigned int i, unsigned int j)" - -.PP -Calculate the force between 2 particles\&. Calculate the force exhibited on particle p_i from particle p_j\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.br -\fIj\fP The index of particle p_j -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB100\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "double PenningTrap::fraction_of_particles_left (double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)" - -.PP -Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation\&. -.PP -\fBParameters\fP -.RS 4 -\fItime\fP The time to simulate in microseconds -.br -\fIsteps\fP The amount of steps for the whole simulation -.br -\fImethod\fP The method to use when moving forward a timestep -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP -\fBReturns\fP -.RS 4 -double -.RE -.PP - -.PP -Definition at line \fB266\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::r_func (unsigned int i, unsigned int j, double dt)\fC [private]\fP" - -.PP -Helper for evolve_RK4 when calculating $k_{r,i,j}$ values\&. Something -.PP -\fBParameters\fP -.RS 4 -\fIi\fP Index i for $k_{r,i,j}$ -.br -\fIj\fP Index j for $k_{r,i,j}$ -.br -\fIdt\fP the step length (delta time) -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB64\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBsim_arr\fP PenningTrap::simulate (double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)" - -.PP -Simulate the particle system inside the Penning trap over a certain amount of time\&. -.PP -\fBParameters\fP -.RS 4 -\fItime\fP The time to simulate in microseconds -.br -\fIsteps\fP The amount of steps for the whole simulation -.br -\fImethod\fP The method to use when moving forward a timestep -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB211\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::total_force (unsigned int i)" - -.PP -calculate the total force on a particle p_i\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB146\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::total_force_external (unsigned 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 -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB114\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::total_force_particles (unsigned int i)" - -.PP -Calculate the total force on a particle p_i from other particles\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB129\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::v_func (unsigned int i, unsigned int j, double dt)\fC [private]\fP" - -.PP -Helper for evolve_RK4 when calculating $k_{v,i,j}$ values\&. Something -.PP -\fBParameters\fP -.RS 4 -\fIi\fP Index i for $k_{v,i,j}$ -.br -\fIj\fP Index j for $k_{v,i,j}$ -.br -\fIdt\fP the step length (delta time) -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB46\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "void PenningTrap::write_simulation_to_dir (std::string path, double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)" - -.PP -Simulate and write the displacement of all particles to files\&. -.PP -\fBParameters\fP -.RS 4 -\fIpath\fP The directory to save the data -.br -\fItime\fP The time to simulate in microseconds -.br -\fIsteps\fP The amount of steps for the whole simulation -.br -\fImethod\fP The method to use when moving forward a timestep -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB240\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 \fB32\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "double PenningTrap::d\fC [private]\fP" - -.PP -Characteristic dimension\&. -.PP -Definition at line \fB34\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "\fBsim_arr\fP PenningTrap::k_r\fC [private]\fP" -A 2D vector containing all $k_{i,j}$ where $j$ is the index of a particle -.PP -Definition at line \fB39\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "\fBsim_arr\fP PenningTrap::k_v\fC [private]\fP" -A 2D vector containing all $k_{i,j}$ where $j$ is the index of a particle -.PP -Definition at line \fB37\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 \fB36\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "double PenningTrap::t\fC [private]\fP" - -.PP -Current time\&. -.PP -Definition at line \fB35\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "std::function PenningTrap::V_0\fC [private]\fP" - -.PP -Applied potential\&. -.PP -Definition at line \fB33\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 d080d97..0000000 --- a/man_pages/man3/PenningTrap.cpp.3 +++ /dev/null @@ -1,48 +0,0 @@ -.TH "src/PenningTrap.cpp" 3 "Sat Oct 14 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 'typedefs\&.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 -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 15d155f..0000000 --- a/man_pages/man3/PenningTrap.hpp.3 +++ /dev/null @@ -1,58 +0,0 @@ -.TH "include/PenningTrap.hpp" 3 "Sat Oct 14 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 -\fC#include 'typedefs\&.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 3bbe27c..0000000 --- a/man_pages/man3/PenningTrapTest.3 +++ /dev/null @@ -1,56 +0,0 @@ -.TH "PenningTrapTest" 3 "Sat Oct 14 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 d21bde1..0000000 --- a/man_pages/man3/bug.3 +++ /dev/null @@ -1,29 +0,0 @@ -.TH "bug" 3 "Sat Oct 14 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 \fBtypedefs\&.hpp\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 b1d978f..0000000 --- a/man_pages/man3/constants.hpp.3 +++ /dev/null @@ -1,75 +0,0 @@ -.TH "include/constants.hpp" 3 "Sat Oct 14 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 23983a7..0000000 --- a/man_pages/man3/main.cpp.3 +++ /dev/null @@ -1,148 +0,0 @@ -.TH "src/main.cpp" 3 "Sat Oct 14 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 \fP -.br -\fC#include \fP -.br -\fC#include \fP -.br -\fC#include 'PenningTrap\&.hpp'\fP -.br -\fC#include 'utils\&.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_single_particle\fP ()" -.br -.ti -1c -.RI "void \fBsimulate_two_particles\fP ()" -.br -.ti -1c -.RI "void \fBsimulate_single_particle_with_different_steps\fP ()" -.br -.ti -1c -.RI "void \fBsimulate_100_particles\fP ()" -.br -.ti -1c -.RI "void \fBsimulate_100_particles_with_time_potential\fP ()" -.br -.ti -1c -.RI "int \fBmain\fP ()" -.br -.in -1c -.SS "Variables" - -.in +1c -.ti -1c -.RI "\fBParticle\fP \fBp1\fP (CHARGE, MASS, \fBvec_3d\fP{20\&., 0\&., 20\&.}, \fBvec_3d\fP{0\&., 25\&., 0\&.})" -.br -.ti -1c -.RI "\fBParticle\fP \fBp2\fP (CHARGE, MASS, \fBvec_3d\fP{25\&., 25\&., 0\&.}, \fBvec_3d\fP{0\&., 40\&., 5\&.})" -.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 \fB25\fP of file \fBmain\&.cpp\fP\&. -.SS "#define MASS 40\&." - -.PP -Definition at line \fB26\fP of file \fBmain\&.cpp\fP\&. -.SS "#define N 10000" - -.PP -Definition at line \fB24\fP of file \fBmain\&.cpp\fP\&. -.SS "#define PARTICLES 100" - -.PP -Definition at line \fB23\fP of file \fBmain\&.cpp\fP\&. -.SH "Function Documentation" -.PP -.SS "int main ()" - -.PP -Definition at line \fB124\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_100_particles ()" - -.PP -Definition at line \fB77\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_100_particles_with_time_potential ()" - -.PP -Definition at line \fB91\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_single_particle ()" - -.PP -Definition at line \fB31\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_single_particle_with_different_steps ()" - -.PP -Definition at line \fB55\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_two_particles ()" - -.PP -Definition at line \fB42\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 c185469..0000000 --- a/man_pages/man3/test_suite.cpp.3 +++ /dev/null @@ -1,70 +0,0 @@ -.TH "src/test_suite.cpp" 3 "Sat Oct 14 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 ef888e2..0000000 --- a/man_pages/man3/todo.3 +++ /dev/null @@ -1,14 +0,0 @@ -.TH "todo" 3 "Sat Oct 14 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/typedefs.hpp.3 b/man_pages/man3/typedefs.hpp.3 deleted file mode 100644 index 1933ad3..0000000 --- a/man_pages/man3/typedefs.hpp.3 +++ /dev/null @@ -1,92 +0,0 @@ -.TH "include/typedefs.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- -.ad l -.nh -.SH NAME -include/typedefs.hpp \- Useful typedefs for cleaner code\&. - -.SH SYNOPSIS -.br -.PP -\fC#include \fP -.br -\fC#include \fP -.br - -.SS "Typedefs" - -.in +1c -.ti -1c -.RI "typedef std::vector< arma::vec::fixed< 3 > > \fBsim_cols\fP" -.br -.RI "Typedef for the column of the result vector from simulating particles\&. " -.ti -1c -.RI "typedef std::vector< arma::vec::fixed< 3 > > \fBsim_rows\fP" -.br -.RI "Typedef for the row of the result vector from simulating particles\&. " -.ti -1c -.RI "typedef std::vector< \fBsim_cols\fP > \fBsim_arr\fP" -.br -.RI "Typedef for the result of the simulate method\&. " -.ti -1c -.RI "typedef arma::vec::fixed< 3 > \fBvec_3d\fP" -.br -.RI "Typedef for a fixed 3d arma vector\&. " -.in -1c -.SH "Detailed Description" -.PP -Useful typedefs for cleaner code\&. - - -.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 typedefs make the code more readable and easy to follow along\&. -.PP -\fBBug\fP -.RS 4 -No known bugs -.RE -.PP - -.PP -Definition in file \fBtypedefs\&.hpp\fP\&. -.SH "Typedef Documentation" -.PP -.SS "typedef std::vector<\fBsim_cols\fP> \fBsim_arr\fP" - -.PP -Typedef for the result of the simulate method\&. -.PP -Definition at line \fB32\fP of file \fBtypedefs\&.hpp\fP\&. -.SS "typedef std::vector > \fBsim_cols\fP" - -.PP -Typedef for the column of the result vector from simulating particles\&. -.PP -Definition at line \fB24\fP of file \fBtypedefs\&.hpp\fP\&. -.SS "typedef std::vector > \fBsim_rows\fP" - -.PP -Typedef for the row of the result vector from simulating particles\&. -.PP -Definition at line \fB28\fP of file \fBtypedefs\&.hpp\fP\&. -.SS "typedef arma::vec::fixed<3> \fBvec_3d\fP" - -.PP -Typedef for a fixed 3d arma vector\&. -.PP -Definition at line \fB36\fP of file \fBtypedefs\&.hpp\fP\&. -.SH "Author" -.PP -Generated automatically by Doxygen for Penning Trap Simulation from the source code\&. diff --git a/man_pages/man3/utils.cpp.3 b/man_pages/man3/utils.cpp.3 deleted file mode 100644 index 335b5f5..0000000 --- a/man_pages/man3/utils.cpp.3 +++ /dev/null @@ -1,179 +0,0 @@ -.TH "src/utils.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- -.ad l -.nh -.SH NAME -src/utils.cpp \- Implementation of the utils\&. - -.SH SYNOPSIS -.br -.PP -\fC#include \fP -.br -\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\&. " -.ti -1c -.RI "bool \fBmkpath\fP (std::string path, int mode)" -.br -.RI "Make path given\&. " -.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 -bool -.RE -.PP - -.PP -Definition at line \fB62\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 \fB43\fP of file \fButils\&.cpp\fP\&. -.SS "bool mkpath (std::string path, int mode = \fC0777\fP)" - -.PP -Make path given\&. This tries to be the equivalent to 'mkdir -p' and creates a new directory whenever it needs to\&. -.PP -\fBParameters\fP -.RS 4 -\fIpath\fP The path to be created -.br -\fImode\fP The mode/permissions for all the new directories -.RE -.PP -\fBReturns\fP -.RS 4 -bool -.RE -.PP - -.PP -Definition at line \fB76\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\&. The code is stolen from https://github.com/anderkve/FYS3150\&. -.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 -std::string -.RE -.PP - -.PP -Definition at line \fB24\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\&. The code is stolen from https://github.com/anderkve/FYS3150\&. -.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 -std::string -.RE -.PP - -.PP -Definition at line \fB17\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 3f934d0..0000000 --- a/man_pages/man3/utils.hpp.3 +++ /dev/null @@ -1,228 +0,0 @@ -.TH "include/utils.hpp" 3 "Sat Oct 14 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 -.RI "Get the name of the current method/function\&. " -.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\&. " -.ti -1c -.RI "bool \fBmkpath\fP (std::string path, int mode=0777)" -.br -.RI "Make path given\&. " -.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 -Get the name of the current method/function\&. -.PP -Definition at line \fB51\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 -bool -.RE -.PP - -.PP -Definition at line \fB62\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 \fB43\fP of file \fButils\&.cpp\fP\&. -.SS "bool mkpath (std::string path, int mode = \fC0777\fP)" - -.PP -Make path given\&. This tries to be the equivalent to 'mkdir -p' and creates a new directory whenever it needs to\&. -.PP -\fBParameters\fP -.RS 4 -\fIpath\fP The path to be created -.br -\fImode\fP The mode/permissions for all the new directories -.RE -.PP -\fBReturns\fP -.RS 4 -bool -.RE -.PP - -.PP -Definition at line \fB76\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\&. The code is stolen from https://github.com/anderkve/FYS3150\&. -.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 -std::string -.RE -.PP - -.PP -Definition at line \fB24\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\&. The code is stolen from https://github.com/anderkve/FYS3150\&. -.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 -std::string -.RE -.PP - -.PP -Definition at line \fB17\fP of file \fButils\&.cpp\fP\&. -.SH "Author" -.PP -Generated automatically by Doxygen for Penning Trap Simulation from the source code\&. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..db5d81e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +matplotlib +numpy diff --git a/src/Makefile b/src/Makefile index f678e43..e939d9c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,8 @@ CLASSOBJS=$(CLASSSRCS:.cpp=.o) INCLUDE=../include -CFLAGS=-Wall -larmadillo -lblas -llapack -std=c++11 -O3 +CFLAGS=-Wall -larmadillo -std=c++11 -O3 -fomit-frame-pointer +#CFLAGS=-Wall -larmadillo -lblas -llapack -std=c++11 -O3 -fomit-frame-pointer OPENMP=-fopenmp # Add a debug flag when compiling (For the DEBUG macro in utils.hpp) @@ -19,21 +20,37 @@ else DBGFLAG= endif +# Add profiling for serial code PROFILE ?= 0 ifeq ($(PROFILE), 1) - PROFFLAG=-pg + PROFFLAG=-pg -fno-inline-functions else PROFFLAG= endif .PHONY: clean -all: test_suite main +all: test_suite main frequency_narrow_sweeps_long + +# Instrumentation using scorep for parallel analysis +instrument: + scorep $(CC) -c PenningTrap.cpp -o PenningTrap.o $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + scorep $(CC) -c Particle.cpp -o Particle.o $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + scorep $(CC) -c utils.cpp -o utils.o $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + scorep $(CC) -c main.cpp -o main.o $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + scorep $(CC) $(LIBOBJS) $(CLASSOBJS) main.o -o main $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + + + # Rules for executables main: main.o $(LIBOBJS) $(CLASSOBJS) $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) +frequency_narrow_sweeps_long: frequency_narrow_sweeps_long.o $(LIBOBJS) $(CLASSOBJS) + $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + + test_suite: test_suite.o $(LIBOBJS) $(CLASSOBJS) $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) @@ -43,5 +60,4 @@ test_suite: test_suite.o $(LIBOBJS) $(CLASSOBJS) clean: rm *.o - rm test_suite - rm main + rm test_suite main frequency_narrow_sweeps_long diff --git a/src/Particle.cpp b/src/Particle.cpp index 2caad68..9d55274 100644 --- a/src/Particle.cpp +++ b/src/Particle.cpp @@ -3,7 +3,7 @@ * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * - * @version 0.1 + * @version 1.0 * * @brief The implementation of the Particle class. * @@ -12,13 +12,11 @@ #include "Particle.hpp" -Particle::Particle(double q, double m, - arma::vec::fixed<3> r_vec, - arma::vec::fixed<3> v_vec) +Particle::Particle(vec3 r_vec, vec3 v_vec, double q, double m) { // Giving the particle its properties - this->q = q; - this->m = m; this->r_vec = r_vec; this->v_vec = v_vec; + this->q = q; + this->m = m; } diff --git a/src/PenningTrap.cpp b/src/PenningTrap.cpp index d0478ec..8f7996f 100644 --- a/src/PenningTrap.cpp +++ b/src/PenningTrap.cpp @@ -3,47 +3,22 @@ * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * - * @version 0.1 + * @version 1.0 * * @brief The implementation of the PenningTrap class. * * @bug No known bugs * */ +#include +#include +#include +#include + #include "PenningTrap.hpp" -#include "constants.hpp" #include "typedefs.hpp" -#include "utils.hpp" -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) +vec3 PenningTrap::v_func(uint i, uint j, double dt) { switch (i) { case 0: @@ -53,15 +28,16 @@ vec_3d PenningTrap::v_func(unsigned int i, unsigned int j, double dt) case 2: return dt * this->k_v[2][j]; case 3: - return (dt / 6.) * (this->k_v[0][j].eval() + this->k_v[1][j].eval() + - this->k_v[2][j].eval() + this->k_v[3][j].eval()); + return vec3((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) +vec3 PenningTrap::r_func(uint i, uint j, double dt) { switch (i) { case 0: @@ -71,165 +47,222 @@ vec_3d PenningTrap::r_func(unsigned int i, unsigned int j, double dt) case 2: return dt * this->k_r[2][j]; case 3: - return (dt / 6.) * (this->k_r[0][j].eval() + this->k_r[1][j].eval() + - this->k_r[2][j].eval() + this->k_r[3][j].eval()); + return vec3((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(); } } +vec3 PenningTrap::external_E_field(vec3 r) +{ + r(2) *= -2.; + + return vec3( + ((this->V_0 * this->perturbation(this->t)) / (this->d * this->d)) * r); +} + +vec3 PenningTrap::external_B_field(vec3 r) +{ + return vec3{0., 0., this->B_0}; +} + +vec3 PenningTrap::force_on_particle(uint i, uint j) +{ + // Calculate the difference between the particles' position + vec3 res = this->particles[i].r_vec - this->particles[j].r_vec; + + // Get the distance between the particles + double norm = arma::norm(res, 2); + + return vec3((this->particles[j].q / (norm * norm * norm)) * res); +} + +vec3 PenningTrap::total_force_external(uint i) +{ + Particle *p = &this->particles[i]; + + return vec3(p->q + * (this->external_E_field(p->r_vec) + + arma::cross(p->v_vec, this->external_B_field(p->r_vec)))); +} + +vec3 PenningTrap::total_force_particles(uint i) +{ + vec3 res; + + for (size_t j = 0; j < this->particles.size(); j++) { + if (i != j) + res += this->force_on_particle(i, j); + } + + return vec3(res * (K_E * this->particles[i].q)); +} + +vec3 PenningTrap::total_force(uint i) +{ + if (arma::norm(this->particles[i].r_vec) > this->d) { + return vec3{0., 0., 0.}; + } + return vec3(this->total_force_external(i) - this->total_force_particles(i)); +} + +vec3 PenningTrap::total_force_no_interaction(uint i) +{ + if (arma::norm(this->particles[i].r_vec) > this->d) { + return vec3{0., 0., 0.}; + } + return vec3(this->total_force_external(i)); +} + +PenningTrap::PenningTrap(double B_0, double V_0, double d, double t) +{ + this->B_0 = B_0; + this->V_0 = V_0; + this->d = d; + this->t = t; + this->perturbation = [](double t) { return 1.; }; +} + +PenningTrap::PenningTrap(uint i, double B_0, double V_0, double d, double t) + : PenningTrap::PenningTrap(B_0, V_0, d) +{ + for (size_t j = 0; j < i; j++) { + this->particles.push_back( + Particle(vec3(vec3().randn() * .1 * this->d), + vec3(vec3().randn() * .1 * this->d))); + } +} + +PenningTrap::PenningTrap(std::vector particles, double B_0, + double V_0, double d, double t) + : PenningTrap::PenningTrap(B_0, V_0, d) +{ + this->particles = particles; +} + +void PenningTrap::set_pertubation(double f, double omega_V) +{ + this->perturbation = [f, omega_V](double t) { + return 1 + f * std::cos(omega_V * t); + }; +} + +void PenningTrap::reinitialize(double f, double omega_V, double t) +{ + this->t = t; + this->set_pertubation(f, omega_V); + Particle *p; + + for (size_t i = 0; i < this->particles.size(); i++) { + p = &this->particles[i]; + p->r_vec = vec3().randn() * .1 * this->d; + p->v_vec = vec3().randn() * .1 * this->d; + } +} + void PenningTrap::add_particle(Particle particle) { this->particles.push_back(particle); } -vec_3d PenningTrap::external_E_field(vec_3d r) -{ - r(2) *= -2.; - double f = this->V_0(this->t) / (this->d * this->d); - - return f * r; -} - -vec_3d PenningTrap::external_B_field(vec_3d r) -{ - return vec_3d{0., 0., this->B_0}; -} - -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 - vec_3d res = this->particles[i].r_vec - p_j.r_vec; - - // Get the distance between the particles - double norm = arma::norm(res, 2); - - // Multiply res with p_j's charge divided by the norm cubed - - return vec_3d(res * p_j.q / (norm * norm * norm)); -} - -vec_3d PenningTrap::total_force_external(unsigned int i) -{ - Particle p = this->particles[i]; - - if (arma::norm(p.r_vec) > this->d) { - return vec_3d{0., 0., 0.}; - } - - 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; -} - -vec_3d PenningTrap::total_force_particles(unsigned int i) -{ - Particle p = this->particles[i]; - - vec_3d res; - - for (size_t j = 0; j < this->particles.size(); j++) { - if (i == j) { - continue; - } - - res += this->force_on_particle(i, j); - } - - return vec_3d(res * K_E * (p.q / p.m)); -} - -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, bool particle_interaction) { + Particle *p; + // Keep original particles std::vector original_particles = this->particles; std::vector tmp_particles = this->particles; - vec_3d (PenningTrap::*force)(unsigned int); - if (particle_interaction) { - force = &PenningTrap::total_force; - } - else { - force = &PenningTrap::total_force_external; - } + vec3 (PenningTrap::*force)(uint) = + particle_interaction ? &PenningTrap::total_force + : &PenningTrap::total_force_no_interaction; size_t size = this->particles.size(); - this->k_v = sim_arr(4, sim_cols(size)); - this->k_r = sim_arr(4, sim_cols(size)); + // Allocating takes a long time, so reuse sim_arr if possible + if (this->k_v.size() != 4 || this->k_r.size() != 4 + || this->k_v[0].size() != size || this->k_r[0].size() != size) { + this->k_v = sim_arr(4, sim_cols(size)); + this->k_r = sim_arr(4, sim_cols(size)); + } + // Each k_{i+1} is dependent on k_i, so outer loop is not parallelizable for (size_t i = 0; i < 4; i++) { -#pragma omp parallel for - for (size_t j = 0; j < this->particles.size(); j++) { + // Inner loop is able to be parallelized +#pragma omp parallel for private(p) + for (size_t j = 0; j < 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 = &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 = tmp_particles; } + this->t += dt; } void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction) { - std::vector new_state = this->particles; - + size_t size = this->particles.size(); + vec3 force_res[size]; Particle *p; - vec_3d (PenningTrap::*force)(unsigned int); - if (particle_interaction) { - force = &PenningTrap::total_force; - } - else { - force = &PenningTrap::total_force_external; + vec3 (PenningTrap::*force)(uint) = + particle_interaction ? &PenningTrap::total_force + : &PenningTrap::total_force_no_interaction; + + // Calculating the force for each particle is independent and therefore + // a good candidate for parallel execution +#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 < this->particles.size(); i++) { - p = &new_state[i]; - p->v_vec += dt * (this->*force)(i) / p->m; - p->r_vec += dt * this->particles[i].v_vec; + // Updating the particles is also independent, so we can parallelize + // this as well +#pragma omp parallel for + 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->particles = new_state; this->t += dt; } -sim_arr PenningTrap::simulate(double time, unsigned int steps, - std::string method, bool particle_interaction) +simulation_t PenningTrap::simulate(double time, uint steps, std::string method, + bool particle_interaction) { + Particle *p; double dt = time / (double)steps; - sim_arr res(this->particles.size(), sim_cols(steps)); + uint size = this->particles.size(); + + 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") { + } else if (method == "euler") { func = &PenningTrap::evolve_forward_euler; - } - else { + } else { std::cout << "Not a valid method!" << std::endl; abort(); } for (size_t j = 0; j < steps; j++) { - for (size_t i = 0; i < this->particles.size(); i++) { - res[i][j] = this->particles[i].r_vec; + for (size_t i = 0; i < size; i++) { + p = &this->particles[i]; + res.r_vecs[i][j] = p->r_vec; + res.v_vecs[i][j] = p->v_vec; } (this->*func)(dt, particle_interaction); } @@ -238,43 +271,72 @@ sim_arr PenningTrap::simulate(double time, unsigned int steps, } void PenningTrap::write_simulation_to_dir(std::string path, double time, - int steps, std::string method, + uint steps, std::string method, bool particle_interaction) { if (path.back() != '/') { path += '/'; } if (mkpath(path, 0777) != 0) { - std::cout << "Hello" << std::endl; - return; + std::cout << "Failed to make path" << std::endl; + abort(); } - sim_arr res = this->simulate(time, steps, method, particle_interaction); + simulation_t res = + this->simulate(time, steps, method, particle_interaction); std::ofstream ofile; + // Writing each particle to its own file is independent and can be run in + // parallel. #pragma omp parallel for private(ofile) for (size_t i = 0; i < this->particles.size(); i++) { - ofile.open(path + "particle_" + std::to_string(i) + ".txt"); - for (vec_3d &vec : res[i]) { - ofile << vec(0) << "," << vec(1) << "," << vec(2) << "\n"; + ofile.open(path + "particle_" + std::to_string(i) + "_r.txt"); + for (vec3 &vec : res.r_vecs[i]) { + ofile << scientific_format(vec(0), 10, 8) << ',' + << scientific_format(vec(1), 10, 8) << ',' + << scientific_format(vec(2), 10, 8) << '\n'; + } + ofile.close(); + ofile.open(path + "particle_" + std::to_string(i) + "_v.txt"); + for (vec3 &vec : res.v_vecs[i]) { + ofile << scientific_format(vec(0), 10, 8) << ',' + << scientific_format(vec(1), 10, 8) << ',' + << scientific_format(vec(2), 10, 8) << '\n'; } ofile.close(); } } -double PenningTrap::fraction_of_particles_left(double time, unsigned int steps, std::string method, bool particle_interaction) +double PenningTrap::fraction_of_particles_left(double time, uint steps, + std::string method, + bool particle_interaction) { - sim_arr res = this->simulate(time, steps, method, particle_interaction); + double dt = time / (double)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++) { + (this->*func)(dt, particle_interaction); + } int particles_left = 0; - for (Particle p : this->particles) { - if (arma::norm(p.r_vec) < this->d) { + // A reduction is perfect here +#pragma omp parallel for reduction(+ : particles_left) + for (size_t i = 0; i < this->particles.size(); i++) { + if (arma::norm(this->particles[i].r_vec) < this->d) { particles_left++; } } - return (double) particles_left / (double) this->particles.size(); + return (double)particles_left / (double)this->particles.size(); } - diff --git a/src/frequency_narrow_sweeps_long.cpp b/src/frequency_narrow_sweeps_long.cpp new file mode 100644 index 0000000..b572f13 --- /dev/null +++ b/src/frequency_narrow_sweeps_long.cpp @@ -0,0 +1,154 @@ +/** @file frequency_narrow_sweeps_long.cpp + * + * @author Cory Alexander Balaton (coryab) + * @author Janita Ovidie Sandtrøen Willumsen (janitaws) + * + * @version 1.0 + * + * @brief Sweep of the frequencies from 1.1 to 1.7 using a small time step + * + * @bug No known bugs + * */ + +#include +#include +#include +#include +#include +#include + +#include "PenningTrap.hpp" +#include "constants.hpp" +#include "utils.hpp" + +#define PARTICLES 100 +#define N 40000 + +/** @brief Simulate 100 particles over 500 \f$ \mu s \f$ using a time + * dependent potential. + * + * @details The simulation sweeps over different frequencies in [1., 1.7] + * MHz. + * + * */ +void potential_resonance_narrow_sweep() +{ + double time = 500.; + + double amplitudes[]{.1, .4, .7}; + + double freq_start = 1.1; + double freq_end = 1.7; + double freq_increment = .0005; + size_t freq_iterations = + (size_t)((freq_end - freq_start) / freq_increment) + 1; + + double res[4][freq_iterations]; + + std::string path = "output/time_dependent_potential/"; + mkpath(path); + + std::ofstream ofile; + +#pragma omp parallel for + // Insert frequencies + for (size_t i = 0; i < freq_iterations; i++) { + res[0][i] = freq_start + freq_increment * i; + } + +#pragma omp parallel + { + // Each thread creates a PenningTrap instance and reuses it throughout + // the sweep. + PenningTrap trap((uint)PARTICLES); +#pragma omp for collapse(2) + for (size_t i = 0; i < 3; i++) { + for (size_t j = 0; j < freq_iterations; j++) { + // Reset particles and give new time dependent potential. + trap.reinitialize(amplitudes[i], res[0][j]); + res[i + 1][j] = + trap.fraction_of_particles_left(time, N, "rk4", false); + } + } + } + + // Write results to file + ofile.open(path + "narrow_sweep_fine.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(); +} + +/** @brief Simulate 100 particles over 500 \f$ \mu s \f$ using a time + * dependent potential. + * + * @details The simulation sweeps over different frequencies in [1., 1.7] + * MHz. + * + * */ +void potential_resonance_narrow_sweep_interaction() +{ + double time = 500.; + + double amplitudes[]{.1, .4, .7}; + + double freq_start = 1.1; + double freq_end = 1.7; + double freq_increment = .0005; + size_t freq_iterations = + (size_t)((freq_end - freq_start) / freq_increment) + 1; + + double res[4][freq_iterations]; + + std::string path = "output/time_dependent_potential/"; + mkpath(path); + + std::ofstream ofile; + +#pragma omp parallel for + for (size_t i = 0; i < freq_iterations; i++) { + res[0][i] = freq_start + freq_increment * i; + } + +#pragma omp parallel + { + // Each thread creates a PenningTrap instance and reuses it throughout + // the sweep. + PenningTrap trap((uint)PARTICLES); +#pragma omp for collapse(2) + for (size_t i = 0; i < 3; i++) { + for (size_t j = 0; j < freq_iterations; j++) { + // Reset particles and give new time dependent potential. + trap.reinitialize(amplitudes[i], res[0][j]); + res[i + 1][j] = trap.fraction_of_particles_left(time, N); + } + } + } + + // Write results to file + ofile.open(path + "narrow_sweep_interactions_fine.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, end; + + start = omp_get_wtime(); + + potential_resonance_narrow_sweep(); + + potential_resonance_narrow_sweep_interaction(); + + end = omp_get_wtime(); + + std::cout << "Time: " << end - start << " seconds" << std::endl; + + return 0; +} diff --git a/src/job.script b/src/job.script new file mode 100644 index 0000000..1d36bd7 --- /dev/null +++ b/src/job.script @@ -0,0 +1,15 @@ +#!/bin/bash + +#SBATCH --account=ec54 +#SBATCH --job-name=particle-sim +#SBATCH --time=0-01:30:00 +#SBATCH --mem-per-cpu=2G +#SBATCH --cpus-per-task=16 + +set -o errexit # Exit the script on any error +set -o nounset # Treat any unset variables as an error + +module --quiet purge # Reset the modules to the system default +module load Armadillo/11.4.3-foss-2022b + +srun ./frequency_narrow_sweeps_long diff --git a/src/main.cpp b/src/main.cpp index b07ed93..e7e982b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * - * @version 0.1 + * @version 1.0 * * @brief The main program for this project * @@ -11,132 +11,404 @@ * */ #include +#include #include #include #include -#include #include #include "PenningTrap.hpp" +#include "constants.hpp" #include "utils.hpp" #define PARTICLES 100 -#define N 10000 -#define CHARGE 1. -#define MASS 40. // unit: amu +#define N 40000 -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.}); +// Particles used for testing +Particle p1(vec3{20., 0., 20.}, vec3{0., 25., 0.}); ///< Particle 1 +Particle p2(vec3{25., 25., 0.}, vec3{0., 40., 5.}); ///< Particle 2 +/** @brief The analytical solution for particle p1 + * + * @param t Time + * + * @return vec3 + * */ +vec3 analytical_solution_particle_1(double t) +{ + double w_0 = T / CA_MASS; + double w_z2 = (50. * V / 1000.) / (CA_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::cout << A_p << "," << A_n << std::endl; + std::complex f = + A_p * std::exp(std::complex(0., -w_p * t)) + + A_n * std::exp(std::complex(0., -w_n * t)); + vec3 res{std::real(f), std::imag(f), 20. * std::cos(std::sqrt(w_z2) * t)}; + return res; +} + +/** @brief Simulate a single particle over the period of 50 \f$ \mu s \f$. + * */ void simulate_single_particle() { - DEBUG("Inside single particle sim"); + // Initialize trap with particle 1 PenningTrap trap(std::vector{p1}); double time = 50.; // microseconds - DEBUG("Write to dir"); - trap.write_simulation_to_dir("output/simulate_single_particle", time, N); + // Simulate and write results to file + trap.write_simulation_to_dir("output/simulate_single_particle", time, N, + "rk4", false); } +/** @brief Simulate 2 particles over the period of 50 \f$ \mu s \f$ with and + * without particle interactions. + * */ void simulate_two_particles() { + // Initialize traps with particles PenningTrap trap_no_interaction(std::vector{p1, p2}); PenningTrap trap_with_interaction(std::vector{p1, p2}); double time = 50.; // microseconds + // Simulate and write results to files 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); } +/** @brief Simulate a single particle over 50 \f$ \mu s \f$ using different + * amount of steps and different methods. + * */ void simulate_single_particle_with_different_steps() { + double time = 50.; // microseconds - double time = 50; // microseconds + std::ofstream ofile; + // Calculate relative error for RK4 + std::string path = "output/relative_error/RK4/"; + mkpath(path); +#pragma omp parallel for private(ofile) for (int i = 0; i < 4; i++) { - int steps = 4000 * (i + 1); + int steps = 4000 * std::pow(2, i); + std::cout << steps << std::endl; + double dt = time / (double)steps; + ofile.open(path + std::to_string(steps) + "_steps.txt"); PenningTrap trap(std::vector{p1}); - trap.write_simulation_to_dir("output/N_steps/RK4/" + - std::to_string(steps) + "_steps", - time, steps, "rk4", false); + simulation_t res = trap.simulate(time, steps, "rk4", false); + for (int i = 0; i < steps; i++) { + ofile << arma::norm(res.r_vecs[0][i] + - analytical_solution_particle_1(dt * i)) + << '\n'; + } + ofile.close(); } + // Calculate relative error for forward Euler + path = "output/relative_error/euler/"; + mkpath(path); +#pragma omp parallel for private(ofile) for (int i = 0; i < 4; i++) { - int steps = 4000 * (i + 1); + int steps = 4000 * std::pow(2, i); + double dt = time / (double)steps; + ofile.open(path + std::to_string(steps) + "_steps.txt"); PenningTrap trap(std::vector{p1}); - trap.write_simulation_to_dir("output/N_steps/euler/" + - std::to_string(steps) + "_steps", - time, steps, "euler", false); + simulation_t res = trap.simulate(time, steps, "euler", false); + for (int i = 0; i < steps; i++) { + ofile << arma::norm(res.r_vecs[0][i] + - analytical_solution_particle_1(dt * i)) + << '\n'; + } + ofile.close(); } } +/** @brief Simulate 100 particles over 50 \f$ \mu s \f$. + * */ void simulate_100_particles() { - PenningTrap trap((unsigned)100, T, - [](double t) { - return 25. * V / 1000. * - (1. + .4 * std::cos(1.5 * t)); - }, - 500., 0); + PenningTrap trap((unsigned)100); - double time = 500.; // microseconds + double time = 50.; // microseconds - trap.write_simulation_to_dir("output/simulate_100_particles", time, N*5); + // trap.write_simulation_to_dir("output/simulate_100_particles", time, N, + //"rk4", false); + trap.simulate(time, N, "rk4", true); } -void simulate_100_particles_with_time_potential() +/** @brief Simulate 100 particles over 500 \f$ \mu s \f$ using a time + * dependent potential. + * + * @details The simulation sweeps over different frequencies in [0.2, 2.5] + * MHz. + * + * */ +void potential_resonance_wide_sweep() { + double time = 500.; + 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); + size_t freq_iterations = + (size_t)((freq_end - freq_start) / freq_increment) + 1; + + double res[4][freq_iterations]; std::string path = "output/time_dependent_potential/"; mkpath(path); std::ofstream ofile; - for (double f : amplitudes) { - ofile.open(path + "f_" + std::to_string(f) + ".txt"); - #pragma omp parallel for ordered schedule(static, 1) - for (size_t i=0; i < freq_iterations; i++) { - double freq = freq_start + i*freq_increment; - PenningTrap trap((unsigned)100, T, - [f, freq](double t) { - return (25. * V / 1000.) * - (1. + f * std::cos(freq * t)); - }, - 500., 0.); - double res = trap.fraction_of_particles_left(500., 40000, "rk4", true); - #pragma omp ordered - ofile << freq << "," << res << "\n"; - } - ofile.close(); +#pragma omp parallel for + // Insert frequencies + for (size_t i = 0; i < freq_iterations; i++) { + res[0][i] = freq_start + freq_increment * i; } + +#pragma omp parallel + { + // Each thread creates a PenningTrap instance and reuses it throughout + // the sweep. + PenningTrap trap((uint)100); +#pragma omp for collapse(2) + for (size_t i = 0; i < 3; i++) { + for (size_t j = 0; j < freq_iterations; j++) { + // Reset particles and give new time dependent potential. + trap.reinitialize(amplitudes[i], res[0][j]); + res[i + 1][j] = + trap.fraction_of_particles_left(time, N, "rk4", false); + } + } + } + + // Write results to file + ofile.open(path + "wide_sweep.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(); +} + +/** @brief Simulate 100 particles over 500 \f$ \mu s \f$ using a time + * dependent potential. + * + * @details The simulation sweeps over different frequencies in [1., 1.7] + * MHz. + * + * */ +void potential_resonance_narrow_sweep() +{ + double time = 500.; + + double amplitudes[]{.1, .4, .7}; + + double freq_start = 1.1; + double freq_end = 1.7; + double freq_increment = .002; + size_t freq_iterations = + (size_t)((freq_end - freq_start) / freq_increment) + 1; + + double res[4][freq_iterations]; + + std::string path = "output/time_dependent_potential/"; + mkpath(path); + + std::ofstream ofile; + +#pragma omp parallel for + // Insert frequencies + for (size_t i = 0; i < freq_iterations; i++) { + res[0][i] = freq_start + freq_increment * i; + } + +#pragma omp parallel + { + // Each thread creates a PenningTrap instance and reuses it throughout + // the sweep. + PenningTrap trap((uint)100); +#pragma omp for collapse(2) + for (size_t i = 0; i < 3; i++) { + for (size_t j = 0; j < freq_iterations; j++) { + // Reset particles and give new time dependent potential. + trap.reinitialize(amplitudes[i], res[0][j]); + res[i + 1][j] = + trap.fraction_of_particles_left(time, N, "rk4", false); + } + } + } + + // Write results to file + ofile.open(path + "narrow_sweep.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(); +} + +/** @brief Simulate 100 particles over 500 \f$ \mu s \f$ using a time + * dependent potential. + * + * @details The simulation sweeps over different frequencies in [1., 1.7] + * MHz. + * + * */ +void potential_resonance_narrow_sweep_interaction() +{ + double time = 500.; + + double amplitudes[]{.1, .4, .7}; + + double freq_start = 1.1; + double freq_end = 1.7; + double freq_increment = .002; + size_t freq_iterations = + (size_t)((freq_end - freq_start) / freq_increment) + 1; + + double res[4][freq_iterations]; + + std::string path = "output/time_dependent_potential/"; + mkpath(path); + + std::ofstream ofile; + +#pragma omp parallel for + for (size_t i = 0; i < freq_iterations; i++) { + res[0][i] = freq_start + freq_increment * i; + } + +#pragma omp parallel + { + // Each thread creates a PenningTrap instance and reuses it throughout + // the sweep. + PenningTrap trap((uint)100); +#pragma omp for collapse(2) + for (size_t i = 0; i < 3; i++) { + for (size_t j = 0; j < freq_iterations; j++) { + // Reset particles and give new time dependent potential. + trap.reinitialize(amplitudes[i], res[0][j]); + res[i + 1][j] = trap.fraction_of_particles_left(time, N); + } + } + } + + // Write results to file + ofile.open(path + "narrow_sweep_interactions.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() { + int option = 1; + bool chosen = false; - simulate_single_particle(); + system("clear"); + std::cout << "(1) All (default)\n" + << "(2) Simulate single particle\n" + << "(3) simulate 2 particles\n" + << "(4) Simulate single particle with different time steps\n" + << "(5) Simulate 100 particles\n" + << "(6) Potential resonance wide sweep\n" + << "(7) Potential resonance narrow sweep without particle " + "interactions\n" + << "(8) Potential resonance narrow sweep with particle " + "interaction\n" + << "Select what to run: "; + std::cin >> std::noskipws; + do { + if (!(std::cin >> option) || option < 1 || option > 8) { + std::cin.clear(); + std::cin.ignore(std::numeric_limits::max(), '\n'); + system("clear"); + std::cout + << "(1) All (default)\n" + << "(2) Simulate single particle\n" + << "(3) simulate 2 particles\n" + << "(4) Simulate single particle with different time steps\n" + << "(5) Simulate 100 particles\n" + << "(6) Potential resonance wide sweep\n" + << "(7) Potential resonance narrow sweep without particle " + "interactions\n" + << "(8) Potential resonance narrow sweep with particle " + "interaction\n" + << "Not a valid option, please enter a valid number: "; + } else { + chosen = true; + } + } while (!chosen); - simulate_two_particles(); + double start, end; - simulate_single_particle_with_different_steps(); + system("clear"); - double start = omp_get_wtime(); + start = omp_get_wtime(); + switch (option) { + case 1: + std::cout << "Running simulate_single_particle\n"; + simulate_single_particle(); - //simulate_100_particles(); + std::cout << "Running simulate_two_particles\n"; + simulate_two_particles(); - simulate_100_particles_with_time_potential(); + std::cout << "Running simulate_single_particle_with_different_steps\n"; + simulate_single_particle_with_different_steps(); - double end = omp_get_wtime(); + std::cout << "Running simulate_100_particles\n"; + simulate_100_particles(); + + std::cout << "Running potential_resonance_wide_sweep\n"; + potential_resonance_wide_sweep(); + + std::cout << "Running potential_resonance_narrow_sweep\n"; + potential_resonance_narrow_sweep(); + + std::cout << "Running potential_resonance_narrow_sweep_interaction\n"; + potential_resonance_narrow_sweep_interaction(); + break; + case 2: + std::cout << "Running simulate_single_particle\n"; + simulate_single_particle(); + break; + case 3: + std::cout << "Running simulate_two_particles\n"; + simulate_two_particles(); + break; + case 4: + std::cout << "Running simulate_single_particle_with_different_steps\n"; + simulate_single_particle_with_different_steps(); + break; + case 5: + std::cout << "Running simulate_100_particles\n"; + simulate_100_particles(); + break; + case 6: + std::cout << "Running potential_resonance_wide_sweep\n"; + potential_resonance_wide_sweep(); + break; + case 7: + std::cout << "Running potential_resonance_narrow_sweep\n"; + potential_resonance_narrow_sweep(); + break; + case 8: + std::cout << "Running potential_resonance_narrow_sweep_interaction\n"; + potential_resonance_narrow_sweep_interaction(); + break; + } + end = omp_get_wtime(); std::cout << "Time: " << end - start << " seconds" << std::endl; diff --git a/src/plot_particles_left.py b/src/plot_particles_left.py deleted file mode 100644 index 1d9a45c..0000000 --- a/src/plot_particles_left.py +++ /dev/null @@ -1,33 +0,0 @@ -import matplotlib.pyplot as plt - -def main(): - files = [ - "output/time_dependent_potential/f_0.100000.txt", - "output/time_dependent_potential/f_0.400000.txt", - "output/time_dependent_potential/f_0.700000.txt", - ] - vals = [ - .1, - .4, - .7 - ] - for i in range(3): - with open(files[i]) as f: - lines = f.readlines() - x = [] - y = [] - for line in lines: - a,b = line.strip().split(",") - x.append(float(a)) - y.append(float(b)) - plt.plot(x,y,label=f"amplitude: {vals[i]}") - - plt.xlabel(r"$\omega_V$") - 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() - -if __name__ == "__main__": - main() diff --git a/src/animate_100_particles.py b/src/scripts/animate_100_particles.py similarity index 81% rename from src/animate_100_particles.py rename to src/scripts/animate_100_particles.py index 0fc0083..dcc2e97 100644 --- a/src/animate_100_particles.py +++ b/src/scripts/animate_100_particles.py @@ -1,3 +1,14 @@ +## @file animate_100_particles.py +# +# @author Cory Alexander Balaton (coryab) +# @author Janita Ovidie Sandtrøen Willumsen (janitaws) +# +# @version 1.0 +# +# @brief Animate 100 particles. +# +# @bug No known bugs + import matplotlib.pyplot as plt import numpy as np from matplotlib import animation @@ -32,9 +43,9 @@ def animate(): fig = plt.figure() ax = fig.add_subplot(projection="3d") - arr = get_data([f"output/simulate_100_particles/particle_{i}.txt" for i in range(100)]) + arr = get_data([f"output/simulate_100_particles/particle_{i}_r.txt" for i in range(100)]) - arr = arr[:, :, ::10] + arr = arr[:, :, ::40] N = len(arr[0][0]) @@ -63,8 +74,7 @@ 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)) 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..70cf290 --- /dev/null +++ b/src/scripts/plot_2_particles.py @@ -0,0 +1,75 @@ +## @file plot_2_particles.py +# +# @author Cory Alexander Balaton (coryab) +# @author Janita Ovidie Sandtrøen Willumsen (janitaws) +# +# @version 1.0 +# +# @brief Plot 2 particles with and without particle interactions in the +# xy-plane. +# +# @bug No known bugs + +import matplotlib.pyplot as plt +import numpy as np +import seaborn as sns + +sns.set_theme() +params = { + "font.family": "Serif", + "font.serif": "Roman", + "text.usetex": True, + "axes.titlesize": "large", + "axes.labelsize": "large", + "xtick.labelsize": "large", + "ytick.labelsize": "large", + "legend.fontsize": "medium" +} +plt.rcParams.update(params) + +def main(): + directories = { + "output/simulate_2_particles/no_interaction/", + "output/simulate_2_particles/with_interaction/", + } + files = [ + "particle_0_r.txt", + "particle_1_r.txt", + ] + outputs = [ + "../latex/images/simulate_2_particles_no_interaction_xy.pdf", + "../latex/images/simulate_2_particles_interaction_xy.pdf", + ] + labels = [ + r"$p_1$", + r"$p_2$", + r"$\hat{p}_1$", + r"$\hat{p}_2$", + ] + colors = [ + "seagreen", + "darkred" + ] + start_pos = set() + for dir, output in zip(directories, outputs): + fig, ax = plt.subplots() + 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]) + ax.plot(r[:,0], r[:,1], label=label, color=color) + start_pos.add((r[0,0],r[0,1])) + + for pos in start_pos: + ax.plot(*pos, "o", color="black") + + ax.set_xlabel(r"x $(\mu m)$") + ax.set_ylabel(r"y $(\mu m)$") + ax.legend(loc="upper right") + ax.axis("equal") + fig.savefig(output, bbox_inches="tight") + + +if __name__ == "__main__": + main() diff --git a/src/scripts/plot_3d.py b/src/scripts/plot_3d.py new file mode 100644 index 0000000..9550e1e --- /dev/null +++ b/src/scripts/plot_3d.py @@ -0,0 +1,67 @@ +## @file plot_3d.py +# +# @author Cory Alexander Balaton (coryab) +# @author Janita Ovidie Sandtrøen Willumsen (janitaws) +# +# @version 1.0 +# +# @brief Plot 2 particles with and without particle interactions in 3D. +# +# @bug No known bugs + +import matplotlib.pyplot as plt +import numpy as np +import seaborn as sns + +sns.set_theme() +params = { + "font.family": "Serif", + "font.serif": "Roman", + "text.usetex": True, + "axes.titlesize": "large", + "axes.labelsize": "large", + "xtick.labelsize": "large", + "ytick.labelsize": "large", + "legend.fontsize": "medium", + "figure.autolayout": True +} +plt.rcParams.update(params) + +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 = [ + r"$p_1$", + r"$p_2$", + r"$\hat{p}_1$", + r"$\hat{p}_2$", + ] + colors = [ + "mediumaquamarine", + "salmon", + "seagreen", + "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)$") + ax.view_init(10,-35) + + 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..fde4146 --- /dev/null +++ b/src/scripts/plot_particles_left.py @@ -0,0 +1,81 @@ +## @file plot_particles_left.py +# +# @author Cory Alexander Balaton (coryab) +# @author Janita Ovidie Sandtrøen Willumsen (janitaws) +# +# @version 1.0 +# +# @brief Plot how many particles are left after 500 microseconds using +# different angular frequencies. +# +# @bug No known bugs + +import matplotlib.pyplot as plt +import seaborn as sns + +sns.set_theme() +params = { + "font.family": "Serif", + "font.serif": "Roman", + "text.usetex": True, + "axes.titlesize": "large", + "axes.labelsize": "large", + "xtick.labelsize": "large", + "ytick.labelsize": "large", + "legend.fontsize": "medium" +} +plt.rcParams.update(params) + +def main(): + colors = [ + "mediumseagreen", + "darkred", + "darkgoldenrod" + ] + files = [ + "output/time_dependent_potential/wide_sweep.txt", + "output/time_dependent_potential/narrow_sweep.txt", + "output/time_dependent_potential/narrow_sweep_fine.txt", + "output/time_dependent_potential/narrow_sweep_interactions.txt", + "output/time_dependent_potential/narrow_sweep_interactions_fine.txt", + ] + outputs = [ + "../latex/images/particles_left_wide_sweep.pdf", + "../latex/images/particles_left_narrow_sweep.pdf", + "../latex/images/particles_left_narrow_sweep_fine.pdf", + "../latex/images/particles_left_narrow_sweep_interactions.pdf", + "../latex/images/particles_left_narrow_sweep_interactions_fine.pdf", + ] + for file, output in zip(files, outputs): + with open(file) 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])) + + fig, ax = plt.subplots() + ax.plot(x, y1, label=r"$f_{1} = 0.1$", color=colors[0]) + ax.plot(x, y2, label=r"$f_{2} = 0.4$", color=colors[1]) + ax.plot(x, y3, label=r"$f_{3} = 0.7$", color=colors[2]) + + ax.set_xlabel(r"Angular frequency $\omega_V$ (MHz)") + # ax.set_xlim((0, 2.8)) + ax.set_ylabel(r"Fraction of particles left") + # ax.set_ylim((-0.1, 1.1)) + # plt.title(r"The fraction of particles left in the Penning trap " + # "after 500 microseconds for different amplitudes and frequencies") + + ax.legend(loc="upper right") + + # plt.show() + fig.savefig(output, bbox_inches="tight") + +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..5ec9c0b --- /dev/null +++ b/src/scripts/plot_phase_space.py @@ -0,0 +1,86 @@ +## @file plot_phase_space.py +# +# @author Cory Alexander Balaton (coryab) +# @author Janita Ovidie Sandtrøen Willumsen (janitaws) +# +# @version 1.0 +# +# @brief Plot the phase space for 2 particles in the x and z direction, with +# and without particle interactions. +# +# @bug No known bugs + +import matplotlib.pyplot as plt +import numpy as np +import seaborn as sns + +sns.set_theme() +params = { + "font.family": "Serif", + "font.serif": "Roman", + "text.usetex": True, + "axes.titlesize": "large", + "axes.labelsize": "large", + "xtick.labelsize": "large", + "ytick.labelsize": "large", + "legend.fontsize": "medium", +} +plt.rcParams.update(params) + + +def main(): + directories = [ + "output/simulate_2_particles/no_interaction/", + "output/simulate_2_particles/with_interaction/", + ] + files = [ + "particle_0", + "particle_1", + ] + labels = [r"$p_1$", r"$p_2$"] + output = [ + "../latex/images/phase_space_no_interaction", + "../latex/images/phase_space_interaction", + ] + colors = [ + "seagreen", + "darkred", + ] + + for i, dir in enumerate(directories): + fig1, axs1 = plt.subplots(sharex=True) + fig2, axs2 = plt.subplots(sharex=True) + for j, (file, label, color) in enumerate(zip(files, labels, colors)): + r = [] + v = [] + with open(dir + file + "_r.txt") as f: + lines = f.readlines() + r = np.array( + [list(map(float, line.strip().split(","))) for line in lines] + ) + + with open(dir + file + "_v.txt") as f: + lines = f.readlines() + v = np.array( + [list(map(float, line.strip().split(","))) for line in lines] + ) + axs1.plot(r[:, 0], v[:, 0], label=label, color=color) + axs1.plot(r[0,0], v[0,0], "ko") + axs2.plot(r[:, 2], v[:, 2], label=label, color=color) + axs2.plot(r[0,2], v[0,2], "ko") + axs1.axis("equal") + axs2.axis("equal") + + axs1.set(xlabel=r"$x (\mu m)$", ylabel=r"$v_x (\mu m / \mu s)$") + axs2.set(xlabel=r"$z (\mu m)$", ylabel=r"$v_z (\mu m / \mu s)$") + + axs1.legend(loc="upper right") + axs2.legend(loc="upper right") + + fig1.savefig(f"{output[i]}_x.pdf", bbox_inches="tight") + fig2.savefig(f"{output[i]}_z.pdf", bbox_inches="tight") + # plt.show() + + +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..30b81d5 --- /dev/null +++ b/src/scripts/plot_relative_error.py @@ -0,0 +1,83 @@ +## @file plot_relative_error.py +# +# @author Cory Alexander Balaton (coryab) +# @author Janita Ovidie Sandtrøen Willumsen (janitaws) +# +# @version 1.0 +# +# @brief Plot the relative error for forward Euler and RK4 method. +# +# @bug No known bugs + +import matplotlib.pyplot as plt +import numpy as np +import seaborn as sns + +sns.set_theme() +params = { + "font.family": "Serif", + "font.serif": "Roman", + "text.usetex": True, + "axes.titlesize": "large", + "axes.labelsize": "large", + "xtick.labelsize": "large", + "ytick.labelsize": "large", + "legend.fontsize": "medium" +} +plt.rcParams.update(params) + +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"$n_1$", + r"$n_2$", + r"$n_3$", + r"$n_4$", + ] + titles = [ + "(a)", + "(b)" + ] + methods = [ + "rk4", + "euler" + ] + colors = [ + "seagreen", + "darkred", + "darkgoldenrod", + "steelblue" + ] + fig1, axs1 = plt.subplots(2,1) + for i, (dir, title) in enumerate(list(zip(directories, titles))): + max_err = [] + for label, file, color in zip(labels, files, colors): + 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, color=color) + + 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.log2(max_err[i+1]/max_err[i])/np.log2(.5) for i in range(3)]) + print(f"{methods[i]}: {conv_rate}") + + plt.tight_layout() + fig1.savefig("../latex/images/relative_error.pdf", bbox_inches="tight") + + +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..52eb2f9 --- /dev/null +++ b/src/scripts/plot_single_particle.py @@ -0,0 +1,59 @@ +## @file plot_single_particle.py +# +# @author Cory Alexander Balaton (coryab) +# @author Janita Ovidie Sandtrøen Willumsen (janitaws) +# +# @version 1.0 +# +# @brief Plot the approximation and analytical solution for one particle +# in the z axis. +# +# @bug No known bugs + +import matplotlib.pyplot as plt +import numpy as np +import seaborn as sns + +sns.set_theme() +params = { + "font.family": "Serif", + "font.serif": "Roman", + "text.usetex": True, + "axes.titlesize": "large", + "axes.labelsize": "large", + "xtick.labelsize": "large", + "ytick.labelsize": "large", + "legend.fontsize": "medium" +} +plt.rcParams.update(params) + +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]) + + fig, ax = plt.subplots() + ax.plot(t, r[:, 2], label="approximation", color="mediumseagreen") + ax.plot(t, z(t), label="analytical", color="black", linestyle="dotted") + ax.set_xlabel(r"t $(\mu s)$") + ax.set_xlim((-5, 55)) + ax.set_ylabel(r"z $(\mu m)$") + ax.set_ylim((-25, 25)) + # plt.title(r"Movement of a single particle in the x direction") + ax.legend(loc="upper right") + fig.savefig("../latex/images/single_particle.pdf", bbox_inches="tight") + # plt.show() + + +if __name__ == "__main__": + main() diff --git a/src/test_suite.cpp b/src/test_suite.cpp index cd422c5..7a1e2ad 100644 --- a/src/test_suite.cpp +++ b/src/test_suite.cpp @@ -3,46 +3,51 @@ * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * - * @version 0.1 + * @version 1.0 * * @brief The test suite for the project * * @bug No known bugs * */ -#include "PenningTrap.hpp" -#include "utils.hpp" - #include #include #include -class PenningTrapTest { +#include "PenningTrap.hpp" +#include "constants.hpp" +#include "utils.hpp" + +/** @brief Test class for the Penning trap. + * */ +class PenningTrapTest +{ public: - static void test_external_E_field() + /** @brief Test that the external E field gives correct values. + * */ + void test_external_E_field() { PenningTrap trap; // Vector containing inputs and expected results - std::vector> tests; + std::vector> tests; + + tests.push_back(std::make_pair(vec3{0., 0., 0.}, vec3{0., 0., 0.})); tests.push_back( - std::make_pair(arma::vec{0., 0., 0.}, arma::vec{0., 0., 0.})); + std::make_pair(vec3{10., 0., 0.}, vec3{96.4852558, 0., 0.})); - tests.push_back(std::make_pair(arma::vec{10., 0., 0.}, - arma::vec{96.4852558, 0., 0.})); + tests.push_back( + std::make_pair(vec3{10., 0., 0.}, vec3{96.4852558, 0., 0.})); - tests.push_back(std::make_pair(arma::vec{10., 0., 0.}, - arma::vec{96.4852558, 0., 0.})); + tests.push_back( + std::make_pair(vec3{0., 10., 0.}, vec3{0., 96.4852558, 0.})); - tests.push_back(std::make_pair(arma::vec{0., 10., 0.}, - arma::vec{0., 96.4852558, 0.})); + tests.push_back( + std::make_pair(vec3{0., 0., 10.}, vec3{0., 0., -192.9705116})); - tests.push_back(std::make_pair(arma::vec{0., 0., 10.}, - arma::vec{0., 0., -192.9705116})); - - arma::vec result; - arma::vec v; + vec3 result; + vec3 v; std::stringstream msg; for (size_t i = 0; i < tests.size(); i++) { v = tests.at(i).first; @@ -52,81 +57,86 @@ public: msg << "Testing the external E field at (" << std::setprecision(2) << v(0) << "," << v(1) << "," << v(2) << ")."; - ASSERT(arma_vector_close_to(result, tests.at(i).second), msg.str()); + ASSERT(close_to(result, tests.at(i).second), msg.str()); } } - static void test_external_B_field() + /** @brief Test that the external B field gives correct values. + * */ + void test_external_B_field() { // No point in testing at different points since it's not dependent // on position. PenningTrap trap; - arma::vec expected{0., 0., T}; - arma::vec result = trap.external_B_field(arma::vec{0., 0., 0.}); - ASSERT(arma_vector_close_to(expected, result), + vec3 expected{0., 0., T}; + vec3 result = trap.external_B_field(vec3{0., 0., 0.}); + ASSERT(close_to(expected, result), "Testing the external B field at (0,0,0)"); } - static void test_force_on_particle() + /** @brief Test that the force between particles gives expected + * results. + * */ + void test_force_on_particle() { PenningTrap trap; - arma::vec v{0., 0., 0.}; + vec3 v{0., 0., 0.}; // Add particles to test - trap.add_particle(Particle(1., 40., arma::vec{0., 0., 0.}, v)); - trap.add_particle(Particle(1., 40., arma::vec{1., 0., 0.}, v)); - trap.add_particle(Particle(1., 40., arma::vec{0., 3., 4.}, v)); + trap.add_particle(Particle(vec3{0., 0., 0.}, v)); + trap.add_particle(Particle(vec3{1., 0., 0.}, v)); + trap.add_particle(Particle(vec3{0., 3., 4.}, v)); // Test p0 and p1 - arma::vec expected{-1., 0., 0.}; - arma::vec result = trap.force_on_particle(0, 1); - ASSERT(arma_vector_close_to(expected, result), + vec3 expected{-1., 0., 0.}; + vec3 result = trap.force_on_particle(0, 1); + ASSERT(close_to(expected, result), "Testing the force on a particle at (0,0,0) from a " "particle at (1,0,0)."); // Test p0 and p2 - expected = arma::vec{0, -.024, -.032}; + expected = vec3{0, -.024, -.032}; result = trap.force_on_particle(0, 2); - ASSERT(arma_vector_close_to(expected, result), + ASSERT(close_to(expected, result), "Testing the force on a particle at (0,0,0) from a " "particle at (0,3,4)."); } - static void test_total_force_external() + /** @brief Test that the total external force returns expected results + * */ + void test_total_force_external() { PenningTrap trap; - trap.add_particle( - Particle(1., 40., arma::vec{1., 2., 3.}, arma::vec{3., 4., 5.})); + trap.add_particle(Particle(vec3{1., 2., 3.}, vec3{3., 4., 5.})); - arma::vec expected{395.58954878, -270.15871624, -57.89115348}; - arma::vec result = trap.total_force_external(0); - ASSERT(arma_vector_close_to(expected, result), + vec3 expected{395.58954878, -270.15871624, -57.89115348}; + vec3 result = trap.total_force_external(0); + ASSERT(close_to(expected, result), "Testing the total external force on a particle at " "(1,2,3) with velocity (3,4,5)"); } - static void test_total_force_particles() + /** @brief Test that the total force of all particles on a single + * particle returns expected results. + * */ + void test_total_force_particles() { PenningTrap trap; - trap.add_particle( - Particle(1., 40., arma::vec{0., 0., 0.}, arma::vec{0., 0., 0.})); + trap.add_particle(Particle(vec3{0., 0., 0.}, vec3{0., 0., 0.})); - arma::vec expected{0., 0., 0.}; - arma::vec result = trap.total_force_particles(0); - ASSERT(arma_vector_close_to(expected, result), + vec3 expected{0., 0., 0.}; + vec3 result = trap.total_force_particles(0); + ASSERT(close_to(expected, result), "Testing the total force of all particles on particle 0 " "with only a single particle"); - trap.add_particle( - Particle(1., 40., arma::vec{1., 0., 0.}, arma::vec{0., 0., 0.})); - trap.add_particle( - Particle(1., 40., arma::vec{0., 1., 0.}, arma::vec{0., 0., 0.})); - trap.add_particle( - Particle(1., 40., arma::vec{0., 0., 1.}, arma::vec{0., 0., 0.})); + trap.add_particle(Particle(vec3{1., 0., 0.}, vec3{0., 0., 0.})); + trap.add_particle(Particle(vec3{0., 1., 0.}, vec3{0., 0., 0.})); + trap.add_particle(Particle(vec3{0., 0., 1.}, vec3{0., 0., 0.})); - expected = arma::vec(3, arma::fill::value(-3473.383325)); + expected = vec3().fill(-138935.333); result = trap.total_force_particles(0); - ASSERT(arma_vector_close_to(expected, result), + ASSERT(close_to(expected, result), "Testing the total force of all particles on particle 0 " "with 3 other particles."); } @@ -134,10 +144,11 @@ public: int main() { - PenningTrapTest::test_external_E_field(); - PenningTrapTest::test_external_B_field(); - PenningTrapTest::test_force_on_particle(); - PenningTrapTest::test_total_force_external(); - PenningTrapTest::test_total_force_particles(); + PenningTrapTest test; + test.test_external_E_field(); + test.test_external_B_field(); + test.test_force_on_particle(); + test.test_total_force_external(); + test.test_total_force_particles(); return 0; } diff --git a/src/utils.cpp b/src/utils.cpp index 14670f0..ca2d50d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -10,8 +10,6 @@ * @bug No known bugs * */ -#include - #include "utils.hpp" std::string scientific_format(double d, int width, int prec) @@ -34,8 +32,7 @@ static void print_message(std::string msg) { if (msg.size() > 0) { std::cout << "message: " << msg << "\n\n"; - } - else { + } else { std::cout << "\n"; } } @@ -49,8 +46,7 @@ void m_assert(bool expr, std::string expr_str, std::string f, std::string file, if (expr) { std::cout << "\x1B[32mOK\033[0m\n"; print_message(msg); - } - else { + } else { std::cout << "\x1B[31mFAIL\033[0m\n"; print_message(msg); std::cout << file << " " << line << ": Assertion \"" << expr_str @@ -59,7 +55,7 @@ void m_assert(bool expr, std::string expr_str, std::string f, std::string file, } } -bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol) +bool close_to(arma::vec &a, arma::vec &b, double tol) { if (a.n_elem != b.n_elem) { return false; @@ -87,11 +83,11 @@ bool mkpath(std::string path, int mode) 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) { + if (mkdir(cur_dir.c_str(), mode) != 0 + && stat(cur_dir.c_str(), &buf) != 0) { return -1; } - } - else { + } else { break; } }