diff --git a/.gitignore b/.gitignore index 7549ca4..5f54c8c 100644 --- a/.gitignore +++ b/.gitignore @@ -35,9 +35,10 @@ *.aux *.log *.out -*.bib *.synctex.gz *.bbl +latex/mainNotes.bib + # C++ specifics src/* diff --git a/docs/100_particles.gif b/docs/100_particles.gif index 337c6e5..3dde053 100644 Binary files a/docs/100_particles.gif and b/docs/100_particles.gif differ diff --git a/docs/Particle_8cpp.html b/docs/Particle_8cpp.html index b3fd0e9..98aaf8d 100644 --- a/docs/Particle_8cpp.html +++ b/docs/Particle_8cpp.html @@ -113,7 +113,7 @@ $(document).ready(function(){initNavTree('Particle_8cpp.html',''); initResizable
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
0.1
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file Particle.cpp.

diff --git a/docs/Particle_8cpp_source.html b/docs/Particle_8cpp_source.html index 13c1950..2eaf72e 100644 --- a/docs/Particle_8cpp_source.html +++ b/docs/Particle_8cpp_source.html @@ -102,24 +102,24 @@ $(document).ready(function(){initNavTree('Particle_8cpp_source.html',''); initRe
Go to the documentation of this file.
1
-
13#include "Particle.hpp"
-
14
-
15Particle::Particle(double q, double m,
-
16 arma::vec::fixed<3> r_vec,
-
17 arma::vec::fixed<3> v_vec)
-
18{
-
19 // Giving the particle its properties
-
20 this->q = q;
-
21 this->m = m;
-
22 this->r_vec = r_vec;
-
23 this->v_vec = v_vec;
-
24}
+
14#include "Particle.hpp"
+
15
+
16Particle::Particle(double q, double m,
+
17 arma::vec::fixed<3> r_vec,
+
18 arma::vec::fixed<3> v_vec)
+
19{
+
20 // Giving the particle its properties
+
21 this->q = q;
+
22 this->m = m;
+
23 this->r_vec = r_vec;
+
24 this->v_vec = v_vec;
+
25}
A class that holds the properties of a particle.
-
double q
Charge.
Definition: Particle.hpp:23
-
Particle(double q, double m, vec_3d r_vec, vec_3d v_vec)
Initialize the particle.
Definition: Particle.cpp:15
-
vec_3d v_vec
velocity
Definition: Particle.hpp:26
-
double m
Mass.
Definition: Particle.hpp:24
-
vec_3d r_vec
position
Definition: Particle.hpp:25
+
Particle(double q, double m, arma::vec::fixed< 3 > r_vec, arma::vec::fixed< 3 > v_vec)
Initialize the particle.
Definition: Particle.cpp:16
+
arma::vec::fixed< 3 > v_vec
velocity
Definition: Particle.hpp:24
+
double q
Charge.
Definition: Particle.hpp:21
+
arma::vec::fixed< 3 > r_vec
position
Definition: Particle.hpp:23
+
double m
Mass.
Definition: Particle.hpp:22
diff --git a/docs/Particle_8hpp.html b/docs/Particle_8hpp.html index 00fc0e2..3516260 100644 --- a/docs/Particle_8hpp.html +++ b/docs/Particle_8hpp.html @@ -107,7 +107,6 @@ $(document).ready(function(){initNavTree('Particle_8hpp.html',''); initResizable

A class that holds the properties of a particle. More...

#include <armadillo>
-#include "typedefs.hpp"

Go to the source code of this file.

diff --git a/docs/Particle_8hpp_source.html b/docs/Particle_8hpp_source.html index f3339f5..dbb28de 100644 --- a/docs/Particle_8hpp_source.html +++ b/docs/Particle_8hpp_source.html @@ -107,30 +107,28 @@ $(document).ready(function(){initNavTree('Particle_8hpp_source.html',''); initRe
14
15#include <armadillo>
16
-
17#include "typedefs.hpp"
-
18
-
21class Particle {
-
22private:
-
23 double q;
-
24 double m;
-
25 vec_3d r_vec;
-
26 vec_3d v_vec;
-
27
-
28public:
-
39 Particle(double q, double m, vec_3d r_vec, vec_3d v_vec);
+
19class Particle {
+
20private:
+
21 double q;
+
22 double m;
+
23 arma::vec::fixed<3> r_vec;
+
24 arma::vec::fixed<3> v_vec;
+
25
+
26public:
+
32 Particle(double q, double m,
+
33 arma::vec::fixed<3> r_vec,
+
34 arma::vec::fixed<3> v_vec);
+
35
+
38 friend class PenningTrap;
+
39};
40
-
43 friend class PenningTrap;
-
44};
-
45
-
46#endif
-
Particle
A class that holds attributes of a particle.
Definition: Particle.hpp:21
-
Particle::q
double q
Charge.
Definition: Particle.hpp:23
-
Particle::v_vec
vec_3d v_vec
velocity
Definition: Particle.hpp:26
-
Particle::m
double m
Mass.
Definition: Particle.hpp:24
-
Particle::r_vec
vec_3d r_vec
position
Definition: Particle.hpp:25
-
PenningTrap
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:30
-
typedefs.hpp
Useful typedefs for cleaner code.
-
vec_3d
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:36
+
41#endif
+
Particle
A class that holds attributes of a particle.
Definition: Particle.hpp:19
+
Particle::v_vec
arma::vec::fixed< 3 > v_vec
velocity
Definition: Particle.hpp:24
+
Particle::q
double q
Charge.
Definition: Particle.hpp:21
+
Particle::r_vec
arma::vec::fixed< 3 > r_vec
position
Definition: Particle.hpp:23
+
Particle::m
double m
Mass.
Definition: Particle.hpp:22
+
PenningTrap
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:29
diff --git a/docs/PenningTrap_8cpp.html b/docs/PenningTrap_8cpp.html index 5817ff6..62355e1 100644 --- a/docs/PenningTrap_8cpp.html +++ b/docs/PenningTrap_8cpp.html @@ -106,7 +106,6 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp.html',''); initResiza More...

#include "PenningTrap.hpp"
#include "constants.hpp"
-#include "typedefs.hpp"
#include "utils.hpp"

Go to the source code of this file.

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

Implement evolve_RK4

+

Implement evolve_forward_euler

+

Definition in file PenningTrap.cpp.

diff --git a/docs/PenningTrap_8cpp_source.html b/docs/PenningTrap_8cpp_source.html index 282e5c2..993de8e 100644 --- a/docs/PenningTrap_8cpp_source.html +++ b/docs/PenningTrap_8cpp_source.html @@ -102,311 +102,205 @@ $(document).ready(function(){initNavTree('PenningTrap_8cpp_source.html',''); ini
Go to the documentation of this file.
1
-
13#include "PenningTrap.hpp"
-
14#include "constants.hpp"
-
15#include "typedefs.hpp"
-
16#include "utils.hpp"
-
17
-
18PenningTrap::PenningTrap(double B_0, std::function<double(double)> V_0,
-
19 double d, double t)
-
20{
-
21 this->B_0 = B_0;
-
22 this->V_0 = V_0;
-
23 this->d = d;
-
24 this->t = t;
+
16#include "PenningTrap.hpp"
+
17#include "constants.hpp"
+
18#include "utils.hpp"
+
19
+
20PenningTrap::PenningTrap(double B_0, double V_0, double d)
+
21{
+
22 this->B_0 = B_0;
+
23 this->V_0 = V_0;
+
24 this->d = d;
25}
26
-
27PenningTrap::PenningTrap(unsigned int i, double B_0,
-
28 std::function<double(double)> V_0, double d, double t)
-
29 : PenningTrap::PenningTrap(B_0, V_0, d)
-
30{
-
31 vec_3d r, v;
-
32 for (size_t j = 0; j < i; j++) {
-
33 r = vec_3d().randn() * .1 * this->d;
-
34 v = vec_3d().randn() * .1 * this->d;
-
35 this->add_particle(Particle(1., 40., r, v));
-
36 }
-
37}
-
38
-
39PenningTrap::PenningTrap(std::vector<Particle> particles, double B_0,
-
40 std::function<double(double)> V_0, double d, double t)
-
41 : PenningTrap::PenningTrap(B_0, V_0, d)
-
42{
-
43 this->particles = particles;
-
44}
-
45
-
46vec_3d PenningTrap::v_func(unsigned int i, unsigned int j, double dt)
-
47{
-
48 switch (i) {
-
49 case 0:
-
50 return .5 * dt * this->k_v[0][j];
-
51 case 1:
-
52 return .5 * dt * this->k_v[1][j];
-
53 case 2:
-
54 return dt * this->k_v[2][j];
-
55 case 3:
-
56 return (dt / 6.) * (this->k_v[0][j].eval() + this->k_v[1][j].eval() +
-
57 this->k_v[2][j].eval() + this->k_v[3][j].eval());
-
58 default:
-
59 std::cout << "Not valid!" << std::endl;
-
60 abort();
-
61 }
-
62}
-
63
-
64vec_3d PenningTrap::r_func(unsigned int i, unsigned int j, double dt)
-
65{
-
66 switch (i) {
-
67 case 0:
-
68 return .5 * dt * this->k_r[0][j];
-
69 case 1:
-
70 return .5 * dt * this->k_r[1][j];
-
71 case 2:
-
72 return dt * this->k_r[2][j];
-
73 case 3:
-
74 return (dt / 6.) * (this->k_r[0][j].eval() + this->k_r[1][j].eval() +
-
75 this->k_r[2][j].eval() + this->k_r[3][j].eval());
-
76 default:
-
77 std::cout << "Not valid!" << std::endl;
-
78 abort();
-
79 }
-
80}
-
81
- -
83{
-
84 this->particles.push_back(particle);
-
85}
-
86
- -
88{
-
89 r(2) *= -2.;
-
90 double f = this->V_0(this->t) / (this->d * this->d);
-
91
-
92 return f * r;
-
93}
-
94
- -
96{
-
97 return vec_3d{0., 0., this->B_0};
-
98}
-
99
-
100vec_3d PenningTrap::force_on_particle(unsigned int i, unsigned int j)
-
101{
-
102 Particle p_j = this->particles[j];
-
103 // Calculate the difference between the particles' position
-
104 vec_3d res = this->particles[i].r_vec - p_j.r_vec;
-
105
-
106 // Get the distance between the particles
-
107 double norm = arma::norm(res, 2);
-
108
-
109 // Multiply res with p_j's charge divided by the norm cubed
+ +
28{
+
29 this->particles.push_back(particle);
+
30}
+
31
+
32arma::vec PenningTrap::external_E_field(arma::vec r)
+
33{
+
34 arma::vec::fixed<3> res;
+
35 double f = this->V_0 / (this->d * this->d);
+
36 res(0) = r(0);
+
37 res(1) = r(1);
+
38 res(2) = -2. * r(2);
+
39
+
40 return f * res;
+
41}
+
42
+
43arma::vec PenningTrap::external_B_field(arma::vec r)
+
44{
+
45 arma::vec::fixed<3> res{0., 0., this->B_0};
+
46
+
47 return res;
+
48}
+
49
+
50arma::vec PenningTrap::force_on_particle(int i, int j)
+
51{
+
52 // Calculate the difference between the particles' position
+
53 arma::vec::fixed<3> res =
+
54 this->particles.at(i).r_vec - this->particles.at(j).r_vec;
+
55
+
56 // Get the distance between the particles
+
57 double norm = arma::norm(res);
+
58
+
59 // Multiply res with p_j's charge divided by the norm cubed
+
60 res *= this->particles.at(j).q / (norm * norm * norm);
+
61
+
62 return res;
+
63}
+
64
+ +
66{
+
67 Particle p = this->particles.at(i);
+
68
+
69 arma::vec::fixed<3> B = this->external_B_field(p.r_vec);
+
70
+
71 arma::vec::fixed<3> v_cross_B{p.v_vec(1) * B(2) - p.v_vec(2) * B(1),
+
72 p.v_vec(2) * B(0) - p.v_vec(0) * B(2),
+
73 p.v_vec(0) * B(1) - p.v_vec(1) * B(0)};
+
74
+
75 arma::vec force = p.q * (this->external_E_field(p.r_vec) + v_cross_B);
+
76
+
77 return force;
+
78}
+
79
+ +
81{
+
82 Particle p = this->particles.at(i);
+
83
+
84 arma::vec res(3);
+
85
+
86 for (int j = 0; j < this->particles.size(); j++) {
+
87 if (i == j) {
+
88 continue;
+
89 }
+
90
+
91 res += this->force_on_particle(i, j);
+
92 }
+
93
+
94 res *= K_E * (p.q / p.m);
+
95
+
96 return res;
+
97}
+
98
+ +
100{
+
101 return this->total_force_external(i) - this->total_force_particles(i);
+
102}
+
103
+ +
105{
+
106 std::vector<Particle> tmp_particles = this->particles;
+
107
+
108 arma::vec::fixed<3> *k_v = new arma::vec::fixed<3>[this->particles.size()*4];
+
109 arma::vec::fixed<3> *k_r = new arma::vec::fixed<3>[this->particles.size()*4];
110
-
111 return vec_3d(res * p_j.q / (norm * norm * norm));
-
112}
-
113
- -
115{
-
116 Particle p = this->particles[i];
+
111 int size = this->particles.size();
+
112
+
113 for (int i=0; i<size; i++) {
+
114 k_v[i] = this->total_force(i)/this->particles.at(i).m;
+
115 k_r[i] = this->particles.at(i).v_vec;
+
116 }
117
-
118 if (arma::norm(p.r_vec) > this->d) {
-
119 return vec_3d{0., 0., 0.};
-
120 }
-
121
-
122 vec_3d force =
-
123 p.q * (this->external_E_field(p.r_vec) +
-
124 arma::cross(p.v_vec, this->external_B_field(p.r_vec)));
+
118 for (int i=0; i<size; i++) {
+
119 Particle *p = &this->particles.at(i);
+
120
+
121 p->v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[i];
+
122 p->r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[i];
+
123 }
+
124
125
-
126 return force;
-
127}
-
128
- -
130{
-
131 Particle p = this->particles[i];
-
132
-
133 vec_3d res;
-
134
-
135 for (size_t j = 0; j < this->particles.size(); j++) {
-
136 if (i == j) {
-
137 continue;
-
138 }
-
139
-
140 res += this->force_on_particle(i, j);
+
126 for (int i=0; i<size; i++) {
+
127 k_v[1*size + i] = this->total_force(i)/this->particles.at(i).m;
+
128 k_r[1*size + i] = this->particles.at(i).v_vec;
+
129 }
+
130
+
131 for (int i=0; i<size; i++) {
+
132 Particle *p = &this->particles.at(i);
+
133
+
134 p->v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[1*size + i];
+
135 p->r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[1*size + i];
+
136 }
+
137
+
138 for (int i=0; i<size; i++) {
+
139 k_v[2*size + i] = this->total_force(i)/this->particles.at(i).m;
+
140 k_r[2*size + i] = this->particles.at(i).v_vec;
141 }
142
-
143 return vec_3d(res * K_E * (p.q / p.m));
-
144}
+
143 for (int i=0; i<size; i++) {
+
144 Particle *p = &this->particles.at(i);
145
- -
147{
-
148 return this->total_force_external(i) - this->total_force_particles(i);
-
149}
+
146 p->v_vec = tmp_particles.at(i).v_vec + dt*k_v[2*size + i];
+
147 p->r_vec = tmp_particles.at(i).r_vec + dt*k_r[2*size + i];
+
148 }
+
149
150
-
151void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
-
152{
-
153
-
154 std::vector<Particle> original_particles = this->particles;
-
155 std::vector<Particle> tmp_particles = this->particles;
-
156
-
157 vec_3d (PenningTrap::*force)(unsigned int);
-
158 if (particle_interaction) {
- -
160 }
-
161 else {
- -
163 }
-
164
-
165 size_t size = this->particles.size();
+
151 for (int i=0; i<size; i++) {
+
152 k_v[3*size + i] = this->total_force(i)/this->particles.at(i).m;
+
153 k_r[3*size + i] = this->particles.at(i).v_vec;
+
154 }
+
155
+
156 for (int i=0; i<size; i++) {
+
157 Particle *p = &this->particles.at(i);
+
158
+
159 p->v_vec = tmp_particles.at(i).v_vec + dt*(k_v[i] + k_v[size + i] + k_v[2*size + i] + k_v[3*size + i])/6;
+
160 p->r_vec = tmp_particles.at(i).r_vec + dt*(k_r[i] + k_r[size + i] + k_r[2*size + i] + k_r[3*size + i])/6;
+
161 }
+
162
+
163 delete [] k_v;
+
164 delete [] k_r;
+
165}
166
-
167 this->k_v = sim_arr(4, sim_cols(size));
-
168 this->k_r = sim_arr(4, sim_cols(size));
-
169
-
170 for (size_t i = 0; i < 4; i++) {
-
171#pragma omp parallel for
-
172 for (size_t j = 0; j < this->particles.size(); j++) {
-
173 this->k_v[i][j] = (this->*force)(j) / this->particles[j].m;
-
174 this->k_r[i][j] = this->particles[j].v_vec;
-
175
-
176 Particle *p = &tmp_particles[j];
-
177
-
178 p->v_vec = original_particles[j].v_vec + this->v_func(i, j, dt);
-
179 p->r_vec = original_particles[j].r_vec + this->r_func(i, j, dt);
-
180 }
-
181 this->particles = tmp_particles;
-
182 }
-
183 this->t += dt;
-
184}
-
185
-
186void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction)
-
187{
-
188 std::vector<Particle> new_state = this->particles;
-
189
-
190 Particle *p;
-
191
-
192 vec_3d (PenningTrap::*force)(unsigned int);
-
193 if (particle_interaction) {
- -
195 }
-
196 else {
- -
198 }
-
199
-
200#pragma omp parallel for private(p)
-
201 for (size_t i = 0; i < this->particles.size(); i++) {
-
202 p = &new_state[i];
-
203 p->v_vec += dt * (this->*force)(i) / p->m;
-
204 p->r_vec += dt * this->particles[i].v_vec;
-
205 }
-
206
-
207 this->particles = new_state;
-
208 this->t += dt;
-
209}
-
210
-
211sim_arr PenningTrap::simulate(double time, unsigned int steps,
-
212 std::string method, bool particle_interaction)
-
213{
-
214 double dt = time / (double)steps;
-
215
-
216 sim_arr res(this->particles.size(), sim_cols(steps));
-
217
-
218 void (PenningTrap::*func)(double, bool);
-
219 if (method == "rk4") {
- -
221 }
-
222 else if (method == "euler") {
- -
224 }
-
225 else {
-
226 std::cout << "Not a valid method!" << std::endl;
-
227 abort();
-
228 }
-
229
-
230 for (size_t j = 0; j < steps; j++) {
-
231 for (size_t i = 0; i < this->particles.size(); i++) {
-
232 res[i][j] = this->particles[i].r_vec;
-
233 }
-
234 (this->*func)(dt, particle_interaction);
-
235 }
-
236
-
237 return res;
-
238}
-
239
-
240void PenningTrap::write_simulation_to_dir(std::string path, double time,
-
241 int steps, std::string method,
-
242 bool particle_interaction)
-
243{
-
244 if (path.back() != '/') {
-
245 path += '/';
-
246 }
-
247 if (mkpath(path, 0777) != 0) {
-
248 std::cout << "Hello" << std::endl;
-
249 return;
-
250 }
-
251
-
252 sim_arr res = this->simulate(time, steps, method, particle_interaction);
-
253
-
254 std::ofstream ofile;
-
255
-
256#pragma omp parallel for private(ofile)
-
257 for (size_t i = 0; i < this->particles.size(); i++) {
-
258 ofile.open(path + "particle_" + std::to_string(i) + ".txt");
-
259 for (vec_3d &vec : res[i]) {
-
260 ofile << vec(0) << "," << vec(1) << "," << vec(2) << "\n";
-
261 }
-
262 ofile.close();
-
263 }
-
264}
-
265
-
266double PenningTrap::fraction_of_particles_left(double time, unsigned int steps, std::string method, bool particle_interaction)
-
267{
-
268 sim_arr res = this->simulate(time, steps, method, particle_interaction);
-
269
-
270 int particles_left = 0;
-
271
-
272 for (Particle p : this->particles) {
-
273 if (arma::norm(p.r_vec) < this->d) {
-
274 particles_left++;
-
275 }
-
276 }
-
277
-
278 return (double) particles_left / (double) this->particles.size();
-
279}
-
280
+ +
168{
+
169 std::vector<Particle> new_state = this->particles;
+
170
+
171 Particle *p;
+
172
+
173#pragma omp parallel for private(p)
+
174 for (int i = 0; i < this->particles.size(); i++) {
+
175 p = &new_state.at(i);
+
176 p->v_vec += dt * this->total_force(i) / new_state.at(i).m;
+
177 p->r_vec += dt * this->particles.at(i).v_vec;
+
178 }
+
179
+
180 this->particles = new_state;
+
181}
+
182
+
183arma::vec PenningTrap::get_particle(int i)
+
184{
+
185 return this->particles.at(i).r_vec;
+
186}
+
187
+
188double PenningTrap::get_d()
+
189{
+
190 return this->d;
+
191}
A class for simulating a Penning trap.
-
A class that holds attributes of a particle.
Definition: Particle.hpp:21
-
double q
Charge.
Definition: Particle.hpp:23
-
vec_3d v_vec
velocity
Definition: Particle.hpp:26
-
double m
Mass.
Definition: Particle.hpp:24
-
vec_3d r_vec
position
Definition: Particle.hpp:25
-
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:30
-
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:36
-
double fraction_of_particles_left(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
-
double B_0
Magnetic field strength.
Definition: PenningTrap.hpp:32
-
vec_3d external_E_field(vec_3d r)
Calculate E at point r.
Definition: PenningTrap.cpp:87
-
vec_3d total_force(unsigned int i)
calculate the total force on a particle p_i.
-
sim_arr k_r
Definition: PenningTrap.hpp:39
-
void evolve_RK4(double dt, bool particle_interaction=true)
Go forward one timestep using the RK4 method.
-
vec_3d r_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:64
-
vec_3d total_force_particles(unsigned int i)
Calculate the total force on a particle p_i from other particles.
-
sim_arr simulate(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate the particle system inside the Penning trap over a certain amount of time.
-
double d
Characteristic dimension.
Definition: PenningTrap.hpp:34
-
void add_particle(Particle particle)
Add a particle to the system.
Definition: PenningTrap.cpp:82
-
double t
Current time.
Definition: PenningTrap.hpp:35
-
vec_3d force_on_particle(unsigned int i, unsigned int j)
Calculate the force between 2 particles.
-
std::function< double(double)> V_0
Applied potential.
Definition: PenningTrap.hpp:33
-
void evolve_forward_euler(double dt, bool particle_interaction=true)
Go forward one timestep using the forward Euler method.
-
void write_simulation_to_dir(std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate and write the displacement of all particles to files.
-
vec_3d external_B_field(vec_3d r)
Calculate B at point r.
Definition: PenningTrap.cpp:95
-
PenningTrap(double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)
Constructor for the PenningTrap class.
Definition: PenningTrap.cpp:18
-
vec_3d total_force_external(unsigned int i)
Calculate the total external force on a particle.
-
sim_arr k_v
Definition: PenningTrap.hpp:37
-
vec_3d v_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:46
+
A class that holds attributes of a particle.
Definition: Particle.hpp:19
+
arma::vec::fixed< 3 > v_vec
velocity
Definition: Particle.hpp:24
+
double q
Charge.
Definition: Particle.hpp:21
+
arma::vec::fixed< 3 > r_vec
position
Definition: Particle.hpp:23
+
double m
Mass.
Definition: Particle.hpp:22
+
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:34
+
arma::vec total_force_external(int i)
Calculate the total external force on a particle.
Definition: PenningTrap.cpp:65
+
double B_0
Magnetic field strength.
Definition: PenningTrap.hpp:31
+
arma::vec total_force_particles(int i)
Calculate the total force on a particle from other particles.
Definition: PenningTrap.cpp:80
+
arma::vec external_B_field(arma::vec r)
Calculate B at point r.
Definition: PenningTrap.cpp:43
+
arma::vec force_on_particle(int i, int j)
Calculate the force between 2 particles.
Definition: PenningTrap.cpp:50
+
void evolve_forward_euler(double dt)
Go forward one timestep using the forward Euler method.
+
double d
Characteristic dimension.
Definition: PenningTrap.hpp:33
+
void add_particle(Particle particle)
Add a particle to the system.
Definition: PenningTrap.cpp:27
+
double V_0
Applied potential.
Definition: PenningTrap.hpp:32
+
PenningTrap(double B_0=T, double V_0=25.*V/1000., double d=500.)
Set B_0, V_0 and d.
Definition: PenningTrap.cpp:20
+
arma::vec total_force(int i)
calculate the total force on a particle.
Definition: PenningTrap.cpp:99
+
arma::vec external_E_field(arma::vec r)
Calculate E at point r.
Definition: PenningTrap.cpp:32
+
void evolve_RK4(double dt)
Go forward one timestep using the RK4 method.
Library of constants.
#define K_E
Coulomb constant. unit: .
Definition: constants.hpp:15
-
Useful typedefs for cleaner code.
-
std::vector< arma::vec::fixed< 3 > > sim_cols
Typedef for the column of the result vector from simulating particles.
Definition: typedefs.hpp:24
-
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:36
-
std::vector< sim_cols > sim_arr
Typedef for the result of the simulate method.
Definition: typedefs.hpp:32
Function prototypes and macros that are useful.
-
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:76
diff --git a/docs/PenningTrap_8hpp.html b/docs/PenningTrap_8hpp.html index 5f6ee45..306bc89 100644 --- a/docs/PenningTrap_8hpp.html +++ b/docs/PenningTrap_8hpp.html @@ -110,7 +110,6 @@ $(document).ready(function(){initNavTree('PenningTrap_8hpp.html',''); initResiza #include <omp.h>
#include "Particle.hpp"
#include "constants.hpp"
-#include "typedefs.hpp"

Go to the source code of this file.

diff --git a/docs/PenningTrap_8hpp_source.html b/docs/PenningTrap_8hpp_source.html index dfdddbe..02b2aed 100644 --- a/docs/PenningTrap_8hpp_source.html +++ b/docs/PenningTrap_8hpp_source.html @@ -110,106 +110,63 @@ $(document).ready(function(){initNavTree('PenningTrap_8hpp_source.html',''); ini
17
18#include "Particle.hpp"
19#include "constants.hpp"
-
20#include "typedefs.hpp"
-
21
-
22#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
-
23 initializer(omp_priv = omp_orig)
-
24
-
30class PenningTrap {
-
31private:
-
32 double B_0;
-
33 std::function<double(double)> V_0;
-
34 double d;
-
35 double t;
-
36 std::vector<Particle> particles;
-
37 sim_arr k_v;
-
39 sim_arr k_r;
-
41
-
52 vec_3d v_func(unsigned int i, unsigned int j, double dt);
-
53
-
64 vec_3d r_func(unsigned int i, unsigned int j, double dt);
-
65
-
66public:
-
74 PenningTrap(
-
75 double B_0 = T,
-
76 std::function<double(double)> V_0 =
-
77 [](double t) { return 25. * V / 1000.; },
-
78 double d = 500., double t = 0.);
-
79
-
88 PenningTrap(
-
89 unsigned int i, double B_0 = T,
-
90 std::function<double(double)> V_0 =
-
91 [](double t) { return 25. * V / 1000.; },
-
92 double d = 500., double t = 0.);
-
93
-
102 PenningTrap(
-
103 std::vector<Particle> particles, double B_0 = T,
-
104 std::function<double(double)> V_0 =
-
105 [](double t) { return 25. * V / 1000.; },
-
106 double d = 500., double t = 0.);
-
107
-
112 void add_particle(Particle particle);
-
113
-
120 vec_3d external_E_field(vec_3d r);
-
121
-
128 vec_3d external_B_field(vec_3d r);
-
129
-
140 vec_3d force_on_particle(unsigned int i, unsigned int j);
-
141
-
151 vec_3d total_force_external(unsigned int i);
-
152
-
159 vec_3d total_force_particles(unsigned int i);
-
160
-
167 vec_3d total_force(unsigned int i);
-
168
-
174 void evolve_RK4(double dt, bool particle_interaction = true);
-
175
-
181 void evolve_forward_euler(double dt, bool particle_interaction = true);
-
182
-
191 sim_arr simulate(double time, unsigned int steps,
-
192 std::string method = "rk4",
-
193 bool particle_interaction = true);
-
194
-
203 void write_simulation_to_dir(std::string path, double time,
-
204 unsigned int steps, std::string method = "rk4",
-
205 bool particle_interaction = true);
-
206
-
217 double fraction_of_particles_left(double time, unsigned int steps,
-
218 std::string method = "rk4",
-
219 bool particle_interaction = true);
-
220};
-
221
-
222#endif
+
20
+
21#pragma omp declare reduction( + : arma::vec : omp_out += omp_in ) \
+
22 initializer( omp_priv = omp_orig )
+
23
+
29class PenningTrap {
+
30private:
+
31 double B_0;
+
32 double V_0;
+
33 double d;
+
34 std::vector<Particle> particles;
+
35
+
36public:
+
39 PenningTrap(double B_0 = T, double V_0 = 25.*V/1000., double d = 500.);
+
40
+
43 void add_particle(Particle particle);
+
44
+
47 arma::vec external_E_field(arma::vec r);
+
48
+
51 arma::vec external_B_field(arma::vec r);
+
52
+
58 arma::vec force_on_particle(int i, int j);
+
59
+
65 arma::vec total_force_external(int i);
+
66
+
69 arma::vec total_force_particles(int i);
+
70
+
73 arma::vec total_force(int i);
+
74
+
77 void evolve_RK4(double dt);
+
78
+
81 void evolve_forward_euler(double dt);
+
82
+
83 arma::vec get_particle(int i);
+
84
+
85 double get_d();
+
86};
+
87
+
88#endif
Particle.hpp
A class that holds the properties of a particle.
-
Particle
A class that holds attributes of a particle.
Definition: Particle.hpp:21
-
PenningTrap
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:30
-
PenningTrap::particles
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:36
-
PenningTrap::fraction_of_particles_left
double fraction_of_particles_left(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
Definition: PenningTrap.cpp:266
-
PenningTrap::B_0
double B_0
Magnetic field strength.
Definition: PenningTrap.hpp:32
-
PenningTrap::external_E_field
vec_3d external_E_field(vec_3d r)
Calculate E at point r.
Definition: PenningTrap.cpp:87
-
PenningTrap::total_force
vec_3d total_force(unsigned int i)
calculate the total force on a particle p_i.
Definition: PenningTrap.cpp:146
-
PenningTrap::k_r
sim_arr k_r
Definition: PenningTrap.hpp:39
-
PenningTrap::evolve_RK4
void evolve_RK4(double dt, bool particle_interaction=true)
Go forward one timestep using the RK4 method.
Definition: PenningTrap.cpp:151
-
PenningTrap::r_func
vec_3d r_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:64
-
PenningTrap::total_force_particles
vec_3d total_force_particles(unsigned int i)
Calculate the total force on a particle p_i from other particles.
Definition: PenningTrap.cpp:129
-
PenningTrap::simulate
sim_arr simulate(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate the particle system inside the Penning trap over a certain amount of time.
Definition: PenningTrap.cpp:211
-
PenningTrap::d
double d
Characteristic dimension.
Definition: PenningTrap.hpp:34
-
PenningTrap::add_particle
void add_particle(Particle particle)
Add a particle to the system.
Definition: PenningTrap.cpp:82
-
PenningTrap::t
double t
Current time.
Definition: PenningTrap.hpp:35
-
PenningTrap::force_on_particle
vec_3d force_on_particle(unsigned int i, unsigned int j)
Calculate the force between 2 particles.
Definition: PenningTrap.cpp:100
-
PenningTrap::V_0
std::function< double(double)> V_0
Applied potential.
Definition: PenningTrap.hpp:33
-
PenningTrap::evolve_forward_euler
void evolve_forward_euler(double dt, bool particle_interaction=true)
Go forward one timestep using the forward Euler method.
Definition: PenningTrap.cpp:186
-
PenningTrap::write_simulation_to_dir
void write_simulation_to_dir(std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
Simulate and write the displacement of all particles to files.
Definition: PenningTrap.cpp:240
-
PenningTrap::external_B_field
vec_3d external_B_field(vec_3d r)
Calculate B at point r.
Definition: PenningTrap.cpp:95
-
PenningTrap::total_force_external
vec_3d total_force_external(unsigned int i)
Calculate the total external force on a particle.
Definition: PenningTrap.cpp:114
-
PenningTrap::k_v
sim_arr k_v
Definition: PenningTrap.hpp:37
-
PenningTrap::v_func
vec_3d v_func(unsigned int i, unsigned int j, double dt)
Helper for evolve_RK4 when calculating values.
Definition: PenningTrap.cpp:46
+
Particle
A class that holds attributes of a particle.
Definition: Particle.hpp:19
+
PenningTrap
A class that simulates a Penning trap.
Definition: PenningTrap.hpp:29
+
PenningTrap::particles
std::vector< Particle > particles
The particles in the Penning trap.
Definition: PenningTrap.hpp:34
+
PenningTrap::total_force_external
arma::vec total_force_external(int i)
Calculate the total external force on a particle.
Definition: PenningTrap.cpp:65
+
PenningTrap::B_0
double B_0
Magnetic field strength.
Definition: PenningTrap.hpp:31
+
PenningTrap::total_force_particles
arma::vec total_force_particles(int i)
Calculate the total force on a particle from other particles.
Definition: PenningTrap.cpp:80
+
PenningTrap::external_B_field
arma::vec external_B_field(arma::vec r)
Calculate B at point r.
Definition: PenningTrap.cpp:43
+
PenningTrap::force_on_particle
arma::vec force_on_particle(int i, int j)
Calculate the force between 2 particles.
Definition: PenningTrap.cpp:50
+
PenningTrap::evolve_forward_euler
void evolve_forward_euler(double dt)
Go forward one timestep using the forward Euler method.
Definition: PenningTrap.cpp:167
+
PenningTrap::d
double d
Characteristic dimension.
Definition: PenningTrap.hpp:33
+
PenningTrap::add_particle
void add_particle(Particle particle)
Add a particle to the system.
Definition: PenningTrap.cpp:27
+
PenningTrap::V_0
double V_0
Applied potential.
Definition: PenningTrap.hpp:32
+
PenningTrap::total_force
arma::vec total_force(int i)
calculate the total force on a particle.
Definition: PenningTrap.cpp:99
+
PenningTrap::external_E_field
arma::vec external_E_field(arma::vec r)
Calculate E at point r.
Definition: PenningTrap.cpp:32
+
PenningTrap::evolve_RK4
void evolve_RK4(double dt)
Go forward one timestep using the RK4 method.
Definition: PenningTrap.cpp:104
constants.hpp
Library of constants.
T
#define T
1 Tesla. unit:
Definition: constants.hpp:17
V
#define V
1 Volt. unit:
Definition: constants.hpp:19
-
typedefs.hpp
Useful typedefs for cleaner code.
-
vec_3d
arma::vec::fixed< 3 > vec_3d
Typedef for a fixed 3d arma vector.
Definition: typedefs.hpp:36
-
sim_arr
std::vector< sim_cols > sim_arr
Typedef for the result of the simulate method.
Definition: typedefs.hpp:32
diff --git a/docs/animate__100__particles_8py_source.html b/docs/animate__100__particles_8py_source.html index af734ca..80feb43 100644 --- a/docs/animate__100__particles_8py_source.html +++ b/docs/animate__100__particles_8py_source.html @@ -103,75 +103,68 @@ $(document).ready(function(){initNavTree('animate__100__particles_8py_source.htm
1import matplotlib.pyplot as plt
2import numpy as np
-
3from matplotlib import animation
-
4from mpl_toolkits.mplot3d import Axes3D
+
3from mpl_toolkits.mplot3d import Axes3D
+
4from matplotlib import animation
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])
+
6def get_data(files):
+
7 res = []
+
8 for file in files:
+
9 arr = [[], [], []]
+
10 with open(file, encoding="utf8") as f:
+
11 lines = f.readlines()
+
12
+
13 for line in lines:
+
14 xi,yi,zi = map(float, line.strip().split(","))
+
15 arr[0].append(xi)
+
16 arr[1].append(yi)
+
17 arr[2].append(zi)
+
18 res.append(arr)
+
19
+
20 return np.array(res)
+
21
+
22def update(num, lines, arr):
+
23 for line, a in zip(lines, arr):
+
24 line.set_data(a[:2, num])
+
25 line.set_3d_properties(a[2, num])
+
26
+
27
28
-
29
-
30def animate():
-
31 plt.style.use("dark_background")
-
32 fig = plt.figure()
-
33 ax = fig.add_subplot(projection="3d")
+
29def animate():
+
30 plt.style.use("dark_background")
+
31 fig = plt.figure()
+
32 ax = fig.add_subplot(projection="3d")
+
33
34
-
35 arr = get_data([f"output/simulate_100_particles/particle_{i}.txt" for i in range(100)])
+
35 arr = get_data([f"output/p{i}_RK4.txt" for i in range(100)])
36
-
37 arr = arr[:, :, ::10]
+
37 arr = arr[:,:,::10]
38
39 N = len(arr[0][0])
40
-
41 lines = [ax.plot(*a[:, 1], "o")[0] for a in arr]
+
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)")
+
43 ax.set_xlim3d([-500.0, 500.0])
+
44 ax.set_xlabel('X')
+
45
+
46 ax.set_ylim3d([-500.0, 500.0])
+
47 ax.set_ylabel('Y')
+
48
+
49 ax.set_zlim3d([-500.0, 500.0])
+
50 ax.set_zlabel('Z')
+
51
+
52 ani = animation.FuncAnimation(fig, update, N, fargs=(lines, arr),
+
53 interval=1,
+
54 blit=False)
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
-
69
-
70if __name__ == "__main__":
-
71 animate()
+
56
+
57 ani.save("100_particles.gif", writer=animation.FFMpegFileWriter(fps=30))
+
58 plt.show()
+
59
+
60
+
61if __name__ == "__main__":
+
62 animate()
+
63
+
64
diff --git a/docs/bug.html b/docs/bug.html index 8ed5241..bbcbbea 100644 --- a/docs/bug.html +++ b/docs/bug.html @@ -105,23 +105,21 @@ $(document).ready(function(){initNavTree('bug.html',''); initResizable(); });
File constants.hpp
No known bugs
File main.cpp
-
No known bugs
+
No known bugs
File Particle.cpp
-
No known bugs
+
No known bugs
File Particle.hpp
No known bugs
File PenningTrap.cpp
-
No known bugs
+
No known bugs
File PenningTrap.hpp
No known bugs
File test_suite.cpp
-
No known bugs
-
File typedefs.hpp
-
No known bugs
+
No known bugs
File utils.cpp
-
No known bugs
+
No known bugs
File utils.hpp
-
No known bugs
+
No known bugs
diff --git a/docs/classParticle-members.html b/docs/classParticle-members.html index b3fc92b..02f2b23 100644 --- a/docs/classParticle-members.html +++ b/docs/classParticle-members.html @@ -105,11 +105,11 @@ $(document).ready(function(){initNavTree('classParticle.html',''); initResizable

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

- + - - + +
mParticleprivate
Particle(double q, double m, vec_3d r_vec, vec_3d v_vec)Particle
Particle(double q, double m, arma::vec::fixed< 3 > r_vec, arma::vec::fixed< 3 > v_vec)Particle
PenningTrapParticlefriend
qParticleprivate
r_vecParticleprivate
v_vecParticleprivate
r_vecParticleprivate
v_vecParticleprivate
diff --git a/docs/classParticle.html b/docs/classParticle.html index 271a213..997eb37 100644 --- a/docs/classParticle.html +++ b/docs/classParticle.html @@ -114,9 +114,9 @@ $(document).ready(function(){initNavTree('classParticle.html',''); initResizable - - - + + +

Public Member Functions

 Particle (double q, double m, vec_3d r_vec, vec_3d v_vec)
 Initialize the particle.
 
 Particle (double q, double m, arma::vec::fixed< 3 > r_vec, arma::vec::fixed< 3 > v_vec)
 Initialize the particle.
 
@@ -126,12 +126,12 @@ Private Attributes - - - - - - + + + + + +

Private Attributes

double m
 Mass.
 
vec_3d r_vec
 position
 
vec_3d v_vec
 velocity
 
arma::vec::fixed< 3 > r_vec
 position
 
arma::vec::fixed< 3 > v_vec
 velocity
 
@@ -142,10 +142,10 @@ Friends

Detailed Description

A class that holds attributes of a particle.

-

Definition at line 21 of file Particle.hpp.

+

Definition at line 19 of file Particle.hpp.

Constructor & Destructor Documentation

- -

◆ Particle()

+ +

◆ Particle()

@@ -165,13 +165,13 @@ Friends
- + - + @@ -183,18 +183,9 @@ Friends

Initialize the particle.

-

Initialize the particle with a charge, mass, position and velocity.

-
Parameters
-

Friends

vec_3d arma::vec::fixed< 3 >  r_vec,
vec_3d arma::vec::fixed< 3 >  v_vec 
- - - - -
qThe charge of the particle
mThe mass of the particle
r_vecThe initial position of the particle
v_vecThe initial velocity of the particle
- - +

Initialize the particle with a charge, mass, position and velocity.

-

Definition at line 15 of file Particle.cpp.

+

Definition at line 16 of file Particle.cpp.

@@ -221,7 +212,7 @@ Friends

Make private attributes available for PenningTrap.

-

Definition at line 43 of file Particle.hpp.

+

Definition at line 38 of file Particle.hpp.

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

Mass.

-

Definition at line 24 of file Particle.hpp.

+

Definition at line 22 of file Particle.hpp.

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

Charge.

-

Definition at line 23 of file Particle.hpp.

+

Definition at line 21 of file Particle.hpp.

- -

◆ r_vec

+ +

◆ r_vec

@@ -288,7 +279,7 @@ Friends - +
vec_3d Particle::r_vecarma::vec::fixed<3> Particle::r_vec
@@ -300,12 +291,12 @@ Friends

position

-

Definition at line 25 of file Particle.hpp.

+

Definition at line 23 of file Particle.hpp.

- -

◆ v_vec

+ +

◆ v_vec

@@ -314,7 +305,7 @@ Friends - +
vec_3d Particle::v_vecarma::vec::fixed<3> Particle::v_vec
@@ -326,7 +317,7 @@ Friends

velocity

-

Definition at line 26 of file Particle.hpp.

+

Definition at line 24 of file Particle.hpp.

diff --git a/docs/classParticle.js b/docs/classParticle.js index 71255c1..113132c 100644 --- a/docs/classParticle.js +++ b/docs/classParticle.js @@ -1,9 +1,9 @@ var classParticle = [ - [ "Particle", "classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4", null ], + [ "Particle", "classParticle.html#a00e108823877a25513ccae7cac011b4c", null ], [ "PenningTrap", "classParticle.html#aa797d319549dc2a0beb06cdbfd430232", null ], [ "m", "classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563", null ], [ "q", "classParticle.html#a566dcc1de4bdc01251776948798ea8e1", null ], - [ "r_vec", "classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6", null ], - [ "v_vec", "classParticle.html#a879692772803d6ab65fa4993b54aea6e", null ] + [ "r_vec", "classParticle.html#acf1a0f3c978b06d76df5bb4279594467", null ], + [ "v_vec", "classParticle.html#a4a5d22c7aeca66f67d083f270cba25df", null ] ]; \ No newline at end of file diff --git a/docs/classPenningTrap-members.html b/docs/classPenningTrap-members.html index 859c052..5a26d52 100644 --- a/docs/classPenningTrap-members.html +++ b/docs/classPenningTrap-members.html @@ -107,27 +107,19 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza add_particle(Particle particle)PenningTrap B_0PenningTrapprivate dPenningTrapprivate - evolve_forward_euler(double dt, bool particle_interaction=true)PenningTrap - evolve_RK4(double dt, bool particle_interaction=true)PenningTrap - external_B_field(vec_3d r)PenningTrap - external_E_field(vec_3d r)PenningTrap - force_on_particle(unsigned int i, unsigned int j)PenningTrap - fraction_of_particles_left(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap - k_rPenningTrapprivate - k_vPenningTrapprivate - particlesPenningTrapprivate - PenningTrap(double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)PenningTrap - PenningTrap(unsigned int i, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)PenningTrap - PenningTrap(std::vector< Particle > particles, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)PenningTrap - r_func(unsigned int i, unsigned int j, double dt)PenningTrapprivate - simulate(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap - tPenningTrapprivate - total_force(unsigned int i)PenningTrap - total_force_external(unsigned int i)PenningTrap - total_force_particles(unsigned int i)PenningTrap - V_0PenningTrapprivate - v_func(unsigned int i, unsigned int j, double dt)PenningTrapprivate - write_simulation_to_dir(std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)PenningTrap + evolve_forward_euler(double dt)PenningTrap + evolve_RK4(double dt)PenningTrap + external_B_field(arma::vec r)PenningTrap + external_E_field(arma::vec r)PenningTrap + force_on_particle(int i, int j)PenningTrap + get_d() (defined in PenningTrap)PenningTrap + get_particle(int i) (defined in PenningTrap)PenningTrap + particlesPenningTrapprivate + PenningTrap(double B_0=T, double V_0=25.*V/1000., double d=500.)PenningTrap + total_force(int i)PenningTrap + total_force_external(int i)PenningTrap + total_force_particles(int i)PenningTrap + V_0PenningTrapprivate diff --git a/docs/classPenningTrap.html b/docs/classPenningTrap.html index 9afb617..af62e25 100644 --- a/docs/classPenningTrap.html +++ b/docs/classPenningTrap.html @@ -100,7 +100,6 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza
Public Member Functions | -Private Member Functions | Private Attributes | List of all members
PenningTrap Class Reference
@@ -114,91 +113,64 @@ $(document).ready(function(){initNavTree('classPenningTrap.html',''); initResiza - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 PenningTrap (double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)
 Constructor for the PenningTrap class.
 
 PenningTrap (unsigned int i, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)
 Constructor for the PenningTrap class.
 
 PenningTrap (std::vector< Particle > particles, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)
 Constructor for the PenningTrap class.
 
 PenningTrap (double B_0=T, double V_0=25.*V/1000., double d=500.)
 Set B_0, V_0 and d.
 
void add_particle (Particle particle)
 Add a particle to the system.
 
vec_3d external_E_field (vec_3d r)
 Calculate E at point r.
 
vec_3d external_B_field (vec_3d r)
 Calculate B at point r.
 
vec_3d force_on_particle (unsigned int i, unsigned int j)
 Calculate the force between 2 particles.
 
vec_3d total_force_external (unsigned int i)
 Calculate the total external force on a particle.
 
vec_3d total_force_particles (unsigned int i)
 Calculate the total force on a particle p_i from other particles.
 
vec_3d total_force (unsigned int i)
 calculate the total force on a particle p_i.
 
void evolve_RK4 (double dt, bool particle_interaction=true)
 Go forward one timestep using the RK4 method.
 
void evolve_forward_euler (double dt, bool particle_interaction=true)
 Go forward one timestep using the forward Euler method.
 
sim_arr simulate (double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
 Simulate the particle system inside the Penning trap over a certain amount of time.
 
void write_simulation_to_dir (std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
 Simulate and write the displacement of all particles to files.
 
double fraction_of_particles_left (double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
 Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation.
 
- - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +

-Private Member Functions

vec_3d v_func (unsigned int i, unsigned int j, double dt)
 Helper for evolve_RK4 when calculating \(k_{v,i,j}\) values.
 
vec_3d r_func (unsigned int i, unsigned int j, double dt)
 Helper for evolve_RK4 when calculating \(k_{r,i,j}\) values.
 
arma::vec external_E_field (arma::vec r)
 Calculate E at point r.
 
arma::vec external_B_field (arma::vec r)
 Calculate B at point r.
 
arma::vec force_on_particle (int i, int j)
 Calculate the force between 2 particles.
 
arma::vec total_force_external (int i)
 Calculate the total external force on a particle.
 
arma::vec total_force_particles (int i)
 Calculate the total force on a particle from other particles.
 
arma::vec total_force (int i)
 calculate the total force on a particle.
 
void evolve_RK4 (double dt)
 Go forward one timestep using the RK4 method.
 
void evolve_forward_euler (double dt)
 Go forward one timestep using the forward Euler method.
 
arma::vec get_particle (int i)
 
double get_d ()
 
- - - + + + - - - - - - -

Private Attributes

double B_0
 Magnetic field strength.
 
std::function< double(double)> V_0
 Applied potential.
 
double V_0
 Applied potential.
 
double d
 Characteristic dimension.
 
double t
 Current time.
 
std::vector< Particleparticles
 The particles in the Penning trap.
 
sim_arr k_v
 
sim_arr k_r
 

Detailed Description

A class that simulates a Penning trap.

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

-

Definition at line 30 of file PenningTrap.hpp.

+

Definition at line 29 of file PenningTrap.hpp.

Constructor & Destructor Documentation

- -

◆ PenningTrap() [1/3]

+ +

◆ PenningTrap()

@@ -212,20 +184,14 @@ Private Attributes - std::function< double(double)>  - V_0 = [](double t) { return 25. * V / 1000.; }, + double  + V_0 = 25.*V/1000., double  - d = 500., - - - - - double  - t = 0.  + d = 500.  @@ -235,138 +201,9 @@ Private Attributes
-

Constructor for the PenningTrap class.

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

Set B_0, V_0 and d.

-

Definition at line 18 of file PenningTrap.cpp.

- -
-
- -

◆ PenningTrap() [2/3]

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PenningTrap::PenningTrap (unsigned int i,
double B_0 = T,
std::function< double(double)> V_0 = [](double t) { return 25. * V / 1000.; },
double d = 500.,
double t = 0. 
)
-
- -

Constructor for the PenningTrap class.

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

Definition at line 27 of file PenningTrap.cpp.

- -
-
- -

◆ PenningTrap() [3/3]

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PenningTrap::PenningTrap (std::vector< Particleparticles,
double B_0 = T,
std::function< double(double)> V_0 = [](double t) { return 25. * V / 1000.; },
double d = 500.,
double t = 0. 
)
-
- -

Constructor for the PenningTrap class.

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

Definition at line 39 of file PenningTrap.cpp.

+

Definition at line 20 of file PenningTrap.cpp.

@@ -388,19 +225,13 @@ Private Attributes

Add a particle to the system.

-
Parameters
- - -
particleThe particle to add to the Penning trap
-
-
-

Definition at line 82 of file PenningTrap.cpp.

+

Definition at line 27 of file PenningTrap.cpp.

- -

◆ evolve_forward_euler()

+ +

◆ evolve_forward_euler()

@@ -409,37 +240,20 @@ Private Attributes void PenningTrap::evolve_forward_euler ( double  - dt, - - - + dt) - bool  - particle_interaction = true  - - - - ) -

Go forward one timestep using the forward Euler method.

-
Parameters
- - - -
dtThe step length
particle_interactionTurn particle interactions on/off
-
-
-

Definition at line 186 of file PenningTrap.cpp.

+

Definition at line 167 of file PenningTrap.cpp.

- -

◆ evolve_RK4()

+ +

◆ evolve_RK4()

@@ -448,45 +262,28 @@ Private Attributes void PenningTrap::evolve_RK4 ( double  - dt, - - - + dt) - bool  - particle_interaction = true  - - - - ) -

Go forward one timestep using the RK4 method.

-
Parameters
- - - -
dtThe step length
particle_interactionTurn particle interactions on/off
-
-
-

Definition at line 151 of file PenningTrap.cpp.

+

Definition at line 104 of file PenningTrap.cpp.

- -

◆ external_B_field()

+ +

◆ external_B_field()

- + - + @@ -494,28 +291,21 @@ Private Attributes

Calculate B at point r.

-
Parameters
-
vec_3d PenningTrap::external_B_field arma::vec PenningTrap::external_B_field (vec_3d arma::vec  r)
- -
rThe position where we want to calculate the B field
- - -
Returns
vec_3d
-

Definition at line 95 of file PenningTrap.cpp.

+

Definition at line 43 of file PenningTrap.cpp.

- -

◆ external_E_field()

+ +

◆ external_E_field()

- + - + @@ -523,34 +313,27 @@ Private Attributes

Calculate E at point r.

-
Parameters
-
vec_3d PenningTrap::external_E_field arma::vec PenningTrap::external_E_field (vec_3d arma::vec  r)
- -
rThe position where we want to calculate the E field
- - -
Returns
vec_3d
-

Definition at line 87 of file PenningTrap.cpp.

+

Definition at line 32 of file PenningTrap.cpp.

- -

◆ force_on_particle()

+ +

◆ force_on_particle()

- + - + - + @@ -562,222 +345,83 @@ Private Attributes

Calculate the force between 2 particles.

-

Calculate the force exhibited on particle p_i from particle p_j.

-
Parameters
-
vec_3d PenningTrap::force_on_particle arma::vec PenningTrap::force_on_particle (unsigned int int  i,
unsigned int int  j 
- - -
iThe index of particle p_i
jThe index of particle p_j
- - -
Returns
vec_3d
+

Calculate the force exhibited on particle p_i from particle p_j.

-

Definition at line 100 of file PenningTrap.cpp.

+

Definition at line 50 of file PenningTrap.cpp.

- -

◆ fraction_of_particles_left()

+ +

◆ get_d()

- + - - - - - + - - - - - - - - - - - - - - - - - - -
double PenningTrap::fraction_of_particles_left double PenningTrap::get_d (double time,
) unsigned int steps,
std::string method = "rk4",
bool particle_interaction = true 
)
-

Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation.

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

Definition at line 266 of file PenningTrap.cpp.

+

Definition at line 188 of file PenningTrap.cpp.

- -

◆ r_func()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
vec_3d PenningTrap::r_func (unsigned int i,
unsigned int j,
double dt 
)
-
-private
-
- -

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

-

Something

-
Parameters
- - - - -
iIndex i for \(k_{r,i,j}\)
jIndex j for \(k_{r,i,j}\)
dtthe step length (delta time)
-
-
-
Returns
vec_3d
- -

Definition at line 64 of file PenningTrap.cpp.

- -
-
- -

◆ simulate()

+ +

◆ get_particle()

- + - - - - - - - - - - - - - - - - - - - - - - - - - - -
sim_arr PenningTrap::simulate arma::vec PenningTrap::get_particle (double time,
unsigned int steps,
std::string method = "rk4",
bool particle_interaction = true 
)
-
- -

Simulate the particle system inside the Penning trap over a certain amount of time.

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

Definition at line 211 of file PenningTrap.cpp.

- -
-
- -

◆ total_force()

- -
-
- - - - - +
vec_3d PenningTrap::total_force (unsigned int int  i)
-

calculate the total force on a particle p_i.

-
Parameters
- - -
iThe index of particle p_i
-
-
-
Returns
vec_3d
- -

Definition at line 146 of file PenningTrap.cpp.

+

Definition at line 183 of file PenningTrap.cpp.

- -

◆ total_force_external()

+ +

◆ total_force()

- + - + + + + +
vec_3d PenningTrap::total_force_external arma::vec PenningTrap::total_force (unsigned int int i)
+
+ +

calculate the total force on a particle.

+ +

Definition at line 99 of file PenningTrap.cpp.

+ +
+
+ +

◆ total_force_external()

+ +
+
+ + + + + @@ -785,161 +429,31 @@ Private Attributes

Calculate the total external force on a particle.

-

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

-
Parameters
-
arma::vec PenningTrap::total_force_external (int  i)
- -
iThe index of particle p_i
- - -
Returns
vec_3d
+

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

-

Definition at line 114 of file PenningTrap.cpp.

+

Definition at line 65 of file PenningTrap.cpp.

- -

◆ total_force_particles()

+ +

◆ total_force_particles()

- + - +
vec_3d PenningTrap::total_force_particles arma::vec PenningTrap::total_force_particles (unsigned int int  i)
-

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

-
Parameters
- - -
iThe index of particle p_i
-
-
-
Returns
vec_3d
+

Calculate the total force on a particle from other particles.

-

Definition at line 129 of file PenningTrap.cpp.

- -
-
- -

◆ v_func()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
vec_3d PenningTrap::v_func (unsigned int i,
unsigned int j,
double dt 
)
-
-private
-
- -

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

-

Something

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

Definition at line 46 of file PenningTrap.cpp.

- -
-
- -

◆ write_simulation_to_dir()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PenningTrap::write_simulation_to_dir (std::string path,
double time,
unsigned int steps,
std::string method = "rk4",
bool particle_interaction = true 
)
-
- -

Simulate and write the displacement of all particles to files.

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

Definition at line 240 of file PenningTrap.cpp.

+

Definition at line 80 of file PenningTrap.cpp.

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

Magnetic field strength.

-

Definition at line 32 of file PenningTrap.hpp.

+

Definition at line 31 of file PenningTrap.hpp.

@@ -992,57 +506,7 @@ Private Attributes

Characteristic dimension.

-

Definition at line 34 of file PenningTrap.hpp.

- - - - -

◆ k_r

- -
-
- - - - - -
- - - - -
sim_arr PenningTrap::k_r
-
-private
-
-

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

- -

Definition at line 39 of file PenningTrap.hpp.

- -
-
- -

◆ k_v

- -
-
- - - - - -
- - - - -
sim_arr PenningTrap::k_v
-
-private
-
-

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

- -

Definition at line 37 of file PenningTrap.hpp.

+

Definition at line 33 of file PenningTrap.hpp.

@@ -1068,12 +532,12 @@ Private Attributes

The particles in the Penning trap.

-

Definition at line 36 of file PenningTrap.hpp.

+

Definition at line 34 of file PenningTrap.hpp.

- -

◆ t

+ +

◆ V_0

@@ -1082,33 +546,7 @@ Private Attributes - - -
double PenningTrap::t
- - -private - - -
- -

Current time.

- -

Definition at line 35 of file PenningTrap.hpp.

- -
-
- -

◆ V_0

- -
-
- - - @@ -1120,7 +558,7 @@ Private Attributes

Applied potential.

-

Definition at line 33 of file PenningTrap.hpp.

+

Definition at line 32 of file PenningTrap.hpp.

diff --git a/docs/classPenningTrap.js b/docs/classPenningTrap.js index 0fd7f36..743d3ea 100644 --- a/docs/classPenningTrap.js +++ b/docs/classPenningTrap.js @@ -1,27 +1,17 @@ var classPenningTrap = [ - [ "PenningTrap", "classPenningTrap.html#ae670d7de621acdb343b01af098086f63", null ], - [ "PenningTrap", "classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1", null ], - [ "PenningTrap", "classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73", null ], + [ "PenningTrap", "classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560", null ], [ "add_particle", "classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8", null ], - [ "evolve_forward_euler", "classPenningTrap.html#ab9ea97a406534bbe621a95215144875e", null ], - [ "evolve_RK4", "classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e", null ], - [ "external_B_field", "classPenningTrap.html#acbf065c9c125682329ad82a8d166554c", null ], - [ "external_E_field", "classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9", null ], - [ "force_on_particle", "classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce", null ], - [ "fraction_of_particles_left", "classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b", null ], - [ "r_func", "classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648", null ], - [ "simulate", "classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854", null ], - [ "total_force", "classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8", null ], - [ "total_force_external", "classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56", null ], - [ "total_force_particles", "classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b", null ], - [ "v_func", "classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e", null ], - [ "write_simulation_to_dir", "classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57", null ], + [ "evolve_forward_euler", "classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965", null ], + [ "evolve_RK4", "classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9", null ], + [ "external_B_field", "classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784", null ], + [ "external_E_field", "classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b", null ], + [ "force_on_particle", "classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182", null ], + [ "total_force", "classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be", null ], + [ "total_force_external", "classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee", null ], + [ "total_force_particles", "classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d", null ], [ "B_0", "classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716", null ], [ "d", "classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2", null ], - [ "k_r", "classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640", null ], - [ "k_v", "classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4", null ], [ "particles", "classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f", null ], - [ "t", "classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e", null ], - [ "V_0", "classPenningTrap.html#aaf105828121c4a33cc2b217453c20317", null ] + [ "V_0", "classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89", null ] ]; \ No newline at end of file diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 4313bbd..81efd6b 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -115,8 +115,6 @@ Files - - diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js index 64ce7a5..13a8a58 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js @@ -4,7 +4,6 @@ var dir_68267d1309a1af8e8297ef4c3efbcdba = [ "main.cpp", "main_8cpp.html", null ], [ "Particle.cpp", "Particle_8cpp.html", null ], [ "PenningTrap.cpp", "PenningTrap_8cpp.html", null ], - [ "plot_particles_left.py", "plot__particles__left_8py_source.html", null ], [ "test_suite.cpp", "test__suite_8cpp.html", "test__suite_8cpp" ], [ "utils.cpp", "utils_8cpp.html", "utils_8cpp" ] ]; \ No newline at end of file diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.html b/docs/dir_d44c64559bbebec7f509842c48db8b23.html index 289eee3..21e883c 100644 --- a/docs/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.html @@ -113,9 +113,6 @@ Files - - - diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.js b/docs/dir_d44c64559bbebec7f509842c48db8b23.js index 192eaa8..48feb88 100644 --- a/docs/dir_d44c64559bbebec7f509842c48db8b23.js +++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.js @@ -3,6 +3,5 @@ var dir_d44c64559bbebec7f509842c48db8b23 = [ "constants.hpp", "constants_8hpp.html", "constants_8hpp" ], [ "Particle.hpp", "Particle_8hpp.html", "Particle_8hpp" ], [ "PenningTrap.hpp", "PenningTrap_8hpp.html", "PenningTrap_8hpp" ], - [ "typedefs.hpp", "typedefs_8hpp.html", "typedefs_8hpp" ], [ "utils.hpp", "utils_8hpp.html", "utils_8hpp" ] ]; \ No newline at end of file diff --git a/docs/files.html b/docs/files.html index e842a47..b07cc8d 100644 --- a/docs/files.html +++ b/docs/files.html @@ -107,16 +107,14 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); }); - - - - - - - - - - + + + + + + + +
- - - +
std::function<double(double)> PenningTrap::V_0double PenningTrap::V_0
file  PenningTrap.cpp [code]
 The implementation of the PenningTrap class.
 
file  plot_particles_left.py [code]
 
file  test_suite.cpp [code]
 The test suite for the project.
 
file  PenningTrap.hpp [code]
 A class for simulating a Penning trap.
 
file  typedefs.hpp [code]
 Useful typedefs for cleaner code.
 
file  utils.hpp [code]
 Function prototypes and macros that are useful.
 
 constants.hppLibrary of constants
 Particle.hppA class that holds the properties of a particle
 PenningTrap.hppA class for simulating a Penning trap
 typedefs.hppUseful typedefs for cleaner code
 utils.hppFunction prototypes and macros that are useful
  src
 animate_100_particles.py
 main.cppThe main program for this project
 Particle.cppThe implementation of the Particle class
 PenningTrap.cppThe implementation of the PenningTrap class
 plot_particles_left.py
 test_suite.cppThe test suite for the project
 utils.cppImplementation of the utils
 utils.hppFunction prototypes and macros that are useful
  src
 animate_100_particles.py
 main.cppThe main program for this project
 Particle.cppThe implementation of the Particle class
 PenningTrap.cppThe implementation of the PenningTrap class
 test_suite.cppThe test suite for the project
 utils.cppImplementation of the utils
diff --git a/docs/functions.html b/docs/functions.html index a2f04ea..eb473bb 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -102,30 +102,22 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable();
  • add_particle() : PenningTrap
  • B_0 : PenningTrap
  • d : PenningTrap
  • -
  • evolve_forward_euler() : PenningTrap
  • -
  • evolve_RK4() : PenningTrap
  • -
  • external_B_field() : PenningTrap
  • -
  • external_E_field() : PenningTrap
  • -
  • force_on_particle() : PenningTrap
  • -
  • fraction_of_particles_left() : PenningTrap
  • -
  • k_r : PenningTrap
  • -
  • k_v : PenningTrap
  • +
  • evolve_forward_euler() : PenningTrap
  • +
  • evolve_RK4() : PenningTrap
  • +
  • external_B_field() : PenningTrap
  • +
  • external_E_field() : PenningTrap
  • +
  • force_on_particle() : PenningTrap
  • m : Particle
  • -
  • Particle() : Particle
  • +
  • Particle() : Particle
  • particles : PenningTrap
  • -
  • PenningTrap : Particle, PenningTrap
  • +
  • PenningTrap : Particle, PenningTrap
  • q : Particle
  • -
  • r_func() : PenningTrap
  • -
  • r_vec : Particle
  • -
  • simulate() : PenningTrap
  • -
  • t : PenningTrap
  • -
  • total_force() : PenningTrap
  • -
  • total_force_external() : PenningTrap
  • -
  • total_force_particles() : PenningTrap
  • -
  • V_0 : PenningTrap
  • -
  • v_func() : PenningTrap
  • -
  • v_vec : Particle
  • -
  • write_simulation_to_dir() : PenningTrap
  • +
  • r_vec : Particle
  • +
  • total_force() : PenningTrap
  • +
  • total_force_external() : PenningTrap
  • +
  • total_force_particles() : PenningTrap
  • +
  • V_0 : PenningTrap
  • +
  • v_vec : Particle
  • diff --git a/docs/functions_func.html b/docs/functions_func.html index 1182b1d..4a36dd3 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -100,21 +100,16 @@ $(document).ready(function(){initNavTree('functions_func.html',''); initResizabl
     
    diff --git a/docs/functions_vars.html b/docs/functions_vars.html index 3ca2e5b..8c0729a 100644 --- a/docs/functions_vars.html +++ b/docs/functions_vars.html @@ -101,15 +101,12 @@ $(document).ready(function(){initNavTree('functions_vars.html',''); initResizabl   diff --git a/docs/globals.html b/docs/globals.html index 19a9638..9107eef 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -99,20 +99,14 @@ $(document).ready(function(){initNavTree('globals.html',''); initResizable(); })
    Here is a list of all documented file members with links to the documentation:
    diff --git a/docs/globals_defs.html b/docs/globals_defs.html index c7eb483..332fce0 100644 --- a/docs/globals_defs.html +++ b/docs/globals_defs.html @@ -99,7 +99,6 @@ $(document).ready(function(){initNavTree('globals_defs.html',''); initResizable(
     
    diff --git a/docs/globals_type.html b/docs/globals_type.html deleted file mode 100644 index b7735cc..0000000 --- a/docs/globals_type.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - -Penning Trap Simulation: File Members - - - - - - - - - - - - - - - - -
    -
    - - - - - - -
    -
    Penning Trap Simulation -
    -
    Simulate particle behavior inside a Penning Trap
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    -
    -
    -
    -
    -
    Loading...
    -
    Searching...
    -
    No Matches
    -
    -
    -
    -
    - -
    -
    -
    - - - - diff --git a/docs/main_8cpp.html b/docs/main_8cpp.html index b83f224..5e67722 100644 --- a/docs/main_8cpp.html +++ b/docs/main_8cpp.html @@ -100,22 +100,17 @@ $(document).ready(function(){initNavTree('main_8cpp.html',''); initResizable();
    Macros | -Functions | -Variables
    +Functions
    main.cpp File Reference

    The main program for this project. More...

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

    Go to the source code of this file.

    @@ -132,27 +127,10 @@ Macros
    - - - - - - - - -

    Functions

    void simulate_single_particle ()
     
    void simulate_two_particles ()
     
    void simulate_single_particle_with_different_steps ()
     
    void simulate_100_particles ()
     
    void simulate_100_particles_with_time_potential ()
     
    int main ()
     
    - - - - -

    -Variables

    -Particle p1 (CHARGE, MASS, vec_3d{20., 0., 20.}, vec_3d{0., 25., 0.})
     
    -Particle p2 (CHARGE, MASS, vec_3d{25., 25., 0.}, vec_3d{0., 40., 5.})
     

    Detailed Description

    The main program for this project.

    @@ -160,7 +138,7 @@ Variables
    Janita Ovidie Sandtrøen Willumsen (janitaws)
    Version
    0.1
    -
    Bug:
    No known bugs
    +
    Bug:
    No known bugs

    Definition in file main.cpp.

    Macro Definition Documentation

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

    Definition at line 25 of file main.cpp.

    +

    Definition at line 21 of file main.cpp.

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

    Definition at line 26 of file main.cpp.

    +

    Definition at line 22 of file main.cpp.

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

    Definition at line 24 of file main.cpp.

    +

    Definition at line 20 of file main.cpp.

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

    Definition at line 23 of file main.cpp.

    +

    Definition at line 19 of file main.cpp.

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

    Definition at line 124 of file main.cpp.

    +

    Definition at line 77 of file main.cpp.

    @@ -263,83 +241,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
    -

    Definition at line 77 of file main.cpp.

    - -
    - - -

    ◆ simulate_100_particles_with_time_potential()

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

    Definition at line 91 of file main.cpp.

    - -
    -
    - -

    ◆ simulate_single_particle()

    - -
    -
    - - - - - - - -
    void simulate_single_particle ()
    -
    - -

    Definition at line 31 of file main.cpp.

    - -
    -
    - -

    ◆ simulate_single_particle_with_different_steps()

    - -
    -
    - - - - - - - -
    void simulate_single_particle_with_different_steps ()
    -
    - -

    Definition at line 55 of file main.cpp.

    - -
    -
    - -

    ◆ simulate_two_particles()

    - -
    -
    - - - - - - - -
    void simulate_two_particles ()
    -
    - -

    Definition at line 42 of file main.cpp.

    +

    Definition at line 24 of file main.cpp.

    diff --git a/docs/main_8cpp_source.html b/docs/main_8cpp_source.html index d437689..5542b5a 100644 --- a/docs/main_8cpp_source.html +++ b/docs/main_8cpp_source.html @@ -102,149 +102,87 @@ $(document).ready(function(){initNavTree('main_8cpp_source.html',''); initResiza
    Go to the documentation of this file.
    1
    -
    13#include <cmath>
    -
    14#include <fstream>
    -
    15#include <omp.h>
    -
    16#include <string>
    -
    17#include <sys/stat.h>
    -
    18#include <vector>
    -
    19
    -
    20#include "PenningTrap.hpp"
    -
    21#include "utils.hpp"
    -
    22
    -
    23#define PARTICLES 100
    -
    24#define N 10000
    -
    25#define CHARGE 1.
    -
    26#define MASS 40. // unit: amu
    +
    13#include <fstream>
    +
    14#include <omp.h>
    +
    15#include <sys/stat.h>
    +
    16
    +
    17#include "PenningTrap.hpp"
    +
    18
    +
    19#define PARTICLES 100
    +
    20#define N 10000
    +
    21#define CHARGE 1.
    +
    22#define MASS 40. // unit: amu
    +
    23
    +
    24void simulate_100_particles()
    +
    25{
    +
    26 PenningTrap trap;
    27
    -
    28Particle p1(CHARGE, MASS, vec_3d{20., 0., 20.}, vec_3d{0., 25., 0.});
    -
    29Particle p2(CHARGE, MASS, vec_3d{25., 25., 0.}, vec_3d{0., 40., 5.});
    -
    30
    -
    31void simulate_single_particle()
    -
    32{
    -
    33 DEBUG("Inside single particle sim");
    -
    34 PenningTrap trap(std::vector<Particle>{p1});
    -
    35
    -
    36 double time = 50.; // microseconds
    -
    37
    -
    38 DEBUG("Write to dir");
    -
    39 trap.write_simulation_to_dir("output/simulate_single_particle", time, N);
    -
    40}
    +
    28 // Add particles inside trap
    +
    29 for (int i = 0; i < PARTICLES; i++) {
    +
    30 arma::vec r = arma::vec(3).randn() * 0.1 *
    +
    31 trap.get_d(); // random initial position
    +
    32 arma::vec v = arma::vec(3).randn() * 0.1 *
    +
    33 trap.get_d(); // random initial velocity
    +
    34 trap.add_particle(Particle(CHARGE, MASS, r, v));
    +
    35 }
    +
    36
    +
    37 double time = 50.; // microseconds
    +
    38 double dt = time / (double)N;
    +
    39
    +
    40 auto res = new arma::vec::fixed<3>[PARTICLES][N];
    41
    -
    42void simulate_two_particles()
    -
    43{
    -
    44 PenningTrap trap_no_interaction(std::vector<Particle>{p1, p2});
    -
    45 PenningTrap trap_with_interaction(std::vector<Particle>{p1, p2});
    -
    46
    -
    47 double time = 50.; // microseconds
    -
    48
    -
    49 trap_no_interaction.write_simulation_to_dir(
    -
    50 "output/simulate_2_particles/no_interaction", time, N, "rk4", false);
    -
    51 trap_with_interaction.write_simulation_to_dir(
    -
    52 "output/simulate_2_particles/with_interaction", time, N);
    -
    53}
    +
    42 int counter = 0;
    +
    43
    +
    44 // Get the path of all particles
    +
    45 for (int j = 0; j < N; j++) {
    +
    46#pragma omp parallel for
    +
    47 for (int i = 0; i < PARTICLES; i++) {
    +
    48 res[i][j] = trap.get_particle(i);
    +
    49 }
    +
    50 trap.evolve_RK4(dt);
    +
    51 }
    +
    52
    +
    53 std::cout << counter << std::endl;
    54
    -
    55void simulate_single_particle_with_different_steps()
    -
    56{
    +
    55 arma::vec::fixed<3> *cur_row;
    +
    56 arma::vec::fixed<3> cur_elem;
    57
    -
    58 double time = 50; // microseconds
    -
    59
    -
    60 for (int i = 0; i < 4; i++) {
    -
    61 int steps = 4000 * (i + 1);
    -
    62 PenningTrap trap(std::vector<Particle>{p1});
    -
    63 trap.write_simulation_to_dir("output/N_steps/RK4/" +
    -
    64 std::to_string(steps) + "_steps",
    -
    65 time, steps, "rk4", false);
    -
    66 }
    -
    67
    -
    68 for (int i = 0; i < 4; i++) {
    -
    69 int steps = 4000 * (i + 1);
    -
    70 PenningTrap trap(std::vector<Particle>{p1});
    -
    71 trap.write_simulation_to_dir("output/N_steps/euler/" +
    -
    72 std::to_string(steps) + "_steps",
    -
    73 time, steps, "euler", false);
    +
    58 mkdir("output", 0777);
    +
    59 mkdir("output/simulate_100_particles", 0777);
    +
    60
    +
    61 std::ofstream ofile;
    +
    62
    +
    63// Write particle paths to file
    +
    64#pragma omp parallel for private(cur_row, cur_elem, ofile)
    +
    65 for (int i = 0; i < PARTICLES; i++) {
    +
    66 cur_row = res[i];
    +
    67 ofile.open("output/simulate_100_particles/p" + std::to_string(i) + ".txt");
    +
    68 for (int j = 0; j < N; j++) {
    +
    69 cur_elem = cur_row[j];
    +
    70 ofile << cur_elem(0) << "," << cur_elem(1) << "," << cur_elem(2)
    +
    71 << "\n";
    +
    72 }
    +
    73 ofile.close();
    74 }
    75}
    76
    -
    77void simulate_100_particles()
    +
    77int main()
    78{
    -
    79 PenningTrap trap((unsigned)100, T,
    -
    80 [](double t) {
    -
    81 return 25. * V / 1000. *
    -
    82 (1. + .4 * std::cos(1.5 * t));
    -
    83 },
    -
    84 500., 0);
    -
    85
    -
    86 double time = 500.; // microseconds
    -
    87
    -
    88 trap.write_simulation_to_dir("output/simulate_100_particles", time, N*5);
    -
    89}
    -
    90
    -
    91void simulate_100_particles_with_time_potential()
    -
    92{
    -
    93 double amplitudes[]{.1, .4, .7};
    -
    94
    -
    95 double freq_start = .2;
    -
    96 double freq_end = 2.5;
    -
    97 double freq_increment = .02;
    -
    98 size_t freq_iterations = (size_t) ((freq_end - freq_start) / freq_increment);
    -
    99
    -
    100 std::string path = "output/time_dependent_potential/";
    -
    101 mkpath(path);
    -
    102
    -
    103 std::ofstream ofile;
    -
    104
    -
    105 for (double f : amplitudes) {
    -
    106 ofile.open(path + "f_" + std::to_string(f) + ".txt");
    -
    107 #pragma omp parallel for ordered schedule(static, 1)
    -
    108 for (size_t i=0; i < freq_iterations; i++) {
    -
    109 double freq = freq_start + i*freq_increment;
    -
    110 PenningTrap trap((unsigned)100, T,
    -
    111 [f, freq](double t) {
    -
    112 return (25. * V / 1000.) *
    -
    113 (1. + f * std::cos(freq * t));
    -
    114 },
    -
    115 500., 0.);
    -
    116 double res = trap.fraction_of_particles_left(500., 40000, "rk4", true);
    -
    117 #pragma omp ordered
    -
    118 ofile << freq << "," << res << "\n";
    -
    119 }
    -
    120 ofile.close();
    -
    121 }
    -
    122}
    -
    123
    -
    124int main()
    -
    125{
    -
    126
    -
    127 simulate_single_particle();
    -
    128
    -
    129 simulate_two_particles();
    -
    130
    -
    131 simulate_single_particle_with_different_steps();
    -
    132
    -
    133 double start = omp_get_wtime();
    -
    134
    -
    135 //simulate_100_particles();
    -
    136
    -
    137 simulate_100_particles_with_time_potential();
    -
    138
    -
    139 double end = omp_get_wtime();
    -
    140
    -
    141 std::cout << "Time: " << end - start << " seconds" << std::endl;
    -
    142
    -
    143 return 0;
    -
    144}
    +
    79 double start = omp_get_wtime();
    +
    80
    +
    81 simulate_100_particles();
    +
    82
    +
    83 double end = omp_get_wtime();
    +
    84
    +
    85 std::cout << "Time: " << end - start << " seconds" << std::endl;
    +
    86
    +
    87 return 0;
    +
    88}
    A class for simulating a Penning trap.
    -
    A class that holds attributes of a particle.
    Definition: Particle.hpp:21
    -
    A class that simulates a Penning trap.
    Definition: PenningTrap.hpp:30
    -
    double fraction_of_particles_left(double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
    Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
    -
    void write_simulation_to_dir(std::string path, double time, unsigned int steps, std::string method="rk4", bool particle_interaction=true)
    Simulate and write the displacement of all particles to files.
    -
    #define T
    1 Tesla. unit:
    Definition: constants.hpp:17
    -
    #define V
    1 Volt. unit:
    Definition: constants.hpp:19
    -
    arma::vec::fixed< 3 > vec_3d
    Typedef for a fixed 3d arma vector.
    Definition: typedefs.hpp:36
    -
    Function prototypes and macros that are useful.
    -
    bool mkpath(std::string path, int mode=0777)
    Make path given.
    Definition: utils.cpp:76
    -
    #define DEBUG(msg)
    Writes a debug message.
    Definition: utils.hpp:36
    +
    A class that holds attributes of a particle.
    Definition: Particle.hpp:19
    +
    A class that simulates a Penning trap.
    Definition: PenningTrap.hpp:29
    +
    void add_particle(Particle particle)
    Add a particle to the system.
    Definition: PenningTrap.cpp:27
    +
    void evolve_RK4(double dt)
    Go forward one timestep using the RK4 method.
    diff --git a/docs/menudata.js b/docs/menudata.js index 74c1d7b..88ec31f 100644 --- a/docs/menudata.js +++ b/docs/menudata.js @@ -38,5 +38,4 @@ var menudata={children:[ {text:"File Members",url:"globals.html",children:[ {text:"All",url:"globals.html"}, {text:"Functions",url:"globals_func.html"}, -{text:"Typedefs",url:"globals_type.html"}, {text:"Macros",url:"globals_defs.html"}]}]}]} diff --git a/docs/navtreedata.js b/docs/navtreedata.js index 9640812..10ee5ad 100644 --- a/docs/navtreedata.js +++ b/docs/navtreedata.js @@ -27,6 +27,7 @@ var NAVTREE = [ "Penning Trap Simulation", "index.html", [ [ "Credits", "index.html#autotoc_md1", null ], [ "Bug List", "bug.html", null ], + [ "Todo List", "todo.html", null ], [ "Classes", "annotated.html", [ [ "Class List", "annotated.html", "annotated_dup" ], [ "Class Index", "classes.html", null ], @@ -42,7 +43,6 @@ var NAVTREE = [ "File Members", "globals.html", [ [ "All", "globals.html", null ], [ "Functions", "globals_func.html", null ], - [ "Typedefs", "globals_type.html", null ], [ "Macros", "globals_defs.html", null ] ] ] ] ] diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js index 16caa0e..27aef05 100644 --- a/docs/navtreeindex0.js +++ b/docs/navtreeindex0.js @@ -1,95 +1,75 @@ var NAVTREEINDEX0 = { -"Particle_8cpp.html":[3,0,1,2], -"Particle_8cpp_source.html":[3,0,1,2], -"Particle_8hpp.html":[3,0,0,1], -"Particle_8hpp_source.html":[3,0,0,1], -"PenningTrap_8cpp.html":[3,0,1,3], -"PenningTrap_8cpp_source.html":[3,0,1,3], -"PenningTrap_8hpp.html":[3,0,0,2], -"PenningTrap_8hpp_source.html":[3,0,0,2], -"animate__100__particles_8py_source.html":[3,0,1,0], -"annotated.html":[2,0], +"Particle_8cpp.html":[4,0,1,2], +"Particle_8cpp_source.html":[4,0,1,2], +"Particle_8hpp.html":[4,0,0,1], +"Particle_8hpp_source.html":[4,0,0,1], +"PenningTrap_8cpp.html":[4,0,1,3], +"PenningTrap_8cpp_source.html":[4,0,1,3], +"PenningTrap_8hpp.html":[4,0,0,2], +"PenningTrap_8hpp_source.html":[4,0,0,2], +"animate__100__particles_8py_source.html":[4,0,1,0], +"annotated.html":[3,0], "bug.html":[1], -"classParticle.html":[2,0,0], -"classParticle.html#a566dcc1de4bdc01251776948798ea8e1":[2,0,0,3], -"classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4":[2,0,0,0], -"classParticle.html#a879692772803d6ab65fa4993b54aea6e":[2,0,0,5], -"classParticle.html#aa797d319549dc2a0beb06cdbfd430232":[2,0,0,1], -"classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563":[2,0,0,2], -"classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6":[2,0,0,4], -"classPenningTrap.html":[2,0,1], -"classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f":[2,0,1,21], -"classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b":[2,0,1,9], -"classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716":[2,0,1,17], -"classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9":[2,0,1,7], -"classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8":[2,0,1,12], -"classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640":[2,0,1,19], -"classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e":[2,0,1,5], -"classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648":[2,0,1,10], -"classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b":[2,0,1,14], -"classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854":[2,0,1,11], -"classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2":[2,0,1,18], -"classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73":[2,0,1,2], -"classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8":[2,0,1,3], -"classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1":[2,0,1,1], -"classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e":[2,0,1,22], -"classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce":[2,0,1,8], -"classPenningTrap.html#aaf105828121c4a33cc2b217453c20317":[2,0,1,23], -"classPenningTrap.html#ab9ea97a406534bbe621a95215144875e":[2,0,1,4], -"classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57":[2,0,1,16], -"classPenningTrap.html#acbf065c9c125682329ad82a8d166554c":[2,0,1,6], -"classPenningTrap.html#ae670d7de621acdb343b01af098086f63":[2,0,1,0], -"classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56":[2,0,1,13], -"classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4":[2,0,1,20], -"classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e":[2,0,1,15], -"classPenningTrapTest.html":[2,0,2], -"classes.html":[2,1], -"constants_8hpp.html":[3,0,0,0], -"constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5":[3,0,0,0,1], -"constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb":[3,0,0,0,0], -"constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb":[3,0,0,0,2], -"constants_8hpp_source.html":[3,0,0,0], -"dir_68267d1309a1af8e8297ef4c3efbcdba.html":[3,0,1], -"dir_d44c64559bbebec7f509842c48db8b23.html":[3,0,0], -"files.html":[3,0], -"functions.html":[2,2,0], -"functions_func.html":[2,2,1], -"functions_rela.html":[2,2,3], -"functions_vars.html":[2,2,2], -"globals.html":[3,1,0], -"globals_defs.html":[3,1,3], -"globals_func.html":[3,1,1], -"globals_type.html":[3,1,2], +"classParticle.html":[3,0,0], +"classParticle.html#a00e108823877a25513ccae7cac011b4c":[3,0,0,0], +"classParticle.html#a4a5d22c7aeca66f67d083f270cba25df":[3,0,0,5], +"classParticle.html#a566dcc1de4bdc01251776948798ea8e1":[3,0,0,3], +"classParticle.html#aa797d319549dc2a0beb06cdbfd430232":[3,0,0,1], +"classParticle.html#acf1a0f3c978b06d76df5bb4279594467":[3,0,0,4], +"classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563":[3,0,0,2], +"classPenningTrap.html":[3,0,1], +"classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f":[3,0,1,12], +"classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee":[3,0,1,8], +"classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716":[3,0,1,10], +"classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d":[3,0,1,9], +"classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784":[3,0,1,4], +"classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182":[3,0,1,6], +"classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965":[3,0,1,2], +"classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2":[3,0,1,11], +"classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8":[3,0,1,1], +"classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89":[3,0,1,13], +"classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560":[3,0,1,0], +"classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be":[3,0,1,7], +"classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b":[3,0,1,5], +"classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9":[3,0,1,3], +"classPenningTrapTest.html":[3,0,2], +"classes.html":[3,1], +"constants_8hpp.html":[4,0,0,0], +"constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5":[4,0,0,0,1], +"constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb":[4,0,0,0,0], +"constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb":[4,0,0,0,2], +"constants_8hpp_source.html":[4,0,0,0], +"dir_68267d1309a1af8e8297ef4c3efbcdba.html":[4,0,1], +"dir_d44c64559bbebec7f509842c48db8b23.html":[4,0,0], +"files.html":[4,0], +"functions.html":[3,2,0], +"functions_func.html":[3,2,1], +"functions_rela.html":[3,2,3], +"functions_vars.html":[3,2,2], +"globals.html":[4,1,0], +"globals_defs.html":[4,1,2], +"globals_func.html":[4,1,1], "index.html":[], "index.html#autotoc_md1":[0], -"main_8cpp.html":[3,0,1,1], -"main_8cpp_source.html":[3,0,1,1], +"main_8cpp.html":[4,0,1,1], +"main_8cpp_source.html":[4,0,1,1], "pages.html":[], -"plot__particles__left_8py_source.html":[3,0,1,4], -"test__suite_8cpp.html":[3,0,1,5], -"test__suite_8cpp_source.html":[3,0,1,5], -"typedefs_8hpp.html":[3,0,0,3], -"typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23":[3,0,0,3,1], -"typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66":[3,0,0,3,2], -"typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df":[3,0,0,3,3], -"typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af":[3,0,0,3,0], -"typedefs_8hpp_source.html":[3,0,0,3], -"utils_8cpp.html":[3,0,1,6], -"utils_8cpp.html#a58565270b643b24e3132f38c653e0199":[3,0,1,6,3], -"utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a":[3,0,1,6,0], -"utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746":[3,0,1,6,4], -"utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de":[3,0,1,6,2], -"utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b":[3,0,1,6,1], -"utils_8cpp_source.html":[3,0,1,6], -"utils_8hpp.html":[3,0,0,4], -"utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772":[3,0,0,4,3], -"utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38":[3,0,0,4,4], -"utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168":[3,0,0,4,0], -"utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa":[3,0,0,4,5], -"utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[3,0,0,4,1], -"utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d":[3,0,0,4,6], -"utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384":[3,0,0,4,7], -"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[3,0,0,4,2], -"utils_8hpp_source.html":[3,0,0,4] +"test__suite_8cpp.html":[4,0,1,4], +"test__suite_8cpp_source.html":[4,0,1,4], +"todo.html":[2], +"utils_8cpp.html":[4,0,1,5], +"utils_8cpp.html#a58565270b643b24e3132f38c653e0199":[4,0,1,5,2], +"utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a":[4,0,1,5,0], +"utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746":[4,0,1,5,3], +"utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b":[4,0,1,5,1], +"utils_8cpp_source.html":[4,0,1,5], +"utils_8hpp.html":[4,0,0,3], +"utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772":[4,0,0,3,2], +"utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38":[4,0,0,3,3], +"utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[4,0,0,3,0], +"utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d":[4,0,0,3,4], +"utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384":[4,0,0,3,5], +"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[4,0,0,3,1], +"utils_8hpp_source.html":[4,0,0,3] }; diff --git a/docs/pages.html b/docs/pages.html index a84d908..eb4abe8 100644 --- a/docs/pages.html +++ b/docs/pages.html @@ -104,6 +104,7 @@ $(document).ready(function(){initNavTree('pages.html',''); initResizable(); });
    Here is a list of all related documentation pages:
    +
     Bug List
     Todo List
    diff --git a/docs/plot__particles__left_8py_source.html b/docs/plot__particles__left_8py_source.html deleted file mode 100644 index c9ab258..0000000 --- a/docs/plot__particles__left_8py_source.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - -Penning Trap Simulation: src/plot_particles_left.py Source File - - - - - - - - - - - - - - - - -
    -
    - - - - - - -
    -
    Penning Trap Simulation -
    -
    Simulate particle behavior inside a Penning Trap
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    -
    -
    -
    -
    -
    Loading...
    -
    Searching...
    -
    No Matches
    -
    -
    -
    -
    - -
    -
    plot_particles_left.py
    -
    -
    -
    1import matplotlib.pyplot as plt
    -
    2
    -
    3def main():
    -
    4 files = [
    -
    5 "output/time_dependent_potential/f_0.100000.txt",
    -
    6 "output/time_dependent_potential/f_0.400000.txt",
    -
    7 "output/time_dependent_potential/f_0.700000.txt",
    -
    8 ]
    -
    9 vals = [
    -
    10 .1,
    -
    11 .4,
    -
    12 .7
    -
    13 ]
    -
    14 for i in range(3):
    -
    15 with open(files[i]) as f:
    -
    16 lines = f.readlines()
    -
    17 x = []
    -
    18 y = []
    -
    19 for line in lines:
    -
    20 a,b = line.strip().split(",")
    -
    21 x.append(float(a))
    -
    22 y.append(float(b))
    -
    23 plt.plot(x,y,label=f"amplitude: {vals[i]}")
    -
    24
    -
    25 plt.xlabel(r"$\omega_V$")
    -
    26 plt.ylabel(r"Fraction of particles left")
    -
    27 plt.title(r"The fraction of particles left in the Penning trap "
    -
    28 "after 500 microseconds for different amplitudes and frequencies")
    -
    29 plt.legend()
    -
    30 plt.show()
    -
    31
    -
    32if __name__ == "__main__":
    -
    33 main()
    -
    -
    - - - - diff --git a/docs/search/all_0.js b/docs/search/all_0.js index 1e5c227..4fc815a 100644 --- a/docs/search/all_0.js +++ b/docs/search/all_0.js @@ -1,4 +1,6 @@ var searchData= [ - ['_5f_5fmethod_5fname_5f_5f_0',['__METHOD_NAME__',['../utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168',1,'utils.hpp']]] + ['add_5fparticle_0',['add_particle',['../classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8',1,'PenningTrap']]], + ['arma_5fvector_5fclose_5fto_1',['arma_vector_close_to',['../utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8): utils.cpp'],['../utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol): utils.cpp']]], + ['assert_2',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]] ]; diff --git a/docs/search/all_1.js b/docs/search/all_1.js index 4fc815a..80ed042 100644 --- a/docs/search/all_1.js +++ b/docs/search/all_1.js @@ -1,6 +1,5 @@ var searchData= [ - ['add_5fparticle_0',['add_particle',['../classPenningTrap.html#a6e9776ff5b149f01080800716455d7c8',1,'PenningTrap']]], - ['arma_5fvector_5fclose_5fto_1',['arma_vector_close_to',['../utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8): utils.cpp'],['../utils_8cpp.html#a5d2e1e032fd19614f2fbb58149a7b02a',1,'arma_vector_close_to(arma::vec &a, arma::vec &b, double tol): utils.cpp']]], - ['assert_2',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]] + ['b_5f0_0',['B_0',['../classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716',1,'PenningTrap']]], + ['bug_20list_1',['Bug List',['../bug.html',1,'']]] ]; diff --git a/docs/search/all_10.js b/docs/search/all_10.js deleted file mode 100644 index 1b9fc74..0000000 --- a/docs/search/all_10.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57',1,'PenningTrap']]] -]; diff --git a/docs/search/all_2.js b/docs/search/all_2.js index 80ed042..0648f09 100644 --- a/docs/search/all_2.js +++ b/docs/search/all_2.js @@ -1,5 +1,4 @@ var searchData= [ - ['b_5f0_0',['B_0',['../classPenningTrap.html#a0cac3509aa96e71a26d3b2c902e27716',1,'PenningTrap']]], - ['bug_20list_1',['Bug List',['../bug.html',1,'']]] + ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]] ]; diff --git a/docs/search/all_3.js b/docs/search/all_3.js index 0648f09..e50dce3 100644 --- a/docs/search/all_3.js +++ b/docs/search/all_3.js @@ -1,4 +1,5 @@ var searchData= [ - ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]] + ['d_0',['d',['../classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2',1,'PenningTrap']]], + ['debug_1',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]] ]; diff --git a/docs/search/all_4.js b/docs/search/all_4.js index e50dce3..c031fe4 100644 --- a/docs/search/all_4.js +++ b/docs/search/all_4.js @@ -1,5 +1,7 @@ var searchData= [ - ['d_0',['d',['../classPenningTrap.html#a66dfe89c68716b9502927b97f59c27d2',1,'PenningTrap']]], - ['debug_1',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]] + ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965',1,'PenningTrap']]], + ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9',1,'PenningTrap']]], + ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784',1,'PenningTrap']]], + ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b',1,'PenningTrap']]] ]; diff --git a/docs/search/all_5.js b/docs/search/all_5.js index c4c479f..ccf47d2 100644 --- a/docs/search/all_5.js +++ b/docs/search/all_5.js @@ -1,7 +1,4 @@ var searchData= [ - ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#ab9ea97a406534bbe621a95215144875e',1,'PenningTrap']]], - ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e',1,'PenningTrap']]], - ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#acbf065c9c125682329ad82a8d166554c',1,'PenningTrap']]], - ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9',1,'PenningTrap']]] + ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182',1,'PenningTrap']]] ]; diff --git a/docs/search/all_6.js b/docs/search/all_6.js index d1d9acc..cb8673f 100644 --- a/docs/search/all_6.js +++ b/docs/search/all_6.js @@ -1,5 +1,4 @@ var searchData= [ - ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce',1,'PenningTrap']]], - ['fraction_5fof_5fparticles_5fleft_1',['fraction_of_particles_left',['../classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b',1,'PenningTrap']]] + ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]] ]; diff --git a/docs/search/all_7.js b/docs/search/all_7.js index 6af262e..959abdd 100644 --- a/docs/search/all_7.js +++ b/docs/search/all_7.js @@ -1,6 +1,6 @@ var searchData= [ - ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]], - ['k_5fr_1',['k_r',['../classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640',1,'PenningTrap']]], - ['k_5fv_2',['k_v',['../classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4',1,'PenningTrap']]] + ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]], + ['m_5fassert_1',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]], + ['main_2ecpp_2',['main.cpp',['../main_8cpp.html',1,'']]] ]; diff --git a/docs/search/all_8.js b/docs/search/all_8.js index d86b301..3ec818e 100644 --- a/docs/search/all_8.js +++ b/docs/search/all_8.js @@ -1,7 +1,12 @@ var searchData= [ - ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]], - ['m_5fassert_1',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]], - ['main_2ecpp_2',['main.cpp',['../main_8cpp.html',1,'']]], - ['mkpath_3',['mkpath',['../utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa',1,'mkpath(std::string path, int mode=0777): utils.cpp'],['../utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de',1,'mkpath(std::string path, int mode): utils.cpp']]] + ['particle_0',['Particle',['../classParticle.html',1,'Particle'],['../classParticle.html#a00e108823877a25513ccae7cac011b4c',1,'Particle::Particle()']]], + ['particle_2ecpp_1',['Particle.cpp',['../Particle_8cpp.html',1,'']]], + ['particle_2ehpp_2',['Particle.hpp',['../Particle_8hpp.html',1,'']]], + ['particles_3',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]], + ['penning_20trap_20simulation_4',['Penning trap simulation',['../index.html',1,'']]], + ['penningtrap_5',['PenningTrap',['../classPenningTrap.html',1,'PenningTrap'],['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle::PenningTrap()'],['../classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560',1,'PenningTrap::PenningTrap()']]], + ['penningtrap_2ecpp_6',['PenningTrap.cpp',['../PenningTrap_8cpp.html',1,'']]], + ['penningtrap_2ehpp_7',['PenningTrap.hpp',['../PenningTrap_8hpp.html',1,'']]], + ['penningtraptest_8',['PenningTrapTest',['../classPenningTrapTest.html',1,'']]] ]; diff --git a/docs/search/all_9.js b/docs/search/all_9.js index 962dfef..a43f9bc 100644 --- a/docs/search/all_9.js +++ b/docs/search/all_9.js @@ -1,12 +1,4 @@ var searchData= [ - ['particle_0',['Particle',['../classParticle.html',1,'Particle'],['../classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4',1,'Particle::Particle()']]], - ['particle_2ecpp_1',['Particle.cpp',['../Particle_8cpp.html',1,'']]], - ['particle_2ehpp_2',['Particle.hpp',['../Particle_8hpp.html',1,'']]], - ['particles_3',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]], - ['penning_20trap_20simulation_4',['Penning trap simulation',['../index.html',1,'']]], - ['penningtrap_5',['PenningTrap',['../classPenningTrap.html',1,'PenningTrap'],['../classParticle.html#aa797d319549dc2a0beb06cdbfd430232',1,'Particle::PenningTrap()'],['../classPenningTrap.html#ae670d7de621acdb343b01af098086f63',1,'PenningTrap::PenningTrap(double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1',1,'PenningTrap::PenningTrap(unsigned int i, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73',1,'PenningTrap::PenningTrap(std::vector< Particle > particles, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)']]], - ['penningtrap_2ecpp_6',['PenningTrap.cpp',['../PenningTrap_8cpp.html',1,'']]], - ['penningtrap_2ehpp_7',['PenningTrap.hpp',['../PenningTrap_8hpp.html',1,'']]], - ['penningtraptest_8',['PenningTrapTest',['../classPenningTrapTest.html',1,'']]] + ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]] ]; diff --git a/docs/search/all_a.js b/docs/search/all_a.js index a43f9bc..b78ca6a 100644 --- a/docs/search/all_a.js +++ b/docs/search/all_a.js @@ -1,4 +1,4 @@ var searchData= [ - ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]] + ['r_5fvec_0',['r_vec',['../classParticle.html#acf1a0f3c978b06d76df5bb4279594467',1,'Particle']]] ]; diff --git a/docs/search/all_b.js b/docs/search/all_b.js index fb8b113..bf61385 100644 --- a/docs/search/all_b.js +++ b/docs/search/all_b.js @@ -1,5 +1,4 @@ var searchData= [ - ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648',1,'PenningTrap']]], - ['r_5fvec_1',['r_vec',['../classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6',1,'Particle']]] + ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]] ]; diff --git a/docs/search/all_c.js b/docs/search/all_c.js index f0c09d2..89cf6c6 100644 --- a/docs/search/all_c.js +++ b/docs/search/all_c.js @@ -1,8 +1,9 @@ var searchData= [ - ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]], - ['sim_5farr_1',['sim_arr',['../typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af',1,'typedefs.hpp']]], - ['sim_5fcols_2',['sim_cols',['../typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23',1,'typedefs.hpp']]], - ['sim_5frows_3',['sim_rows',['../typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66',1,'typedefs.hpp']]], - ['simulate_4',['simulate',['../classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854',1,'PenningTrap']]] + ['t_0',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]], + ['test_5fsuite_2ecpp_1',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], + ['todo_20list_2',['Todo List',['../todo.html',1,'']]], + ['total_5fforce_3',['total_force',['../classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be',1,'PenningTrap']]], + ['total_5fforce_5fexternal_4',['total_force_external',['../classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee',1,'PenningTrap']]], + ['total_5fforce_5fparticles_5',['total_force_particles',['../classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d',1,'PenningTrap']]] ]; diff --git a/docs/search/all_d.js b/docs/search/all_d.js index c04457d..cd921db 100644 --- a/docs/search/all_d.js +++ b/docs/search/all_d.js @@ -1,10 +1,5 @@ var searchData= [ - ['t_0',['t',['../classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e',1,'PenningTrap']]], - ['t_1',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]], - ['test_5fsuite_2ecpp_2',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], - ['total_5fforce_3',['total_force',['../classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8',1,'PenningTrap']]], - ['total_5fforce_5fexternal_4',['total_force_external',['../classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56',1,'PenningTrap']]], - ['total_5fforce_5fparticles_5',['total_force_particles',['../classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b',1,'PenningTrap']]], - ['typedefs_2ehpp_6',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]] + ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]], + ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]] ]; diff --git a/docs/search/all_e.js b/docs/search/all_e.js index cd921db..b447fa7 100644 --- a/docs/search/all_e.js +++ b/docs/search/all_e.js @@ -1,5 +1,6 @@ var searchData= [ - ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]], - ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]] + ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]], + ['v_5f0_1',['V_0',['../classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89',1,'PenningTrap']]], + ['v_5fvec_2',['v_vec',['../classParticle.html#a4a5d22c7aeca66f67d083f270cba25df',1,'Particle']]] ]; diff --git a/docs/search/all_f.js b/docs/search/all_f.js deleted file mode 100644 index bb9c0eb..0000000 --- a/docs/search/all_f.js +++ /dev/null @@ -1,8 +0,0 @@ -var searchData= -[ - ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]], - ['v_5f0_1',['V_0',['../classPenningTrap.html#aaf105828121c4a33cc2b217453c20317',1,'PenningTrap']]], - ['v_5ffunc_2',['v_func',['../classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e',1,'PenningTrap']]], - ['v_5fvec_3',['v_vec',['../classParticle.html#a879692772803d6ab65fa4993b54aea6e',1,'Particle']]], - ['vec_5f3d_4',['vec_3d',['../typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df',1,'typedefs.hpp']]] -]; diff --git a/docs/search/defines_0.js b/docs/search/defines_0.js index 1e5c227..97ce9d9 100644 --- a/docs/search/defines_0.js +++ b/docs/search/defines_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['_5f_5fmethod_5fname_5f_5f_0',['__METHOD_NAME__',['../utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168',1,'utils.hpp']]] + ['assert_0',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]] ]; diff --git a/docs/search/defines_1.js b/docs/search/defines_1.js index 97ce9d9..c6466cb 100644 --- a/docs/search/defines_1.js +++ b/docs/search/defines_1.js @@ -1,4 +1,4 @@ var searchData= [ - ['assert_0',['ASSERT',['../utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'utils.hpp']]] + ['debug_0',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]] ]; diff --git a/docs/search/defines_2.js b/docs/search/defines_2.js index c6466cb..cb8673f 100644 --- a/docs/search/defines_2.js +++ b/docs/search/defines_2.js @@ -1,4 +1,4 @@ var searchData= [ - ['debug_0',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]] + ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]] ]; diff --git a/docs/search/defines_3.js b/docs/search/defines_3.js index cb8673f..6eef01f 100644 --- a/docs/search/defines_3.js +++ b/docs/search/defines_3.js @@ -1,4 +1,4 @@ var searchData= [ - ['k_5fe_0',['K_E',['../constants_8hpp.html#a4e451456ad7e9276ed0afa42826e7ccb',1,'constants.hpp']]] + ['t_0',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]] ]; diff --git a/docs/search/defines_4.js b/docs/search/defines_4.js index 6eef01f..06f433f 100644 --- a/docs/search/defines_4.js +++ b/docs/search/defines_4.js @@ -1,4 +1,4 @@ var searchData= [ - ['t_0',['T',['../constants_8hpp.html#a0acb682b8260ab1c60b918599864e2e5',1,'constants.hpp']]] + ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]] ]; diff --git a/docs/search/defines_5.js b/docs/search/defines_5.js deleted file mode 100644 index 06f433f..0000000 --- a/docs/search/defines_5.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['v_0',['V',['../constants_8hpp.html#af40a326b23c68a27cebe60f16634a2cb',1,'constants.hpp']]] -]; diff --git a/docs/search/files_3.js b/docs/search/files_3.js index 5e3fea9..1ca9264 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,'']]] + ['test_5fsuite_2ecpp_0',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]] ]; diff --git a/docs/search/functions_1.js b/docs/search/functions_1.js index c4c479f..c031fe4 100644 --- a/docs/search/functions_1.js +++ b/docs/search/functions_1.js @@ -1,7 +1,7 @@ var searchData= [ - ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#ab9ea97a406534bbe621a95215144875e',1,'PenningTrap']]], - ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#a36946152fd951b1f7c346c51ff900d8e',1,'PenningTrap']]], - ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#acbf065c9c125682329ad82a8d166554c',1,'PenningTrap']]], - ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a1d58feaa2c9e34cbf26b1c5ed75ca9d9',1,'PenningTrap']]] + ['evolve_5fforward_5feuler_0',['evolve_forward_euler',['../classPenningTrap.html#a56544b6f4befb42984e9650cf2a40965',1,'PenningTrap']]], + ['evolve_5frk4_1',['evolve_RK4',['../classPenningTrap.html#ab891b839c40eeb38d8a2a636c70090a9',1,'PenningTrap']]], + ['external_5fb_5ffield_2',['external_B_field',['../classPenningTrap.html#a2a3e7f480ba52e9f24d4c50c3981a784',1,'PenningTrap']]], + ['external_5fe_5ffield_3',['external_E_field',['../classPenningTrap.html#a978a2e2026a4b5308d5184712f81704b',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_2.js b/docs/search/functions_2.js index d1d9acc..ccf47d2 100644 --- a/docs/search/functions_2.js +++ b/docs/search/functions_2.js @@ -1,5 +1,4 @@ var searchData= [ - ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a9ae34ad740a230e667e96bc6ee8730ce',1,'PenningTrap']]], - ['fraction_5fof_5fparticles_5fleft_1',['fraction_of_particles_left',['../classPenningTrap.html#a0194be61c956a9259c747c23e4163c5b',1,'PenningTrap']]] + ['force_5fon_5fparticle_0',['force_on_particle',['../classPenningTrap.html#a4790f41e4fbc6ede4991aa7bbda92182',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_3.js b/docs/search/functions_3.js index ffb26d6..30ce46b 100644 --- a/docs/search/functions_3.js +++ b/docs/search/functions_3.js @@ -1,5 +1,4 @@ var searchData= [ - ['m_5fassert_0',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]], - ['mkpath_1',['mkpath',['../utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa',1,'mkpath(std::string path, int mode=0777): utils.cpp'],['../utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de',1,'mkpath(std::string path, int mode): utils.cpp']]] + ['m_5fassert_0',['m_assert',['../utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38',1,'m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg): utils.cpp'],['../utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b',1,'m_assert(bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg): utils.cpp']]] ]; diff --git a/docs/search/functions_4.js b/docs/search/functions_4.js index 852716e..2dc79c5 100644 --- a/docs/search/functions_4.js +++ b/docs/search/functions_4.js @@ -1,5 +1,5 @@ var searchData= [ - ['particle_0',['Particle',['../classParticle.html#a7af9f8d1fef63dd7643b06629ac7bef4',1,'Particle']]], - ['penningtrap_1',['PenningTrap',['../classPenningTrap.html#ae670d7de621acdb343b01af098086f63',1,'PenningTrap::PenningTrap(double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a763700316b502d5900e587c1f61e6bf1',1,'PenningTrap::PenningTrap(unsigned int i, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)'],['../classPenningTrap.html#a67139e04ef69c0bcffde8f30f67cbf73',1,'PenningTrap::PenningTrap(std::vector< Particle > particles, double B_0=T, std::function< double(double)> V_0=[](double t) { return 25. *V/1000.;}, double d=500., double t=0.)']]] + ['particle_0',['Particle',['../classParticle.html#a00e108823877a25513ccae7cac011b4c',1,'Particle']]], + ['penningtrap_1',['PenningTrap',['../classPenningTrap.html#a81add5063bd5f29d77f0b5c299c6c560',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_5.js b/docs/search/functions_5.js index 07b3041..bf61385 100644 --- a/docs/search/functions_5.js +++ b/docs/search/functions_5.js @@ -1,4 +1,4 @@ var searchData= [ - ['r_5ffunc_0',['r_func',['../classPenningTrap.html#a43e74792ab4b3f9299f35cb64bdb2648',1,'PenningTrap']]] + ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]] ]; diff --git a/docs/search/functions_6.js b/docs/search/functions_6.js index a7b65b4..83f26c2 100644 --- a/docs/search/functions_6.js +++ b/docs/search/functions_6.js @@ -1,5 +1,6 @@ var searchData= [ - ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384',1,'scientific_format(double d, int width=20, int prec=10): utils.cpp'],['../utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d',1,'scientific_format(const std::vector< double > &v, int width=20, int prec=10): utils.cpp'],['../utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746',1,'scientific_format(double d, int width, int prec): utils.cpp'],['../utils_8cpp.html#a58565270b643b24e3132f38c653e0199',1,'scientific_format(const std::vector< double > &v, int width, int prec): utils.cpp']]], - ['simulate_1',['simulate',['../classPenningTrap.html#a5331837e6dd7bce807a99edd2ba7e854',1,'PenningTrap']]] + ['total_5fforce_0',['total_force',['../classPenningTrap.html#a83cc7a04dae009ed8e75453c38fdf8be',1,'PenningTrap']]], + ['total_5fforce_5fexternal_1',['total_force_external',['../classPenningTrap.html#a045adb85e97a8e0c38fb36d2fd74eeee',1,'PenningTrap']]], + ['total_5fforce_5fparticles_2',['total_force_particles',['../classPenningTrap.html#a135db7d991d9b88b00fde4edee71f78d',1,'PenningTrap']]] ]; diff --git a/docs/search/functions_7.js b/docs/search/functions_7.js deleted file mode 100644 index 73e1881..0000000 --- a/docs/search/functions_7.js +++ /dev/null @@ -1,6 +0,0 @@ -var searchData= -[ - ['total_5fforce_0',['total_force',['../classPenningTrap.html#a1f668c4433421136ad51741741aa1bc8',1,'PenningTrap']]], - ['total_5fforce_5fexternal_1',['total_force_external',['../classPenningTrap.html#ae72d203b0bfa1b9e72bea28cb2863c56',1,'PenningTrap']]], - ['total_5fforce_5fparticles_2',['total_force_particles',['../classPenningTrap.html#a46a954a0946def199e30fb300ba1c47b',1,'PenningTrap']]] -]; diff --git a/docs/search/functions_8.js b/docs/search/functions_8.js deleted file mode 100644 index 8d7b6ff..0000000 --- a/docs/search/functions_8.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['v_5ffunc_0',['v_func',['../classPenningTrap.html#af98a720da60b0e1a62aefa5f5cb37c1e',1,'PenningTrap']]] -]; diff --git a/docs/search/functions_9.js b/docs/search/functions_9.js deleted file mode 100644 index 1b9fc74..0000000 --- a/docs/search/functions_9.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['write_5fsimulation_5fto_5fdir_0',['write_simulation_to_dir',['../classPenningTrap.html#abbb832a85139b1a56ebde57d7b8f9a57',1,'PenningTrap']]] -]; diff --git a/docs/search/searchdata.js b/docs/search/searchdata.js index 4d47bbf..906104d 100644 --- a/docs/search/searchdata.js +++ b/docs/search/searchdata.js @@ -1,14 +1,13 @@ var indexSectionsWithContent = { - 0: "_abcdefkmpqrstuvw", + 0: "abcdefkmpqrstuv", 1: "p", 2: "cmptu", - 3: "aefmprstvw", - 4: "bdkmpqrtv", - 5: "sv", - 6: "p", - 7: "_adktv", - 8: "bp" + 3: "aefmpst", + 4: "bdmpqrv", + 5: "p", + 6: "adktv", + 7: "bpt" }; var indexSectionNames = @@ -18,10 +17,9 @@ var indexSectionNames = 2: "files", 3: "functions", 4: "variables", - 5: "typedefs", - 6: "related", - 7: "defines", - 8: "pages" + 5: "related", + 6: "defines", + 7: "pages" }; var indexSectionLabels = @@ -31,9 +29,8 @@ var indexSectionLabels = 2: "Files", 3: "Functions", 4: "Variables", - 5: "Typedefs", - 6: "Friends", - 7: "Macros", - 8: "Pages" + 5: "Friends", + 6: "Macros", + 7: "Pages" }; diff --git a/docs/search/typedefs_0.js b/docs/search/typedefs_0.js deleted file mode 100644 index e79ff95..0000000 --- a/docs/search/typedefs_0.js +++ /dev/null @@ -1,6 +0,0 @@ -var searchData= -[ - ['sim_5farr_0',['sim_arr',['../typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af',1,'typedefs.hpp']]], - ['sim_5fcols_1',['sim_cols',['../typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23',1,'typedefs.hpp']]], - ['sim_5frows_2',['sim_rows',['../typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66',1,'typedefs.hpp']]] -]; diff --git a/docs/search/typedefs_1.js b/docs/search/typedefs_1.js deleted file mode 100644 index fe88abf..0000000 --- a/docs/search/typedefs_1.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['vec_5f3d_0',['vec_3d',['../typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df',1,'typedefs.hpp']]] -]; diff --git a/docs/search/variables_2.js b/docs/search/variables_2.js index 7ff6c24..8411aec 100644 --- a/docs/search/variables_2.js +++ b/docs/search/variables_2.js @@ -1,5 +1,4 @@ var searchData= [ - ['k_5fr_0',['k_r',['../classPenningTrap.html#a2f168622587709b9e3c49077f0b9a640',1,'PenningTrap']]], - ['k_5fv_1',['k_v',['../classPenningTrap.html#ae9b5afdaa5cd366e94bd294452a1eed4',1,'PenningTrap']]] + ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]] ]; diff --git a/docs/search/variables_3.js b/docs/search/variables_3.js index 8411aec..c9f603d 100644 --- a/docs/search/variables_3.js +++ b/docs/search/variables_3.js @@ -1,4 +1,4 @@ var searchData= [ - ['m_0',['m',['../classParticle.html#aedcc7e1bc53b0e2b1a4a07c9a1b47563',1,'Particle']]] + ['particles_0',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]] ]; diff --git a/docs/search/variables_4.js b/docs/search/variables_4.js index c9f603d..a43f9bc 100644 --- a/docs/search/variables_4.js +++ b/docs/search/variables_4.js @@ -1,4 +1,4 @@ var searchData= [ - ['particles_0',['particles',['../classPenningTrap.html#a0112525d9e79a472e761f8ef402a339f',1,'PenningTrap']]] + ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]] ]; diff --git a/docs/search/variables_5.js b/docs/search/variables_5.js index a43f9bc..b78ca6a 100644 --- a/docs/search/variables_5.js +++ b/docs/search/variables_5.js @@ -1,4 +1,4 @@ var searchData= [ - ['q_0',['q',['../classParticle.html#a566dcc1de4bdc01251776948798ea8e1',1,'Particle']]] + ['r_5fvec_0',['r_vec',['../classParticle.html#acf1a0f3c978b06d76df5bb4279594467',1,'Particle']]] ]; diff --git a/docs/search/variables_6.js b/docs/search/variables_6.js index fa44d82..01f3a29 100644 --- a/docs/search/variables_6.js +++ b/docs/search/variables_6.js @@ -1,4 +1,5 @@ var searchData= [ - ['r_5fvec_0',['r_vec',['../classParticle.html#af9497cd8f2dcad0fad54f571ddb383e6',1,'Particle']]] + ['v_5f0_0',['V_0',['../classPenningTrap.html#a715329844d75ec4c04f8391421fb4e89',1,'PenningTrap']]], + ['v_5fvec_1',['v_vec',['../classParticle.html#a4a5d22c7aeca66f67d083f270cba25df',1,'Particle']]] ]; diff --git a/docs/search/variables_7.js b/docs/search/variables_7.js deleted file mode 100644 index c7c5d99..0000000 --- a/docs/search/variables_7.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['t_0',['t',['../classPenningTrap.html#a8ca4e21291f60fde619c14099d8c4e8e',1,'PenningTrap']]] -]; diff --git a/docs/search/variables_8.js b/docs/search/variables_8.js deleted file mode 100644 index 601b41d..0000000 --- a/docs/search/variables_8.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['v_5f0_0',['V_0',['../classPenningTrap.html#aaf105828121c4a33cc2b217453c20317',1,'PenningTrap']]], - ['v_5fvec_1',['v_vec',['../classParticle.html#a879692772803d6ab65fa4993b54aea6e',1,'Particle']]] -]; diff --git a/docs/test__suite_8cpp.html b/docs/test__suite_8cpp.html index 7c69921..787939b 100644 --- a/docs/test__suite_8cpp.html +++ b/docs/test__suite_8cpp.html @@ -131,7 +131,7 @@ Functions
    Janita Ovidie Sandtrøen Willumsen (janitaws)
    Version
    0.1
    -
    Bug:
    No known bugs
    +
    Bug:
    No known bugs

    Definition in file test_suite.cpp.

    Function Documentation

    diff --git a/docs/test__suite_8cpp_source.html b/docs/test__suite_8cpp_source.html index b317c82..3fab92c 100644 --- a/docs/test__suite_8cpp_source.html +++ b/docs/test__suite_8cpp_source.html @@ -136,9 +136,9 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    44 arma::vec result;
    45 arma::vec v;
    46 std::stringstream msg;
    -
    47 for (size_t i = 0; i < tests.size(); i++) {
    +
    47 for (int i = 0; i < tests.size(); i++) {
    48 v = tests.at(i).first;
    -
    49 result = trap.external_E_field(v);
    +
    49 result = trap.external_E_field(v);
    50
    51 msg.str("");
    52 msg << "Testing the external E field at (" << std::setprecision(2)
    @@ -154,7 +154,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    62 // on position.
    63 PenningTrap trap;
    64 arma::vec expected{0., 0., T};
    -
    65 arma::vec result = trap.external_B_field(arma::vec{0., 0., 0.});
    +
    65 arma::vec result = trap.external_B_field(arma::vec{0., 0., 0.});
    66 ASSERT(arma_vector_close_to(expected, result),
    67 "Testing the external B field at (0,0,0)");
    68 }
    @@ -171,14 +171,14 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    79
    80 // Test p0 and p1
    81 arma::vec expected{-1., 0., 0.};
    -
    82 arma::vec result = trap.force_on_particle(0, 1);
    +
    82 arma::vec result = trap.force_on_particle(0, 1);
    83 ASSERT(arma_vector_close_to(expected, result),
    84 "Testing the force on a particle at (0,0,0) from a "
    85 "particle at (1,0,0).");
    86
    87 // Test p0 and p2
    88 expected = arma::vec{0, -.024, -.032};
    -
    89 result = trap.force_on_particle(0, 2);
    +
    89 result = trap.force_on_particle(0, 2);
    90 ASSERT(arma_vector_close_to(expected, result),
    91 "Testing the force on a particle at (0,0,0) from a "
    92 "particle at (0,3,4).");
    @@ -191,7 +191,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    99 Particle(1., 40., arma::vec{1., 2., 3.}, arma::vec{3., 4., 5.}));
    100
    101 arma::vec expected{395.58954878, -270.15871624, -57.89115348};
    -
    102 arma::vec result = trap.total_force_external(0);
    +
    102 arma::vec result = trap.total_force_external(0);
    103 ASSERT(arma_vector_close_to(expected, result),
    104 "Testing the total external force on a particle at "
    105 "(1,2,3) with velocity (3,4,5)");
    @@ -204,7 +204,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    112 Particle(1., 40., arma::vec{0., 0., 0.}, arma::vec{0., 0., 0.}));
    113
    114 arma::vec expected{0., 0., 0.};
    -
    115 arma::vec result = trap.total_force_particles(0);
    +
    115 arma::vec result = trap.total_force_particles(0);
    116 ASSERT(arma_vector_close_to(expected, result),
    117 "Testing the total force of all particles on particle 0 "
    118 "with only a single particle");
    @@ -217,7 +217,7 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    125 Particle(1., 40., arma::vec{0., 0., 1.}, arma::vec{0., 0., 0.}));
    126
    127 expected = arma::vec(3, arma::fill::value(-3473.383325));
    -
    128 result = trap.total_force_particles(0);
    +
    128 result = trap.total_force_particles(0);
    129 ASSERT(arma_vector_close_to(expected, result),
    130 "Testing the total force of all particles on particle 0 "
    131 "with 3 other particles.");
    @@ -234,18 +234,18 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
    142 return 0;
    143}
    PenningTrap.hpp
    A class for simulating a Penning trap.
    -
    Particle
    A class that holds attributes of a particle.
    Definition: Particle.hpp:21
    +
    Particle
    A class that holds attributes of a particle.
    Definition: Particle.hpp:19
    PenningTrapTest
    Definition: test_suite.cpp:20
    -
    PenningTrap
    A class that simulates a Penning trap.
    Definition: PenningTrap.hpp:30
    -
    PenningTrap::external_E_field
    vec_3d external_E_field(vec_3d r)
    Calculate E at point r.
    Definition: PenningTrap.cpp:87
    -
    PenningTrap::total_force_particles
    vec_3d total_force_particles(unsigned int i)
    Calculate the total force on a particle p_i from other particles.
    Definition: PenningTrap.cpp:129
    -
    PenningTrap::add_particle
    void add_particle(Particle particle)
    Add a particle to the system.
    Definition: PenningTrap.cpp:82
    -
    PenningTrap::force_on_particle
    vec_3d force_on_particle(unsigned int i, unsigned int j)
    Calculate the force between 2 particles.
    Definition: PenningTrap.cpp:100
    -
    PenningTrap::external_B_field
    vec_3d external_B_field(vec_3d r)
    Calculate B at point r.
    Definition: PenningTrap.cpp:95
    -
    PenningTrap::total_force_external
    vec_3d total_force_external(unsigned int i)
    Calculate the total external force on a particle.
    Definition: PenningTrap.cpp:114
    +
    PenningTrap
    A class that simulates a Penning trap.
    Definition: PenningTrap.hpp:29
    +
    PenningTrap::total_force_external
    arma::vec total_force_external(int i)
    Calculate the total external force on a particle.
    Definition: PenningTrap.cpp:65
    +
    PenningTrap::total_force_particles
    arma::vec total_force_particles(int i)
    Calculate the total force on a particle from other particles.
    Definition: PenningTrap.cpp:80
    +
    PenningTrap::external_B_field
    arma::vec external_B_field(arma::vec r)
    Calculate B at point r.
    Definition: PenningTrap.cpp:43
    +
    PenningTrap::force_on_particle
    arma::vec force_on_particle(int i, int j)
    Calculate the force between 2 particles.
    Definition: PenningTrap.cpp:50
    +
    PenningTrap::add_particle
    void add_particle(Particle particle)
    Add a particle to the system.
    Definition: PenningTrap.cpp:27
    +
    PenningTrap::external_E_field
    arma::vec external_E_field(arma::vec r)
    Calculate E at point r.
    Definition: PenningTrap.cpp:32
    T
    #define T
    1 Tesla. unit:
    Definition: constants.hpp:17
    utils.hpp
    Function prototypes and macros that are useful.
    -
    arma_vector_close_to
    bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
    Test if two armadillo vectors are close to each other.
    Definition: utils.cpp:62
    +
    arma_vector_close_to
    bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
    Test if two armadillo vectors are close to each other.
    Definition: utils.cpp:59
    ASSERT
    #define ASSERT(expr, msg)
    A prettier assertion function.
    Definition: utils.hpp:45
    diff --git a/docs/typedefs_8hpp.html b/docs/typedefs_8hpp.html deleted file mode 100644 index 1f2eedb..0000000 --- a/docs/typedefs_8hpp.html +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - -Penning Trap Simulation: include/typedefs.hpp File Reference - - - - - - - - - - - - - - - - -
    -
    - - - - - - -
    -
    Penning Trap Simulation -
    -
    Simulate particle behavior inside a Penning Trap
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    -
    -
    -
    -
    -
    Loading...
    -
    Searching...
    -
    No Matches
    -
    -
    -
    -
    - -
    - -
    typedefs.hpp File Reference
    -
    -
    - -

    Useful typedefs for cleaner code. -More...

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

    Go to the source code of this file.

    - - - - - - - - - - - - - - -

    -Typedefs

    typedef std::vector< arma::vec::fixed< 3 > > sim_cols
     Typedef for the column of the result vector from simulating particles.
     
    typedef std::vector< arma::vec::fixed< 3 > > sim_rows
     Typedef for the row of the result vector from simulating particles.
     
    typedef std::vector< sim_colssim_arr
     Typedef for the result of the simulate method.
     
    typedef arma::vec::fixed< 3 > vec_3d
     Typedef for a fixed 3d arma vector.
     
    -

    Detailed Description

    -

    Useful typedefs for cleaner code.

    -
    Author
    Cory Alexander Balaton (coryab)
    -
    -Janita Ovidie Sandtrøen Willumsen (janitaws)
    -
    Version
    1.0
    -

    These typedefs make the code more readable and easy to follow along.

    -
    Bug:
    No known bugs
    - -

    Definition in file typedefs.hpp.

    -

    Typedef Documentation

    - -

    ◆ sim_arr

    - -
    -
    - - - - -
    typedef std::vector<sim_cols> sim_arr
    -
    - -

    Typedef for the result of the simulate method.

    - -

    Definition at line 32 of file typedefs.hpp.

    - -
    -
    - -

    ◆ sim_cols

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

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

    - -

    Definition at line 24 of file typedefs.hpp.

    - -
    -
    - -

    ◆ sim_rows

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

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

    - -

    Definition at line 28 of file typedefs.hpp.

    - -
    -
    - -

    ◆ vec_3d

    - -
    -
    - - - - -
    typedef arma::vec::fixed<3> vec_3d
    -
    - -

    Typedef for a fixed 3d arma vector.

    - -

    Definition at line 36 of file typedefs.hpp.

    - -
    -
    -
    -
    - - - - diff --git a/docs/typedefs_8hpp.js b/docs/typedefs_8hpp.js deleted file mode 100644 index d014844..0000000 --- a/docs/typedefs_8hpp.js +++ /dev/null @@ -1,7 +0,0 @@ -var typedefs_8hpp = -[ - [ "sim_arr", "typedefs_8hpp.html#aec69d34220fff45de238b9e01f2686af", null ], - [ "sim_cols", "typedefs_8hpp.html#a7c2dfa854274262c4e00e4ef0ab2ce23", null ], - [ "sim_rows", "typedefs_8hpp.html#a8502989b1b361725834fc185bd575f66", null ], - [ "vec_3d", "typedefs_8hpp.html#a9f33f4962c8fb62cc5ccd0e4e039a8df", null ] -]; \ No newline at end of file diff --git a/docs/typedefs_8hpp_source.html b/docs/typedefs_8hpp_source.html deleted file mode 100644 index 475ff07..0000000 --- a/docs/typedefs_8hpp_source.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - -Penning Trap Simulation: include/typedefs.hpp Source File - - - - - - - - - - - - - - - - -
    -
    - - - - - - -
    -
    Penning Trap Simulation -
    -
    Simulate particle behavior inside a Penning Trap
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    -
    -
    -
    -
    -
    Loading...
    -
    Searching...
    -
    No Matches
    -
    -
    -
    -
    - -
    -
    typedefs.hpp
    -
    -
    -Go to the documentation of this file.
    1
    -
    15#ifndef __TYPEDEFS__
    -
    16#define __TYPEDEFS__
    -
    17
    -
    18#include <vector>
    -
    19#include <armadillo>
    -
    20
    -
    24typedef std::vector<arma::vec::fixed<3>> sim_cols;
    -
    25
    -
    28typedef std::vector<arma::vec::fixed<3>> sim_rows;
    -
    29
    -
    32typedef std::vector<sim_cols> sim_arr;
    -
    33
    -
    36typedef arma::vec::fixed<3> vec_3d;
    -
    37
    -
    38#endif
    -
    std::vector< arma::vec::fixed< 3 > > sim_cols
    Typedef for the column of the result vector from simulating particles.
    Definition: typedefs.hpp:24
    -
    std::vector< arma::vec::fixed< 3 > > sim_rows
    Typedef for the row of the result vector from simulating particles.
    Definition: typedefs.hpp:28
    -
    arma::vec::fixed< 3 > vec_3d
    Typedef for a fixed 3d arma vector.
    Definition: typedefs.hpp:36
    -
    std::vector< sim_cols > sim_arr
    Typedef for the result of the simulate method.
    Definition: typedefs.hpp:32
    -
    -
    - - - - diff --git a/docs/utils_8cpp.html b/docs/utils_8cpp.html index 9401b51..c2ffd2e 100644 --- a/docs/utils_8cpp.html +++ b/docs/utils_8cpp.html @@ -106,8 +106,7 @@ $(document).ready(function(){initNavTree('utils_8cpp.html',''); initResizable();

    Implementation of the utils. More...

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

    Go to the source code of this file.

    @@ -125,9 +124,6 @@ Functions - - -
    bool arma_vector_close_to (arma::vec &a, arma::vec &b, double tol)
     Test if two armadillo vectors are close to each other.
     
    bool mkpath (std::string path, int mode)
     Make path given.
     

    Detailed Description

    Implementation of the utils.

    @@ -135,7 +131,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

    @@ -181,9 +177,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) -
    Returns
    bool
    +
    Returns
    Boolean
    -

    Definition at line 62 of file utils.cpp.

    +

    Definition at line 59 of file utils.cpp.

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

    Definition at line 43 of file utils.cpp.

    - - - - -

    ◆ mkpath()

    - -
    -
    - - - - - - - - - - - - - - - - - - -
    bool mkpath (std::string path,
    int mode = 0777 
    )
    -
    - -

    Make path given.

    -

    This tries to be the equivalent to "mkdir -p" and creates a new directory whenever it needs to.

    -
    Parameters
    - - - -
    pathThe path to be created
    modeThe mode/permissions for all the new directories
    -
    -
    -
    Returns
    bool
    - -

    Definition at line 76 of file utils.cpp.

    +

    Definition at line 40 of file utils.cpp.

    @@ -329,7 +284,6 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

    Turns a vector of doubles into a string written in scientific format.

    -

    The code is stolen from https://github.com/anderkve/FYS3150.

    Parameters
    @@ -338,9 +292,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
    vThe vector to stringify
    -
    Returns
    std::string
    +
    Returns
    String
    -

    Definition at line 24 of file utils.cpp.

    +

    Definition at line 21 of file utils.cpp.

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

    Turns a double into a string written in scientific format.

    -

    The code is stolen from https://github.com/anderkve/FYS3150.

    +

    Code stolen from https://github.com/anderkve/FYS3150 Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp

    Parameters
    @@ -386,9 +340,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
    dThe number to stringify
    -
    Returns
    std::string
    +
    Returns
    String
    -

    Definition at line 17 of file utils.cpp.

    +

    Definition at line 14 of file utils.cpp.

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

    @@ -141,9 +140,6 @@ Functions

    bool arma_vector_close_to (arma::vec &a, arma::vec &b, double tol=1e-8)
     Test if two armadillo vectors are close to each other.
     
    bool mkpath (std::string path, int mode=0777)
     Make path given.
     

    Detailed Description

    Function prototypes and macros that are useful.

    @@ -152,7 +148,7 @@ Functions Janita Ovidie Sandtrøen Willumsen (janitaws)
    Version
    1.0

    These utility function are mainly for convenience and aren't directly related to the project.

    -
    Bug:
    No known bugs
    +
    Bug:
    No known bugs

    Definition in file utils.hpp.

    Macro Definition Documentation

    @@ -168,9 +164,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
    -

    Get the name of the current method/function.

    - -

    Definition at line 51 of file utils.hpp.

    +

    Definition at line 48 of file utils.hpp.

    @@ -199,10 +193,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
    -Value:
    m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
    +Value:
    m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
    __LINE__, msg)
    -
    void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
    Test an expression, confirm that test is ok, or abort execution.
    Definition: utils.cpp:43
    -
    #define __METHOD_NAME__
    Get the name of the current method/function.
    Definition: utils.hpp:51
    +
    void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
    Test an expression, confirm that test is ok, or abort execution.
    Definition: utils.cpp:40

    A prettier assertion function.

    This macro calls the m_assert function which is a more informative assertion function than the regular assert function from cassert.

    @@ -277,9 +270,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) -
    Returns
    bool
    +
    Returns
    Boolean
    -

    Definition at line 62 of file utils.cpp.

    +

    Definition at line 59 of file utils.cpp.

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

    Definition at line 43 of file utils.cpp.

    - - - - -

    ◆ mkpath()

    - -
    -
    - - - - - - - - - - - - - - - - - - -
    bool mkpath (std::string path,
    int mode = 0777 
    )
    -
    - -

    Make path given.

    -

    This tries to be the equivalent to "mkdir -p" and creates a new directory whenever it needs to.

    -
    Parameters
    - - - -
    pathThe path to be created
    modeThe mode/permissions for all the new directories
    -
    -
    -
    Returns
    bool
    - -

    Definition at line 76 of file utils.cpp.

    +

    Definition at line 40 of file utils.cpp.

    @@ -425,7 +377,6 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

    Turns a vector of doubles into a string written in scientific format.

    -

    The code is stolen from https://github.com/anderkve/FYS3150.

    Parameters
    @@ -434,9 +385,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
    vThe vector to stringify
    -
    Returns
    std::string
    +
    Returns
    String
    -

    Definition at line 24 of file utils.cpp.

    +

    Definition at line 21 of file utils.cpp.

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

    Turns a double into a string written in scientific format.

    -

    The code is stolen from https://github.com/anderkve/FYS3150.

    +

    Code stolen from https://github.com/anderkve/FYS3150 Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp

    Parameters
    @@ -482,9 +433,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
    dThe number to stringify
    -
    Returns
    std::string
    +
    Returns
    String
    -

    Definition at line 17 of file utils.cpp.

    +

    Definition at line 14 of file utils.cpp.

    diff --git a/docs/utils_8hpp.js b/docs/utils_8hpp.js index 68951df..34c7b36 100644 --- a/docs/utils_8hpp.js +++ b/docs/utils_8hpp.js @@ -1,11 +1,9 @@ var utils_8hpp = [ - [ "__METHOD_NAME__", "utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168", null ], [ "ASSERT", "utils_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9", null ], [ "DEBUG", "utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b", null ], [ "arma_vector_close_to", "utils_8hpp.html#a0c95c4791692b06f8811905a76dbd772", null ], [ "m_assert", "utils_8hpp.html#a2cc3a2cdb635bac3c8b02e89d4d6af38", null ], - [ "mkpath", "utils_8hpp.html#a6fdd7217b750aff5b6295ece7cbdeffa", null ], [ "scientific_format", "utils_8hpp.html#ad54b96a1074f9df4dc892a41d115b72d", null ], [ "scientific_format", "utils_8hpp.html#adfb618b2fdff47ef30a4a2b62c04f384", null ] ]; \ No newline at end of file diff --git a/docs/utils_8hpp_source.html b/docs/utils_8hpp_source.html index 1c7052d..33ddc52 100644 --- a/docs/utils_8hpp_source.html +++ b/docs/utils_8hpp_source.html @@ -121,45 +121,39 @@ $(document).ready(function(){initNavTree('utils_8hpp_source.html',''); initResiz
    45#define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
    46 __LINE__, msg)
    47
    -
    51#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
    -
    52
    -
    53
    +
    48#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
    +
    49
    +
    50
    64std::string scientific_format(double d, int width=20, int prec=10);
    65
    -
    66
    -
    77std::string scientific_format(const std::vector<double>& v,
    -
    78 int width=20,
    -
    79 int prec=10);
    -
    80
    -
    81
    -
    94void m_assert(bool expr,
    -
    95 std::string expr_str,
    -
    96 std::string func,
    -
    97 std::string file,
    -
    98 int line,
    -
    99 std::string msg);
    -
    100
    -
    101
    -
    113bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
    -
    114
    -
    115
    -
    126static inline std::string methodName(const std::string& pretty_function)
    -
    127{
    -
    128 size_t colons = pretty_function.find("::");
    -
    129 size_t begin = pretty_function.substr(0,colons).rfind(" ") + 1;
    -
    130 size_t end = pretty_function.rfind("(") - begin;
    -
    131
    -
    132 return pretty_function.substr(begin,end) + "()";
    -
    133}
    -
    134
    -
    135
    -
    146bool mkpath(std::string path, int mode = 0777);
    -
    147
    -
    148#endif
    -
    arma_vector_close_to
    bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
    Test if two armadillo vectors are close to each other.
    Definition: utils.cpp:62
    -
    m_assert
    void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
    Test an expression, confirm that test is ok, or abort execution.
    Definition: utils.cpp:43
    -
    mkpath
    bool mkpath(std::string path, int mode=0777)
    Make path given.
    Definition: utils.cpp:76
    -
    scientific_format
    std::string scientific_format(double d, int width=20, int prec=10)
    Turns a double into a string written in scientific format.
    Definition: utils.cpp:17
    +
    74std::string scientific_format(const std::vector<double>& v,
    +
    75 int width=20,
    +
    76 int prec=10);
    +
    77
    +
    90void m_assert(bool expr,
    +
    91 std::string expr_str,
    +
    92 std::string func,
    +
    93 std::string file,
    +
    94 int line,
    +
    95 std::string msg);
    +
    96
    +
    97
    +
    109bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
    +
    110
    +
    111
    +
    112static inline std::string methodName(const std::string& prettyFunction)
    +
    113{
    +
    114 size_t colons = prettyFunction.find("::");
    +
    115 size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
    +
    116 size_t end = prettyFunction.rfind("(") - begin;
    +
    117
    +
    118 return prettyFunction.substr(begin,end) + "()";
    +
    119}
    +
    120
    +
    121#endif
    +
    arma_vector_close_to
    bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
    Test if two armadillo vectors are close to each other.
    Definition: utils.cpp:59
    +
    m_assert
    void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
    Test an expression, confirm that test is ok, or abort execution.
    Definition: utils.cpp:40
    +
    scientific_format
    std::string scientific_format(double d, int width=20, int prec=10)
    Turns a double into a string written in scientific format.
    Definition: utils.cpp:14
    diff --git a/include/Particle.hpp b/include/Particle.hpp index 4b5e716..29b4ccb 100644 --- a/include/Particle.hpp +++ b/include/Particle.hpp @@ -14,29 +14,24 @@ #include -#include "typedefs.hpp" - /** @brief A class that holds attributes of a particle * */ class Particle { private: - double q; ///< Charge - double m; ///< Mass - vec_3d r_vec; ///< position - vec_3d v_vec; ///< velocity + double q; ///< Charge + double m; ///< Mass + arma::vec::fixed<3> r_vec; ///< position + arma::vec::fixed<3> v_vec; ///< velocity public: /** @brief Initialize the particle. * * @details Initialize the particle with a charge, mass, position and * velocity. - * - * @param q The charge of the particle - * @param m The mass of the particle - * @param r_vec The initial position of the particle - * @param v_vec The initial velocity of the particle * */ - Particle(double q, double m, vec_3d r_vec, vec_3d v_vec); + Particle(double q, double m, + arma::vec::fixed<3> r_vec, + arma::vec::fixed<3> v_vec); /** @brief Make private attributes available for PenningTrap. * */ diff --git a/include/PenningTrap.hpp b/include/PenningTrap.hpp index f6cf2c0..3601634 100644 --- a/include/PenningTrap.hpp +++ b/include/PenningTrap.hpp @@ -17,10 +17,9 @@ #include "Particle.hpp" #include "constants.hpp" -#include "typedefs.hpp" -#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \ - initializer(omp_priv = omp_orig) +#pragma omp declare reduction( + : arma::vec : omp_out += omp_in ) \ + initializer( omp_priv = omp_orig ) /** @brief A class that simulates a Penning trap. * @@ -29,194 +28,61 @@ * */ class PenningTrap { private: - double B_0; ///< Magnetic field strength - std::function V_0; ///< Applied potential - double d; ///< Characteristic dimension - double t; ///< Current time - std::vector particles; ///< The particles in the Penning trap - sim_arr k_v; ///< A 2D vector containing all \f$k_{i,j}\f$ where \f$j\f$ is - ///< the index of a particle - sim_arr k_r; ///< A 2D vector containing all \f$k_{i,j}\f$ where \f$j\f$ is - ///< the index of a particle - - /** @brief Helper for evolve_RK4 when calculating \f$k_{v,i,j}\f$ values - * - * @details Something - * - * @param i Index i for \f$k_{v,i,j}\f$ - * @param j Index j for \f$k_{v,i,j}\f$ - * @param dt the step length (delta time) - * - * @return vec_3d - * */ - vec_3d v_func(unsigned int i, unsigned int j, double dt); - - /** @brief Helper for evolve_RK4 when calculating \f$k_{r,i,j}\f$ values - * - * @details Something - * - * @param i Index i for \f$k_{r,i,j}\f$ - * @param j Index j for \f$k_{r,i,j}\f$ - * @param dt the step length (delta time) - * - * @return vec_3d - * */ - vec_3d r_func(unsigned int i, unsigned int j, double dt); + double B_0; ///< Magnetic field strength + double V_0; ///< Applied potential + double d; ///< Characteristic dimension + std::vector particles; ///< The particles in the Penning trap public: - /** @brief Constructor for the PenningTrap class - * - * @param B_0 The magnetic field strength - * @param V_0 The time dependent applied potential - * @param d The characteristic dimension - * @param t The starting time + /** @brief Set B_0, V_0 and d. * */ - PenningTrap( - double B_0 = T, - std::function V_0 = - [](double t) { return 25. * V / 1000.; }, - double d = 500., double t = 0.); - - /** @brief Constructor for the PenningTrap class - * - * @param i The number of particles to generate - * @param B_0 The magnetic field strength - * @param V_0 The time dependent applied potential - * @param d The characteristic dimension - * @param t The starting time - * */ - PenningTrap( - unsigned int i, double B_0 = T, - std::function V_0 = - [](double t) { return 25. * V / 1000.; }, - double d = 500., double t = 0.); - - /** @brief Constructor for the PenningTrap class - * - * @param particles The starting particles - * @param B_0 The magnetic field strength - * @param V_0 The time dependent applied potential - * @param d The characteristic dimension - * @param t The starting time - * */ - PenningTrap( - std::vector particles, double B_0 = T, - std::function V_0 = - [](double t) { return 25. * V / 1000.; }, - double d = 500., double t = 0.); + PenningTrap(double B_0 = T, double V_0 = 25.*V/1000., double d = 500.); /** @brief Add a particle to the system - * - * @param particle The particle to add to the Penning trap * */ void add_particle(Particle particle); /** @brief Calculate E at point r - * - * @param r The position where we want to calculate the E field - * - * @return vec_3d * */ - vec_3d external_E_field(vec_3d r); + arma::vec external_E_field(arma::vec r); /** @brief Calculate B at point r - * - * @param r The position where we want to calculate the B field - * - * @return vec_3d * */ - vec_3d external_B_field(vec_3d r); + arma::vec external_B_field(arma::vec r); /** @brief Calculate the force between 2 particles. * - * @details Calculate the force exhibited on particle p_i from + * @details Calculate the force exhibited on particle p_i from * particle p_j. - * - * @param i The index of particle p_i - * @param j The index of particle p_j - * - * @return vec_3d * */ - vec_3d force_on_particle(unsigned int i, unsigned int j); + arma::vec force_on_particle(int i, int j); /** @brief Calculate the total external force on a particle. * * @details Calculate the total amount of force that E and B exhibits * on particle p_i. - * - * @param i The index of particle p_i - * - * @return vec_3d * */ - vec_3d total_force_external(unsigned int i); + arma::vec total_force_external(int i); - /** @brief Calculate the total force on a particle p_i from other particles. - * - * @param i The index of particle p_i - * - * @return vec_3d + /** @brief Calculate the total force on a particle from other particles. * */ - vec_3d total_force_particles(unsigned int i); + arma::vec total_force_particles(int i); - /** @brief calculate the total force on a particle p_i. - * - * @param i The index of particle p_i - * - * @return vec_3d - * */ - vec_3d total_force(unsigned int i); + /** @brief calculate the total force on a particle. + * */ + arma::vec total_force(int i); /** @brief Go forward one timestep using the RK4 method - * - * @param dt The step length - * @param particle_interaction Turn particle interactions on/off * */ - void evolve_RK4(double dt, bool particle_interaction = true); + void evolve_RK4(double dt); /** @brief Go forward one timestep using the forward Euler method - * - * @param dt The step length - * @param particle_interaction Turn particle interactions on/off * */ - void evolve_forward_euler(double dt, bool particle_interaction = true); + void evolve_forward_euler(double dt); - /** @brief Simulate the particle system inside the Penning trap over - * a certain amount of time. - * - * @param time The time to simulate in microseconds - * @param steps The amount of steps for the whole simulation - * @param method The method to use when moving forward a timestep - * @param particle_interaction Turn particle interactions on/off - * */ - sim_arr simulate(double time, unsigned int steps, - std::string method = "rk4", - bool particle_interaction = true); + arma::vec get_particle(int i); - /** @brief Simulate and write the displacement of all particles to files. - * - * @param path The directory to save the data - * @param time The time to simulate in microseconds - * @param steps The amount of steps for the whole simulation - * @param method The method to use when moving forward a timestep - * @param particle_interaction Turn particle interactions on/off - * */ - void write_simulation_to_dir(std::string path, double time, - unsigned int steps, std::string method = "rk4", - bool particle_interaction = true); - - /** @brief Simulate and calculate what fraction of particles are still - * left inside the Penning trap after the simulation. - * - * @param time The time to simulate in microseconds - * @param steps The amount of steps for the whole simulation - * @param method The method to use when moving forward a timestep - * @param particle_interaction Turn particle interactions on/off - * - * @return double - * */ - double fraction_of_particles_left(double time, unsigned int steps, - std::string method = "rk4", - bool particle_interaction = true); + double get_d(); }; #endif diff --git a/include/typedefs.hpp b/include/typedefs.hpp deleted file mode 100644 index f0ceca2..0000000 --- a/include/typedefs.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/** @file typedefs.hpp - * - * @author Cory Alexander Balaton (coryab) - * @author Janita Ovidie Sandtrøen Willumsen (janitaws) - * - * @version 1.0 - * - * @brief Useful typedefs for cleaner code. - * - * @details These typedefs make the code more readable and easy to follow - * along. - * - * @bug No known bugs - * */ -#ifndef __TYPEDEFS__ -#define __TYPEDEFS__ - -#include -#include - -/** @brief Typedef for the column of the result vector from simulating - * particles. - * */ -typedef std::vector> sim_cols; - -/** @brief Typedef for the row of the result vector from simulating particles. - * */ -typedef std::vector> sim_rows; - -/** @brief Typedef for the result of the simulate method. - * */ -typedef std::vector sim_arr; - -/** @brief Typedef for a fixed 3d arma vector. - * */ -typedef arma::vec::fixed<3> vec_3d; - -#endif diff --git a/include/utils.hpp b/include/utils.hpp index c9c9485..7a03149 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -45,44 +45,40 @@ #define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \ __LINE__, msg) -/** @def __METHOD_NAME__ - * @brief Get the name of the current method/function. - * */ #define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__) +/** Code stolen from https://github.com/anderkve/FYS3150 + * Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp + * Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp + * */ + /** @brief Turns a double into a string written in scientific format. - * - * @details The code is stolen from https://github.com/anderkve/FYS3150. * * @param d The number to stringify * @param width The reserved width of the string * @param prec The precision of the stringified number * - * @return std::string + * @return String * */ std::string scientific_format(double d, int width=20, int prec=10); - /** @brief Turns a vector of doubles into a string written in scientific format. - * - * @details The code is stolen from https://github.com/anderkve/FYS3150. * * @param v The vector to stringify * @param width The reserved width of the string * @param prec The precision of the stringified number * - * @return std::string + * @return String * */ std::string scientific_format(const std::vector& v, int width=20, int prec=10); - /** @brief Test an expression, confirm that test is ok, or abort execution. * - * @details This function takes in an expression and prints an OK message if - * it's true, or it prints a fail message and aborts execution if it fails. + * This function takes in an expression and prints an OK message if it's + * true, or it prints a fail message and aborts execution if it fails. * * @param expr The expression to be evaluated * @param expr_str The stringified version of the expression @@ -101,48 +97,25 @@ void m_assert(bool expr, /** @brief Test if two armadillo vectors are close to each other. * - * @details This function takes in 2 vectors and checks if they are - * approximately equal to each other given a tolerance. + * This function takes in 2 vectors and checks if they are approximately + * equal to each other given a tolerance. * * @param a Vector a * @param b Vector b * @param tol The tolerance * - * @return bool + * @return Boolean * */ bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8); -/** @brief Takes in the __PRETTY_FUNCTION__ string and removes the return type. - * - * @details This function should only be used for the __METHOD_NAME__ macro, - * since it takes the output from __PRETTY_FUNCTION__ and strips the return - * type. - * - * @param pretty_function The string from __PRETTY_FUNCTION__ - * - * @return std::string - * */ -static inline std::string methodName(const std::string& pretty_function) +static inline std::string methodName(const std::string& prettyFunction) { - size_t colons = pretty_function.find("::"); - size_t begin = pretty_function.substr(0,colons).rfind(" ") + 1; - size_t end = pretty_function.rfind("(") - begin; + size_t colons = prettyFunction.find("::"); + size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1; + size_t end = prettyFunction.rfind("(") - begin; - return pretty_function.substr(begin,end) + "()"; + return prettyFunction.substr(begin,end) + "()"; } - -/** @brief Make path given. - * - * @details This tries to be the equivalent to "mkdir -p" and creates a new - * directory whenever it needs to. - * - * @param path The path to be created - * @param mode The mode/permissions for all the new directories - * - * @return bool - * */ -bool mkpath(std::string path, int mode = 0777); - #endif diff --git a/latex/main.pdf b/latex/main.pdf new file mode 100644 index 0000000..ed5a52c Binary files /dev/null and b/latex/main.pdf differ diff --git a/latex/main.tex b/latex/main.tex new file mode 100644 index 0000000..7649808 --- /dev/null +++ b/latex/main.tex @@ -0,0 +1,77 @@ +\documentclass[english,notitlepage,reprint,nofootinbib]{revtex4-1} % defines the basic parameters of the document +\usepackage{subfiles} +% For preview: skriv i terminal: latexmk -pdf -pvc filnavn +% If you want a single-column, remove "reprint" + +% Silence warning of revtex4-1 +\usepackage{silence} +\WarningFilter{revtex4-1}{Repair the float} + +% Allows special characters (including æøå) +\usepackage[utf8]{inputenc} +\usepackage{fontawesome} +% \usepackage[english]{babel} + +%% Note that you may need to download some of these packages manually, it depends on your setup. +%% I recommend downloading TeXMaker, because it includes a large library of the most common packages. + +\usepackage{physics,amssymb} % mathematical symbols (physics imports amsmath) + +\usepackage{graphicx} % include graphics such as plots +\def\resources{\graphicspath{{"./images/"}}} +\usepackage{xcolor} % set colors +\usepackage{hyperref} % automagic cross-referencing +\usepackage{listings} % display code +\usepackage{subfigure} % imports a lot of cool and useful figure commands +% \usepackage{float} +%\usepackage[section]{placeins} +\usepackage{algorithm} +\usepackage[noend]{algpseudocode} +\usepackage{subfigure} +\usepackage{tikz} +\usetikzlibrary{quantikz} +% defines the color of hyperref objects +% Blending two colors: blue!80!black = 80% blue and 20% black +\hypersetup{ % this is just my personal choice, feel free to change things + colorlinks, + linkcolor={red!50!black}, + citecolor={blue!50!black}, + urlcolor={blue!80!black}} + +% Biblio stuff +\def\biblio{\bibliographystyle{plain}\bibliography{./references}} + + +\begin{document} + +\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. + +% Abstract +\subfile{./sections/abstract.tex} + + +\maketitle + + +% Introduction +\subfile{./sections/introduction.tex} + +% Methods +\subfile{./sections/methods.tex} + +% Results +\subfile{./sections/results.tex} + +% Conclusion +\subfile{./sections/conclusion.tex} + +\onecolumngrid + +\bibliographystyle{plain} +\bibliography{.references/references} + + +\end{document} diff --git a/latex/references/references.bib b/latex/references/references.bib new file mode 100644 index 0000000..236bbd0 --- /dev/null +++ b/latex/references/references.bib @@ -0,0 +1,9 @@ + +@inbook{midpoint_rule, + author = "A.C Faul", + title = "A Concise Introduction to Numerical Analysis", + chapter = "5", + pages = "131", + publisher= "CRC Press", + year = "2016", +} diff --git a/latex/sections/abstract.tex b/latex/sections/abstract.tex new file mode 100644 index 0000000..e170ec7 --- /dev/null +++ b/latex/sections/abstract.tex @@ -0,0 +1,12 @@ +\documentclass[../main.tex]{subfiles} +\resources % search for graphics in ../res/imgs/ + + +\begin{document} + +\begin{abstract} + Add an abstract for the project? +\end{abstract} + +\biblio +\end{document} \ No newline at end of file diff --git a/latex/sections/conclusion.tex b/latex/sections/conclusion.tex new file mode 100644 index 0000000..4107c03 --- /dev/null +++ b/latex/sections/conclusion.tex @@ -0,0 +1,13 @@ +\documentclass[../main.tex]{subfiles} +\resources % search for graphics in ../res/imgs/ + + +\begin{document} + +\section{Conclusion} + + + + +\biblio +\end{document} \ No newline at end of file diff --git a/latex/sections/introduction.tex b/latex/sections/introduction.tex new file mode 100644 index 0000000..da0b77f --- /dev/null +++ b/latex/sections/introduction.tex @@ -0,0 +1,13 @@ +\documentclass[../main.tex]{subfiles} +\resources % search for graphics in ../res/imgs/ + + +\begin{document} + +\section{Introduction} + + + + +\biblio +\end{document} \ No newline at end of file diff --git a/latex/sections/methods.tex b/latex/sections/methods.tex new file mode 100644 index 0000000..e2f6d07 --- /dev/null +++ b/latex/sections/methods.tex @@ -0,0 +1,13 @@ +\documentclass[../main.tex]{subfiles} +\resources % search for graphics in ../res/imgs/ + + +\begin{document} + +\section{Methods} + + + + +\biblio +\end{document} \ No newline at end of file diff --git a/latex/sections/results.tex b/latex/sections/results.tex new file mode 100644 index 0000000..003cba3 --- /dev/null +++ b/latex/sections/results.tex @@ -0,0 +1,13 @@ +\documentclass[../main.tex]{subfiles} +\resources % search for graphics in ../res/imgs/ + + +\begin{document} + +\section{Results} + + + + +\biblio +\end{document} \ No newline at end of file diff --git a/man_pages/man3/Particle.3 b/man_pages/man3/Particle.3 index ebff781..f37639d 100644 --- a/man_pages/man3/Particle.3 +++ b/man_pages/man3/Particle.3 @@ -1,4 +1,4 @@ -.TH "Particle" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "Particle" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -13,7 +13,7 @@ Particle \- A class that holds attributes of a particle\&. .in +1c .ti -1c -.RI "\fBParticle\fP (double \fBq\fP, double \fBm\fP, \fBvec_3d\fP \fBr_vec\fP, \fBvec_3d\fP \fBv_vec\fP)" +.RI "\fBParticle\fP (double \fBq\fP, double \fBm\fP, arma::vec::fixed< 3 > \fBr_vec\fP, arma::vec::fixed< 3 > \fBv_vec\fP)" .br .RI "Initialize the particle\&. " .in -1c @@ -29,11 +29,11 @@ Particle \- A class that holds attributes of a particle\&. .br .RI "Mass\&. " .ti -1c -.RI "\fBvec_3d\fP \fBr_vec\fP" +.RI "arma::vec::fixed< 3 > \fBr_vec\fP" .br .RI "position " .ti -1c -.RI "\fBvec_3d\fP \fBv_vec\fP" +.RI "arma::vec::fixed< 3 > \fBv_vec\fP" .br .RI "velocity " .in -1c @@ -49,28 +49,15 @@ Particle \- A class that holds attributes of a particle\&. .PP A class that holds attributes of a particle\&. .PP -Definition at line \fB21\fP of file \fBParticle\&.hpp\fP\&. +Definition at line \fB19\fP of file \fBParticle\&.hpp\fP\&. .SH "Constructor & Destructor Documentation" .PP -.SS "Particle::Particle (double q, double m, \fBvec_3d\fP r_vec, \fBvec_3d\fP v_vec)" +.SS "Particle::Particle (double q, double m, arma::vec::fixed< 3 > r_vec, arma::vec::fixed< 3 > v_vec)" .PP -Initialize the particle\&. Initialize the particle with a charge, mass, position and velocity\&. +Initialize the particle\&. Initialize the particle with a charge, mass, position and velocity\&. .PP -\fBParameters\fP -.RS 4 -\fIq\fP The charge of the particle -.br -\fIm\fP The mass of the particle -.br -\fIr_vec\fP The initial position of the particle -.br -\fIv_vec\fP The initial velocity of the particle -.RE -.PP - -.PP -Definition at line \fB15\fP of file \fBParticle\&.cpp\fP\&. +Definition at line \fB16\fP of file \fBParticle\&.cpp\fP\&. .SH "Friends And Related Function Documentation" .PP .SS "friend class \fBPenningTrap\fP\fC [friend]\fP" @@ -78,7 +65,7 @@ Definition at line \fB15\fP of file \fBParticle\&.cpp\fP\&. .PP Make private attributes available for \fBPenningTrap\fP\&. .PP -Definition at line \fB43\fP of file \fBParticle\&.hpp\fP\&. +Definition at line \fB38\fP of file \fBParticle\&.hpp\fP\&. .SH "Member Data Documentation" .PP .SS "double Particle::m\fC [private]\fP" @@ -86,25 +73,25 @@ Definition at line \fB43\fP of file \fBParticle\&.hpp\fP\&. .PP Mass\&. .PP -Definition at line \fB24\fP of file \fBParticle\&.hpp\fP\&. +Definition at line \fB22\fP of file \fBParticle\&.hpp\fP\&. .SS "double Particle::q\fC [private]\fP" .PP Charge\&. .PP -Definition at line \fB23\fP of file \fBParticle\&.hpp\fP\&. -.SS "\fBvec_3d\fP Particle::r_vec\fC [private]\fP" +Definition at line \fB21\fP of file \fBParticle\&.hpp\fP\&. +.SS "arma::vec::fixed<3> Particle::r_vec\fC [private]\fP" .PP position .PP -Definition at line \fB25\fP of file \fBParticle\&.hpp\fP\&. -.SS "\fBvec_3d\fP Particle::v_vec\fC [private]\fP" +Definition at line \fB23\fP of file \fBParticle\&.hpp\fP\&. +.SS "arma::vec::fixed<3> Particle::v_vec\fC [private]\fP" .PP velocity .PP -Definition at line \fB26\fP of file \fBParticle\&.hpp\fP\&. +Definition at line \fB24\fP of file \fBParticle\&.hpp\fP\&. .SH "Author" .PP diff --git a/man_pages/man3/Particle.cpp.3 b/man_pages/man3/Particle.cpp.3 index 904c7a4..7a93b45 100644 --- a/man_pages/man3/Particle.cpp.3 +++ b/man_pages/man3/Particle.cpp.3 @@ -1,4 +1,4 @@ -.TH "src/Particle.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "src/Particle.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -31,7 +31,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) .PP \fBBug\fP .RS 4 -No known bugs +No known bugs .RE .PP diff --git a/man_pages/man3/Particle.hpp.3 b/man_pages/man3/Particle.hpp.3 index 2033d14..abb26a7 100644 --- a/man_pages/man3/Particle.hpp.3 +++ b/man_pages/man3/Particle.hpp.3 @@ -1,4 +1,4 @@ -.TH "include/Particle.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "include/Particle.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -9,8 +9,6 @@ include/Particle.hpp \- A class that holds the properties of a particle\&. .PP \fC#include \fP .br -\fC#include 'typedefs\&.hpp'\fP -.br .SS "Classes" diff --git a/man_pages/man3/PenningTrap.3 b/man_pages/man3/PenningTrap.3 index 51cca93..2087bb5 100644 --- a/man_pages/man3/PenningTrap.3 +++ b/man_pages/man3/PenningTrap.3 @@ -1,4 +1,4 @@ -.TH "PenningTrap" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "PenningTrap" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -13,77 +13,51 @@ PenningTrap \- A class that simulates a Penning trap\&. .in +1c .ti -1c -.RI "\fBPenningTrap\fP (double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)" +.RI "\fBPenningTrap\fP (double \fBB_0\fP=\fBT\fP, double \fBV_0\fP=25\&.*\fBV\fP/1000\&., double \fBd\fP=500\&.)" .br -.RI "Constructor for the \fBPenningTrap\fP class\&. " -.ti -1c -.RI "\fBPenningTrap\fP (unsigned int i, double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)" -.br -.RI "Constructor for the \fBPenningTrap\fP class\&. " -.ti -1c -.RI "\fBPenningTrap\fP (std::vector< \fBParticle\fP > \fBparticles\fP, double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)" -.br -.RI "Constructor for the \fBPenningTrap\fP class\&. " +.RI "Set B_0, V_0 and d\&. " .ti -1c .RI "void \fBadd_particle\fP (\fBParticle\fP particle)" .br .RI "Add a particle to the system\&. " .ti -1c -.RI "\fBvec_3d\fP \fBexternal_E_field\fP (\fBvec_3d\fP r)" +.RI "arma::vec \fBexternal_E_field\fP (arma::vec r)" .br .RI "Calculate E at point r\&. " .ti -1c -.RI "\fBvec_3d\fP \fBexternal_B_field\fP (\fBvec_3d\fP r)" +.RI "arma::vec \fBexternal_B_field\fP (arma::vec r)" .br .RI "Calculate B at point r\&. " .ti -1c -.RI "\fBvec_3d\fP \fBforce_on_particle\fP (unsigned int i, unsigned int j)" +.RI "arma::vec \fBforce_on_particle\fP (int i, int j)" .br .RI "Calculate the force between 2 particles\&. " .ti -1c -.RI "\fBvec_3d\fP \fBtotal_force_external\fP (unsigned int i)" +.RI "arma::vec \fBtotal_force_external\fP (int i)" .br .RI "Calculate the total external force on a particle\&. " .ti -1c -.RI "\fBvec_3d\fP \fBtotal_force_particles\fP (unsigned int i)" +.RI "arma::vec \fBtotal_force_particles\fP (int i)" .br -.RI "Calculate the total force on a particle p_i from other particles\&. " +.RI "Calculate the total force on a particle from other particles\&. " .ti -1c -.RI "\fBvec_3d\fP \fBtotal_force\fP (unsigned int i)" +.RI "arma::vec \fBtotal_force\fP (int i)" .br -.RI "calculate the total force on a particle p_i\&. " +.RI "calculate the total force on a particle\&. " .ti -1c -.RI "void \fBevolve_RK4\fP (double dt, bool particle_interaction=true)" +.RI "void \fBevolve_RK4\fP (double dt)" .br .RI "Go forward one timestep using the RK4 method\&. " .ti -1c -.RI "void \fBevolve_forward_euler\fP (double dt, bool particle_interaction=true)" +.RI "void \fBevolve_forward_euler\fP (double dt)" .br .RI "Go forward one timestep using the forward Euler method\&. " .ti -1c -.RI "\fBsim_arr\fP \fBsimulate\fP (double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)" +.RI "arma::vec \fBget_particle\fP (int i)" .br -.RI "Simulate the particle system inside the Penning trap over a certain amount of time\&. " .ti -1c -.RI "void \fBwrite_simulation_to_dir\fP (std::string path, double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)" +.RI "double \fBget_d\fP ()" .br -.RI "Simulate and write the displacement of all particles to files\&. " -.ti -1c -.RI "double \fBfraction_of_particles_left\fP (double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)" -.br -.RI "Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation\&. " -.in -1c -.SS "Private Member Functions" - -.in +1c -.ti -1c -.RI "\fBvec_3d\fP \fBv_func\fP (unsigned int i, unsigned int j, double dt)" -.br -.RI "Helper for evolve_RK4 when calculating $k_{v,i,j}$ values\&. " -.ti -1c -.RI "\fBvec_3d\fP \fBr_func\fP (unsigned int i, unsigned int j, double dt)" -.br -.RI "Helper for evolve_RK4 when calculating $k_{r,i,j}$ values\&. " .in -1c .SS "Private Attributes" @@ -93,7 +67,7 @@ PenningTrap \- A class that simulates a Penning trap\&. .br .RI "Magnetic field strength\&. " .ti -1c -.RI "std::function< double(double)> \fBV_0\fP" +.RI "double \fBV_0\fP" .br .RI "Applied potential\&. " .ti -1c @@ -101,19 +75,9 @@ PenningTrap \- A class that simulates a Penning trap\&. .br .RI "Characteristic dimension\&. " .ti -1c -.RI "double \fBt\fP" -.br -.RI "Current time\&. " -.ti -1c .RI "std::vector< \fBParticle\fP > \fBparticles\fP" .br .RI "The particles in the Penning trap\&. " -.ti -1c -.RI "\fBsim_arr\fP \fBk_v\fP" -.br -.ti -1c -.RI "\fBsim_arr\fP \fBk_r\fP" -.br .in -1c .SH "Detailed Description" .PP @@ -121,70 +85,15 @@ A class that simulates a Penning trap\&. This class simulates a Penning trap\&. It can take in a number of particles and simulate how they would behave inside a Penning trap\&. .PP -Definition at line \fB30\fP of file \fBPenningTrap\&.hpp\fP\&. +Definition at line \fB29\fP of file \fBPenningTrap\&.hpp\fP\&. .SH "Constructor & Destructor Documentation" .PP -.SS "PenningTrap::PenningTrap (double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)" +.SS "PenningTrap::PenningTrap (double B_0 = \fC\fBT\fP\fP, double V_0 = \fC25\&.*\fBV\fP/1000\&.\fP, double d = \fC500\&.\fP)" .PP -Constructor for the \fBPenningTrap\fP class\&. +Set B_0, V_0 and d\&. .PP -\fBParameters\fP -.RS 4 -\fIB_0\fP The magnetic field strength -.br -\fIV_0\fP The time dependent applied potential -.br -\fId\fP The characteristic dimension -.br -\fIt\fP The starting time -.RE -.PP - -.PP -Definition at line \fB18\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "PenningTrap::PenningTrap (unsigned int i, double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)" - -.PP -Constructor for the \fBPenningTrap\fP class\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The number of particles to generate -.br -\fIB_0\fP The magnetic field strength -.br -\fIV_0\fP The time dependent applied potential -.br -\fId\fP The characteristic dimension -.br -\fIt\fP The starting time -.RE -.PP - -.PP -Definition at line \fB27\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "PenningTrap::PenningTrap (std::vector< \fBParticle\fP > particles, double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)" - -.PP -Constructor for the \fBPenningTrap\fP class\&. -.PP -\fBParameters\fP -.RS 4 -\fIparticles\fP The starting particles -.br -\fIB_0\fP The magnetic field strength -.br -\fIV_0\fP The time dependent applied potential -.br -\fId\fP The characteristic dimension -.br -\fIt\fP The starting time -.RE -.PP - -.PP -Definition at line \fB39\fP of file \fBPenningTrap\&.cpp\fP\&. +Definition at line \fB20\fP of file \fBPenningTrap\&.cpp\fP\&. .SH "Member Function Documentation" .PP .SS "void PenningTrap::add_particle (\fBParticle\fP particle)" @@ -192,262 +101,63 @@ Definition at line \fB39\fP of file \fBPenningTrap\&.cpp\fP\&. .PP Add a particle to the system\&. .PP -\fBParameters\fP -.RS 4 -\fIparticle\fP The particle to add to the Penning trap -.RE -.PP - -.PP -Definition at line \fB82\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "void PenningTrap::evolve_forward_euler (double dt, bool particle_interaction = \fCtrue\fP)" +Definition at line \fB27\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "void PenningTrap::evolve_forward_euler (double dt)" .PP Go forward one timestep using the forward Euler method\&. .PP -\fBParameters\fP -.RS 4 -\fIdt\fP The step length -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB186\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "void PenningTrap::evolve_RK4 (double dt, bool particle_interaction = \fCtrue\fP)" +Definition at line \fB167\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "void PenningTrap::evolve_RK4 (double dt)" .PP Go forward one timestep using the RK4 method\&. .PP -\fBParameters\fP -.RS 4 -\fIdt\fP The step length -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB151\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::external_B_field (\fBvec_3d\fP r)" +Definition at line \fB104\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "arma::vec PenningTrap::external_B_field (arma::vec r)" .PP Calculate B at point r\&. .PP -\fBParameters\fP -.RS 4 -\fIr\fP The position where we want to calculate the B field -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB95\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::external_E_field (\fBvec_3d\fP r)" +Definition at line \fB43\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "arma::vec PenningTrap::external_E_field (arma::vec r)" .PP Calculate E at point r\&. .PP -\fBParameters\fP -.RS 4 -\fIr\fP The position where we want to calculate the E field -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP +Definition at line \fB32\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "arma::vec PenningTrap::force_on_particle (int i, int j)" .PP -Definition at line \fB87\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::force_on_particle (unsigned int i, unsigned int j)" +Calculate the force between 2 particles\&. Calculate the force exhibited on particle p_i from particle p_j\&. +.PP +Definition at line \fB50\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "double PenningTrap::get_d ()" .PP -Calculate the force between 2 particles\&. Calculate the force exhibited on particle p_i from particle p_j\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.br -\fIj\fP The index of particle p_j -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP +Definition at line \fB188\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "arma::vec PenningTrap::get_particle (int i)" .PP -Definition at line \fB100\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "double PenningTrap::fraction_of_particles_left (double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)" +Definition at line \fB183\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "arma::vec PenningTrap::total_force (int i)" .PP -Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation\&. -.PP -\fBParameters\fP -.RS 4 -\fItime\fP The time to simulate in microseconds -.br -\fIsteps\fP The amount of steps for the whole simulation -.br -\fImethod\fP The method to use when moving forward a timestep -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP -\fBReturns\fP -.RS 4 -double -.RE +calculate the total force on a particle\&. .PP +Definition at line \fB99\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "arma::vec PenningTrap::total_force_external (int i)" .PP -Definition at line \fB266\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::r_func (unsigned int i, unsigned int j, double dt)\fC [private]\fP" +Calculate the total external force on a particle\&. Calculate the total amount of force that E and B exhibits on particle p_i\&. +.PP +Definition at line \fB65\fP of file \fBPenningTrap\&.cpp\fP\&. +.SS "arma::vec PenningTrap::total_force_particles (int i)" .PP -Helper for evolve_RK4 when calculating $k_{r,i,j}$ values\&. Something +Calculate the total force on a particle from other particles\&. .PP -\fBParameters\fP -.RS 4 -\fIi\fP Index i for $k_{r,i,j}$ -.br -\fIj\fP Index j for $k_{r,i,j}$ -.br -\fIdt\fP the step length (delta time) -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB64\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBsim_arr\fP PenningTrap::simulate (double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)" - -.PP -Simulate the particle system inside the Penning trap over a certain amount of time\&. -.PP -\fBParameters\fP -.RS 4 -\fItime\fP The time to simulate in microseconds -.br -\fIsteps\fP The amount of steps for the whole simulation -.br -\fImethod\fP The method to use when moving forward a timestep -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB211\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::total_force (unsigned int i)" - -.PP -calculate the total force on a particle p_i\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB146\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::total_force_external (unsigned int i)" - -.PP -Calculate the total external force on a particle\&. Calculate the total amount of force that E and B exhibits on particle p_i\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB114\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::total_force_particles (unsigned int i)" - -.PP -Calculate the total force on a particle p_i from other particles\&. -.PP -\fBParameters\fP -.RS 4 -\fIi\fP The index of particle p_i -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB129\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "\fBvec_3d\fP PenningTrap::v_func (unsigned int i, unsigned int j, double dt)\fC [private]\fP" - -.PP -Helper for evolve_RK4 when calculating $k_{v,i,j}$ values\&. Something -.PP -\fBParameters\fP -.RS 4 -\fIi\fP Index i for $k_{v,i,j}$ -.br -\fIj\fP Index j for $k_{v,i,j}$ -.br -\fIdt\fP the step length (delta time) -.RE -.PP -\fBReturns\fP -.RS 4 -vec_3d -.RE -.PP - -.PP -Definition at line \fB46\fP of file \fBPenningTrap\&.cpp\fP\&. -.SS "void PenningTrap::write_simulation_to_dir (std::string path, double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)" - -.PP -Simulate and write the displacement of all particles to files\&. -.PP -\fBParameters\fP -.RS 4 -\fIpath\fP The directory to save the data -.br -\fItime\fP The time to simulate in microseconds -.br -\fIsteps\fP The amount of steps for the whole simulation -.br -\fImethod\fP The method to use when moving forward a timestep -.br -\fIparticle_interaction\fP Turn particle interactions on/off -.RE -.PP - -.PP -Definition at line \fB240\fP of file \fBPenningTrap\&.cpp\fP\&. +Definition at line \fB80\fP of file \fBPenningTrap\&.cpp\fP\&. .SH "Member Data Documentation" .PP .SS "double PenningTrap::B_0\fC [private]\fP" @@ -455,39 +165,25 @@ Definition at line \fB240\fP of file \fBPenningTrap\&.cpp\fP\&. .PP Magnetic field strength\&. .PP -Definition at line \fB32\fP of file \fBPenningTrap\&.hpp\fP\&. +Definition at line \fB31\fP of file \fBPenningTrap\&.hpp\fP\&. .SS "double PenningTrap::d\fC [private]\fP" .PP Characteristic dimension\&. .PP -Definition at line \fB34\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "\fBsim_arr\fP PenningTrap::k_r\fC [private]\fP" -A 2D vector containing all $k_{i,j}$ where $j$ is the index of a particle -.PP -Definition at line \fB39\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "\fBsim_arr\fP PenningTrap::k_v\fC [private]\fP" -A 2D vector containing all $k_{i,j}$ where $j$ is the index of a particle -.PP -Definition at line \fB37\fP of file \fBPenningTrap\&.hpp\fP\&. +Definition at line \fB33\fP of file \fBPenningTrap\&.hpp\fP\&. .SS "std::vector<\fBParticle\fP> PenningTrap::particles\fC [private]\fP" .PP The particles in the Penning trap\&. .PP -Definition at line \fB36\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "double PenningTrap::t\fC [private]\fP" - -.PP -Current time\&. -.PP -Definition at line \fB35\fP of file \fBPenningTrap\&.hpp\fP\&. -.SS "std::function PenningTrap::V_0\fC [private]\fP" +Definition at line \fB34\fP of file \fBPenningTrap\&.hpp\fP\&. +.SS "double PenningTrap::V_0\fC [private]\fP" .PP Applied potential\&. .PP -Definition at line \fB33\fP of file \fBPenningTrap\&.hpp\fP\&. +Definition at line \fB32\fP of file \fBPenningTrap\&.hpp\fP\&. .SH "Author" .PP diff --git a/man_pages/man3/PenningTrap.cpp.3 b/man_pages/man3/PenningTrap.cpp.3 index d080d97..f850299 100644 --- a/man_pages/man3/PenningTrap.cpp.3 +++ b/man_pages/man3/PenningTrap.cpp.3 @@ -1,4 +1,4 @@ -.TH "src/PenningTrap.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "src/PenningTrap.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -11,8 +11,6 @@ src/PenningTrap.cpp \- The implementation of the \fBPenningTrap\fP class\&. .br \fC#include 'constants\&.hpp'\fP .br -\fC#include 'typedefs\&.hpp'\fP -.br \fC#include 'utils\&.hpp'\fP .br @@ -37,7 +35,15 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) .PP \fBBug\fP .RS 4 -No known bugs +No known bugs +.RE +.PP +.PP +\fBTodo\fP +.RS 4 +Implement evolve_RK4 +.PP +Implement evolve_forward_euler .RE .PP diff --git a/man_pages/man3/PenningTrap.hpp.3 b/man_pages/man3/PenningTrap.hpp.3 index 15d155f..c16a94b 100644 --- a/man_pages/man3/PenningTrap.hpp.3 +++ b/man_pages/man3/PenningTrap.hpp.3 @@ -1,4 +1,4 @@ -.TH "include/PenningTrap.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "include/PenningTrap.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -15,8 +15,6 @@ include/PenningTrap.hpp \- A class for simulating a Penning trap\&. .br \fC#include 'constants\&.hpp'\fP .br -\fC#include 'typedefs\&.hpp'\fP -.br .SS "Classes" diff --git a/man_pages/man3/PenningTrapTest.3 b/man_pages/man3/PenningTrapTest.3 index 3bbe27c..07c0b75 100644 --- a/man_pages/man3/PenningTrapTest.3 +++ b/man_pages/man3/PenningTrapTest.3 @@ -1,4 +1,4 @@ -.TH "PenningTrapTest" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "PenningTrapTest" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME diff --git a/man_pages/man3/bug.3 b/man_pages/man3/bug.3 index d21bde1..f93d6e3 100644 --- a/man_pages/man3/bug.3 +++ b/man_pages/man3/bug.3 @@ -1,4 +1,4 @@ -.TH "bug" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "bug" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -10,17 +10,15 @@ No known bugs .IP "\fBFile \fBmain\&.cpp\fP \fP" 1c No known bugs .IP "\fBFile \fBParticle\&.cpp\fP \fP" 1c -No known bugs +No known bugs .IP "\fBFile \fBParticle\&.hpp\fP \fP" 1c No known bugs .IP "\fBFile \fBPenningTrap\&.cpp\fP \fP" 1c -No known bugs +No known bugs .IP "\fBFile \fBPenningTrap\&.hpp\fP \fP" 1c No known bugs .IP "\fBFile \fBtest_suite\&.cpp\fP \fP" 1c No known bugs -.IP "\fBFile \fBtypedefs\&.hpp\fP \fP" 1c -No known bugs .IP "\fBFile \fButils\&.cpp\fP \fP" 1c No known bugs .IP "\fBFile \fButils\&.hpp\fP \fP" 1c diff --git a/man_pages/man3/constants.hpp.3 b/man_pages/man3/constants.hpp.3 index b1d978f..ed6ff65 100644 --- a/man_pages/man3/constants.hpp.3 +++ b/man_pages/man3/constants.hpp.3 @@ -1,4 +1,4 @@ -.TH "include/constants.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "include/constants.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME diff --git a/man_pages/man3/main.cpp.3 b/man_pages/man3/main.cpp.3 index 23983a7..e02bbe4 100644 --- a/man_pages/man3/main.cpp.3 +++ b/man_pages/man3/main.cpp.3 @@ -1,4 +1,4 @@ -.TH "src/main.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "src/main.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -7,22 +7,14 @@ src/main.cpp \- The main program for this project\&. .SH SYNOPSIS .br .PP -\fC#include \fP -.br \fC#include \fP .br \fC#include \fP .br -\fC#include \fP -.br \fC#include \fP .br -\fC#include \fP -.br \fC#include 'PenningTrap\&.hpp'\fP .br -\fC#include 'utils\&.hpp'\fP -.br .SS "Macros" @@ -44,34 +36,12 @@ src/main.cpp \- The main program for this project\&. .in +1c .ti -1c -.RI "void \fBsimulate_single_particle\fP ()" -.br -.ti -1c -.RI "void \fBsimulate_two_particles\fP ()" -.br -.ti -1c -.RI "void \fBsimulate_single_particle_with_different_steps\fP ()" -.br -.ti -1c .RI "void \fBsimulate_100_particles\fP ()" .br .ti -1c -.RI "void \fBsimulate_100_particles_with_time_potential\fP ()" -.br -.ti -1c .RI "int \fBmain\fP ()" .br .in -1c -.SS "Variables" - -.in +1c -.ti -1c -.RI "\fBParticle\fP \fBp1\fP (CHARGE, MASS, \fBvec_3d\fP{20\&., 0\&., 20\&.}, \fBvec_3d\fP{0\&., 25\&., 0\&.})" -.br -.ti -1c -.RI "\fBParticle\fP \fBp2\fP (CHARGE, MASS, \fBvec_3d\fP{25\&., 25\&., 0\&.}, \fBvec_3d\fP{0\&., 40\&., 5\&.})" -.br -.in -1c .SH "Detailed Description" .PP The main program for this project\&. @@ -104,45 +74,29 @@ Definition in file \fBmain\&.cpp\fP\&. .SS "#define CHARGE 1\&." .PP -Definition at line \fB25\fP of file \fBmain\&.cpp\fP\&. +Definition at line \fB21\fP of file \fBmain\&.cpp\fP\&. .SS "#define MASS 40\&." .PP -Definition at line \fB26\fP of file \fBmain\&.cpp\fP\&. +Definition at line \fB22\fP of file \fBmain\&.cpp\fP\&. .SS "#define N 10000" .PP -Definition at line \fB24\fP of file \fBmain\&.cpp\fP\&. +Definition at line \fB20\fP of file \fBmain\&.cpp\fP\&. .SS "#define PARTICLES 100" .PP -Definition at line \fB23\fP of file \fBmain\&.cpp\fP\&. +Definition at line \fB19\fP of file \fBmain\&.cpp\fP\&. .SH "Function Documentation" .PP .SS "int main ()" .PP -Definition at line \fB124\fP of file \fBmain\&.cpp\fP\&. +Definition at line \fB77\fP of file \fBmain\&.cpp\fP\&. .SS "void simulate_100_particles ()" .PP -Definition at line \fB77\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_100_particles_with_time_potential ()" - -.PP -Definition at line \fB91\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_single_particle ()" - -.PP -Definition at line \fB31\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_single_particle_with_different_steps ()" - -.PP -Definition at line \fB55\fP of file \fBmain\&.cpp\fP\&. -.SS "void simulate_two_particles ()" - -.PP -Definition at line \fB42\fP of file \fBmain\&.cpp\fP\&. +Definition at line \fB24\fP of file \fBmain\&.cpp\fP\&. .SH "Author" .PP Generated automatically by Doxygen for Penning Trap Simulation from the source code\&. diff --git a/man_pages/man3/test_suite.cpp.3 b/man_pages/man3/test_suite.cpp.3 index c185469..fa522ef 100644 --- a/man_pages/man3/test_suite.cpp.3 +++ b/man_pages/man3/test_suite.cpp.3 @@ -1,4 +1,4 @@ -.TH "src/test_suite.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "src/test_suite.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME diff --git a/man_pages/man3/todo.3 b/man_pages/man3/todo.3 index ef888e2..a66e064 100644 --- a/man_pages/man3/todo.3 +++ b/man_pages/man3/todo.3 @@ -1,4 +1,4 @@ -.TH "todo" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "todo" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME diff --git a/man_pages/man3/typedefs.hpp.3 b/man_pages/man3/typedefs.hpp.3 deleted file mode 100644 index 1933ad3..0000000 --- a/man_pages/man3/typedefs.hpp.3 +++ /dev/null @@ -1,92 +0,0 @@ -.TH "include/typedefs.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- -.ad l -.nh -.SH NAME -include/typedefs.hpp \- Useful typedefs for cleaner code\&. - -.SH SYNOPSIS -.br -.PP -\fC#include \fP -.br -\fC#include \fP -.br - -.SS "Typedefs" - -.in +1c -.ti -1c -.RI "typedef std::vector< arma::vec::fixed< 3 > > \fBsim_cols\fP" -.br -.RI "Typedef for the column of the result vector from simulating particles\&. " -.ti -1c -.RI "typedef std::vector< arma::vec::fixed< 3 > > \fBsim_rows\fP" -.br -.RI "Typedef for the row of the result vector from simulating particles\&. " -.ti -1c -.RI "typedef std::vector< \fBsim_cols\fP > \fBsim_arr\fP" -.br -.RI "Typedef for the result of the simulate method\&. " -.ti -1c -.RI "typedef arma::vec::fixed< 3 > \fBvec_3d\fP" -.br -.RI "Typedef for a fixed 3d arma vector\&. " -.in -1c -.SH "Detailed Description" -.PP -Useful typedefs for cleaner code\&. - - -.PP -\fBAuthor\fP -.RS 4 -Cory Alexander Balaton (coryab) -.PP -Janita Ovidie Sandtrøen Willumsen (janitaws) -.RE -.PP -\fBVersion\fP -.RS 4 -1\&.0 -.RE -.PP -.PP -These typedefs make the code more readable and easy to follow along\&. -.PP -\fBBug\fP -.RS 4 -No known bugs -.RE -.PP - -.PP -Definition in file \fBtypedefs\&.hpp\fP\&. -.SH "Typedef Documentation" -.PP -.SS "typedef std::vector<\fBsim_cols\fP> \fBsim_arr\fP" - -.PP -Typedef for the result of the simulate method\&. -.PP -Definition at line \fB32\fP of file \fBtypedefs\&.hpp\fP\&. -.SS "typedef std::vector > \fBsim_cols\fP" - -.PP -Typedef for the column of the result vector from simulating particles\&. -.PP -Definition at line \fB24\fP of file \fBtypedefs\&.hpp\fP\&. -.SS "typedef std::vector > \fBsim_rows\fP" - -.PP -Typedef for the row of the result vector from simulating particles\&. -.PP -Definition at line \fB28\fP of file \fBtypedefs\&.hpp\fP\&. -.SS "typedef arma::vec::fixed<3> \fBvec_3d\fP" - -.PP -Typedef for a fixed 3d arma vector\&. -.PP -Definition at line \fB36\fP of file \fBtypedefs\&.hpp\fP\&. -.SH "Author" -.PP -Generated automatically by Doxygen for Penning Trap Simulation from the source code\&. diff --git a/man_pages/man3/utils.cpp.3 b/man_pages/man3/utils.cpp.3 index 335b5f5..3d60a86 100644 --- a/man_pages/man3/utils.cpp.3 +++ b/man_pages/man3/utils.cpp.3 @@ -1,4 +1,4 @@ -.TH "src/utils.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "src/utils.cpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -7,8 +7,6 @@ src/utils.cpp \- Implementation of the utils\&. .SH SYNOPSIS .br .PP -\fC#include \fP -.br \fC#include 'utils\&.hpp'\fP .br @@ -31,10 +29,6 @@ src/utils.cpp \- Implementation of the utils\&. .RI "bool \fBarma_vector_close_to\fP (arma::vec &a, arma::vec &b, double tol)" .br .RI "Test if two armadillo vectors are close to each other\&. " -.ti -1c -.RI "bool \fBmkpath\fP (std::string path, int mode)" -.br -.RI "Make path given\&. " .in -1c .SH "Detailed Description" .PP @@ -81,12 +75,12 @@ Test if two armadillo vectors are close to each other\&. This function takes in .PP \fBReturns\fP .RS 4 -bool +Boolean .RE .PP .PP -Definition at line \fB62\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB59\fP of file \fButils\&.cpp\fP\&. .SS "void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)" .PP @@ -109,31 +103,11 @@ Test an expression, confirm that test is ok, or abort execution\&. This function .PP .PP -Definition at line \fB43\fP of file \fButils\&.cpp\fP\&. -.SS "bool mkpath (std::string path, int mode = \fC0777\fP)" - -.PP -Make path given\&. This tries to be the equivalent to 'mkdir -p' and creates a new directory whenever it needs to\&. -.PP -\fBParameters\fP -.RS 4 -\fIpath\fP The path to be created -.br -\fImode\fP The mode/permissions for all the new directories -.RE -.PP -\fBReturns\fP -.RS 4 -bool -.RE -.PP - -.PP -Definition at line \fB76\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB40\fP of file \fButils\&.cpp\fP\&. .SS "std::string scientific_format (const std::vector< double > & v, int width = \fC20\fP, int prec = \fC10\fP)" .PP -Turns a vector of doubles into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&. +Turns a vector of doubles into a string written in scientific format\&. .PP \fBParameters\fP .RS 4 @@ -146,16 +120,16 @@ Turns a vector of doubles into a string written in scientific format\&. The code .PP \fBReturns\fP .RS 4 -std::string +String .RE .PP .PP -Definition at line \fB24\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB21\fP of file \fButils\&.cpp\fP\&. .SS "std::string scientific_format (double d, int width = \fC20\fP, int prec = \fC10\fP)" .PP -Turns a double into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&. +Turns a double into a string written in scientific format\&. Code stolen from https://github.com/anderkve/FYS3150 Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp .PP \fBParameters\fP .RS 4 @@ -168,12 +142,12 @@ Turns a double into a string written in scientific format\&. The code is stolen .PP \fBReturns\fP .RS 4 -std::string +String .RE .PP .PP -Definition at line \fB17\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB14\fP of file \fButils\&.cpp\fP\&. .SH "Author" .PP Generated automatically by Doxygen for Penning Trap Simulation from the source code\&. diff --git a/man_pages/man3/utils.hpp.3 b/man_pages/man3/utils.hpp.3 index 3f934d0..a67beb7 100644 --- a/man_pages/man3/utils.hpp.3 +++ b/man_pages/man3/utils.hpp.3 @@ -1,4 +1,4 @@ -.TH "include/utils.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*- +.TH "include/utils.hpp" 3 "Sun Oct 8 2023" "Penning Trap Simulation" \" -*- nroff -*- .ad l .nh .SH NAME @@ -32,7 +32,6 @@ include/utils.hpp \- Function prototypes and macros that are useful\&. .ti -1c .RI "#define \fB__METHOD_NAME__\fP methodName(__PRETTY_FUNCTION__)" .br -.RI "Get the name of the current method/function\&. " .in -1c .SS "Functions" @@ -53,10 +52,6 @@ include/utils.hpp \- Function prototypes and macros that are useful\&. .RI "bool \fBarma_vector_close_to\fP (arma::vec &a, arma::vec &b, double tol=1e\-8)" .br .RI "Test if two armadillo vectors are close to each other\&. " -.ti -1c -.RI "bool \fBmkpath\fP (std::string path, int mode=0777)" -.br -.RI "Make path given\&. " .in -1c .SH "Detailed Description" .PP @@ -92,9 +87,7 @@ Definition in file \fButils\&.hpp\fP\&. .SS "#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)" .PP -Get the name of the current method/function\&. -.PP -Definition at line \fB51\fP of file \fButils\&.hpp\fP\&. +Definition at line \fB48\fP of file \fButils\&.hpp\fP\&. .SS "#define ASSERT(expr, msg)" \fBValue:\fP.PP .nf @@ -130,12 +123,12 @@ Test if two armadillo vectors are close to each other\&. This function takes in .PP \fBReturns\fP .RS 4 -bool +Boolean .RE .PP .PP -Definition at line \fB62\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB59\fP of file \fButils\&.cpp\fP\&. .SS "void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)" .PP @@ -158,31 +151,11 @@ Test an expression, confirm that test is ok, or abort execution\&. This function .PP .PP -Definition at line \fB43\fP of file \fButils\&.cpp\fP\&. -.SS "bool mkpath (std::string path, int mode = \fC0777\fP)" - -.PP -Make path given\&. This tries to be the equivalent to 'mkdir -p' and creates a new directory whenever it needs to\&. -.PP -\fBParameters\fP -.RS 4 -\fIpath\fP The path to be created -.br -\fImode\fP The mode/permissions for all the new directories -.RE -.PP -\fBReturns\fP -.RS 4 -bool -.RE -.PP - -.PP -Definition at line \fB76\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB40\fP of file \fButils\&.cpp\fP\&. .SS "std::string scientific_format (const std::vector< double > & v, int width = \fC20\fP, int prec = \fC10\fP)" .PP -Turns a vector of doubles into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&. +Turns a vector of doubles into a string written in scientific format\&. .PP \fBParameters\fP .RS 4 @@ -195,16 +168,16 @@ Turns a vector of doubles into a string written in scientific format\&. The code .PP \fBReturns\fP .RS 4 -std::string +String .RE .PP .PP -Definition at line \fB24\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB21\fP of file \fButils\&.cpp\fP\&. .SS "std::string scientific_format (double d, int width = \fC20\fP, int prec = \fC10\fP)" .PP -Turns a double into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&. +Turns a double into a string written in scientific format\&. Code stolen from https://github.com/anderkve/FYS3150 Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp .PP \fBParameters\fP .RS 4 @@ -217,12 +190,12 @@ Turns a double into a string written in scientific format\&. The code is stolen .PP \fBReturns\fP .RS 4 -std::string +String .RE .PP .PP -Definition at line \fB17\fP of file \fButils\&.cpp\fP\&. +Definition at line \fB14\fP of file \fButils\&.cpp\fP\&. .SH "Author" .PP Generated automatically by Doxygen for Penning Trap Simulation from the source code\&. diff --git a/src/Makefile b/src/Makefile index f678e43..52c16b7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ CLASSOBJS=$(CLASSSRCS:.cpp=.o) INCLUDE=../include -CFLAGS=-Wall -larmadillo -lblas -llapack -std=c++11 -O3 +CFLAGS=-larmadillo -llapack -std=c++11 -O2 OPENMP=-fopenmp # Add a debug flag when compiling (For the DEBUG macro in utils.hpp) @@ -19,27 +19,20 @@ else DBGFLAG= endif -PROFILE ?= 0 -ifeq ($(PROFILE), 1) - PROFFLAG=-pg -else - PROFFLAG= -endif - .PHONY: clean all: test_suite main # Rules for executables main: main.o $(LIBOBJS) $(CLASSOBJS) - $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP) test_suite: test_suite.o $(LIBOBJS) $(CLASSOBJS) - $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + $(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP) # Rule for object files %.o: %.cpp - $(CC) -c $^ -o $@ $(CFLAGS) $(DBGFLAG) $(PROFFLAG) -I$(INCLUDE) $(OPENMP) + $(CC) -c $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP) clean: rm *.o diff --git a/src/Particle.cpp b/src/Particle.cpp index 2caad68..0ff18e8 100644 --- a/src/Particle.cpp +++ b/src/Particle.cpp @@ -8,6 +8,7 @@ * @brief The implementation of the Particle class. * * @bug No known bugs + * * */ #include "Particle.hpp" diff --git a/src/PenningTrap.cpp b/src/PenningTrap.cpp index d0478ec..5d9a16b 100644 --- a/src/PenningTrap.cpp +++ b/src/PenningTrap.cpp @@ -8,75 +8,20 @@ * @brief The implementation of the PenningTrap class. * * @bug No known bugs + * + * @todo Implement evolve_RK4 + * @todo Implement evolve_forward_euler * */ #include "PenningTrap.hpp" #include "constants.hpp" -#include "typedefs.hpp" #include "utils.hpp" -PenningTrap::PenningTrap(double B_0, std::function V_0, - double d, double t) +PenningTrap::PenningTrap(double B_0, double V_0, double d) { this->B_0 = B_0; this->V_0 = V_0; this->d = d; - this->t = t; -} - -PenningTrap::PenningTrap(unsigned int i, double B_0, - std::function V_0, double d, double t) - : PenningTrap::PenningTrap(B_0, V_0, d) -{ - vec_3d r, v; - for (size_t j = 0; j < i; j++) { - r = vec_3d().randn() * .1 * this->d; - v = vec_3d().randn() * .1 * this->d; - this->add_particle(Particle(1., 40., r, v)); - } -} - -PenningTrap::PenningTrap(std::vector particles, double B_0, - std::function V_0, double d, double t) - : PenningTrap::PenningTrap(B_0, V_0, d) -{ - this->particles = particles; -} - -vec_3d PenningTrap::v_func(unsigned int i, unsigned int j, double dt) -{ - switch (i) { - case 0: - return .5 * dt * this->k_v[0][j]; - case 1: - return .5 * dt * this->k_v[1][j]; - case 2: - return dt * this->k_v[2][j]; - case 3: - return (dt / 6.) * (this->k_v[0][j].eval() + this->k_v[1][j].eval() + - this->k_v[2][j].eval() + this->k_v[3][j].eval()); - default: - std::cout << "Not valid!" << std::endl; - abort(); - } -} - -vec_3d PenningTrap::r_func(unsigned int i, unsigned int j, double dt) -{ - switch (i) { - case 0: - return .5 * dt * this->k_r[0][j]; - case 1: - return .5 * dt * this->k_r[1][j]; - case 2: - return dt * this->k_r[2][j]; - case 3: - return (dt / 6.) * (this->k_r[0][j].eval() + this->k_r[1][j].eval() + - this->k_r[2][j].eval() + this->k_r[3][j].eval()); - default: - std::cout << "Not valid!" << std::endl; - abort(); - } } void PenningTrap::add_particle(Particle particle) @@ -84,55 +29,61 @@ void PenningTrap::add_particle(Particle particle) this->particles.push_back(particle); } -vec_3d PenningTrap::external_E_field(vec_3d r) +arma::vec PenningTrap::external_E_field(arma::vec r) { - r(2) *= -2.; - double f = this->V_0(this->t) / (this->d * this->d); + arma::vec::fixed<3> res; + double f = this->V_0 / (this->d * this->d); + res(0) = r(0); + res(1) = r(1); + res(2) = -2. * r(2); - return f * r; + return f * res; } -vec_3d PenningTrap::external_B_field(vec_3d r) +arma::vec PenningTrap::external_B_field(arma::vec r) { - return vec_3d{0., 0., this->B_0}; + arma::vec::fixed<3> res{0., 0., this->B_0}; + + return res; } -vec_3d PenningTrap::force_on_particle(unsigned int i, unsigned int j) +arma::vec PenningTrap::force_on_particle(int i, int j) { - Particle p_j = this->particles[j]; // Calculate the difference between the particles' position - vec_3d res = this->particles[i].r_vec - p_j.r_vec; + arma::vec::fixed<3> res = + this->particles.at(i).r_vec - this->particles.at(j).r_vec; // Get the distance between the particles - double norm = arma::norm(res, 2); + double norm = arma::norm(res); // Multiply res with p_j's charge divided by the norm cubed + res *= this->particles.at(j).q / (norm * norm * norm); - return vec_3d(res * p_j.q / (norm * norm * norm)); + return res; } -vec_3d PenningTrap::total_force_external(unsigned int i) +arma::vec PenningTrap::total_force_external(int i) { - Particle p = this->particles[i]; + Particle p = this->particles.at(i); - if (arma::norm(p.r_vec) > this->d) { - return vec_3d{0., 0., 0.}; - } + arma::vec::fixed<3> B = this->external_B_field(p.r_vec); - vec_3d force = - p.q * (this->external_E_field(p.r_vec) + - arma::cross(p.v_vec, this->external_B_field(p.r_vec))); + arma::vec::fixed<3> v_cross_B{p.v_vec(1) * B(2) - p.v_vec(2) * B(1), + p.v_vec(2) * B(0) - p.v_vec(0) * B(2), + p.v_vec(0) * B(1) - p.v_vec(1) * B(0)}; + + arma::vec force = p.q * (this->external_E_field(p.r_vec) + v_cross_B); return force; } -vec_3d PenningTrap::total_force_particles(unsigned int i) +arma::vec PenningTrap::total_force_particles(int i) { - Particle p = this->particles[i]; + Particle p = this->particles.at(i); - vec_3d res; + arma::vec res(3); - for (size_t j = 0; j < this->particles.size(); j++) { + for (int j = 0; j < this->particles.size(); j++) { if (i == j) { continue; } @@ -140,141 +91,101 @@ vec_3d PenningTrap::total_force_particles(unsigned int i) res += this->force_on_particle(i, j); } - return vec_3d(res * K_E * (p.q / p.m)); + res *= K_E * (p.q / p.m); + + return res; } -vec_3d PenningTrap::total_force(unsigned int i) +arma::vec PenningTrap::total_force(int i) { return this->total_force_external(i) - this->total_force_particles(i); } -void PenningTrap::evolve_RK4(double dt, bool particle_interaction) +void PenningTrap::evolve_RK4(double dt) { - - std::vector original_particles = this->particles; std::vector tmp_particles = this->particles; + + arma::vec::fixed<3> *k_v = new arma::vec::fixed<3>[this->particles.size()*4]; + arma::vec::fixed<3> *k_r = new arma::vec::fixed<3>[this->particles.size()*4]; - vec_3d (PenningTrap::*force)(unsigned int); - if (particle_interaction) { - force = &PenningTrap::total_force; - } - else { - force = &PenningTrap::total_force_external; + int size = this->particles.size(); + + for (int i=0; itotal_force(i)/this->particles.at(i).m; + k_r[i] = this->particles.at(i).v_vec; } - size_t size = this->particles.size(); + for (int i=0; iparticles.at(i); - this->k_v = sim_arr(4, sim_cols(size)); - this->k_r = sim_arr(4, sim_cols(size)); - - for (size_t i = 0; i < 4; i++) { -#pragma omp parallel for - for (size_t j = 0; j < this->particles.size(); j++) { - this->k_v[i][j] = (this->*force)(j) / this->particles[j].m; - this->k_r[i][j] = this->particles[j].v_vec; - - Particle *p = &tmp_particles[j]; - - p->v_vec = original_particles[j].v_vec + this->v_func(i, j, dt); - p->r_vec = original_particles[j].r_vec + this->r_func(i, j, dt); - } - this->particles = tmp_particles; + p->v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[i]; + p->r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[i]; } - this->t += dt; + + + for (int i=0; itotal_force(i)/this->particles.at(i).m; + k_r[1*size + i] = this->particles.at(i).v_vec; + } + + for (int i=0; iparticles.at(i); + + p->v_vec = tmp_particles.at(i).v_vec + (dt/2)*k_v[1*size + i]; + p->r_vec = tmp_particles.at(i).r_vec + (dt/2)*k_r[1*size + i]; + } + + for (int i=0; itotal_force(i)/this->particles.at(i).m; + k_r[2*size + i] = this->particles.at(i).v_vec; + } + + for (int i=0; iparticles.at(i); + + p->v_vec = tmp_particles.at(i).v_vec + dt*k_v[2*size + i]; + p->r_vec = tmp_particles.at(i).r_vec + dt*k_r[2*size + i]; + } + + + for (int i=0; itotal_force(i)/this->particles.at(i).m; + k_r[3*size + i] = this->particles.at(i).v_vec; + } + + for (int i=0; iparticles.at(i); + + p->v_vec = tmp_particles.at(i).v_vec + dt*(k_v[i] + k_v[size + i] + k_v[2*size + i] + k_v[3*size + i])/6; + p->r_vec = tmp_particles.at(i).r_vec + dt*(k_r[i] + k_r[size + i] + k_r[2*size + i] + k_r[3*size + i])/6; + } + + delete [] k_v; + delete [] k_r; } -void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction) +void PenningTrap::evolve_forward_euler(double dt) { std::vector new_state = this->particles; Particle *p; - vec_3d (PenningTrap::*force)(unsigned int); - if (particle_interaction) { - force = &PenningTrap::total_force; - } - else { - force = &PenningTrap::total_force_external; - } - #pragma omp parallel for private(p) - for (size_t i = 0; i < this->particles.size(); i++) { - p = &new_state[i]; - p->v_vec += dt * (this->*force)(i) / p->m; - p->r_vec += dt * this->particles[i].v_vec; + for (int i = 0; i < this->particles.size(); i++) { + p = &new_state.at(i); + p->v_vec += dt * this->total_force(i) / new_state.at(i).m; + p->r_vec += dt * this->particles.at(i).v_vec; } this->particles = new_state; - this->t += dt; } -sim_arr PenningTrap::simulate(double time, unsigned int steps, - std::string method, bool particle_interaction) +arma::vec PenningTrap::get_particle(int i) { - double dt = time / (double)steps; - - sim_arr res(this->particles.size(), sim_cols(steps)); - - void (PenningTrap::*func)(double, bool); - if (method == "rk4") { - func = &PenningTrap::evolve_RK4; - } - else if (method == "euler") { - func = &PenningTrap::evolve_forward_euler; - } - else { - std::cout << "Not a valid method!" << std::endl; - abort(); - } - - for (size_t j = 0; j < steps; j++) { - for (size_t i = 0; i < this->particles.size(); i++) { - res[i][j] = this->particles[i].r_vec; - } - (this->*func)(dt, particle_interaction); - } - - return res; + return this->particles.at(i).r_vec; } -void PenningTrap::write_simulation_to_dir(std::string path, double time, - int steps, std::string method, - bool particle_interaction) +double PenningTrap::get_d() { - if (path.back() != '/') { - path += '/'; - } - if (mkpath(path, 0777) != 0) { - std::cout << "Hello" << std::endl; - return; - } - - sim_arr res = this->simulate(time, steps, method, particle_interaction); - - std::ofstream ofile; - -#pragma omp parallel for private(ofile) - for (size_t i = 0; i < this->particles.size(); i++) { - ofile.open(path + "particle_" + std::to_string(i) + ".txt"); - for (vec_3d &vec : res[i]) { - ofile << vec(0) << "," << vec(1) << "," << vec(2) << "\n"; - } - ofile.close(); - } + return this->d; } - -double PenningTrap::fraction_of_particles_left(double time, unsigned int steps, std::string method, bool particle_interaction) -{ - sim_arr res = this->simulate(time, steps, method, particle_interaction); - - int particles_left = 0; - - for (Particle p : this->particles) { - if (arma::norm(p.r_vec) < this->d) { - particles_left++; - } - } - - return (double) particles_left / (double) this->particles.size(); -} - diff --git a/src/animate_100_particles.py b/src/animate_100_particles.py index 0fc0083..19f10ca 100644 --- a/src/animate_100_particles.py +++ b/src/animate_100_particles.py @@ -32,7 +32,7 @@ def animate(): fig = plt.figure() ax = fig.add_subplot(projection="3d") - arr = get_data([f"output/simulate_100_particles/particle_{i}.txt" for i in range(100)]) + arr = get_data([f"output/simulate_100_particles/p{i}.txt" for i in range(100)]) arr = arr[:, :, ::10] @@ -63,8 +63,8 @@ def animate(): fig, update, N, fargs=(lines, arr), interval=1, blit=False ) - # ani.save("../images/100_particles.gif", writer=animation.FFMpegFileWriter(fps=50)) - plt.show() + ani.save("../images/100_particles.gif", writer=animation.FFMpegFileWriter(fps=50)) + # plt.show() if __name__ == "__main__": diff --git a/src/main.cpp b/src/main.cpp index b07ed93..1c55279 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,112 +10,65 @@ * @bug No known bugs * */ -#include #include #include -#include #include -#include #include "PenningTrap.hpp" -#include "utils.hpp" #define PARTICLES 100 #define N 10000 #define CHARGE 1. #define MASS 40. // unit: amu -Particle p1(CHARGE, MASS, vec_3d{20., 0., 20.}, vec_3d{0., 25., 0.}); -Particle p2(CHARGE, MASS, vec_3d{25., 25., 0.}, vec_3d{0., 40., 5.}); - -void simulate_single_particle() -{ - DEBUG("Inside single particle sim"); - PenningTrap trap(std::vector{p1}); - - double time = 50.; // microseconds - - DEBUG("Write to dir"); - trap.write_simulation_to_dir("output/simulate_single_particle", time, N); -} - -void simulate_two_particles() -{ - PenningTrap trap_no_interaction(std::vector{p1, p2}); - PenningTrap trap_with_interaction(std::vector{p1, p2}); - - double time = 50.; // microseconds - - trap_no_interaction.write_simulation_to_dir( - "output/simulate_2_particles/no_interaction", time, N, "rk4", false); - trap_with_interaction.write_simulation_to_dir( - "output/simulate_2_particles/with_interaction", time, N); -} - -void simulate_single_particle_with_different_steps() -{ - - double time = 50; // microseconds - - for (int i = 0; i < 4; i++) { - int steps = 4000 * (i + 1); - PenningTrap trap(std::vector{p1}); - trap.write_simulation_to_dir("output/N_steps/RK4/" + - std::to_string(steps) + "_steps", - time, steps, "rk4", false); - } - - for (int i = 0; i < 4; i++) { - int steps = 4000 * (i + 1); - PenningTrap trap(std::vector{p1}); - trap.write_simulation_to_dir("output/N_steps/euler/" + - std::to_string(steps) + "_steps", - time, steps, "euler", false); - } -} - void simulate_100_particles() { - PenningTrap trap((unsigned)100, T, - [](double t) { - return 25. * V / 1000. * - (1. + .4 * std::cos(1.5 * t)); - }, - 500., 0); + PenningTrap trap; - double time = 500.; // microseconds + // Add particles inside trap + for (int i = 0; i < PARTICLES; i++) { + arma::vec r = arma::vec(3).randn() * 0.1 * + trap.get_d(); // random initial position + arma::vec v = arma::vec(3).randn() * 0.1 * + trap.get_d(); // random initial velocity + trap.add_particle(Particle(CHARGE, MASS, r, v)); + } - trap.write_simulation_to_dir("output/simulate_100_particles", time, N*5); -} + double time = 50.; // microseconds + double dt = time / (double)N; -void simulate_100_particles_with_time_potential() -{ - double amplitudes[]{.1, .4, .7}; + auto res = new arma::vec::fixed<3>[PARTICLES][N]; - double freq_start = .2; - double freq_end = 2.5; - double freq_increment = .02; - size_t freq_iterations = (size_t) ((freq_end - freq_start) / freq_increment); + int counter = 0; - std::string path = "output/time_dependent_potential/"; - mkpath(path); + // Get the path of all particles + for (int j = 0; j < N; j++) { +#pragma omp parallel for + for (int i = 0; i < PARTICLES; i++) { + res[i][j] = trap.get_particle(i); + } + trap.evolve_RK4(dt); + } + + std::cout << counter << std::endl; + + arma::vec::fixed<3> *cur_row; + arma::vec::fixed<3> cur_elem; + + mkdir("output", 0777); + mkdir("output/simulate_100_particles", 0777); std::ofstream ofile; - for (double f : amplitudes) { - ofile.open(path + "f_" + std::to_string(f) + ".txt"); - #pragma omp parallel for ordered schedule(static, 1) - for (size_t i=0; i < freq_iterations; i++) { - double freq = freq_start + i*freq_increment; - PenningTrap trap((unsigned)100, T, - [f, freq](double t) { - return (25. * V / 1000.) * - (1. + f * std::cos(freq * t)); - }, - 500., 0.); - double res = trap.fraction_of_particles_left(500., 40000, "rk4", true); - #pragma omp ordered - ofile << freq << "," << res << "\n"; +// Write particle paths to file +#pragma omp parallel for private(cur_row, cur_elem, ofile) + for (int i = 0; i < PARTICLES; i++) { + cur_row = res[i]; + ofile.open("output/simulate_100_particles/p" + std::to_string(i) + ".txt"); + for (int j = 0; j < N; j++) { + cur_elem = cur_row[j]; + ofile << cur_elem(0) << "," << cur_elem(1) << "," << cur_elem(2) + << "\n"; } ofile.close(); } @@ -123,18 +76,9 @@ void simulate_100_particles_with_time_potential() int main() { - - simulate_single_particle(); - - simulate_two_particles(); - - simulate_single_particle_with_different_steps(); - double start = omp_get_wtime(); - //simulate_100_particles(); - - simulate_100_particles_with_time_potential(); + simulate_100_particles(); double end = omp_get_wtime(); diff --git a/src/plot_particles_left.py b/src/plot_particles_left.py deleted file mode 100644 index 1d9a45c..0000000 --- a/src/plot_particles_left.py +++ /dev/null @@ -1,33 +0,0 @@ -import matplotlib.pyplot as plt - -def main(): - files = [ - "output/time_dependent_potential/f_0.100000.txt", - "output/time_dependent_potential/f_0.400000.txt", - "output/time_dependent_potential/f_0.700000.txt", - ] - vals = [ - .1, - .4, - .7 - ] - for i in range(3): - with open(files[i]) as f: - lines = f.readlines() - x = [] - y = [] - for line in lines: - a,b = line.strip().split(",") - x.append(float(a)) - y.append(float(b)) - plt.plot(x,y,label=f"amplitude: {vals[i]}") - - plt.xlabel(r"$\omega_V$") - plt.ylabel(r"Fraction of particles left") - plt.title(r"The fraction of particles left in the Penning trap " - "after 500 microseconds for different amplitudes and frequencies") - plt.legend() - plt.show() - -if __name__ == "__main__": - main() diff --git a/src/test_suite.cpp b/src/test_suite.cpp index cd422c5..81ea5c1 100644 --- a/src/test_suite.cpp +++ b/src/test_suite.cpp @@ -44,7 +44,7 @@ public: arma::vec result; arma::vec v; std::stringstream msg; - for (size_t i = 0; i < tests.size(); i++) { + for (int i = 0; i < tests.size(); i++) { v = tests.at(i).first; result = trap.external_E_field(v); diff --git a/src/utils.cpp b/src/utils.cpp index 14670f0..b55fa34 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -9,9 +9,6 @@ * * @bug No known bugs * */ - -#include - #include "utils.hpp" std::string scientific_format(double d, int width, int prec) @@ -65,35 +62,10 @@ bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol) return false; } - for (size_t i = 0; i < a.n_elem; i++) { + for (int i = 0; i < a.n_elem; i++) { if (std::abs(a(i) - b(i)) >= tol) { return false; } } return true; } - -bool mkpath(std::string path, int mode) -{ - std::string cur_dir; - std::string::size_type pos = -1; - struct stat buf; - - if (path.back() != '/') { - path += '/'; - } - while (true) { - pos++; - pos = path.find('/', pos); - if (pos != std::string::npos) { - cur_dir = path.substr(0, pos); - if (mkdir(cur_dir.c_str(), mode) != 0 && stat(cur_dir.c_str(), &buf) != 0) { - return -1; - } - } - else { - break; - } - } - return 0; -}