diff --git a/.gitignore b/.gitignore index 2cdfb30..b3816d1 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,6 @@ *.out *.synctex.gz *.bbl -*.blg latex/mainNotes.bib diff --git a/README.md b/README.md index eabf24f..e6614ba 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,29 @@ If you have any problems running the scripts, you might have to run this instead 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 diff --git a/docs/100_particles.gif b/docs/100_particles.gif index 53eb275..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 e5f553c..d825cb9 100644 --- a/docs/Particle_8cpp.html +++ b/docs/Particle_8cpp.html @@ -113,7 +113,7 @@ $(document).ready(function(){initNavTree('Particle_8cpp.html',''); initResizable
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file Particle.cpp.

diff --git a/docs/PenningTrap_8cpp.html b/docs/PenningTrap_8cpp.html index f90f9c5..9ca258f 100644 --- a/docs/PenningTrap_8cpp.html +++ b/docs/PenningTrap_8cpp.html @@ -104,12 +104,12 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp.html',''); initResiza

The implementation of the PenningTrap class. More...

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

Go to the source code of this file.

Detailed Description

@@ -118,7 +118,7 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp.html',''); initResiza
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file PenningTrap.cpp.

diff --git a/docs/PenningTrap_8cpp_source.html b/docs/PenningTrap_8cpp_source.html index 7a2c773..eff147a 100644 --- a/docs/PenningTrap_8cpp_source.html +++ b/docs/PenningTrap_8cpp_source.html @@ -102,351 +102,367 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp_source.html',''); ini
Go to the documentation of this file.
1
-
13#include "PenningTrap.hpp"
-
14#include "typedefs.hpp"
-
15#include <algorithm>
-
16#include <functional>
-
17#include <sys/types.h>
-
18#include <vector>
-
19
-
20vec3 PenningTrap::v_func(uint i, uint j, double dt)
-
21{
-
22 switch (i) {
-
23 case 0:
-
24 return .5 * dt * this->k_v[0][j];
-
25 case 1:
-
26 return .5 * dt * this->k_v[1][j];
-
27 case 2:
-
28 return dt * this->k_v[2][j];
-
29 case 3:
-
30 return vec3((dt / 6.)
-
31 * (this->k_v[0][j] + 2. * this->k_v[1][j]
-
32 + 2. * this->k_v[2][j] + this->k_v[3][j]));
-
33 default:
-
34 std::cout << "Not valid!" << std::endl;
-
35 abort();
-
36 }
-
37}
-
38
-
39vec3 PenningTrap::r_func(uint i, uint j, double dt)
-
40{
-
41 switch (i) {
-
42 case 0:
-
43 return .5 * dt * this->k_r[0][j];
-
44 case 1:
-
45 return .5 * dt * this->k_r[1][j];
-
46 case 2:
-
47 return dt * this->k_r[2][j];
-
48 case 3:
-
49 return vec3((dt / 6.)
-
50 * (this->k_r[0][j] + 2. * this->k_r[1][j]
-
51 + 2. * this->k_r[2][j] + this->k_r[3][j]));
-
52 default:
-
53 std::cout << "Not valid!" << std::endl;
-
54 abort();
-
55 }
-
56}
-
57
- -
59{
-
60 r(2) *= -2.;
-
61
-
62 return vec3((this->V_0 * this->perturbation(this->t) / (this->d * this->d))
-
63 * r);
-
64}
-
65
- -
67{
-
68 return vec3{0., 0., this->B_0};
-
69}
-
70
- -
72{
-
73 // Calculate the difference between the particles' position
-
74 vec3 res = this->particles[i].r_vec - this->particles[j].r_vec;
-
75
-
76 // Get the distance between the particles
-
77 double norm = arma::norm(res, 2);
-
78
-
79 return vec3((this->particles[j].q / (norm * norm * norm)) * res);
-
80}
-
81
- -
83{
-
84 Particle *p = &this->particles[i];
-
85
-
86 if (arma::norm(p->r_vec) > this->d) {
-
87 return vec3{0., 0., 0.};
-
88 }
-
89
-
90 return vec3(p->q
-
91 * (this->external_E_field(p->r_vec)
-
92 + arma::cross(p->v_vec, this->external_B_field(p->r_vec))));
-
93}
-
94
- -
96{
-
97 vec3 res;
-
98
-
99 for (size_t j = 0; j < this->particles.size(); j++) {
-
100 if (i != j)
-
101 res += this->force_on_particle(i, j);
-
102 }
+
13#include <algorithm>
+
14#include <functional>
+
15#include <sys/types.h>
+
16#include <vector>
+
17
+
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
+
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
+ +
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
-
104 return vec3(res * (K_E * this->particles[i].q));
-
105}
-
106
- -
108{
-
109 if (arma::norm(this->particles[i].r_vec) > this->d) {
-
110 return vec3{0., 0., 0.};
-
111 }
-
112 return vec3(this->total_force_external(i) - this->total_force_particles(i));
-
113}
-
114
-
115PenningTrap::PenningTrap(double B_0, double V_0, double d, double t)
-
116{
-
117 this->B_0 = B_0;
-
118 this->V_0 = V_0;
-
119 this->d = d;
-
120 this->t = t;
-
121 this->perturbation = [](double t) { return 1.; };
-
122}
-
123
-
124PenningTrap::PenningTrap(uint i, double B_0, double V_0, double d, double t)
-
125 : PenningTrap::PenningTrap(B_0, V_0, d)
-
126{
-
127 for (size_t j = 0; j < i; j++) {
-
128 this->particles.push_back(
-
129 Particle(vec3(vec3().randn() * .1 * this->d),
-
130 vec3(vec3().randn() * .1 * this->d)));
-
131 }
-
132}
-
133
-
134PenningTrap::PenningTrap(std::vector<Particle> particles, double B_0,
-
135 double V_0, double d, double t)
-
136 : PenningTrap::PenningTrap(B_0, V_0, d)
-
137{
-
138 this->particles = particles;
-
139}
-
140
-
141void PenningTrap::set_pertubation(double f, double omega_V)
+ +
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
+
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->perturbation = [f, omega_V](double t) {
-
144 return 1 + f * std::cos(omega_V * t);
-
145 };
-
146}
-
147
-
148void PenningTrap::reinitialize(double f, double omega_V, double t)
-
149{
-
150 this->t = t;
-
151 this->set_pertubation(f, omega_V);
+
143 this->particles = particles;
+
144}
+
145
+
146void PenningTrap::set_pertubation(double f, double omega_V)
+
147{
+
148 this->perturbation = [f, omega_V](double t) {
+
149 return 1 + f * std::cos(omega_V * t);
+
150 };
+
151}
152
-
153 for (size_t i = 0; i < this->particles.size(); i++) {
-
154 this->particles[i].r_vec = vec3().randn() * .1 * this->d;
-
155 }
-
156}
-
157
- -
159{
-
160 this->particles.push_back(particle);
-
161}
-
162
-
163void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
-
164{
+
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
-
166 std::vector<Particle> original_particles = this->particles;
-
167 std::vector<Particle> tmp_particles = this->particles;
-
168
-
169 vec3 (PenningTrap::*force)(uint) = particle_interaction
- - -
172
-
173 size_t size = this->particles.size();
+ +
167{
+
168 this->particles.push_back(particle);
+
169}
+
170
+
171void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
+
172{
+
173 Particle *p;
174
-
175 // Allocating takes a long time, so reuse sim_arr if possible
-
176 if (this->k_v.size() != 4 || this->k_r.size() != 4
-
177 || this->k_v[0].size() != size || this->k_r[0].size() != size) {
-
178 this->k_v = sim_arr(4, sim_cols(size));
-
179 this->k_r = sim_arr(4, sim_cols(size));
-
180 }
-
181
-
182 // Each k_{i+1} is dependent on k_i, so outer loop is not parallelizable
-
183 for (size_t i = 0; i < 4; i++) {
-
184 // Inner loop is able to be parallelized
-
185#pragma omp parallel for
-
186 for (size_t j = 0; j < size; j++) {
-
187 this->k_v[i][j] = (this->*force)(j) / this->particles[j].m;
-
188 this->k_r[i][j] = this->particles[j].v_vec;
-
189
-
190 tmp_particles[j].v_vec =
-
191 original_particles[j].v_vec + this->v_func(i, j, dt);
-
192 tmp_particles[j].r_vec =
-
193 original_particles[j].r_vec + this->r_func(i, j, dt);
-
194 }
-
195 this->particles = tmp_particles;
-
196 }
-
197
-
198 this->t += dt;
-
199}
-
200
-
201void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction)
-
202{
-
203 size_t size = this->particles.size();
-
204 vec3 force_res[size];
-
205
-
206 vec3 (PenningTrap::*force)(uint) = particle_interaction
- - -
209
-
210 // Calculating the force for each particle is independent and therefore
-
211 // a good candidate for parallel execution
-
212#pragma omp parallel for
-
213 for (size_t i = 0; i < size; i++) {
-
214 force_res[i] = (this->*force)(i);
-
215 }
+
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 // 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 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
+
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 // Updating the particles is also independent, so we can parallelize
-
218 // this as well
-
219#pragma omp parallel for
-
220 for (size_t i = 0; i < size; i++) {
-
221 this->particles[i].r_vec += dt * this->particles[i].v_vec;
-
222 this->particles[i].v_vec += dt * force_res[i] / this->particles[i].m;
-
223 }
-
224
-
225 this->t += dt;
-
226}
+
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
-
228simulation_t PenningTrap::simulate(double time, uint steps, std::string method,
-
229 bool particle_interaction)
-
230{
-
231 double dt = time / (double)steps;
-
232
-
233 uint size = this->particles.size();
-
234
-
235 simulation_t res{sim_arr(size, sim_cols(steps)),
-
236 sim_arr(size, sim_cols(steps))};
-
237
-
238 void (PenningTrap::*func)(double, bool);
-
239 if (method == "rk4") {
- -
241 } else if (method == "euler") {
- -
243 } else {
-
244 std::cout << "Not a valid method!" << std::endl;
-
245 abort();
-
246 }
+
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 this->t += dt;
+
238}
+
239
+
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 for (size_t j = 0; j < steps; j++) {
-
249 for (size_t i = 0; i < size; i++) {
-
250 res.r_vecs[i][j] = this->particles[i].r_vec;
-
251 res.v_vecs[i][j] = this->particles[i].v_vec;
-
252 }
-
253 (this->*func)(dt, particle_interaction);
-
254 }
-
255
-
256 return res;
-
257}
-
258
-
259void PenningTrap::write_simulation_to_dir(std::string path, double time,
-
260 uint steps, std::string method,
-
261 bool particle_interaction)
-
262{
-
263 if (path.back() != '/') {
-
264 path += '/';
-
265 }
-
266 if (mkpath(path, 0777) != 0) {
-
267 std::cout << "Failed to make path" << std::endl;
-
268 abort();
-
269 }
-
270
-
271 simulation_t res =
-
272 this->simulate(time, steps, method, particle_interaction);
-
273
-
274 std::ofstream ofile;
-
275
-
276 // Writing each particle to its own file is independent and can be run in
-
277 // parallel.
-
278#pragma omp parallel for private(ofile)
-
279 for (size_t i = 0; i < this->particles.size(); i++) {
-
280 ofile.open(path + "particle_" + std::to_string(i) + "_r.txt");
-
281 for (vec3 &vec : res.r_vecs[i]) {
-
282 ofile << scientific_format(vec(0), 10, 8) << ','
-
283 << scientific_format(vec(1), 10, 8) << ','
-
284 << scientific_format(vec(2), 10, 8) << '\n';
-
285 }
-
286 ofile.close();
-
287 ofile.open(path + "particle_" + std::to_string(i) + "_v.txt");
-
288 for (vec3 &vec : res.v_vecs[i]) {
-
289 ofile << scientific_format(vec(0), 10, 8) << ','
-
290 << scientific_format(vec(1), 10, 8) << ','
-
291 << scientific_format(vec(2), 10, 8) << '\n';
-
292 }
-
293 ofile.close();
-
294 }
-
295}
-
296
-
297double PenningTrap::fraction_of_particles_left(double time, uint steps,
-
298 std::string method,
-
299 bool particle_interaction)
-
300{
-
301 double dt = time / (double)steps;
-
302
-
303 void (PenningTrap::*func)(double, bool);
-
304 if (method == "rk4") {
- -
306 } else if (method == "euler") {
- -
308 } else {
-
309 std::cout << "Not a valid method!" << std::endl;
-
310 abort();
-
311 }
-
312
-
313 for (size_t j = 0; j < steps; j++) {
-
314 (this->*func)(dt, particle_interaction);
-
315 }
+
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 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 int particles_left = 0;
-
318
-
319 // A reduction is perfect here
-
320#pragma omp parallel for reduction(+ : particles_left)
-
321 for (size_t i = 0; i < this->particles.size(); i++) {
-
322 if (arma::norm(this->particles[i].r_vec) < this->d) {
-
323 particles_left++;
-
324 }
+
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 return (double)particles_left / (double)this->particles.size();
-
328}
+
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: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:82
+
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:95
-
vec3 external_B_field(vec3 r)
Calculate B at point r.
Definition: PenningTrap.cpp:66
-
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:20
-
vec3 external_E_field(vec3 r)
Calculate E at point r.
Definition: PenningTrap.cpp:58
-
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_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.
+
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:71
-
vec3 r_func(uint i, uint j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:39
+
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.
+
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
diff --git a/docs/PenningTrap_8hpp_source.html b/docs/PenningTrap_8hpp_source.html index 50f6910..9c94007 100644 --- a/docs/PenningTrap_8hpp_source.html +++ b/docs/PenningTrap_8hpp_source.html @@ -147,66 +147,69 @@ $(document).ready(function(){initNavTree('PenningTrap_8hpp_source.html',''); ini
125
132 vec3 total_force(uint i);
133
-
134public:
-
142 PenningTrap(double B_0 = T, double V_0 = (25. * V) / 1000., double d = 500.,
-
143 double t = 0.);
-
144
-
153 PenningTrap(uint i, double B_0 = T, double V_0 = (25. * V) / 1000.,
-
154 double d = 500., double t = 0.);
-
155
-
164 PenningTrap(std::vector<Particle> particles, double B_0 = T,
-
165 double V_0 = (25. * V) / 1000., double d = 500., double t = 0.);
-
166
-
172 void set_pertubation(double f, double omega_V);
-
173
-
180 void reinitialize(double f, double omega_V, double t = 0.);
+ +
141
+
142public:
+
150 PenningTrap(double B_0 = T, double V_0 = (25. * V) / 1000., double d = 500.,
+
151 double t = 0.);
+
152
+
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
-
186 void add_particle(Particle particle);
-
187
-
193 void evolve_RK4(double dt, bool particle_interaction = true);
-
194
-
200 void evolve_forward_euler(double dt, bool particle_interaction = true);
-
201
-
212 simulation_t simulate(double time, uint steps, std::string method = "rk4",
-
213 bool particle_interaction = true);
-
214
-
223 void write_simulation_to_dir(std::string path, double time, uint steps,
-
224 std::string method = "rk4",
-
225 bool particle_interaction = true);
-
226
-
237 double fraction_of_particles_left(double time, uint steps,
-
238 std::string method = "rk4",
-
239 bool particle_interaction = true);
-
240
-
241};
-
242
-
243#endif
+
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: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:82
+
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:95
-
vec3 external_B_field(vec3 r)
Calculate B at point r.
Definition: PenningTrap.cpp:66
-
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:20
-
vec3 external_E_field(vec3 r)
Calculate E at point r.
Definition: PenningTrap.cpp:58
+
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.
+
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:71
-
vec3 r_func(uint i, uint j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:39
+
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.
+
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.
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 6367e48..d99bdbd 100644 --- a/docs/animate__100__particles_8py_source.html +++ b/docs/animate__100__particles_8py_source.html @@ -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}_r.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/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/classPenningTrap-members.html b/docs/classPenningTrap-members.html index f7e9ce3..7e5d5c4 100644 --- a/docs/classPenningTrap-members.html +++ b/docs/classPenningTrap-members.html @@ -128,10 +128,11 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza tPenningTrapprivate total_force(uint i)PenningTrapprivate total_force_external(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 + 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 3cac359..8879bd4 100644 --- a/docs/classPenningTrap.html +++ b/docs/classPenningTrap.html @@ -175,6 +175,9 @@ Private Member Functions 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
+  @@ -264,7 +267,7 @@ Friends -

Definition at line 115 of file PenningTrap.cpp.

+

Definition at line 120 of file PenningTrap.cpp.

@@ -324,7 +327,7 @@ Friends -

Definition at line 124 of file PenningTrap.cpp.

+

Definition at line 129 of file PenningTrap.cpp.

@@ -384,7 +387,7 @@ Friends -

Definition at line 134 of file PenningTrap.cpp.

+

Definition at line 139 of file PenningTrap.cpp.

@@ -413,7 +416,7 @@ Friends -

Definition at line 158 of file PenningTrap.cpp.

+

Definition at line 166 of file PenningTrap.cpp.

@@ -452,7 +455,7 @@ Friends -

Definition at line 201 of file PenningTrap.cpp.

+

Definition at line 211 of file PenningTrap.cpp.

@@ -491,7 +494,7 @@ Friends -

Definition at line 163 of file PenningTrap.cpp.

+

Definition at line 171 of file PenningTrap.cpp.

@@ -528,7 +531,7 @@ Friends
Returns
vec3
-

Definition at line 66 of file PenningTrap.cpp.

+

Definition at line 67 of file PenningTrap.cpp.

@@ -565,7 +568,7 @@ Friends
Returns
vec3
-

Definition at line 58 of file PenningTrap.cpp.

+

Definition at line 59 of file PenningTrap.cpp.

@@ -614,7 +617,7 @@ Friends
Returns
vec3
-

Definition at line 71 of file PenningTrap.cpp.

+

Definition at line 72 of file PenningTrap.cpp.

@@ -668,7 +671,7 @@ Friends
Returns
double
-

Definition at line 297 of file PenningTrap.cpp.

+

Definition at line 311 of file PenningTrap.cpp.

@@ -724,7 +727,7 @@ Friends
Returns
vec3
-

Definition at line 39 of file PenningTrap.cpp.

+

Definition at line 40 of file PenningTrap.cpp.

@@ -769,7 +772,7 @@ Friends -

Definition at line 148 of file PenningTrap.cpp.

+

Definition at line 153 of file PenningTrap.cpp.

@@ -807,7 +810,7 @@ Friends -

Definition at line 141 of file PenningTrap.cpp.

+

Definition at line 146 of file PenningTrap.cpp.

@@ -861,7 +864,7 @@ Friends
Returns
simulation_t
-

Definition at line 228 of file PenningTrap.cpp.

+

Definition at line 240 of file PenningTrap.cpp.

@@ -898,7 +901,7 @@ Friends
Returns
vec3
-

Definition at line 107 of file PenningTrap.cpp.

+

Definition at line 104 of file PenningTrap.cpp.

@@ -936,7 +939,44 @@ Friends
Returns
vec3
-

Definition at line 82 of file PenningTrap.cpp.

+

Definition at line 83 of file PenningTrap.cpp.

+ + + + +

◆ total_force_no_interaction()

+ +
+
+

Private Attributes

+ + + + +
+ + + + + + + + +
vec3 PenningTrap::total_force_no_interaction (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.

@@ -973,7 +1013,7 @@ Friends
Returns
vec3
-

Definition at line 95 of file PenningTrap.cpp.

+

Definition at line 92 of file PenningTrap.cpp.

@@ -1029,7 +1069,7 @@ Friends
Returns
vec3
-

Definition at line 20 of file PenningTrap.cpp.

+

Definition at line 21 of file PenningTrap.cpp.

@@ -1089,7 +1129,7 @@ Friends -

Definition at line 259 of file PenningTrap.cpp.

+

Definition at line 273 of file PenningTrap.cpp.

diff --git a/docs/classPenningTrap.js b/docs/classPenningTrap.js index 6e5d013..38310ad 100644 --- a/docs/classPenningTrap.js +++ b/docs/classPenningTrap.js @@ -16,6 +16,7 @@ var classPenningTrap = [ "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 ], diff --git a/docs/dir_634e799a3947388232110823971192a8.html b/docs/dir_634e799a3947388232110823971192a8.html index 95b55e3..6e5a151 100644 --- a/docs/dir_634e799a3947388232110823971192a8.html +++ b/docs/dir_634e799a3947388232110823971192a8.html @@ -104,19 +104,26 @@ $(document).ready(function(){initNavTree('dir_634e799a3947388232110823971192a8.h - + + - + + - + + - + + - + + - + + - + +

Files

file  animate_100_particles.py [code]
file  animate_100_particles.py [code]
 Animate 100 particles.
 
file  plot_2_particles.py [code]
file  plot_2_particles.py [code]
 Plot 2 particles with and without particle interactions in the xy-plane.
 
file  plot_3d.py [code]
file  plot_3d.py [code]
 Plot 2 particles with and without particle interactions in 3D.
 
file  plot_particles_left.py [code]
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]
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]
file  plot_relative_error.py [code]
 Plot the relative error for forward Euler and RK4 method.
 
file  plot_single_particle.py [code]
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 index f6030ae..e1f93d8 100644 --- a/docs/dir_634e799a3947388232110823971192a8.js +++ b/docs/dir_634e799a3947388232110823971192a8.js @@ -1,10 +1,10 @@ var dir_634e799a3947388232110823971192a8 = [ - [ "animate_100_particles.py", "animate__100__particles_8py_source.html", null ], - [ "plot_2_particles.py", "plot__2__particles_8py_source.html", null ], - [ "plot_3d.py", "plot__3d_8py_source.html", null ], - [ "plot_particles_left.py", "plot__particles__left_8py_source.html", null ], - [ "plot_phase_space.py", "plot__phase__space_8py_source.html", null ], - [ "plot_relative_error.py", "plot__relative__error_8py_source.html", null ], - [ "plot_single_particle.py", "plot__single__particle_8py_source.html", null ] + [ "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 a595b88..ef64c5f 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -109,6 +109,9 @@ Directories + + + diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js index b85a8c3..702a957 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js @@ -1,6 +1,7 @@ var dir_68267d1309a1af8e8297ef4c3efbcdba = [ [ "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 ], diff --git a/docs/files.html b/docs/files.html index 0176ee4..e40fb96 100644 --- a/docs/files.html +++ b/docs/files.html @@ -111,18 +111,19 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); }); - - - - - - - - - - - - + + + + + + + + + + + + +

Files

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.
 
 utils.hppFunction prototypes and macros that are useful
  src
  scripts
 animate_100_particles.py
 plot_2_particles.py
 plot_3d.py
 plot_particles_left.py
 plot_phase_space.py
 plot_relative_error.py
 plot_single_particle.py
 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
 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 86b463b..ff9a215 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -176,6 +176,7 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable();
  • test_total_force_particles() : PenningTrapTest
  • total_force() : PenningTrap
  • total_force_external() : PenningTrap
  • +
  • total_force_no_interaction() : PenningTrap
  • total_force_particles() : PenningTrap
  • diff --git a/docs/functions_func.html b/docs/functions_func.html index 1b82d50..e821456 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -119,6 +119,7 @@ $(document).ready(function(){initNavTree('functions_func.html',''); initResizabl
  • 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/globals.html b/docs/globals.html index 23a1b12..98cafee 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -137,8 +137,8 @@ $(document).ready(function(){initNavTree('globals.html',''); initResizable(); })

    - p -

    diff --git a/docs/globals_func.html b/docs/globals_func.html index 376c50c..5d664cd 100644 --- a/docs/globals_func.html +++ b/docs/globals_func.html @@ -103,8 +103,8 @@ $(document).ready(function(){initNavTree('globals_func.html',''); initResizable(
  • close_to() : utils.hpp, utils.cpp
  • m_assert() : utils.hpp, utils.cpp
  • mkpath() : utils.hpp, utils.cpp
  • -
  • potential_resonance_narrow_sweep() : main.cpp
  • -
  • potential_resonance_narrow_sweep_interaction() : main.cpp
  • +
  • potential_resonance_narrow_sweep() : frequency_narrow_sweeps_long.cpp, main.cpp
  • +
  • potential_resonance_narrow_sweep_interaction() : frequency_narrow_sweeps_long.cpp, main.cpp
  • potential_resonance_wide_sweep() : main.cpp
  • scientific_format() : utils.hpp, utils.cpp
  • simulate_100_particles() : main.cpp
  • diff --git a/docs/index.html b/docs/index.html index b9d7673..4015ebb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -126,6 +126,16 @@ Operating systems

    +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:

    + +

    +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 5edc69f..dab738a 100644 --- a/docs/main_8cpp.html +++ b/docs/main_8cpp.html @@ -173,7 +173,7 @@ Variables
    Janita Ovidie Sandtrøen Willumsen (janitaws)
    Version
    1.0
    -
    Bug:
    No known bugs
    +
    Bug:
    No known bugs

    Definition in file main.cpp.

    Macro Definition Documentation

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

    Definition at line 309 of file main.cpp.

    +

    Definition at line 314 of file main.cpp.

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

    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 206 of file main.cpp.

    +

    Definition at line 209 of file main.cpp.

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

    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 262 of file main.cpp.

    +

    Definition at line 266 of file main.cpp.

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

    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 149 of file main.cpp.

    +

    Definition at line 152 of file main.cpp.

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

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

    -

    Definition at line 132 of file main.cpp.

    +

    Definition at line 134 of file main.cpp.

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

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

    -

    Definition at line 54 of file main.cpp.

    +

    Definition at line 55 of file main.cpp.

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

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

    -

    Definition at line 87 of file main.cpp.

    +

    Definition at line 88 of file main.cpp.

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

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

    -

    Definition at line 69 of file main.cpp.

    +

    Definition at line 70 of file main.cpp.

    diff --git a/docs/main_8cpp_source.html b/docs/main_8cpp_source.html index ecc9633..22654cb 100644 --- a/docs/main_8cpp_source.html +++ b/docs/main_8cpp_source.html @@ -128,317 +128,367 @@ $(document).ready(function(){initNavTree('main_8cpp_source.html',''); initResiza
    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::complex<double> f =
    -
    46 A_p * std::exp(std::complex<double>(0., -w_p * t))
    -
    47 + A_n * std::exp(std::complex<double>(0., -w_n * t));
    -
    48 vec3 res{std::real(f), std::imag(f), 20. * std::cos(std::sqrt(w_z2) * t)};
    -
    49 return res;
    -
    50}
    -
    51
    -
    54void simulate_single_particle()
    -
    55{
    -
    56 // Initialize trap with particle 1
    -
    57 PenningTrap trap(std::vector<Particle>{p1});
    -
    58
    -
    59 double time = 50.; // microseconds
    -
    60
    -
    61 // Simulate and write results to file
    -
    62 trap.write_simulation_to_dir("output/simulate_single_particle", time, N,
    -
    63 "rk4", false);
    -
    64}
    -
    65
    -
    69void simulate_two_particles()
    -
    70{
    -
    71 // Initialize traps with particles
    -
    72 PenningTrap trap_no_interaction(std::vector<Particle>{p1, p2});
    -
    73 PenningTrap trap_with_interaction(std::vector<Particle>{p1, p2});
    -
    74
    -
    75 double time = 50.; // microseconds
    -
    76
    -
    77 // Simulate and write results to files
    -
    78 trap_no_interaction.write_simulation_to_dir(
    -
    79 "output/simulate_2_particles/no_interaction", time, N, "rk4", false);
    -
    80 trap_with_interaction.write_simulation_to_dir(
    -
    81 "output/simulate_2_particles/with_interaction", time, N);
    -
    82}
    -
    83
    -
    87void simulate_single_particle_with_different_steps()
    -
    88{
    -
    89 double time = 50.; // microseconds
    -
    90
    -
    91 std::ofstream ofile;
    -
    92
    -
    93 // Calculate relative error for RK4
    -
    94 std::string path = "output/relative_error/RK4/";
    -
    95 mkpath(path);
    -
    96#pragma omp parallel for
    -
    97 for (int i = 0; i < 4; i++) {
    -
    98 int steps = 4000 * std::pow(2, i);
    -
    99 double dt = time / (double)steps;
    -
    100 ofile.open(path + std::to_string(steps) + "_steps.txt");
    -
    101 PenningTrap trap(std::vector<Particle>{p1});
    -
    102 simulation_t res = trap.simulate(time, steps, "rk4", false);
    -
    103 for (int i = 0; i < steps; i++) {
    -
    104 ofile << arma::norm(res.r_vecs[0][i]
    -
    105 - analytical_solution_particle_1(dt * i))
    -
    106 << '\n';
    -
    107 }
    -
    108 ofile.close();
    -
    109 }
    -
    110
    -
    111 // Calculate relative error for forward Euler
    -
    112 path = "output/relative_error/euler/";
    -
    113 mkpath(path);
    -
    114#pragma omp parallel for
    -
    115 for (int i = 0; i < 4; i++) {
    -
    116 int steps = 4000 * std::pow(2, i);
    -
    117 double dt = time / (double)steps;
    -
    118 ofile.open(path + std::to_string(steps) + "_steps.txt");
    -
    119 PenningTrap trap(std::vector<Particle>{p1});
    -
    120 simulation_t res = trap.simulate(time, steps, "euler", false);
    -
    121 for (int i = 0; i < steps; i++) {
    -
    122 ofile << arma::norm(res.r_vecs[0][i]
    -
    123 - analytical_solution_particle_1(dt * i))
    -
    124 << '\n';
    -
    125 }
    -
    126 ofile.close();
    -
    127 }
    -
    128}
    -
    129
    -
    132void simulate_100_particles()
    -
    133{
    -
    134 PenningTrap trap((unsigned)100);
    -
    135
    -
    136 double time = 50.; // microseconds
    +
    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
    +
    55void simulate_single_particle()
    +
    56{
    +
    57 // Initialize trap with particle 1
    +
    58 PenningTrap trap(std::vector<Particle>{p1});
    +
    59
    +
    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
    +
    70void simulate_two_particles()
    +
    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
    +
    88void simulate_single_particle_with_different_steps()
    +
    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]
    +
    107 - analytical_solution_particle_1(dt * 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]
    +
    125 - analytical_solution_particle_1(dt * i))
    +
    126 << '\n';
    +
    127 }
    +
    128 ofile.close();
    +
    129 }
    +
    130}
    +
    131
    +
    134void simulate_100_particles()
    +
    135{
    +
    136 PenningTrap trap((unsigned)100);
    137
    -
    138 trap.write_simulation_to_dir("output/simulate_100_particles", time, N,
    -
    139 "rk4", false);
    -
    140}
    -
    141
    -
    149void potential_resonance_wide_sweep()
    -
    150{
    -
    151 double time = 500.;
    -
    152
    -
    153 double amplitudes[]{.1, .4, .7};
    -
    154
    -
    155 double freq_start = .2;
    -
    156 double freq_end = 2.5;
    -
    157 double freq_increment = .02;
    -
    158 size_t freq_iterations =
    -
    159 (size_t)((freq_end - freq_start) / freq_increment) + 1;
    -
    160
    -
    161 double res[4][freq_iterations];
    -
    162
    -
    163 std::string path = "output/time_dependent_potential/";
    -
    164 mkpath(path);
    +
    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
    +
    152void potential_resonance_wide_sweep()
    +
    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::ofstream ofile;
    -
    167
    -
    168#pragma omp parallel for
    -
    169 // Insert frequencies
    -
    170 for (size_t i = 0; i < freq_iterations; i++) {
    -
    171 res[0][i] = freq_start + freq_increment * i;
    -
    172 }
    -
    173
    -
    174#pragma omp parallel
    -
    175 {
    -
    176 // Each thread creates a PenningTrap instance and reuses it throughout
    -
    177 // the sweep.
    -
    178 PenningTrap trap((uint)100);
    -
    179#pragma omp for collapse(2)
    -
    180 for (size_t i = 0; i < 3; i++) {
    -
    181 for (size_t j = 0; j < freq_iterations; j++) {
    -
    182 // Reset particles and give new time dependent potential.
    -
    183 trap.reinitialize(amplitudes[i], res[0][j]);
    -
    184 res[i + 1][j] =
    -
    185 trap.fraction_of_particles_left(time, N, "rk4", false);
    -
    186 }
    -
    187 }
    -
    188 }
    -
    189
    -
    190 // Write results to file
    -
    191 ofile.open(path + "wide_sweep.txt");
    -
    192 for (size_t i = 0; i < freq_iterations; i++) {
    -
    193 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
    -
    194 << res[3][i] << '\n';
    -
    195 }
    -
    196 ofile.close();
    -
    197}
    -
    198
    -
    206void potential_resonance_narrow_sweep()
    -
    207{
    -
    208 double time = 500.;
    -
    209
    -
    210 double amplitudes[]{.1, .4, .7};
    -
    211
    -
    212 double freq_start = 1.;
    -
    213 double freq_end = 1.7;
    -
    214 double freq_increment = .002;
    -
    215 size_t freq_iterations = (size_t)((freq_end - freq_start) / freq_increment);
    -
    216
    -
    217 double res[4][freq_iterations];
    -
    218
    -
    219 std::string path = "output/time_dependent_potential/";
    -
    220 mkpath(path);
    -
    221
    -
    222 std::ofstream ofile;
    -
    223
    -
    224#pragma omp parallel for
    -
    225 // Insert frequencies
    -
    226 for (size_t i = 0; i < freq_iterations; i++) {
    -
    227 res[0][i] = freq_start + freq_increment * i;
    -
    228 }
    -
    229
    -
    230#pragma omp parallel
    -
    231 {
    -
    232 // Each thread creates a PenningTrap instance and reuses it throughout
    -
    233 // the sweep.
    -
    234 PenningTrap trap((uint)100);
    -
    235#pragma omp for collapse(2)
    -
    236 for (size_t i = 0; i < 3; i++) {
    -
    237 for (size_t j = 0; j < freq_iterations; j++) {
    -
    238 // Reset particles and give new time dependent potential.
    -
    239 trap.reinitialize(amplitudes[i], res[0][j]);
    -
    240 res[i + 1][j] =
    -
    241 trap.fraction_of_particles_left(time, N, "rk4", false);
    -
    242 }
    -
    243 }
    -
    244 }
    -
    245
    -
    246 // Write results to file
    -
    247 ofile.open(path + "narrow_sweep.txt");
    -
    248 for (size_t i = 0; i < freq_iterations; i++) {
    -
    249 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
    -
    250 << res[3][i] << '\n';
    -
    251 }
    -
    252 ofile.close();
    -
    253}
    -
    254
    -
    262void potential_resonance_narrow_sweep_interaction()
    -
    263{
    -
    264 double time = 500.;
    -
    265
    -
    266 double amplitudes[]{.1, .4, .7};
    -
    267
    -
    268 double freq_start = 1.;
    -
    269 double freq_end = 1.7;
    -
    270 double freq_increment = .002;
    -
    271 size_t freq_iterations = (size_t)((freq_end - freq_start) / freq_increment);
    -
    272
    -
    273 double res[4][freq_iterations];
    -
    274
    -
    275 std::string path = "output/time_dependent_potential/";
    -
    276 mkpath(path);
    +
    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
    +
    209void potential_resonance_narrow_sweep()
    +
    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
    +
    266void potential_resonance_narrow_sweep_interaction()
    +
    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 std::ofstream ofile;
    +
    278 double res[4][freq_iterations];
    279
    -
    280#pragma omp parallel for
    -
    281 for (size_t i = 0; i < freq_iterations; i++) {
    -
    282 res[0][i] = freq_start + freq_increment * i;
    -
    283 }
    +
    280 std::string path = "output/time_dependent_potential/";
    +
    281 mkpath(path);
    +
    282
    +
    283 std::ofstream ofile;
    284
    -
    285#pragma omp parallel
    -
    286 {
    -
    287 // Each thread creates a PenningTrap instance and reuses it throughout
    -
    288 // the sweep.
    -
    289 PenningTrap trap((uint)100);
    -
    290#pragma omp for collapse(2)
    -
    291 for (size_t i = 0; i < 3; i++) {
    -
    292 for (size_t j = 0; j < freq_iterations; j++) {
    -
    293 // Reset particles and give new time dependent potential.
    -
    294 trap.reinitialize(amplitudes[i], res[0][j]);
    -
    295 res[i + 1][j] = trap.fraction_of_particles_left(time, N);
    -
    296 }
    -
    297 }
    -
    298 }
    -
    299
    -
    300 // Write results to file
    -
    301 ofile.open(path + "narrow_sweep_interactions.txt");
    -
    302 for (size_t i = 0; i < freq_iterations; i++) {
    -
    303 ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
    -
    304 << res[3][i] << '\n';
    -
    305 }
    -
    306 ofile.close();
    -
    307}
    -
    308
    -
    309int main()
    -
    310{
    -
    311 double start, end, t1, t2;
    -
    312 start = omp_get_wtime();
    +
    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
    -
    314 simulate_single_particle();
    -
    315
    -
    316 simulate_two_particles();
    -
    317
    -
    318 simulate_single_particle_with_different_steps();
    -
    319
    -
    320 t2 = omp_get_wtime();
    -
    321
    -
    322 std::cout << "Time single and double : " << (t2 - start)
    -
    323 << " seconds" << std::endl;
    -
    324
    -
    325 t1 = omp_get_wtime();
    -
    326
    -
    327 simulate_100_particles();
    -
    328
    -
    329 t2 = omp_get_wtime();
    -
    330
    -
    331 std::cout << "Time 100 particles : " << (t2 - t1)
    -
    332 << " seconds" << std::endl;
    -
    333
    -
    334 t1 = omp_get_wtime();
    -
    335
    -
    336 potential_resonance_wide_sweep();
    -
    337
    -
    338 t2 = omp_get_wtime();
    -
    339
    -
    340 std::cout << "Time wide sweep : " << (t2 - t1)
    -
    341 << " seconds" << std::endl;
    -
    342
    -
    343 t1 = omp_get_wtime();
    -
    344
    -
    345 potential_resonance_narrow_sweep();
    -
    346
    -
    347 t2 = omp_get_wtime();
    -
    348
    -
    349 std::cout << "Time narrow sweep no interaction : " << (t2 - t1)
    -
    350 << " seconds" << std::endl;
    -
    351
    -
    352 t1 = omp_get_wtime();
    +
    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 potential_resonance_narrow_sweep_interaction();
    +
    354 double start, end;
    355
    -
    356 t2 = omp_get_wtime();
    +
    356 system("clear");
    357
    -
    358 std::cout << "Time narrow sweep with interaction: " << (t2 - t1)
    -
    359 << " seconds" << std::endl;
    -
    360
    -
    361 end = omp_get_wtime();
    -
    362
    -
    363 std::cout << "Time : " << (end - start)
    -
    364 << " seconds" << std::endl;
    -
    365
    -
    366 return 0;
    -
    367}
    +
    358 start = omp_get_wtime();
    +
    359 switch (option) {
    +
    360 case 1:
    +
    361 std::cout << "Running simulate_single_particle\n";
    +
    362 simulate_single_particle();
    +
    363
    +
    364 std::cout << "Running simulate_two_particles\n";
    +
    365 simulate_two_particles();
    +
    366
    +
    367 std::cout << "Running simulate_single_particle_with_different_steps\n";
    +
    368 simulate_single_particle_with_different_steps();
    +
    369
    +
    370 std::cout << "Running simulate_100_particles\n";
    +
    371 simulate_100_particles();
    +
    372
    +
    373 std::cout << "Running potential_resonance_wide_sweep\n";
    +
    374 potential_resonance_wide_sweep();
    +
    375
    +
    376 std::cout << "Running potential_resonance_narrow_sweep\n";
    +
    377 potential_resonance_narrow_sweep();
    +
    378
    +
    379 std::cout << "Running potential_resonance_narrow_sweep_interaction\n";
    +
    380 potential_resonance_narrow_sweep_interaction();
    +
    381 break;
    +
    382 case 2:
    +
    383 std::cout << "Running simulate_single_particle\n";
    +
    384 simulate_single_particle();
    +
    385 break;
    +
    386 case 3:
    +
    387 std::cout << "Running simulate_two_particles\n";
    +
    388 simulate_two_particles();
    +
    389 break;
    +
    390 case 4:
    +
    391 std::cout << "Running simulate_single_particle_with_different_steps\n";
    +
    392 simulate_single_particle_with_different_steps();
    +
    393 break;
    +
    394 case 5:
    +
    395 std::cout << "Running simulate_100_particles\n";
    +
    396 simulate_100_particles();
    +
    397 break;
    +
    398 case 6:
    +
    399 std::cout << "Running potential_resonance_wide_sweep\n";
    +
    400 potential_resonance_wide_sweep();
    +
    401 break;
    +
    402 case 7:
    +
    403 std::cout << "Running potential_resonance_narrow_sweep\n";
    +
    404 potential_resonance_narrow_sweep();
    +
    405 break;
    +
    406 case 8:
    +
    407 std::cout << "Running potential_resonance_narrow_sweep_interaction\n";
    +
    408 potential_resonance_narrow_sweep_interaction();
    +
    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:23
    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...
    -
    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.
    +
    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:132
    +
    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:206
    -
    void potential_resonance_wide_sweep()
    Simulate 100 particles over 500 using a time dependent potential.
    Definition: main.cpp:149
    -
    void simulate_two_particles()
    Simulate 2 particles over the period of 50 with and without particle interactions.
    Definition: main.cpp:69
    +
    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:54
    -
    void potential_resonance_narrow_sweep_interaction()
    Simulate 100 particles over 500 using a time dependent potential.
    Definition: main.cpp:262
    -
    void simulate_single_particle_with_different_steps()
    Simulate a single particle over 50 using different amount of steps and different methods.
    Definition: main.cpp:87
    +
    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
    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 6156c4d..681af00 100644 --- a/docs/navtreedata.js +++ b/docs/navtreedata.js @@ -27,17 +27,23 @@ var NAVTREE = [ "Penning Trap Simulation", "index.html", [ [ "Requirements", "index.html#autotoc_md1", [ [ "Operating systems", "index.html#autotoc_md2", null ], - [ "Libraries", "index.html#autotoc_md3", null ] + [ "Tools", "index.html#autotoc_md3", null ], + [ "Libraries", "index.html#autotoc_md4", null ] ] ], - [ "Compiling", "index.html#autotoc_md4", null ], - [ "Running programs", "index.html#autotoc_md5", [ - [ "C++ binaries", "index.html#autotoc_md6", null ], - [ "Python scripts", "index.html#autotoc_md7", [ - [ "Install libraries", "index.html#autotoc_md8", null ], - [ "Running scripts", "index.html#autotoc_md9", 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 ] ] ], - [ "Credits", "index.html#autotoc_md10", 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" ], diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js index 68d8951..e8420ad 100644 --- a/docs/navtreeindex0.js +++ b/docs/navtreeindex0.js @@ -1,134 +1,151 @@ var NAVTREEINDEX0 = { -"Particle_8cpp.html":[6,0,1,2], -"Particle_8cpp_source.html":[6,0,1,2], -"Particle_8hpp.html":[6,0,0,1], -"Particle_8hpp_source.html":[6,0,0,1], -"PenningTrap_8cpp.html":[6,0,1,3], -"PenningTrap_8cpp_source.html":[6,0,1,3], -"PenningTrap_8hpp.html":[6,0,0,2], -"PenningTrap_8hpp_source.html":[6,0,0,2], -"animate__100__particles_8py_source.html":[6,0,1,0,0], -"annotated.html":[5,0], -"bug.html":[4], -"classParticle.html":[5,0,0], -"classParticle.html#a1c59101411db43624828b766f87ad460":[5,0,0,4], -"classParticle.html#a3a10400add8dd22b8031330c2aafb6fe":[5,0,0,5], -"classParticle.html#a566dcc1de4bdc01251776948798ea8e1":[5,0,0,3], -"classParticle.html#aa797d319549dc2a0beb06cdbfd430232":[5,0,0,1], -"classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563":[5,0,0,2], -"classParticle.html#af1d7535fb8311eaa77d2b7b345882ec4":[5,0,0,0], -"classPenningTrap.html":[5,0,1], -"classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f":[5,0,1,24], -"classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716":[5,0,1,20], -"classPenningTrap.html#a2c01108b52c8e2a003cf9170da9e7682":[5,0,1,15], -"classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640":[5,0,1,22], -"classPenningTrap.html#a2fe1cefbae18fa5808155ee0d2df713c":[5,0,1,16], -"classPenningTrap.html#a361f2c4862c90b5e8e2a2f50c6a95655":[5,0,1,6], -"classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e":[5,0,1,5], -"classPenningTrap.html#a3c0a44e4e0a94366ff609e81fe463fa2":[5,0,1,17], -"classPenningTrap.html#a5846c8f75cdc543fd9cf0b2185a3ef22":[5,0,1,7], -"classPenningTrap.html#a5b6c6d4636f3a6e279ccde59d4a345e8":[5,0,1,0], -"classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2":[5,0,1,21], -"classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8":[5,0,1,3], -"classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89":[5,0,1,27], -"classPenningTrap.html#a7a1d9f0528a12308de25bc30718da20a":[5,0,1,13], -"classPenningTrap.html#a7f210bb2768a5d79ced4b0df0df97598":[5,0,1,8], -"classPenningTrap.html#a826b7fa8e709d481eb1dee7d0c2cdc08":[5,0,1,10], -"classPenningTrap.html#a830be1b8cbf59664e060b6edbeaa302f":[5,0,1,1], -"classPenningTrap.html#a869f032f37d0569ed16f224b4c4356ae":[5,0,1,19], -"classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e":[5,0,1,26], -"classPenningTrap.html#a9a301b0540078c36697880ef204afdf3":[5,0,1,14], -"classPenningTrap.html#a9d1d8e90ca839b928aee1ad0cd4aff43":[5,0,1,12], -"classPenningTrap.html#aaee129f177657455348d0c8ae1441dea":[5,0,1,11], -"classPenningTrap.html#ab9ea97a406534bbe621a95215144875e":[5,0,1,4], -"classPenningTrap.html#ac529aa26c288f34eae184a67e6bac41f":[5,0,1,9], -"classPenningTrap.html#ad8bc4df7ab3eed53b16cfdff38e7760b":[5,0,1,18], -"classPenningTrap.html#addc96789dcfec07b75156e19fee82f4f":[5,0,1,2], -"classPenningTrap.html#ae915f6ad0eef1fb46530e836b6e071e5":[5,0,1,25], -"classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4":[5,0,1,23], -"classPenningTrapTest.html":[5,0,2], -"classPenningTrapTest.html#a5f4f0b150e54ce463bb29f76d49883f9":[5,0,2,2], -"classPenningTrapTest.html#a68449d508e66205bc8b27fa5f60db508":[5,0,2,4], -"classPenningTrapTest.html#a6a303be62039ca2ecccd8252744d4dc8":[5,0,2,1], -"classPenningTrapTest.html#ad668d7d875bdc1909a42426bf9dead9e":[5,0,2,0], -"classPenningTrapTest.html#ae6d0c8e0d80338fb7c7edefc97331046":[5,0,2,3], -"classes.html":[5,1], -"constants_8hpp.html":[6,0,0,0], -"constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5":[6,0,0,0,3], -"constants_8hpp.html#a2ff491cc7958ffd5e749c518a4a60ec8":[6,0,0,0,1], -"constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb":[6,0,0,0,2], -"constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb":[6,0,0,0,4], -"constants_8hpp.html#af7602a3a314957137ad1cd719aa23789":[6,0,0,0,0], -"constants_8hpp_source.html":[6,0,0,0], -"dir_634e799a3947388232110823971192a8.html":[6,0,1,0], -"dir_68267d1309a1af8e8297ef4c3efbcdba.html":[6,0,1], -"dir_d44c64559bbebec7f509842c48db8b23.html":[6,0,0], -"files.html":[6,0], -"functions.html":[5,2,0], -"functions_func.html":[5,2,1], -"functions_rela.html":[5,2,3], -"functions_vars.html":[5,2,2], -"globals.html":[6,1,0], -"globals_defs.html":[6,1,4], -"globals_func.html":[6,1,1], -"globals_type.html":[6,1,3], -"globals_vars.html":[6,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], -"index.html#autotoc_md10":[3], +"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":[1], -"index.html#autotoc_md5":[2], -"index.html#autotoc_md6":[2,0], -"index.html#autotoc_md7":[2,1], -"index.html#autotoc_md8":[2,1,0], -"index.html#autotoc_md9":[2,1,1], -"main_8cpp.html":[6,0,1,1], -"main_8cpp.html#a213713d6ecc02a32b588ffd179dc7513":[6,0,1,1,4], -"main_8cpp.html#a2efa69bb9d93049429ce4637075f1d30":[6,0,1,1,8], -"main_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea":[6,0,1,1,1], -"main_8cpp.html#a6b38b477c18e2f4268779751a88edab1":[6,0,1,1,3], -"main_8cpp.html#a783789519f97c6430081171cacb0ffb1":[6,0,1,1,7], -"main_8cpp.html#a8d92fb2ad085065fbd14718647551657":[6,0,1,1,0], -"main_8cpp.html#a8fdbe2d5a872e50ef5ec1263243589d6":[6,0,1,1,5], -"main_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb":[6,0,1,1,2], -"main_8cpp.html#ac67e0d59227856c4d42e7d01c75e0ad2":[6,0,1,1,6], -"main_8cpp.html#ac70b61df65f4336f57ea9b4c35250df7":[6,0,1,1,9], -"main_8cpp_source.html":[6,0,1,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__2__particles_8py_source.html":[6,0,1,0,1], -"plot__3d_8py_source.html":[6,0,1,0,2], -"plot__particles__left_8py_source.html":[6,0,1,0,3], -"plot__phase__space_8py_source.html":[6,0,1,0,4], -"plot__relative__error_8py_source.html":[6,0,1,0,5], -"plot__single__particle_8py_source.html":[6,0,1,0,6], -"structsimulation.html":[5,0,3], -"test__suite_8cpp.html":[6,0,1,4], -"test__suite_8cpp_source.html":[6,0,1,4], -"typedefs_8hpp.html":[6,0,0,3], -"typedefs_8hpp.html#a33418f31f28663b8414c8f7182998c22":[6,0,0,3,3], -"typedefs_8hpp.html#a3bdfb73a02f88ae32b6128ef747c4aea":[6,0,0,3,5], -"typedefs_8hpp.html#a46482a2697556c00556c9d73f461784f":[6,0,0,3,2], -"typedefs_8hpp.html#a784799c37b5e4fb8bf4f6368e004dec6":[6,0,0,3,4], -"typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af":[6,0,0,3,1], -"typedefs_8hpp_source.html":[6,0,0,3], -"utils_8cpp.html":[6,0,1,5], -"utils_8cpp.html#a58565270b643b24e3132f38c653e0199":[6,0,1,5,3], -"utils_8cpp.html#a6be6f938bcbb235ebb6a2ed9d08411b2":[6,0,1,5,0], -"utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746":[6,0,1,5,4], -"utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de":[6,0,1,5,2], -"utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b":[6,0,1,5,1], -"utils_8cpp_source.html":[6,0,1,5], -"utils_8hpp.html":[6,0,0,4], -"utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38":[6,0,0,4,4], -"utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168":[6,0,0,4,0], -"utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa":[6,0,0,4,5], -"utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[6,0,0,4,1], -"utils_8hpp.html#ab3e0cf669bddc59bd53998490ffb68b9":[6,0,0,4,3], -"utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d":[6,0,0,4,6], -"utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384":[6,0,0,4,7], -"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[6,0,0,4,2], -"utils_8hpp_source.html":[6,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 index 648387a..f248e58 100644 --- a/docs/plot__2__particles_8py_source.html +++ b/docs/plot__2__particles_8py_source.html @@ -101,51 +101,77 @@ $(document).ready(function(){initNavTree('plot__2__particles_8py_source.html',''
    plot_2_particles.py
    -
    1import matplotlib.pyplot as plt
    -
    2import numpy as np
    -
    3
    -
    4def main():
    -
    5 files = [
    -
    6 "output/simulate_2_particles/no_interaction/particle_0_r.txt",
    -
    7 "output/simulate_2_particles/no_interaction/particle_1_r.txt",
    -
    8 "output/simulate_2_particles/with_interaction/particle_0_r.txt",
    -
    9 "output/simulate_2_particles/with_interaction/particle_1_r.txt"
    -
    10 ]
    -
    11 labels = [
    -
    12 "particle 1 no interaction",
    -
    13 "particle 2 no interaction",
    -
    14 "particle 1 with interaction",
    -
    15 "particle 2 with interaction",
    -
    16 ]
    -
    17 colors = [
    -
    18 "lightskyblue",
    -
    19 "lightskyblue",
    -
    20 "salmon",
    -
    21 "salmon"
    -
    22 ]
    -
    23 for label, color, file in zip(labels, colors, files):
    -
    24 with open(file) as f:
    -
    25 lines = f.readlines()
    -
    26 t = np.linspace(0, 50, len(lines))
    -
    27 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
    -
    28 plt.plot(r[:,0], r[:,1], label=label, color=color)
    -
    29
    -
    30 plt.xlabel(r"x $(\mu m)$")
    -
    31 plt.ylabel(r"y $(\mu m)$")
    -
    32 plt.title(r"2 particles with and without interactions.")
    -
    33 # plt.legend()
    -
    34 # plt.show()
    -
    35 plt.savefig("../latex/images/plot_2_particles_xy.pdf")
    -
    36
    -
    37
    -
    38if __name__ == "__main__":
    -
    39 main()
    +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 index d297968..039e889 100644 --- a/docs/plot__3d_8py_source.html +++ b/docs/plot__3d_8py_source.html @@ -101,52 +101,70 @@ $(document).ready(function(){initNavTree('plot__3d_8py_source.html',''); initRes
    plot_3d.py
    -
    1import matplotlib.pyplot as plt
    -
    2import numpy as np
    -
    3
    -
    4def main():
    -
    5 files = [
    -
    6 "output/simulate_2_particles/no_interaction/particle_0_r.txt",
    -
    7 "output/simulate_2_particles/no_interaction/particle_1_r.txt",
    -
    8 "output/simulate_2_particles/with_interaction/particle_0_r.txt",
    -
    9 "output/simulate_2_particles/with_interaction/particle_1_r.txt"
    -
    10 ]
    -
    11 labels = [
    -
    12 "particle 1 no interaction",
    -
    13 "particle 2 no interaction",
    -
    14 "particle 1 with interaction",
    -
    15 "particle 2 with interaction",
    -
    16 ]
    -
    17 colors = [
    -
    18 "lightskyblue",
    -
    19 "deepskyblue",
    -
    20 "salmon",
    -
    21 "darkred"
    -
    22 ]
    -
    23 ax = plt.figure().add_subplot(projection="3d")
    -
    24 for label, color, file in zip(labels, colors, files):
    -
    25 with open(file) as f:
    -
    26 lines = f.readlines()
    -
    27 t = np.linspace(0, 50, len(lines))
    -
    28 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
    -
    29 ax.plot(r[:,0], r[:,1], r[:,2], label=label, color=color)
    -
    30
    -
    31 ax.set_xlabel(r"x $(\mu m)$")
    -
    32 ax.set_ylabel(r"y $(\mu m)$")
    -
    33 ax.set_zlabel(r"z $(\mu m)$")
    -
    34 plt.title(r"2 particles with and without interactions.")
    -
    35 plt.legend()
    -
    36 plt.savefig("../latex/images/3d_plot.pdf")
    -
    37
    -
    38
    -
    39if __name__ == "__main__":
    -
    40 main()
    +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 4e37019..9de8c42 100644 --- a/docs/plot__particles__left_8py_source.html +++ b/docs/plot__particles__left_8py_source.html @@ -101,80 +101,83 @@ $(document).ready(function(){initNavTree('plot__particles__left_8py_source.html'
    plot_particles_left.py
    -
    1import matplotlib.pyplot as plt
    -
    2import seaborn as sns
    -
    3
    -
    4sns.set_theme()
    -
    5params = {
    -
    6 "font.family": "Serif",
    -
    7 "font.serif": "Roman",
    -
    8 "text.usetex": True,
    -
    9 "axes.titlesize": "large",
    -
    10 "axes.labelsize": "large",
    -
    11 "xtick.labelsize": "large",
    -
    12 "ytick.labelsize": "large",
    -
    13 "legend.fontsize": "medium"
    -
    14}
    -
    15plt.rcParams.update(params)
    -
    16
    -
    17def main():
    -
    18 colors = [
    -
    19 "lightskyblue",
    -
    20 "deepskyblue",
    -
    21 "salmon",
    -
    22 "tomato",
    -
    23 "mediumaquamarine",
    -
    24 "mediumseagreen"
    -
    25 ]
    -
    26 files = [
    -
    27 "output/time_dependent_potential/wide_sweep.txt",
    -
    28 "output/time_dependent_potential/narrow_sweep.txt",
    -
    29 "output/time_dependent_potential/narrow_sweep_interactions.txt",
    -
    30 ]
    -
    31 outputs = [
    -
    32 "../latex/images/wide_sweep.pdf",
    -
    33 "../latex/images/narrow_sweep.pdf",
    -
    34 "../latex/images/narrow_sweep_interactions.pdf",
    -
    35 ]
    -
    36 for file, output in zip(files, outputs):
    -
    37 with open(file) as f:
    -
    38 lines = f.readlines()
    -
    39 x = []
    -
    40 y1 = []
    -
    41 y2 = []
    -
    42 y3 = []
    -
    43 for line in lines:
    -
    44 l = line.strip().split(",")
    -
    45 x.append(float(l[0]))
    -
    46 y1.append(float(l[1]))
    -
    47 y2.append(float(l[2]))
    -
    48 y3.append(float(l[3]))
    -
    49
    -
    50 fig, ax = plt.subplots()
    -
    51 ax.plot(x, y1, label=r"$f_{1} = 0.1$", color=colors[0])
    -
    52 ax.plot(x, y2, label=r"$f_{2} = 0.4$", color=colors[2])
    -
    53 ax.plot(x, y3, label=r"$f_{3} = 0.7$", color=colors[4])
    -
    54
    -
    55 ax.set_xlabel(r"Frequency $\omega_V$ (MHz)")
    -
    56 # ax.set_xlim((0, 2.8))
    -
    57 ax.set_ylabel(r"Fraction of particles left")
    -
    58 # ax.set_ylim((-0.1, 1.1))
    -
    59 # plt.title(r"The fraction of particles left in the Penning trap "
    -
    60 # "after 500 microseconds for different amplitudes and frequencies")
    -
    61
    -
    62 ax.legend(loc="upper right")
    -
    63
    -
    64 # plt.show()
    -
    65 fig.savefig(output, bbox_inches="tight")
    -
    66
    -
    67if __name__ == "__main__":
    -
    68 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 index c746ef7..8bb2bfc 100644 --- a/docs/plot__phase__space_8py_source.html +++ b/docs/plot__phase__space_8py_source.html @@ -101,65 +101,88 @@ $(document).ready(function(){initNavTree('plot__phase__space_8py_source.html',''
    plot_phase_space.py
    -
    1import matplotlib.pyplot as plt
    -
    2import numpy as np
    -
    3
    -
    4def main():
    -
    5 directories = {
    -
    6 "output/simulate_2_particles/no_interaction/",
    -
    7 "output/simulate_2_particles/with_interaction/",
    -
    8 }
    -
    9 titles = {
    -
    10 "particles without interaction",
    -
    11 "particles with interaction"
    -
    12 }
    -
    13 files = [
    -
    14 "particle_0_r.txt",
    -
    15 "particle_0_v.txt",
    -
    16 "particle_1_r.txt",
    -
    17 "particle_1_v.txt",
    -
    18 ]
    -
    19 labels = [
    -
    20 r"particle 1 r",
    -
    21 r"particle 1 v",
    -
    22 r"particle 2 r",
    -
    23 r"particle 2 v",
    -
    24 ]
    -
    25 colors = [
    -
    26 "lightskyblue",
    -
    27 "deepskyblue",
    -
    28 "salmon",
    -
    29 "tomato",
    -
    30 ]
    -
    31 fig1, axs1 = plt.subplots(2,1)
    -
    32 fig2, axs2 = plt.subplots(2,1)
    -
    33 for i, (dir, title) in enumerate(zip(directories, titles)):
    -
    34 for label, color, file in zip(labels, colors, files):
    -
    35 with open(dir+file) as f:
    -
    36 lines = f.readlines()
    -
    37 t = np.linspace(0, 50, len(lines))
    -
    38 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
    -
    39 axs1[i].plot(t, r[:,0], label=label, color=color)
    -
    40 axs2[i].plot(t, r[:,2], label=label, color=color)
    -
    41
    -
    42 axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"z $(\mu m)$")
    -
    43
    -
    44 axs1[i].legend()
    -
    45 axs1[i].set_title(title)
    -
    46
    -
    47 # plt.show()
    -
    48 fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
    -
    49 fig2.savefig("../latex/images/phase_space_2_particles_z.pdf")
    -
    50
    -
    51
    -
    52if __name__ == "__main__":
    -
    53 main()
    +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 index 8628d31..f37bb78 100644 --- a/docs/plot__relative__error_8py_source.html +++ b/docs/plot__relative__error_8py_source.html @@ -101,63 +101,86 @@ $(document).ready(function(){initNavTree('plot__relative__error_8py_source.html'
    plot_relative_error.py
    -
    1import matplotlib.pyplot as plt
    -
    2import numpy as np
    -
    3
    -
    4def main():
    -
    5 directories = [
    -
    6 "output/relative_error/RK4/",
    -
    7 "output/relative_error/euler/",
    -
    8 ]
    -
    9 files = [
    -
    10 "4000_steps.txt",
    -
    11 "8000_steps.txt",
    -
    12 "16000_steps.txt",
    -
    13 "32000_steps.txt",
    -
    14 ]
    -
    15 labels = [
    -
    16 r"4000 steps",
    -
    17 r"8000 steps",
    -
    18 r"16000 steps",
    -
    19 r"32000 steps",
    -
    20 ]
    -
    21 titles = [
    -
    22 "Relative error for the RK4 method",
    -
    23 "Relative error for the forward Euler method"
    -
    24 ]
    -
    25 methods = [
    -
    26 "rk4",
    -
    27 "euler"
    -
    28 ]
    -
    29 fig1, axs1 = plt.subplots(2,1)
    -
    30 for i, (dir, title) in enumerate(list(zip(directories, titles))):
    -
    31 max_err = []
    -
    32 for label, file in zip(labels, files):
    -
    33 with open(dir+file) as f:
    -
    34 lines = f.readlines()
    -
    35 t = np.linspace(0, 50, len(lines))
    -
    36 r = np.array([float(line.strip()) for line in lines])
    -
    37 max_err.append(max(r))
    -
    38 axs1[i].plot(t, r, label=label)
    -
    39
    -
    40 axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"relative_error $(\mu m)$")
    -
    41 axs1[i].legend()
    -
    42 axs1[i].set_title(title)
    -
    43
    -
    44 conv_rate = 1/3 * sum([np.log2(max_err[i+1]/max_err[i])/np.log2(.5) for i in range(3)])
    -
    45 print(f"{methods[i]}: {conv_rate}")
    -
    46
    -
    47 fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
    -
    48
    -
    49
    -
    50if __name__ == "__main__":
    -
    51 main()
    +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 index d5eff34..376227f 100644 --- a/docs/plot__single__particle_8py_source.html +++ b/docs/plot__single__particle_8py_source.html @@ -101,42 +101,61 @@ $(document).ready(function(){initNavTree('plot__single__particle_8py_source.html
    plot_single_particle.py
    -
    1import matplotlib.pyplot as plt
    -
    2import numpy as np
    -
    3
    -
    4def z(t):
    -
    5 V_0 = 25.*9.64852558 * 10**4
    -
    6 m = 40.
    -
    7 d = 500.
    -
    8 w_z = np.sqrt((2.*V_0)/(m*d*d))
    -
    9 return 20.*np.cos(w_z*t)
    -
    10
    -
    11def main():
    -
    12 filename = "output/simulate_single_particle/particle_0_r.txt"
    -
    13 r = t = []
    -
    14 with open(filename) as f:
    -
    15 lines = f.readlines()
    -
    16 t = np.linspace(0, 50, len(lines))
    -
    17 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
    -
    18
    -
    19 plt.plot(t, r[:, 2], label="approximation")
    -
    20 plt.plot(t, z(t), label="analytical")
    -
    21 plt.xlabel(r"time $(\mu s)$")
    -
    22 plt.ylabel(r"z $(\mu m)$")
    -
    23 plt.title(r"Movement of a single particle in the x direction")
    -
    24 plt.legend()
    -
    25 # plt.savefig("../latex/images/single_particle.pdf")
    -
    26 plt.show()
    -
    27
    -
    28
    -
    29if __name__ == "__main__":
    -
    30 main()
    +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 6effb5c..737ed4a 100644 --- a/docs/search/all_1.js +++ b/docs/search/all_1.js @@ -2,5 +2,6 @@ var searchData= [ ['add_5fparticle_0',['add_particle',['../classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8',1,'PenningTrap']]], ['analytical_5fsolution_5fparticle_5f1_1',['analytical_solution_particle_1',['../main_8cpp.html#a8d92fb2ad085065fbd14718647551657',1,'main.cpp']]], - ['assert_2',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]] + ['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_6.js b/docs/search/all_6.js index e6919eb..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#a7f210bb2768a5d79ced4b0df0df97598',1,'PenningTrap']]], - ['fraction_5fof_5fparticles_5fleft_1',['fraction_of_particles_left',['../classPenningTrap.html#ac529aa26c288f34eae184a67e6bac41f',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 8d94e1e..70494b2 100644 --- a/docs/search/all_9.js +++ b/docs/search/all_9.js @@ -2,17 +2,23 @@ var searchData= [ ['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#af1d7535fb8311eaa77d2b7b345882ec4',1,'Particle::Particle()'],['../classParticle.html',1,'Particle']]], + ['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#a5b6c6d4636f3a6e279ccde59d4a345e8',1,'PenningTrap::PenningTrap(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.)'],['../classPenningTrap.html#a830be1b8cbf59664e060b6edbeaa302f',1,'PenningTrap::PenningTrap(uint i, double B_0=T, double V_0=(25. *V)/1000., double d=500., double t=0.)'],['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle::PenningTrap()'],['../classPenningTrap.html',1,'PenningTrap']]], + ['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']]], - ['potential_5fresonance_5fnarrow_5fsweep_12',['potential_resonance_narrow_sweep',['../main_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea',1,'main.cpp']]], - ['potential_5fresonance_5fnarrow_5fsweep_5finteraction_13',['potential_resonance_narrow_sweep_interaction',['../main_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb',1,'main.cpp']]], - ['potential_5fresonance_5fwide_5fsweep_14',['potential_resonance_wide_sweep',['../main_8cpp.html#a6b38b477c18e2f4268779751a88edab1',1,'main.cpp']]] + ['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_d.js b/docs/search/all_d.js index 4af72aa..80bb0f1 100644 --- a/docs/search/all_d.js +++ b/docs/search/all_d.js @@ -10,6 +10,7 @@ var searchData= ['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_5fparticles_10',['total_force_particles',['../classPenningTrap.html#a2fe1cefbae18fa5808155ee0d2df713c',1,'PenningTrap']]], - ['typedefs_2ehpp_11',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]] + ['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/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_5.js b/docs/search/functions_5.js index f49bd4c..ae92b61 100644 --- a/docs/search/functions_5.js +++ b/docs/search/functions_5.js @@ -2,7 +2,7 @@ var searchData= [ ['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',['../main_8cpp.html#a33d9b1c76c3c80902f89a58b1a6d96ea',1,'main.cpp']]], - ['potential_5fresonance_5fnarrow_5fsweep_5finteraction_3',['potential_resonance_narrow_sweep_interaction',['../main_8cpp.html#ac1816f70ec612edc27848ef7f0875fdb',1,'main.cpp']]], + ['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_8.js b/docs/search/functions_8.js index 6ad3539..14193ad 100644 --- a/docs/search/functions_8.js +++ b/docs/search/functions_8.js @@ -7,5 +7,6 @@ var searchData= ['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_5fparticles_7',['total_force_particles',['../classPenningTrap.html#a2fe1cefbae18fa5808155ee0d2df713c',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/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/searchdata.js b/docs/search/searchdata.js index 8aa7be2..bd9004d 100644 --- a/docs/search/searchdata.js +++ b/docs/search/searchdata.js @@ -2,7 +2,7 @@ var indexSectionsWithContent = { 0: "_abcdefkmpqrstuvw", 1: "ps", - 2: "cmptu", + 2: "acfmptu", 3: "acefmprstvw", 4: "bdkmpqrtv", 5: "sv", diff --git a/docs/test__suite_8cpp.html b/docs/test__suite_8cpp.html index 6211476..bae411e 100644 --- a/docs/test__suite_8cpp.html +++ b/docs/test__suite_8cpp.html @@ -133,7 +133,7 @@ Functions
    Janita Ovidie Sandtrøen Willumsen (janitaws)
    Version
    1.0
    -
    Bug:
    No known bugs
    +
    Bug:
    No known bugs

    Definition in file test_suite.cpp.

    Function Documentation

    diff --git a/docs/test__suite_8cpp_source.html b/docs/test__suite_8cpp_source.html index 0e0fee5..9247504 100644 --- a/docs/test__suite_8cpp_source.html +++ b/docs/test__suite_8cpp_source.html @@ -239,12 +239,12 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    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:82
    -
    vec3 total_force_particles(uint i)
    Calculate the total force on a particle p_i from other particles.
    Definition: PenningTrap.cpp:95
    -
    vec3 external_B_field(vec3 r)
    Calculate B at point r.
    Definition: PenningTrap.cpp:66
    -
    vec3 external_E_field(vec3 r)
    Calculate E at point r.
    Definition: PenningTrap.cpp:58
    -
    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:71
    +
    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
    diff --git a/docs/utils_8cpp.html b/docs/utils_8cpp.html index d94bebf..89ca470 100644 --- a/docs/utils_8cpp.html +++ b/docs/utils_8cpp.html @@ -134,7 +134,7 @@ 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

    diff --git a/latex/appendix.tex b/latex/appendix.tex deleted file mode 100644 index 315fbec..0000000 --- a/latex/appendix.tex +++ /dev/null @@ -1,266 +0,0 @@ -\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/images/penning_trap.pdf b/latex/images/penning_trap.pdf deleted file mode 100644 index f6bd81b..0000000 Binary files a/latex/images/penning_trap.pdf and /dev/null differ diff --git a/latex/main.blg b/latex/main.blg new file mode 100644 index 0000000..23ebaca --- /dev/null +++ b/latex/main.blg @@ -0,0 +1,53 @@ +This is BibTeX, Version 0.99d (TeX Live 2022/CVE-2023-32700 patched) +Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 +The top-level auxiliary file: main.aux +The style file: unsrt.bst +Database file #1: mainNotes.bib +Database file #2: references/references.bib +Warning--entry type for "britannica:2023:matter" isn't style-file defined +--line 63 of file references/references.bib +Warning--entry type for "openmp:2018" isn't style-file defined +--line 92 of file references/references.bib +Warning--empty chapter and pages in vogel:2018:ch1 +You've used 7 entries, + 1791 wiz_defined-function locations, + 485 strings with 4118 characters, +and the built_in function-call counts, 1494 in all, are: += -- 143 +> -- 28 +< -- 2 ++ -- 14 +- -- 7 +* -- 72 +:= -- 212 +add.period$ -- 19 +call.type$ -- 7 +change.case$ -- 7 +chr.to.int$ -- 0 +cite$ -- 8 +duplicate$ -- 79 +empty$ -- 172 +format.name$ -- 7 +if$ -- 355 +int.to.chr$ -- 0 +int.to.str$ -- 7 +missing$ -- 8 +newline$ -- 36 +num.names$ -- 7 +pop$ -- 35 +preamble$ -- 1 +purify$ -- 0 +quote$ -- 0 +skip$ -- 46 +stack$ -- 0 +substring$ -- 95 +swap$ -- 25 +text.length$ -- 2 +text.prefix$ -- 0 +top$ -- 0 +type$ -- 0 +warning$ -- 1 +while$ -- 16 +width$ -- 8 +write$ -- 75 +(There were 3 warnings) diff --git a/latex/main.pdf b/latex/main.pdf index 962bca8..46e5ae2 100644 Binary files a/latex/main.pdf and b/latex/main.pdf differ diff --git a/latex/main.tex b/latex/main.tex index f73c54a..e7ab021 100644 --- a/latex/main.tex +++ b/latex/main.tex @@ -49,7 +49,7 @@ \begin{document} -\title{Simulating Particles in an Ideal Penning Trap} +\title{Project 3} % self-explanatory \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. @@ -73,13 +73,11 @@ % Conclusion \subfile{sections/conclusion} -\newpage \appendix -\subfile{appendix} -% \subfile{appendix/appendix_b} -% \subfile{appendix/appendix_c} -% \subfile{appendix/appendix_d} +\subfile{appendix/appendix_a} +\subfile{appendix/appendix_b} +\subfile{appendix/appendix_c} \onecolumngrid diff --git a/latex/references/references.bib b/latex/references/references.bib index b461fd7..341ff73 100644 --- a/latex/references/references.bib +++ b/latex/references/references.bib @@ -97,32 +97,8 @@ urldate = {2023-10-22} } -@online{penning:fig, - author = {Ludwig-Maximilians-Universität München}, - title = {Penning traps}, +@misc{penning:fig, + key = {something}, 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.} + note = {Configuration figure a} } diff --git a/latex/sections/abstract.tex b/latex/sections/abstract.tex index cbd63f7..c7b5481 100644 --- a/latex/sections/abstract.tex +++ b/latex/sections/abstract.tex @@ -4,7 +4,7 @@ \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$. + Add an abstract for the project? \end{abstract} \end{document} \ No newline at end of file diff --git a/latex/sections/conclusion.tex b/latex/sections/conclusion.tex index 9469d4c..10a537a 100644 --- a/latex/sections/conclusion.tex +++ b/latex/sections/conclusion.tex @@ -2,10 +2,11 @@ \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 index 5a3cbfc..0ef8ecb 100644 --- a/latex/sections/introduction.tex +++ b/latex/sections/introduction.tex @@ -4,12 +4,10 @@ \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}. +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, measure their physical quantities, not to mention 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}. +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 fiels to a vaccum 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. +In practice, a Penning trap is not easy to obtain, and an experiment is both time consuming and expensive. A numerical approach, allow us to study the effects of the Penning trap on a charged particle, without the cost. We can use ordinary differential equations to model the particle's movement, confined within an Penning trap. Our focus will be on 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.pdf b/latex/sections/methods.pdf new file mode 100644 index 0000000..abf8b57 Binary files /dev/null and b/latex/sections/methods.pdf differ diff --git a/latex/sections/methods.tex b/latex/sections/methods.tex index 1027824..ad8c06f 100644 --- a/latex/sections/methods.tex +++ b/latex/sections/methods.tex @@ -2,48 +2,15 @@ \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} % +\section{Methods} +% Problem 1 +When we study the Penning traps effect on a particle with a charge $q$, we need to consider the forces acting on the particle. We can use Newton's second law \eqref{eq:newton_second} to determine the position of a particle as a function of time. In addition, we introduce the Lorentz force \eqref{eq:lorentz_force}, which describes the force on the particle. The position can be described by % % -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} % + 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 +Using eq. \eqref{eq:newton_lorentz} we derive the differential equations in sec. \ref{sec:eq_motion}, and can rewrite them as \begin{align} \label{eq:motion_x} \ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x &= 0, \\ @@ -53,36 +20,32 @@ and derive the differential equations in appendix \ref{sec:eq_motion}. We can re \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$. +derived in sec. \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 +% Problem 2 +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 sec. \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} % -% +\end{equation} + +% Problem 3 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} +The amplitude $A_{+}$ and $A_{-}$ are positive, the phases $\phi_{+}$ and $\phi_{-}$ are constant, and the rate is given by +\begin{equation*} \omega_{\pm} = \frac{\omega_{0} \pm \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}}{2}. -\end{equation} +\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 +and eq. \eqref{eq:general_solution}. We can rearrange the right hand side of the derived expression in \ref{sec:eq_coord}, and 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_{-}) @@ -92,74 +55,104 @@ However, to obtain a bound on the particle's movement in the radial direction, w \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_{-} \\ R_{-} &= |A_{+} - A_{-}|, \end{align} -which we derive in appendix \ref{sec:upper_lower_bound}. +derived in sec. \ref{sec:bounded_solution}. -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 +% Problem 3 +To obtain the bounded solution, we need to consider the expression \begin{equation*} - z(t) = z_{0} \cos (\omega_{z} t) + \alpha = (\omega_{+} - \omega_{-}) t +( \phi_{+} - \phi_{-}). \end{equation*} -For the particle movement in the radial direction, we find the specific solution using eq. \eqref{eq:general_solution} with +When $t \rightarrow \infty$ the constant phases will not affect the expression, we obtain a bounded solution if we consider the rate such that $|f(t)| < \infty$. That is, we need $\omega_{0}^{2} - 2 \omega_{z}^{2}$ in eq. \eqref{eq:angular_rate} to be real. \begin{align*} - A_{+} &= \frac{v_{0} + \omega_{-} x{0}}{\omega_{-} - \omega_{+}}, & A_{-} &= - \frac{v_{0} + \omega_{+} x{0}}{\omega_{-} - \omega_{+}}, \\ - \phi_{+} &= 0, & \phi_{-} &= 0. + \omega_{0}^{2} - 2 \omega_{z}^{2} = 0, \quad \omega_{0} > 2 \omega_{z} \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)), +\begin{equation}\label{eq:angular_rate} + \omega_{\pm} = \frac{\omega_{0} \pm \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}}{2} \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}), +We find the solution +Physical properties given by newtons second law \eqref{eq:newton_second} + +The particle moves and its position can be determined using newton. where the electric field + + + + + +\begin{table}[H] + \centering + \begin{tabular}[c]{lll} + Constant & 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} + +\subsection{Dealing with a multi--particle system} + +For a multi-particles system, we need to modify $\vb{F}$ to account for the +force of other particles in the system acting upon each other. To do that, we +add another term to $\vb{F}$ +\begin{equation} + \vb{F}_i(t, \vb{v}_i, \vb{r}_i) = q_i \vb{E}(t, \vb{r}_i) + q_i \vb{v}_i \cross \vb{B} - \vb{E}_p(t, \vb{r}_i), +\end{equation} +where $i$ and $j$ are particle indices and +\begin{equation} + \vb{E}_p(t, \vb{r}_i) = q_i k_e \sum_{j \neq i} + q_j \frac{\vb{r_i} - \vb{r_j}}{\left| \vb{r_i} - \vb{r_j} \right|^3}. + \label{eq:} \end{equation} -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}. +Newton's second law for a particle $i$ is then +\begin{equation} + \frac{d^2\vb{r}_i}{dt^2} = \frac{\vb{F}_i\left(t, \frac{d\vb{r}_i}{dt}, \vb{r_i}\right)}{m_i}, + \label{eq:newtonlaw2} +\end{equation} +We can then rewrite the second order ODE from equation~\ref{eq:newtonlaw2} +into a set of coupled first order ODEs. +We now rewrite Newton's second law of motion as +\begin{equation} + \begin{split} + \frac{d\vb{r}_i}{dt} &= \vb{v}_i \\ + \frac{d\vb{v}_i}{dt} &= \frac{\vb{F}_i(t, \vb{v}_i, \vb{r}_i)}{m_i}. + \end{split} + \label{eq:coupled} +\end{equation} + +\subsection{Forward Euler} + +For a particle $i$, the forward Euler method for a coupled system is +expressed as +\begin{equation} + \begin{split} + \vb{r}_{i,j+1} &= \vb{r}_{i,j} + h \cdot \frac{d\vb{r}_{i,j}}{dt} = \vb{r}_{i,j} + h \cdot \vb{v}_{i,j} \\ + \vb{v}_{i,j+1} &= \vb{v}_{i,j} + h \cdot \frac{\vb{v}_{i,j}}{dt} = \vb{v}_{i,j} + h \cdot \frac{\vb{F}\left( t_{j}, \vb{v}_{i,j}, \vb{r}_{i,j} \right)}{m}, + \end{split} +\end{equation} +for particle $i$ where $j$ is the current time step of the particle, +$m$ is the mass of the particle, and $h$ is the step length. + +When dealing with a multi-particle system, we need to ensure that we do not +update the position of any particles until every particle has calculated their +next step. An easy way of doing this is to create a copy of all the particles, +then update the copy, and when all the particles have calculated their next +step, simply replace the particles with the copies. +Algorithm~\ref{algo:forwardeuler} provides an overview on how that can be achieved. % Make this better + \begin{figure}[H] \begin{algorithm}[H] \caption{Forward Euler method} - \label{algo:forward_euler} + \label{algo:forwardeuler} \begin{algorithmic} \Procedure{Evolve forward Euler}{$particles, dt$} \State $N \leftarrow \text{Number of particles in } particles$ @@ -173,7 +166,56 @@ We first implemented the forward Euler method, using the expression for a couple \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$. +\subsection{4th order Runge-Kutta} + +For a particle $i$, we can express the 4th order Runge-Kutta (RK4) method as +\begin{equation} + \begin{split} + \vb{v}_{i,j+1} &= \vb{v}_{i,j} + \frac{h}{6} \left( \vb{k}_{\vb{v},1,i} + + 2\vb{k}_{\vb{v},2,i} + 2\vb{k}_{\vb{v},3,i} + \vb{k}_{\vb{v},4,i} + \right) \\ + \vb{r}_{i,j+1} &= \vb{r}_{i,j} + \frac{h}{6} \left( \vb{k}_{\vb{r},1,i} + + 2\vb{k}_{\vb{r},2,i} + 2\vb{k}_{\vb{r},3,i} + \vb{k}_{\vb{r},4,i} + \right), + \end{split} +\end{equation} +where +\begin{equation} + \begin{split} + \vb{k}_{\vb{v},1,i} &= \frac{\vb{F}_i(t_j, \vb{v}_{i,j}, + \vb{r}_{i,j})}{m} \\ + \vb{k}_{\vb{r},1,i} &= \vb{v}_{i,j} \\ + \vb{k}_{\vb{v},2,i} &= \frac{\vb{F}_i(t_j+\frac{h}{2}, \vb{v}_{i,j} + + h \cdot \frac{\vb{k}_{\vb{v},1,i}}{2}, \vb{r}_{i,j} + + h \cdot \frac{\vb{k}_{\vb{r},1,i}}{2})}{m} \\ + \vb{k}_{\vb{r},2,i} &= \vb{v}_{i,j} + + h \cdot \frac{\vb{k}_{\vb{v},1,i}}{2} \\ + \vb{k}_{\vb{v},3,i} &= \frac{\vb{F}_i(t_j+\frac{h}{2}, \vb{v}_{i,j} + + h \cdot \frac{\vb{k}_{\vb{v},2,i}}{2}, \vb{r}_{i,j} + + h \frac{\cdot \vb{k}_{\vb{r},2,i}}{2})}{m} \\ + \vb{k}_{\vb{r},3,i} &= \vb{v}_{i,j} + + h \cdot \frac{\vb{k}_{\vb{v},2,i}}{2} \\ + \vb{k}_{\vb{v},4,i} &= \frac{\vb{F}_i(t_j+h, \vb{v}_{i,j} + + h \cdot \vb{k}_{\vb{v},3,i}, \vb{r}_{i,j} + + h \cdot \vb{k}_{\vb{r},3,i})}{m} \\ + \vb{k}_{\vb{r},4,i} &= \vb{v}_{i,j} + + h \cdot \frac{\vb{k}_{\vb{v},1,i}}{2}. + \end{split} +\end{equation} + +In order to find each $\vb{k}_{\vb{r},i}$ and $\vb{k}_{\vb{v},i}$, +we need to first compute all $\vb{k}_{\vb{r},i}$ and $\vb{k}_{\vb{v},i}$ +for all particles, then we can update the particles in order to compute +$\vb{k}_{\vb{r},i+1}$ and $\vb{k}_{\vb{v},i+1}$. In order for the algorithm +to work, we need to save a copy of each particle before starting so that we +can update the particles correctly for each step. + +This approach would require 8 loops to be able to complete the calculation since +we cannot update the particles until after all $\vb{k}$ values have been +computed, however if we create a temporary array that holds particles, we can +put the updated particles in there, and then use that array in the next loop, +and would reduce the required amount of loops down to 4. + \begin{figure} \begin{algorithm}[H] \caption{RK4 method} @@ -225,12 +267,12 @@ We also implemented the 4th order Runge-Kutta (RK4) method, using the expression \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)$ + \cdot \left( \vb{k}_{\vb{r},1,i} + \vb{k}_{\vb{r},2,i} + + \vb{k}_{\vb{r},3,i} + \vb{k}_{\vb{r},4,i} \right)$ \State $tmp\_p_i.\vb{v} \leftarrow orig\_p_i.\vb{v} + \frac{dt}{6} - \cdot \left( \vb{k}_{\vb{v},1,i} + 2 \vb{k}_{\vb{v},2,i} - + 2 \vb{k}_{\vb{v},3,i} + \vb{k}_{\vb{v},4,i} \right)$ + \cdot \left( \vb{k}_{\vb{v},1,i} + \vb{k}_{\vb{v},2,i} + + \vb{k}_{\vb{v},3,i} + \vb{k}_{\vb{v},4,i} \right)$ \EndFor @@ -238,20 +280,17 @@ We also implemented the 4th order Runge-Kutta (RK4) method, using the expression \EndProcedure \end{algorithmic} \end{algorithm} + $\vb{F}$ in the algorithm does not take any arguments as it uses the + velocities and positions of the particles inside the array $particles$ to + calculate the total force acting on particle $i$. \end{figure} -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{Testing the simulation} + +\subsection{Relative error and error convergance rate} \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. +The numerical methods implemented in C++, are parallelized using OpenMP \cite{openmp:2018}. We used the Python library matplotlib \cite{hunter:2007:matplotlib} to produce all the plots, and 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 index 8960f00..2dfa504 100644 --- a/latex/sections/results.tex +++ b/latex/sections/results.tex @@ -2,122 +2,88 @@ \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 +\section{Results and Discussion} +% Single particle +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_condition_particles}. + +First we simulated a single particle for $50 \mu s$, approximating the particle's motion using the RK4 method. In addition we compared the motion of particle 1 with the analytical solution in figure \ref{fig:single_particle}. What we see is a complete overlap of the analytical solution completely overlap the approximated, suggest that the simulation result is good. +% Add something about why the simulated result is good, cos(wt) when w is +% +\begin{table}[H] + \centering + \begin{tabular}[c]{lll} + Particle & Position & Velocity \\ + \hline + $p_{1}$ & $(20, 0, 20) \mu m$ & $(0, 25, 0) \mu m/ \mu s$ \\ + $p_{2}$ & $(25, 25, 0) \mu m$ & $(0, 40, 5) \mu m/ \mu s$ \\ + \hline + \end{tabular} + \caption{Initial position and velocity of particle 1 ($p_{1}$) particle 2 ($p_{2}$), where the analytical solution is given by $z(t) = z_{0} \cos (\omega_{z} t)$} + \label{tab:initial_condition_particles} +\end{table} \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)$.} + \caption{A single particle in the Penning trap, approximated and analytical motion in z-direction.} \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] +% Add equations of motion for particle with interaction eq. (18, 19, 20) +% Multiple particles +% Add initial condition of Penning trap +We will now consider the Penning trap with initial conditions given in table \ref{tab:initial_condition_penning}, and simulate using one or two particles. In addition, we simulate two particles both with and without interactions, the result is found in figure \ref{fig:two_particles}. When we add interaction between the particles, they both still follow the same inherent path. However, we observe a small shift in both particle's movement. +\begin{table}[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] + \begin{tabular}{lll} + $B_0$ & $V_{0}$ & $d$ \\ + \hline + \end{tabular} + \caption{Caption} + \label{tab:initial_condition_penning} +\end{table} +% +\begin{figure} \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} + \includegraphics[width=\linewidth]{images/plot_2_particles_xy.pdf} + \caption{Movement of two particles in the xy-plane. $\hat{p}_{1}$ and $\hat{p}_{2}$ include particle interaction, whereas $p_{1}$ and $p_{2}$ does not include particle interaction.} + \label{fig:two_particles} \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] +% Phase space plot +When we simulate two particles, we can see the effect of interaction between the particles in the xy-plane in fig. \ref{fig:phase_space_2x} and in the z-direction in fig. \ref{fig:phase_space_2z}. What we observe is a very small shift in position for particle 1 in x-direction, whereas particle 2 does not have a visible shift. In the z-direction, however, the oscillation of particle 2 experience a greater shift. Particle 2 experience the force of particle 1 such that particle 2 moves larger distance. +% +\begin{figure} \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} + \caption{Phase space plot of two particles in x-direction.} + \label{fig:phase_space_2x} \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] +% +\begin{figure} \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} + \caption{Phase space plot of two particles in z-direction.} + \label{fig:phase_space_2z} \end{figure} -\begin{figure}[H] +\begin{figure} \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.} + \caption{3D plot of particles-} \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. +\begin{figure} + \centering + \includegraphics[width=\linewidth]{images/relative_error.pdf} + \caption{Relative error of RK4 and forward Euler method.} + \label{fig:rel_err} +\end{figure} -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] +\begin{figure} \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} + \caption{Fraction of particles left in the Penning trap, with a given amplitude $f$.} + \label{fig:particles_left} \end{figure} \end{document} diff --git a/src/Makefile b/src/Makefile index 22514b4..e939d9c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -30,7 +30,7 @@ endif .PHONY: clean -all: test_suite main +all: test_suite main frequency_narrow_sweeps_long # Instrumentation using scorep for parallel analysis instrument: @@ -60,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/frequency_narrow_sweeps_long.cpp b/src/frequency_narrow_sweeps_long.cpp index d22db4b..b572f13 100644 --- a/src/frequency_narrow_sweeps_long.cpp +++ b/src/frequency_narrow_sweeps_long.cpp @@ -1,11 +1,11 @@ -/** @file main.cpp +/** @file frequency_narrow_sweeps_long.cpp * * @author Cory Alexander Balaton (coryab) * @author Janita Ovidie Sandtrøen Willumsen (janitaws) * * @version 1.0 * - * @brief The main program for this project + * @brief Sweep of the frequencies from 1.1 to 1.7 using a small time step * * @bug No known bugs * */ diff --git a/src/scripts/animate_100_particles.py b/src/scripts/animate_100_particles.py index 717e31b..dcc2e97 100644 --- a/src/scripts/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 diff --git a/src/scripts/plot_2_particles.py b/src/scripts/plot_2_particles.py index 07401f6..70cf290 100644 --- a/src/scripts/plot_2_particles.py +++ b/src/scripts/plot_2_particles.py @@ -1,3 +1,15 @@ +## @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 diff --git a/src/scripts/plot_3d.py b/src/scripts/plot_3d.py index 5a6c107..9550e1e 100644 --- a/src/scripts/plot_3d.py +++ b/src/scripts/plot_3d.py @@ -1,3 +1,14 @@ +## @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 diff --git a/src/scripts/plot_particles_left.py b/src/scripts/plot_particles_left.py index 5116be7..fde4146 100644 --- a/src/scripts/plot_particles_left.py +++ b/src/scripts/plot_particles_left.py @@ -1,3 +1,15 @@ +## @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 diff --git a/src/scripts/plot_phase_space.py b/src/scripts/plot_phase_space.py index 2302c54..5ec9c0b 100644 --- a/src/scripts/plot_phase_space.py +++ b/src/scripts/plot_phase_space.py @@ -1,3 +1,15 @@ +## @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 diff --git a/src/scripts/plot_relative_error.py b/src/scripts/plot_relative_error.py index df3e64d..30b81d5 100644 --- a/src/scripts/plot_relative_error.py +++ b/src/scripts/plot_relative_error.py @@ -1,3 +1,14 @@ +## @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 diff --git a/src/scripts/plot_single_particle.py b/src/scripts/plot_single_particle.py index a80a8b4..52eb2f9 100644 --- a/src/scripts/plot_single_particle.py +++ b/src/scripts/plot_single_particle.py @@ -1,3 +1,15 @@ +## @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 @@ -23,14 +35,6 @@ def z(t): return 20.*np.cos(w_z*t) def main(): - colors = [ - "lightskyblue", - "deepskyblue", - "salmon", - "tomato", - "mediumaquamarine", - "mediumseagreen" - ] filename = "output/simulate_single_particle/particle_0_r.txt" r = t = [] with open(filename) as f: