Merge branch 'coryab/code' into develop
This commit is contained in:
commit
58db1d9928
1
.gitignore
vendored
1
.gitignore
vendored
@ -47,3 +47,4 @@ src/*
|
||||
!src/*.hpp
|
||||
!src/*.py
|
||||
!src/Doxyfile
|
||||
!src/scripts
|
||||
|
||||
2
Doxyfile
2
Doxyfile
@ -2174,7 +2174,7 @@ RTF_EXTENSIONS_FILE =
|
||||
# classes and files.
|
||||
# The default value is: NO.
|
||||
|
||||
GENERATE_MAN = YES
|
||||
GENERATE_MAN = NO
|
||||
|
||||
# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
|
||||
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
|
||||
|
||||
@ -22,6 +22,11 @@
|
||||
#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
|
||||
initializer(omp_priv = omp_orig)
|
||||
|
||||
typedef struct simulation {
|
||||
sim_arr r_vecs;
|
||||
sim_arr v_vecs;
|
||||
} simulation_t;
|
||||
|
||||
/** @brief A class that simulates a Penning trap.
|
||||
*
|
||||
* This class simulates a Penning trap. It can take in a number of particles
|
||||
@ -188,7 +193,7 @@ public:
|
||||
* @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,
|
||||
simulation_t simulate(double time, unsigned int steps,
|
||||
std::string method = "rk4",
|
||||
bool particle_interaction = true);
|
||||
|
||||
@ -217,6 +222,9 @@ public:
|
||||
double fraction_of_particles_left(double time, unsigned int steps,
|
||||
std::string method = "rk4",
|
||||
bool particle_interaction = true);
|
||||
|
||||
vec_3d get_r(int i);
|
||||
double get_t();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
BIN
latex/images/3d_plot.pdf
Normal file
BIN
latex/images/3d_plot.pdf
Normal file
Binary file not shown.
BIN
latex/images/particles_left.pdf
Normal file
BIN
latex/images/particles_left.pdf
Normal file
Binary file not shown.
BIN
latex/images/phase_space_2_particles.pdf
Normal file
BIN
latex/images/phase_space_2_particles.pdf
Normal file
Binary file not shown.
BIN
latex/images/phase_space_2_particles_x.pdf
Normal file
BIN
latex/images/phase_space_2_particles_x.pdf
Normal file
Binary file not shown.
BIN
latex/images/phase_space_2_particles_z.pdf
Normal file
BIN
latex/images/phase_space_2_particles_z.pdf
Normal file
Binary file not shown.
BIN
latex/images/plot_2_particles_xy.pdf
Normal file
BIN
latex/images/plot_2_particles_xy.pdf
Normal file
Binary file not shown.
BIN
latex/images/single_particle.pdf
Normal file
BIN
latex/images/single_particle.pdf
Normal file
Binary file not shown.
@ -1,111 +0,0 @@
|
||||
.TH "Particle" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
Particle \- A class that holds attributes of a particle\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
.PP
|
||||
\fC#include <Particle\&.hpp>\fP
|
||||
.SS "Public Member Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "\fBParticle\fP (double \fBq\fP, double \fBm\fP, \fBvec_3d\fP \fBr_vec\fP, \fBvec_3d\fP \fBv_vec\fP)"
|
||||
.br
|
||||
.RI "Initialize the particle\&. "
|
||||
.in -1c
|
||||
.SS "Private Attributes"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "double \fBq\fP"
|
||||
.br
|
||||
.RI "Charge\&. "
|
||||
.ti -1c
|
||||
.RI "double \fBm\fP"
|
||||
.br
|
||||
.RI "Mass\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBr_vec\fP"
|
||||
.br
|
||||
.RI "position "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBv_vec\fP"
|
||||
.br
|
||||
.RI "velocity "
|
||||
.in -1c
|
||||
.SS "Friends"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "class \fBPenningTrap\fP"
|
||||
.br
|
||||
.RI "Make private attributes available for \fBPenningTrap\fP\&. "
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
A class that holds attributes of a particle\&.
|
||||
.PP
|
||||
Definition at line \fB21\fP of file \fBParticle\&.hpp\fP\&.
|
||||
.SH "Constructor & Destructor Documentation"
|
||||
.PP
|
||||
.SS "Particle::Particle (double q, double m, \fBvec_3d\fP r_vec, \fBvec_3d\fP v_vec)"
|
||||
|
||||
.PP
|
||||
Initialize the particle\&. Initialize the particle with a charge, mass, position and velocity\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIq\fP The charge of the particle
|
||||
.br
|
||||
\fIm\fP The mass of the particle
|
||||
.br
|
||||
\fIr_vec\fP The initial position of the particle
|
||||
.br
|
||||
\fIv_vec\fP The initial velocity of the particle
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB15\fP of file \fBParticle\&.cpp\fP\&.
|
||||
.SH "Friends And Related Function Documentation"
|
||||
.PP
|
||||
.SS "friend class \fBPenningTrap\fP\fC [friend]\fP"
|
||||
|
||||
.PP
|
||||
Make private attributes available for \fBPenningTrap\fP\&.
|
||||
.PP
|
||||
Definition at line \fB43\fP of file \fBParticle\&.hpp\fP\&.
|
||||
.SH "Member Data Documentation"
|
||||
.PP
|
||||
.SS "double Particle::m\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Mass\&.
|
||||
.PP
|
||||
Definition at line \fB24\fP of file \fBParticle\&.hpp\fP\&.
|
||||
.SS "double Particle::q\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Charge\&.
|
||||
.PP
|
||||
Definition at line \fB23\fP of file \fBParticle\&.hpp\fP\&.
|
||||
.SS "\fBvec_3d\fP Particle::r_vec\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
position
|
||||
.PP
|
||||
Definition at line \fB25\fP of file \fBParticle\&.hpp\fP\&.
|
||||
.SS "\fBvec_3d\fP Particle::v_vec\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
velocity
|
||||
.PP
|
||||
Definition at line \fB26\fP of file \fBParticle\&.hpp\fP\&.
|
||||
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,42 +0,0 @@
|
||||
.TH "src/Particle.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
src/Particle.cpp \- The implementation of the \fBParticle\fP class\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include 'Particle\&.hpp'\fP
|
||||
.br
|
||||
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
The implementation of the \fBParticle\fP class\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
0\&.1
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fBParticle\&.cpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,52 +0,0 @@
|
||||
.TH "include/Particle.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
include/Particle.hpp \- A class that holds the properties of a particle\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include <armadillo>\fP
|
||||
.br
|
||||
\fC#include 'typedefs\&.hpp'\fP
|
||||
.br
|
||||
|
||||
.SS "Classes"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "class \fBParticle\fP"
|
||||
.br
|
||||
.RI "A class that holds attributes of a particle\&. "
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
A class that holds the properties of a particle\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
0\&.1
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fBParticle\&.hpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,494 +0,0 @@
|
||||
.TH "PenningTrap" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
PenningTrap \- A class that simulates a Penning trap\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
.PP
|
||||
\fC#include <PenningTrap\&.hpp>\fP
|
||||
.SS "Public Member Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "\fBPenningTrap\fP (double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)"
|
||||
.br
|
||||
.RI "Constructor for the \fBPenningTrap\fP class\&. "
|
||||
.ti -1c
|
||||
.RI "\fBPenningTrap\fP (unsigned int i, double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)"
|
||||
.br
|
||||
.RI "Constructor for the \fBPenningTrap\fP class\&. "
|
||||
.ti -1c
|
||||
.RI "\fBPenningTrap\fP (std::vector< \fBParticle\fP > \fBparticles\fP, double \fBB_0\fP=\fBT\fP, std::function< double(double)> \fBV_0\fP=[](double \fBt\fP) { return 25\&. *\fBV\fP/1000\&.;}, double \fBd\fP=500\&., double \fBt\fP=0\&.)"
|
||||
.br
|
||||
.RI "Constructor for the \fBPenningTrap\fP class\&. "
|
||||
.ti -1c
|
||||
.RI "void \fBadd_particle\fP (\fBParticle\fP particle)"
|
||||
.br
|
||||
.RI "Add a particle to the system\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBexternal_E_field\fP (\fBvec_3d\fP r)"
|
||||
.br
|
||||
.RI "Calculate E at point r\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBexternal_B_field\fP (\fBvec_3d\fP r)"
|
||||
.br
|
||||
.RI "Calculate B at point r\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBforce_on_particle\fP (unsigned int i, unsigned int j)"
|
||||
.br
|
||||
.RI "Calculate the force between 2 particles\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBtotal_force_external\fP (unsigned int i)"
|
||||
.br
|
||||
.RI "Calculate the total external force on a particle\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBtotal_force_particles\fP (unsigned int i)"
|
||||
.br
|
||||
.RI "Calculate the total force on a particle p_i from other particles\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBtotal_force\fP (unsigned int i)"
|
||||
.br
|
||||
.RI "calculate the total force on a particle p_i\&. "
|
||||
.ti -1c
|
||||
.RI "void \fBevolve_RK4\fP (double dt, bool particle_interaction=true)"
|
||||
.br
|
||||
.RI "Go forward one timestep using the RK4 method\&. "
|
||||
.ti -1c
|
||||
.RI "void \fBevolve_forward_euler\fP (double dt, bool particle_interaction=true)"
|
||||
.br
|
||||
.RI "Go forward one timestep using the forward Euler method\&. "
|
||||
.ti -1c
|
||||
.RI "\fBsim_arr\fP \fBsimulate\fP (double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)"
|
||||
.br
|
||||
.RI "Simulate the particle system inside the Penning trap over a certain amount of time\&. "
|
||||
.ti -1c
|
||||
.RI "void \fBwrite_simulation_to_dir\fP (std::string path, double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)"
|
||||
.br
|
||||
.RI "Simulate and write the displacement of all particles to files\&. "
|
||||
.ti -1c
|
||||
.RI "double \fBfraction_of_particles_left\fP (double time, unsigned int steps, std::string method='rk4', bool particle_interaction=true)"
|
||||
.br
|
||||
.RI "Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation\&. "
|
||||
.in -1c
|
||||
.SS "Private Member Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBv_func\fP (unsigned int i, unsigned int j, double dt)"
|
||||
.br
|
||||
.RI "Helper for evolve_RK4 when calculating $k_{v,i,j}$ values\&. "
|
||||
.ti -1c
|
||||
.RI "\fBvec_3d\fP \fBr_func\fP (unsigned int i, unsigned int j, double dt)"
|
||||
.br
|
||||
.RI "Helper for evolve_RK4 when calculating $k_{r,i,j}$ values\&. "
|
||||
.in -1c
|
||||
.SS "Private Attributes"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "double \fBB_0\fP"
|
||||
.br
|
||||
.RI "Magnetic field strength\&. "
|
||||
.ti -1c
|
||||
.RI "std::function< double(double)> \fBV_0\fP"
|
||||
.br
|
||||
.RI "Applied potential\&. "
|
||||
.ti -1c
|
||||
.RI "double \fBd\fP"
|
||||
.br
|
||||
.RI "Characteristic dimension\&. "
|
||||
.ti -1c
|
||||
.RI "double \fBt\fP"
|
||||
.br
|
||||
.RI "Current time\&. "
|
||||
.ti -1c
|
||||
.RI "std::vector< \fBParticle\fP > \fBparticles\fP"
|
||||
.br
|
||||
.RI "The particles in the Penning trap\&. "
|
||||
.ti -1c
|
||||
.RI "\fBsim_arr\fP \fBk_v\fP"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "\fBsim_arr\fP \fBk_r\fP"
|
||||
.br
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
A class that simulates a Penning trap\&.
|
||||
|
||||
This class simulates a Penning trap\&. It can take in a number of particles and simulate how they would behave inside a Penning trap\&.
|
||||
.PP
|
||||
Definition at line \fB30\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SH "Constructor & Destructor Documentation"
|
||||
.PP
|
||||
.SS "PenningTrap::PenningTrap (double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)"
|
||||
|
||||
.PP
|
||||
Constructor for the \fBPenningTrap\fP class\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIB_0\fP The magnetic field strength
|
||||
.br
|
||||
\fIV_0\fP The time dependent applied potential
|
||||
.br
|
||||
\fId\fP The characteristic dimension
|
||||
.br
|
||||
\fIt\fP The starting time
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB18\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "PenningTrap::PenningTrap (unsigned int i, double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)"
|
||||
|
||||
.PP
|
||||
Constructor for the \fBPenningTrap\fP class\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIi\fP The number of particles to generate
|
||||
.br
|
||||
\fIB_0\fP The magnetic field strength
|
||||
.br
|
||||
\fIV_0\fP The time dependent applied potential
|
||||
.br
|
||||
\fId\fP The characteristic dimension
|
||||
.br
|
||||
\fIt\fP The starting time
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB27\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "PenningTrap::PenningTrap (std::vector< \fBParticle\fP > particles, double B_0 = \fC\fBT\fP\fP, std::function< double(double)> V_0 = \fC[](double \fBt\fP) { return 25\&. * \fBV\fP / 1000\&.; }\fP, double d = \fC500\&.\fP, double t = \fC0\&.\fP)"
|
||||
|
||||
.PP
|
||||
Constructor for the \fBPenningTrap\fP class\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIparticles\fP The starting particles
|
||||
.br
|
||||
\fIB_0\fP The magnetic field strength
|
||||
.br
|
||||
\fIV_0\fP The time dependent applied potential
|
||||
.br
|
||||
\fId\fP The characteristic dimension
|
||||
.br
|
||||
\fIt\fP The starting time
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB39\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SH "Member Function Documentation"
|
||||
.PP
|
||||
.SS "void PenningTrap::add_particle (\fBParticle\fP particle)"
|
||||
|
||||
.PP
|
||||
Add a particle to the system\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIparticle\fP The particle to add to the Penning trap
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB82\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "void PenningTrap::evolve_forward_euler (double dt, bool particle_interaction = \fCtrue\fP)"
|
||||
|
||||
.PP
|
||||
Go forward one timestep using the forward Euler method\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIdt\fP The step length
|
||||
.br
|
||||
\fIparticle_interaction\fP Turn particle interactions on/off
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB186\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "void PenningTrap::evolve_RK4 (double dt, bool particle_interaction = \fCtrue\fP)"
|
||||
|
||||
.PP
|
||||
Go forward one timestep using the RK4 method\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIdt\fP The step length
|
||||
.br
|
||||
\fIparticle_interaction\fP Turn particle interactions on/off
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB151\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::external_B_field (\fBvec_3d\fP r)"
|
||||
|
||||
.PP
|
||||
Calculate B at point r\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIr\fP The position where we want to calculate the B field
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB95\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::external_E_field (\fBvec_3d\fP r)"
|
||||
|
||||
.PP
|
||||
Calculate E at point r\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIr\fP The position where we want to calculate the E field
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB87\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::force_on_particle (unsigned int i, unsigned int j)"
|
||||
|
||||
.PP
|
||||
Calculate the force between 2 particles\&. Calculate the force exhibited on particle p_i from particle p_j\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIi\fP The index of particle p_i
|
||||
.br
|
||||
\fIj\fP The index of particle p_j
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB100\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "double PenningTrap::fraction_of_particles_left (double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)"
|
||||
|
||||
.PP
|
||||
Simulate and calculate what fraction of particles are still left inside the Penning trap after the simulation\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fItime\fP The time to simulate in microseconds
|
||||
.br
|
||||
\fIsteps\fP The amount of steps for the whole simulation
|
||||
.br
|
||||
\fImethod\fP The method to use when moving forward a timestep
|
||||
.br
|
||||
\fIparticle_interaction\fP Turn particle interactions on/off
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
double
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB266\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::r_func (unsigned int i, unsigned int j, double dt)\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Helper for evolve_RK4 when calculating $k_{r,i,j}$ values\&. Something
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIi\fP Index i for $k_{r,i,j}$
|
||||
.br
|
||||
\fIj\fP Index j for $k_{r,i,j}$
|
||||
.br
|
||||
\fIdt\fP the step length (delta time)
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB64\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBsim_arr\fP PenningTrap::simulate (double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)"
|
||||
|
||||
.PP
|
||||
Simulate the particle system inside the Penning trap over a certain amount of time\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fItime\fP The time to simulate in microseconds
|
||||
.br
|
||||
\fIsteps\fP The amount of steps for the whole simulation
|
||||
.br
|
||||
\fImethod\fP The method to use when moving forward a timestep
|
||||
.br
|
||||
\fIparticle_interaction\fP Turn particle interactions on/off
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB211\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::total_force (unsigned int i)"
|
||||
|
||||
.PP
|
||||
calculate the total force on a particle p_i\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIi\fP The index of particle p_i
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB146\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::total_force_external (unsigned int i)"
|
||||
|
||||
.PP
|
||||
Calculate the total external force on a particle\&. Calculate the total amount of force that E and B exhibits on particle p_i\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIi\fP The index of particle p_i
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB114\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::total_force_particles (unsigned int i)"
|
||||
|
||||
.PP
|
||||
Calculate the total force on a particle p_i from other particles\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIi\fP The index of particle p_i
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB129\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "\fBvec_3d\fP PenningTrap::v_func (unsigned int i, unsigned int j, double dt)\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Helper for evolve_RK4 when calculating $k_{v,i,j}$ values\&. Something
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIi\fP Index i for $k_{v,i,j}$
|
||||
.br
|
||||
\fIj\fP Index j for $k_{v,i,j}$
|
||||
.br
|
||||
\fIdt\fP the step length (delta time)
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
vec_3d
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB46\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SS "void PenningTrap::write_simulation_to_dir (std::string path, double time, unsigned int steps, std::string method = \fC'rk4'\fP, bool particle_interaction = \fCtrue\fP)"
|
||||
|
||||
.PP
|
||||
Simulate and write the displacement of all particles to files\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIpath\fP The directory to save the data
|
||||
.br
|
||||
\fItime\fP The time to simulate in microseconds
|
||||
.br
|
||||
\fIsteps\fP The amount of steps for the whole simulation
|
||||
.br
|
||||
\fImethod\fP The method to use when moving forward a timestep
|
||||
.br
|
||||
\fIparticle_interaction\fP Turn particle interactions on/off
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB240\fP of file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SH "Member Data Documentation"
|
||||
.PP
|
||||
.SS "double PenningTrap::B_0\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Magnetic field strength\&.
|
||||
.PP
|
||||
Definition at line \fB32\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SS "double PenningTrap::d\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Characteristic dimension\&.
|
||||
.PP
|
||||
Definition at line \fB34\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SS "\fBsim_arr\fP PenningTrap::k_r\fC [private]\fP"
|
||||
A 2D vector containing all $k_{i,j}$ where $j$ is the index of a particle
|
||||
.PP
|
||||
Definition at line \fB39\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SS "\fBsim_arr\fP PenningTrap::k_v\fC [private]\fP"
|
||||
A 2D vector containing all $k_{i,j}$ where $j$ is the index of a particle
|
||||
.PP
|
||||
Definition at line \fB37\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SS "std::vector<\fBParticle\fP> PenningTrap::particles\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
The particles in the Penning trap\&.
|
||||
.PP
|
||||
Definition at line \fB36\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SS "double PenningTrap::t\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Current time\&.
|
||||
.PP
|
||||
Definition at line \fB35\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SS "std::function<double(double)> PenningTrap::V_0\fC [private]\fP"
|
||||
|
||||
.PP
|
||||
Applied potential\&.
|
||||
.PP
|
||||
Definition at line \fB33\fP of file \fBPenningTrap\&.hpp\fP\&.
|
||||
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,48 +0,0 @@
|
||||
.TH "src/PenningTrap.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
src/PenningTrap.cpp \- The implementation of the \fBPenningTrap\fP class\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include 'PenningTrap\&.hpp'\fP
|
||||
.br
|
||||
\fC#include 'constants\&.hpp'\fP
|
||||
.br
|
||||
\fC#include 'typedefs\&.hpp'\fP
|
||||
.br
|
||||
\fC#include 'utils\&.hpp'\fP
|
||||
.br
|
||||
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
The implementation of the \fBPenningTrap\fP class\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
0\&.1
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fBPenningTrap\&.cpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,58 +0,0 @@
|
||||
.TH "include/PenningTrap.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
include/PenningTrap.hpp \- A class for simulating a Penning trap\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include <armadillo>\fP
|
||||
.br
|
||||
\fC#include <omp\&.h>\fP
|
||||
.br
|
||||
\fC#include 'Particle\&.hpp'\fP
|
||||
.br
|
||||
\fC#include 'constants\&.hpp'\fP
|
||||
.br
|
||||
\fC#include 'typedefs\&.hpp'\fP
|
||||
.br
|
||||
|
||||
.SS "Classes"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "class \fBPenningTrap\fP"
|
||||
.br
|
||||
.RI "A class that simulates a Penning trap\&. "
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
A class for simulating a Penning trap\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
0\&.1
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fBPenningTrap\&.hpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,56 +0,0 @@
|
||||
.TH "PenningTrapTest" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
PenningTrapTest
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
.SS "Static Public Member Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "static void \fBtest_external_E_field\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "static void \fBtest_external_B_field\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "static void \fBtest_force_on_particle\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "static void \fBtest_total_force_external\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "static void \fBtest_total_force_particles\fP ()"
|
||||
.br
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
Definition at line \fB20\fP of file \fBtest_suite\&.cpp\fP\&.
|
||||
.SH "Member Function Documentation"
|
||||
.PP
|
||||
.SS "static void PenningTrapTest::test_external_B_field ()\fC [inline]\fP, \fC [static]\fP"
|
||||
|
||||
.PP
|
||||
Definition at line \fB59\fP of file \fBtest_suite\&.cpp\fP\&.
|
||||
.SS "static void PenningTrapTest::test_external_E_field ()\fC [inline]\fP, \fC [static]\fP"
|
||||
|
||||
.PP
|
||||
Definition at line \fB22\fP of file \fBtest_suite\&.cpp\fP\&.
|
||||
.SS "static void PenningTrapTest::test_force_on_particle ()\fC [inline]\fP, \fC [static]\fP"
|
||||
|
||||
.PP
|
||||
Definition at line \fB70\fP of file \fBtest_suite\&.cpp\fP\&.
|
||||
.SS "static void PenningTrapTest::test_total_force_external ()\fC [inline]\fP, \fC [static]\fP"
|
||||
|
||||
.PP
|
||||
Definition at line \fB95\fP of file \fBtest_suite\&.cpp\fP\&.
|
||||
.SS "static void PenningTrapTest::test_total_force_particles ()\fC [inline]\fP, \fC [static]\fP"
|
||||
|
||||
.PP
|
||||
Definition at line \fB108\fP of file \fBtest_suite\&.cpp\fP\&.
|
||||
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,29 +0,0 @@
|
||||
.TH "bug" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
bug \- Bug List
|
||||
.PP
|
||||
|
||||
.IP "\fBFile \fBconstants\&.hpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fBmain\&.cpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fBParticle\&.cpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fBParticle\&.hpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fBPenningTrap\&.cpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fBPenningTrap\&.hpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fBtest_suite\&.cpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fBtypedefs\&.hpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fButils\&.cpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.IP "\fBFile \fButils\&.hpp\fP \fP" 1c
|
||||
No known bugs
|
||||
.PP
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
.TH "include/constants.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
include/constants.hpp \- Library of constants\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
.SS "Macros"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "#define \fBK_E\fP 138935\&.333"
|
||||
.br
|
||||
.RI "Coulomb constant\&. unit: $\frac{u(\mu m)^3}{(\mu s)^2 e^2}$\&. "
|
||||
.ti -1c
|
||||
.RI "#define \fBT\fP 96\&.4852558"
|
||||
.br
|
||||
.RI "1 Tesla\&. unit: $ \frac{u}{(\mu s) e} $ "
|
||||
.ti -1c
|
||||
.RI "#define \fBV\fP 96485255\&.8"
|
||||
.br
|
||||
.RI "1 Volt\&. unit: $ \frac{u (\mu m)^2}{(\mu s)^2 e} $ "
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
Library of constants\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
0\&.1
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fBconstants\&.hpp\fP\&.
|
||||
.SH "Macro Definition Documentation"
|
||||
.PP
|
||||
.SS "#define K_E 138935\&.333"
|
||||
|
||||
.PP
|
||||
Coulomb constant\&. unit: $\frac{u(\mu m)^3}{(\mu s)^2 e^2}$\&.
|
||||
.PP
|
||||
Definition at line \fB15\fP of file \fBconstants\&.hpp\fP\&.
|
||||
.SS "#define T 96\&.4852558"
|
||||
|
||||
.PP
|
||||
1 Tesla\&. unit: $ \frac{u}{(\mu s) e} $
|
||||
.PP
|
||||
Definition at line \fB17\fP of file \fBconstants\&.hpp\fP\&.
|
||||
.SS "#define V 96485255\&.8"
|
||||
|
||||
.PP
|
||||
1 Volt\&. unit: $ \frac{u (\mu m)^2}{(\mu s)^2 e} $
|
||||
.PP
|
||||
Definition at line \fB19\fP of file \fBconstants\&.hpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,148 +0,0 @@
|
||||
.TH "src/main.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
src/main.cpp \- The main program for this project\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include <cmath>\fP
|
||||
.br
|
||||
\fC#include <fstream>\fP
|
||||
.br
|
||||
\fC#include <omp\&.h>\fP
|
||||
.br
|
||||
\fC#include <string>\fP
|
||||
.br
|
||||
\fC#include <sys/stat\&.h>\fP
|
||||
.br
|
||||
\fC#include <vector>\fP
|
||||
.br
|
||||
\fC#include 'PenningTrap\&.hpp'\fP
|
||||
.br
|
||||
\fC#include 'utils\&.hpp'\fP
|
||||
.br
|
||||
|
||||
.SS "Macros"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "#define \fBPARTICLES\fP 100"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "#define \fBN\fP 10000"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "#define \fBCHARGE\fP 1\&."
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "#define \fBMASS\fP 40\&."
|
||||
.br
|
||||
.in -1c
|
||||
.SS "Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "void \fBsimulate_single_particle\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "void \fBsimulate_two_particles\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "void \fBsimulate_single_particle_with_different_steps\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "void \fBsimulate_100_particles\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "void \fBsimulate_100_particles_with_time_potential\fP ()"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "int \fBmain\fP ()"
|
||||
.br
|
||||
.in -1c
|
||||
.SS "Variables"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "\fBParticle\fP \fBp1\fP (CHARGE, MASS, \fBvec_3d\fP{20\&., 0\&., 20\&.}, \fBvec_3d\fP{0\&., 25\&., 0\&.})"
|
||||
.br
|
||||
.ti -1c
|
||||
.RI "\fBParticle\fP \fBp2\fP (CHARGE, MASS, \fBvec_3d\fP{25\&., 25\&., 0\&.}, \fBvec_3d\fP{0\&., 40\&., 5\&.})"
|
||||
.br
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
The main program for this project\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
0\&.1
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fBmain\&.cpp\fP\&.
|
||||
.SH "Macro Definition Documentation"
|
||||
.PP
|
||||
.SS "#define CHARGE 1\&."
|
||||
|
||||
.PP
|
||||
Definition at line \fB25\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "#define MASS 40\&."
|
||||
|
||||
.PP
|
||||
Definition at line \fB26\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "#define N 10000"
|
||||
|
||||
.PP
|
||||
Definition at line \fB24\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "#define PARTICLES 100"
|
||||
|
||||
.PP
|
||||
Definition at line \fB23\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SH "Function Documentation"
|
||||
.PP
|
||||
.SS "int main ()"
|
||||
|
||||
.PP
|
||||
Definition at line \fB124\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "void simulate_100_particles ()"
|
||||
|
||||
.PP
|
||||
Definition at line \fB77\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "void simulate_100_particles_with_time_potential ()"
|
||||
|
||||
.PP
|
||||
Definition at line \fB91\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "void simulate_single_particle ()"
|
||||
|
||||
.PP
|
||||
Definition at line \fB31\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "void simulate_single_particle_with_different_steps ()"
|
||||
|
||||
.PP
|
||||
Definition at line \fB55\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SS "void simulate_two_particles ()"
|
||||
|
||||
.PP
|
||||
Definition at line \fB42\fP of file \fBmain\&.cpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,70 +0,0 @@
|
||||
.TH "src/test_suite.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
src/test_suite.cpp \- The test suite for the project\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include 'PenningTrap\&.hpp'\fP
|
||||
.br
|
||||
\fC#include 'utils\&.hpp'\fP
|
||||
.br
|
||||
\fC#include <iomanip>\fP
|
||||
.br
|
||||
\fC#include <sstream>\fP
|
||||
.br
|
||||
\fC#include <string>\fP
|
||||
.br
|
||||
|
||||
.SS "Classes"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "class \fBPenningTrapTest\fP"
|
||||
.br
|
||||
.in -1c
|
||||
.SS "Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "int \fBmain\fP ()"
|
||||
.br
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
The test suite for the project\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
0\&.1
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fBtest_suite\&.cpp\fP\&.
|
||||
.SH "Function Documentation"
|
||||
.PP
|
||||
.SS "int main ()"
|
||||
|
||||
.PP
|
||||
Definition at line \fB135\fP of file \fBtest_suite\&.cpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,14 +0,0 @@
|
||||
.TH "todo" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
todo \- Todo List
|
||||
.PP
|
||||
|
||||
.IP "\fBFile \fBPenningTrap\&.cpp\fP \fP" 1c
|
||||
Implement evolve_RK4
|
||||
.PP
|
||||
.PP
|
||||
Implement evolve_forward_euler
|
||||
.PP
|
||||
|
||||
@ -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 <vector>\fP
|
||||
.br
|
||||
\fC#include <armadillo>\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<arma::vec::fixed<3> > \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<arma::vec::fixed<3> > \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\&.
|
||||
@ -1,179 +0,0 @@
|
||||
.TH "src/utils.cpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
src/utils.cpp \- Implementation of the utils\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include <sys/stat\&.h>\fP
|
||||
.br
|
||||
\fC#include 'utils\&.hpp'\fP
|
||||
.br
|
||||
|
||||
.SS "Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "std::string \fBscientific_format\fP (double d, int width, int prec)"
|
||||
.br
|
||||
.RI "Turns a double into a string written in scientific format\&. "
|
||||
.ti -1c
|
||||
.RI "std::string \fBscientific_format\fP (const std::vector< double > &v, int width, int prec)"
|
||||
.br
|
||||
.RI "Turns a vector of doubles into a string written in scientific format\&. "
|
||||
.ti -1c
|
||||
.RI "void \fBm_assert\fP (bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg)"
|
||||
.br
|
||||
.RI "Test an expression, confirm that test is ok, or abort execution\&. "
|
||||
.ti -1c
|
||||
.RI "bool \fBarma_vector_close_to\fP (arma::vec &a, arma::vec &b, double tol)"
|
||||
.br
|
||||
.RI "Test if two armadillo vectors are close to each other\&. "
|
||||
.ti -1c
|
||||
.RI "bool \fBmkpath\fP (std::string path, int mode)"
|
||||
.br
|
||||
.RI "Make path given\&. "
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
Implementation of the utils\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
1\&.0
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fButils\&.cpp\fP\&.
|
||||
.SH "Function Documentation"
|
||||
.PP
|
||||
.SS "bool arma_vector_close_to (arma::vec & a, arma::vec & b, double tol = \fC1e\-8\fP)"
|
||||
|
||||
.PP
|
||||
Test if two armadillo vectors are close to each other\&. This function takes in 2 vectors and checks if they are approximately equal to each other given a tolerance\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIa\fP Vector a
|
||||
.br
|
||||
\fIb\fP Vector b
|
||||
.br
|
||||
\fItol\fP The tolerance
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
bool
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB62\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)"
|
||||
|
||||
.PP
|
||||
Test an expression, confirm that test is ok, or abort execution\&. This function takes in an expression and prints an OK message if it's true, or it prints a fail message and aborts execution if it fails\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIexpr\fP The expression to be evaluated
|
||||
.br
|
||||
\fIexpr_str\fP The stringified version of the expression
|
||||
.br
|
||||
\fIfunc\fP The function name of the caller
|
||||
.br
|
||||
\fIfile\fP The file of the caller
|
||||
.br
|
||||
\fIline\fP The line number where this function is called from
|
||||
.br
|
||||
\fImsg\fP The message to be displayed
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB43\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "bool mkpath (std::string path, int mode = \fC0777\fP)"
|
||||
|
||||
.PP
|
||||
Make path given\&. This tries to be the equivalent to 'mkdir -p' and creates a new directory whenever it needs to\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIpath\fP The path to be created
|
||||
.br
|
||||
\fImode\fP The mode/permissions for all the new directories
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
bool
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB76\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "std::string scientific_format (const std::vector< double > & v, int width = \fC20\fP, int prec = \fC10\fP)"
|
||||
|
||||
.PP
|
||||
Turns a vector of doubles into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIv\fP The vector to stringify
|
||||
.br
|
||||
\fIwidth\fP The reserved width of the string
|
||||
.br
|
||||
\fIprec\fP The precision of the stringified number
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
std::string
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB24\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "std::string scientific_format (double d, int width = \fC20\fP, int prec = \fC10\fP)"
|
||||
|
||||
.PP
|
||||
Turns a double into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fId\fP The number to stringify
|
||||
.br
|
||||
\fIwidth\fP The reserved width of the string
|
||||
.br
|
||||
\fIprec\fP The precision of the stringified number
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
std::string
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB17\fP of file \fButils\&.cpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -1,228 +0,0 @@
|
||||
.TH "include/utils.hpp" 3 "Sat Oct 14 2023" "Penning Trap Simulation" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.SH NAME
|
||||
include/utils.hpp \- Function prototypes and macros that are useful\&.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include <armadillo>\fP
|
||||
.br
|
||||
\fC#include <iomanip>\fP
|
||||
.br
|
||||
\fC#include <sstream>\fP
|
||||
.br
|
||||
\fC#include <string>\fP
|
||||
.br
|
||||
\fC#include <vector>\fP
|
||||
.br
|
||||
|
||||
.SS "Macros"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "#define \fBDEBUG\fP(msg)"
|
||||
.br
|
||||
.RI "Writes a debug message\&. "
|
||||
.ti -1c
|
||||
.RI "#define \fBASSERT\fP(expr, msg)"
|
||||
.br
|
||||
.RI "A prettier assertion function\&. "
|
||||
.ti -1c
|
||||
.RI "#define \fB__METHOD_NAME__\fP methodName(__PRETTY_FUNCTION__)"
|
||||
.br
|
||||
.RI "Get the name of the current method/function\&. "
|
||||
.in -1c
|
||||
.SS "Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "std::string \fBscientific_format\fP (double d, int width=20, int prec=10)"
|
||||
.br
|
||||
.RI "Turns a double into a string written in scientific format\&. "
|
||||
.ti -1c
|
||||
.RI "std::string \fBscientific_format\fP (const std::vector< double > &v, int width=20, int prec=10)"
|
||||
.br
|
||||
.RI "Turns a vector of doubles into a string written in scientific format\&. "
|
||||
.ti -1c
|
||||
.RI "void \fBm_assert\fP (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)"
|
||||
.br
|
||||
.RI "Test an expression, confirm that test is ok, or abort execution\&. "
|
||||
.ti -1c
|
||||
.RI "bool \fBarma_vector_close_to\fP (arma::vec &a, arma::vec &b, double tol=1e\-8)"
|
||||
.br
|
||||
.RI "Test if two armadillo vectors are close to each other\&. "
|
||||
.ti -1c
|
||||
.RI "bool \fBmkpath\fP (std::string path, int mode=0777)"
|
||||
.br
|
||||
.RI "Make path given\&. "
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
Function prototypes and macros that are useful\&.
|
||||
|
||||
|
||||
.PP
|
||||
\fBAuthor\fP
|
||||
.RS 4
|
||||
Cory Alexander Balaton (coryab)
|
||||
.PP
|
||||
Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
.RE
|
||||
.PP
|
||||
\fBVersion\fP
|
||||
.RS 4
|
||||
1\&.0
|
||||
.RE
|
||||
.PP
|
||||
.PP
|
||||
These utility function are mainly for convenience and aren't directly related to the project\&.
|
||||
.PP
|
||||
\fBBug\fP
|
||||
.RS 4
|
||||
No known bugs
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition in file \fButils\&.hpp\fP\&.
|
||||
.SH "Macro Definition Documentation"
|
||||
.PP
|
||||
.SS "#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)"
|
||||
|
||||
.PP
|
||||
Get the name of the current method/function\&.
|
||||
.PP
|
||||
Definition at line \fB51\fP of file \fButils\&.hpp\fP\&.
|
||||
.SS "#define ASSERT(expr, msg)"
|
||||
\fBValue:\fP.PP
|
||||
.nf
|
||||
m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \\
|
||||
__LINE__, msg)
|
||||
.fi
|
||||
|
||||
.PP
|
||||
A prettier assertion function\&. This macro calls the m_assert function which is a more informative assertion function than the regular assert function from cassert\&.
|
||||
.PP
|
||||
Definition at line \fB45\fP of file \fButils\&.hpp\fP\&.
|
||||
.SS "#define DEBUG(msg)"
|
||||
|
||||
.PP
|
||||
Writes a debug message\&. This macro writes a debug message that includes the filename, line number, and a custom message\&. The function is wrapped in an ifdef that checks if DBG is defined, so one can choose to display the debug messages by adding the -DDBG flag when compiling\&.
|
||||
.PP
|
||||
Definition at line \fB36\fP of file \fButils\&.hpp\fP\&.
|
||||
.SH "Function Documentation"
|
||||
.PP
|
||||
.SS "bool arma_vector_close_to (arma::vec & a, arma::vec & b, double tol = \fC1e\-8\fP)"
|
||||
|
||||
.PP
|
||||
Test if two armadillo vectors are close to each other\&. This function takes in 2 vectors and checks if they are approximately equal to each other given a tolerance\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIa\fP Vector a
|
||||
.br
|
||||
\fIb\fP Vector b
|
||||
.br
|
||||
\fItol\fP The tolerance
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
bool
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB62\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)"
|
||||
|
||||
.PP
|
||||
Test an expression, confirm that test is ok, or abort execution\&. This function takes in an expression and prints an OK message if it's true, or it prints a fail message and aborts execution if it fails\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIexpr\fP The expression to be evaluated
|
||||
.br
|
||||
\fIexpr_str\fP The stringified version of the expression
|
||||
.br
|
||||
\fIfunc\fP The function name of the caller
|
||||
.br
|
||||
\fIfile\fP The file of the caller
|
||||
.br
|
||||
\fIline\fP The line number where this function is called from
|
||||
.br
|
||||
\fImsg\fP The message to be displayed
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB43\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "bool mkpath (std::string path, int mode = \fC0777\fP)"
|
||||
|
||||
.PP
|
||||
Make path given\&. This tries to be the equivalent to 'mkdir -p' and creates a new directory whenever it needs to\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIpath\fP The path to be created
|
||||
.br
|
||||
\fImode\fP The mode/permissions for all the new directories
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
bool
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB76\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "std::string scientific_format (const std::vector< double > & v, int width = \fC20\fP, int prec = \fC10\fP)"
|
||||
|
||||
.PP
|
||||
Turns a vector of doubles into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fIv\fP The vector to stringify
|
||||
.br
|
||||
\fIwidth\fP The reserved width of the string
|
||||
.br
|
||||
\fIprec\fP The precision of the stringified number
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
std::string
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB24\fP of file \fButils\&.cpp\fP\&.
|
||||
.SS "std::string scientific_format (double d, int width = \fC20\fP, int prec = \fC10\fP)"
|
||||
|
||||
.PP
|
||||
Turns a double into a string written in scientific format\&. The code is stolen from https://github.com/anderkve/FYS3150\&.
|
||||
.PP
|
||||
\fBParameters\fP
|
||||
.RS 4
|
||||
\fId\fP The number to stringify
|
||||
.br
|
||||
\fIwidth\fP The reserved width of the string
|
||||
.br
|
||||
\fIprec\fP The precision of the stringified number
|
||||
.RE
|
||||
.PP
|
||||
\fBReturns\fP
|
||||
.RS 4
|
||||
std::string
|
||||
.RE
|
||||
.PP
|
||||
|
||||
.PP
|
||||
Definition at line \fB17\fP of file \fButils\&.cpp\fP\&.
|
||||
.SH "Author"
|
||||
.PP
|
||||
Generated automatically by Doxygen for Penning Trap Simulation from the source code\&.
|
||||
@ -53,8 +53,8 @@ vec_3d PenningTrap::v_func(unsigned int i, unsigned int j, double dt)
|
||||
case 2:
|
||||
return dt * this->k_v[2][j];
|
||||
case 3:
|
||||
return (dt / 6.) * (this->k_v[0][j].eval() + this->k_v[1][j].eval() +
|
||||
this->k_v[2][j].eval() + this->k_v[3][j].eval());
|
||||
return (dt / 6.) * (this->k_v[0][j] + 2. * this->k_v[1][j] +
|
||||
2. * this->k_v[2][j] + this->k_v[3][j]);
|
||||
default:
|
||||
std::cout << "Not valid!" << std::endl;
|
||||
abort();
|
||||
@ -71,8 +71,8 @@ vec_3d PenningTrap::r_func(unsigned int i, unsigned int j, double dt)
|
||||
case 2:
|
||||
return dt * this->k_r[2][j];
|
||||
case 3:
|
||||
return (dt / 6.) * (this->k_r[0][j].eval() + this->k_r[1][j].eval() +
|
||||
this->k_r[2][j].eval() + this->k_r[3][j].eval());
|
||||
return (dt / 6.) * (this->k_r[0][j] + 2. * this->k_r[1][j] +
|
||||
2. * this->k_r[2][j] + this->k_r[3][j]);
|
||||
default:
|
||||
std::cout << "Not valid!" << std::endl;
|
||||
abort();
|
||||
@ -106,8 +106,6 @@ vec_3d PenningTrap::force_on_particle(unsigned int i, unsigned int j)
|
||||
// Get the distance between the particles
|
||||
double norm = arma::norm(res, 2);
|
||||
|
||||
// Multiply res with p_j's charge divided by the norm cubed
|
||||
|
||||
return vec_3d(res * p_j.q / (norm * norm * norm));
|
||||
}
|
||||
|
||||
@ -178,15 +176,15 @@ void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
|
||||
p->v_vec = original_particles[j].v_vec + this->v_func(i, j, dt);
|
||||
p->r_vec = original_particles[j].r_vec + this->r_func(i, j, dt);
|
||||
}
|
||||
this->particles = tmp_particles;
|
||||
this->particles.swap(tmp_particles);
|
||||
}
|
||||
this->t += dt;
|
||||
}
|
||||
|
||||
void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction)
|
||||
{
|
||||
std::vector<Particle> new_state = this->particles;
|
||||
|
||||
size_t size = this->particles.size();
|
||||
vec_3d force_res[size];
|
||||
Particle *p;
|
||||
|
||||
vec_3d (PenningTrap::*force)(unsigned int);
|
||||
@ -197,23 +195,31 @@ void PenningTrap::evolve_forward_euler(double dt, bool particle_interaction)
|
||||
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;
|
||||
#pragma omp parallel for
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
force_res[i] = (this->*force)(i);
|
||||
}
|
||||
|
||||
#pragma omp parallel for private(p)
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
p = &this->particles[i];
|
||||
p->r_vec += dt * p->v_vec;
|
||||
p->v_vec += dt * force_res[i] / p->m;
|
||||
}
|
||||
|
||||
this->particles = new_state;
|
||||
this->t += dt;
|
||||
}
|
||||
|
||||
sim_arr PenningTrap::simulate(double time, unsigned int steps,
|
||||
std::string method, bool particle_interaction)
|
||||
simulation_t PenningTrap::simulate(double time, unsigned int steps,
|
||||
std::string method,
|
||||
bool particle_interaction)
|
||||
{
|
||||
double dt = time / (double)steps;
|
||||
|
||||
sim_arr res(this->particles.size(), sim_cols(steps));
|
||||
unsigned int size = this->particles.size();
|
||||
// sim_arr res(this->particles.size(), sim_cols(steps));
|
||||
simulation_t res{sim_arr(size, sim_cols(steps)),
|
||||
sim_arr(size, sim_cols(steps))};
|
||||
|
||||
void (PenningTrap::*func)(double, bool);
|
||||
if (method == "rk4") {
|
||||
@ -228,8 +234,9 @@ sim_arr PenningTrap::simulate(double time, unsigned int steps,
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < steps; j++) {
|
||||
for (size_t i = 0; i < this->particles.size(); i++) {
|
||||
res[i][j] = this->particles[i].r_vec;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
res.r_vecs[i][j] = this->particles[i].r_vec;
|
||||
res.v_vecs[i][j] = this->particles[i].v_vec;
|
||||
}
|
||||
(this->*func)(dt, particle_interaction);
|
||||
}
|
||||
@ -238,7 +245,8 @@ sim_arr PenningTrap::simulate(double time, unsigned int steps,
|
||||
}
|
||||
|
||||
void PenningTrap::write_simulation_to_dir(std::string path, double time,
|
||||
int steps, std::string method,
|
||||
unsigned int steps,
|
||||
std::string method,
|
||||
bool particle_interaction)
|
||||
{
|
||||
if (path.back() != '/') {
|
||||
@ -249,23 +257,34 @@ void PenningTrap::write_simulation_to_dir(std::string path, double time,
|
||||
return;
|
||||
}
|
||||
|
||||
sim_arr res = this->simulate(time, steps, method, particle_interaction);
|
||||
simulation_t res =
|
||||
this->simulate(time, steps, method, particle_interaction);
|
||||
|
||||
std::ofstream ofile;
|
||||
|
||||
#pragma omp parallel for private(ofile)
|
||||
for (size_t i = 0; i < this->particles.size(); i++) {
|
||||
ofile.open(path + "particle_" + std::to_string(i) + ".txt");
|
||||
for (vec_3d &vec : res[i]) {
|
||||
ofile.open(path + "particle_" + std::to_string(i) + "_r.txt");
|
||||
for (vec_3d &vec : res.r_vecs[i]) {
|
||||
ofile << vec(0) << "," << vec(1) << "," << vec(2) << "\n";
|
||||
}
|
||||
ofile.close();
|
||||
ofile.open(path + "particle_" + std::to_string(i) + "_v.txt");
|
||||
for (vec_3d &vec : res.v_vecs[i]) {
|
||||
ofile << scientific_format(vec(0), 10, 8) << ","
|
||||
<< scientific_format(vec(1), 8, 10) << ","
|
||||
<< scientific_format(vec(2), 8, 10) << "\n";
|
||||
}
|
||||
ofile.close();
|
||||
}
|
||||
}
|
||||
|
||||
double PenningTrap::fraction_of_particles_left(double time, unsigned int steps, std::string method, bool particle_interaction)
|
||||
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);
|
||||
simulation_t res =
|
||||
this->simulate(time, steps, method, particle_interaction);
|
||||
|
||||
int particles_left = 0;
|
||||
|
||||
@ -278,3 +297,12 @@ double PenningTrap::fraction_of_particles_left(double time, unsigned int steps,
|
||||
return (double)particles_left / (double)this->particles.size();
|
||||
}
|
||||
|
||||
vec_3d PenningTrap::get_r(int i)
|
||||
{
|
||||
return this->particles[i].r_vec;
|
||||
}
|
||||
|
||||
double PenningTrap::get_t()
|
||||
{
|
||||
return this->t;
|
||||
}
|
||||
|
||||
106
src/main.cpp
106
src/main.cpp
@ -11,7 +11,9 @@
|
||||
* */
|
||||
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <omp.h>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
@ -21,13 +23,27 @@
|
||||
#include "utils.hpp"
|
||||
|
||||
#define PARTICLES 100
|
||||
#define N 10000
|
||||
#define N 40000
|
||||
#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.});
|
||||
|
||||
vec_3d analytical_solution_particle_1(double t)
|
||||
{
|
||||
double w_0 = T / MASS;
|
||||
double w_z2 = (50. * V / 1000.) / (MASS * 500. * 500.);
|
||||
double w_p = (w_0 + std::sqrt(w_0 * w_0 - 2. * w_z2)) / 2.;
|
||||
double w_n = (w_0 - std::sqrt(w_0 * w_0 - 2. * w_z2)) / 2.;
|
||||
double A_p = (25. + w_n * 20.) / (w_n - w_p);
|
||||
double A_n = -(25. + w_p * 20.) / (w_n - w_p);
|
||||
std::complex<double> f = A_p * std::exp(std::complex<double>(0., -w_p * t)) +
|
||||
A_n * std::exp(std::complex<double>(0., -w_n * t));
|
||||
vec_3d res{std::real(f), std::imag(f), 20. * std::cos(std::sqrt(w_z2) * t)};
|
||||
return res;
|
||||
}
|
||||
|
||||
void simulate_single_particle()
|
||||
{
|
||||
DEBUG("Inside single particle sim");
|
||||
@ -36,7 +52,8 @@ void simulate_single_particle()
|
||||
double time = 50.; // microseconds
|
||||
|
||||
DEBUG("Write to dir");
|
||||
trap.write_simulation_to_dir("output/simulate_single_particle", time, N);
|
||||
trap.write_simulation_to_dir("output/simulate_single_particle", time, N,
|
||||
"rk4", false);
|
||||
}
|
||||
|
||||
void simulate_two_particles()
|
||||
@ -55,22 +72,40 @@ void simulate_two_particles()
|
||||
void simulate_single_particle_with_different_steps()
|
||||
{
|
||||
|
||||
double time = 50; // microseconds
|
||||
double time = 50.; // microseconds
|
||||
|
||||
std::ofstream ofile;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int steps = 4000 * (i + 1);
|
||||
int steps = 4000 * std::pow(2, i);
|
||||
double dt = time / (double)steps;
|
||||
std::string path = "output/relative_error/RK4/";
|
||||
mkpath(path);
|
||||
ofile.open(path + std::to_string(steps) + "_steps.txt");
|
||||
PenningTrap trap(std::vector<Particle>{p1});
|
||||
trap.write_simulation_to_dir("output/N_steps/RK4/" +
|
||||
std::to_string(steps) + "_steps",
|
||||
time, steps, "rk4", false);
|
||||
for (int i = 0; i < steps; i++) {
|
||||
trap.evolve_RK4(dt);
|
||||
ofile << arma::norm(trap.get_r(0) -
|
||||
analytical_solution_particle_1(trap.get_t()))
|
||||
<< "\n";
|
||||
}
|
||||
ofile.close();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int steps = 4000 * (i + 1);
|
||||
int steps = 4000 * std::pow(2, i);
|
||||
double dt = time / (double)steps;
|
||||
std::string path = "output/relative_error/euler/";
|
||||
mkpath(path);
|
||||
ofile.open(path + std::to_string(steps) + "_steps.txt");
|
||||
PenningTrap trap(std::vector<Particle>{p1});
|
||||
trap.write_simulation_to_dir("output/N_steps/euler/" +
|
||||
std::to_string(steps) + "_steps",
|
||||
time, steps, "euler", false);
|
||||
for (int i = 0; i < steps; i++) {
|
||||
trap.evolve_forward_euler(dt);
|
||||
ofile << arma::norm(trap.get_r(0) -
|
||||
analytical_solution_particle_1(trap.get_t()))
|
||||
<< "\n";
|
||||
}
|
||||
ofile.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,14 +113,13 @@ void simulate_100_particles()
|
||||
{
|
||||
PenningTrap trap((unsigned)100, T,
|
||||
[](double t) {
|
||||
return 25. * V / 1000. *
|
||||
(1. + .4 * std::cos(1.5 * t));
|
||||
return 25. * V / 1000. * (1. + .4 * std::cos(1.5 * t));
|
||||
},
|
||||
500., 0);
|
||||
|
||||
double time = 500.; // microseconds
|
||||
|
||||
trap.write_simulation_to_dir("output/simulate_100_particles", time, N*5);
|
||||
trap.write_simulation_to_dir("output/simulate_100_particles", time, N * 4);
|
||||
}
|
||||
|
||||
void simulate_100_particles_with_time_potential()
|
||||
@ -97,32 +131,46 @@ void simulate_100_particles_with_time_potential()
|
||||
double freq_increment = .02;
|
||||
size_t freq_iterations = (size_t)((freq_end - freq_start) / freq_increment);
|
||||
|
||||
double res[4][freq_iterations];
|
||||
|
||||
std::string path = "output/time_dependent_potential/";
|
||||
mkpath(path);
|
||||
|
||||
std::ofstream ofile;
|
||||
|
||||
for (double f : amplitudes) {
|
||||
ofile.open(path + "f_" + std::to_string(f) + ".txt");
|
||||
#pragma omp parallel for ordered schedule(static, 1)
|
||||
double freq = freq_start;
|
||||
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));
|
||||
res[0][i] = freq;
|
||||
freq += freq_increment;
|
||||
}
|
||||
|
||||
#pragma omp parallel for collapse(2) num_threads(4)
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
for (size_t j = 0; j < freq_iterations; j++) {
|
||||
PenningTrap trap(
|
||||
(unsigned)100, T,
|
||||
std::bind(
|
||||
[](double f, double r, double t) {
|
||||
return (25. * V / 1000.) * (1. + f * std::cos(r * t));
|
||||
},
|
||||
amplitudes[i], res[0][j], std::placeholders::_1),
|
||||
500., 0.);
|
||||
double res = trap.fraction_of_particles_left(500., 40000, "rk4", true);
|
||||
#pragma omp ordered
|
||||
ofile << freq << "," << res << "\n";
|
||||
res[i + 1][j] =
|
||||
trap.fraction_of_particles_left(500., 40000, "rk4", false);
|
||||
}
|
||||
}
|
||||
|
||||
ofile.open(path + "res.txt");
|
||||
for (size_t i = 0; i < freq_iterations; i++) {
|
||||
ofile << res[0][i] << "," << res[1][i] << "," << res[2][i] << ","
|
||||
<< res[3][i] << "\n";
|
||||
}
|
||||
ofile.close();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
double start = omp_get_wtime();
|
||||
|
||||
simulate_single_particle();
|
||||
|
||||
@ -130,15 +178,13 @@ int main()
|
||||
|
||||
simulate_single_particle_with_different_steps();
|
||||
|
||||
double start = omp_get_wtime();
|
||||
|
||||
// simulate_100_particles();
|
||||
|
||||
simulate_100_particles_with_time_potential();
|
||||
// simulate_100_particles_with_time_potential();
|
||||
|
||||
double end = omp_get_wtime();
|
||||
|
||||
std::cout << "Time: " << end - start << " seconds" << std::endl;
|
||||
std::cout << "Time: " << (end - start) << " seconds" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -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()
|
||||
39
src/scripts/plot_2_particles.py
Normal file
39
src/scripts/plot_2_particles.py
Normal file
@ -0,0 +1,39 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
def main():
|
||||
files = [
|
||||
"output/simulate_2_particles/no_interaction/particle_0_r.txt",
|
||||
"output/simulate_2_particles/no_interaction/particle_1_r.txt",
|
||||
"output/simulate_2_particles/with_interaction/particle_0_r.txt",
|
||||
"output/simulate_2_particles/with_interaction/particle_1_r.txt"
|
||||
]
|
||||
labels = [
|
||||
"particle 1 no interaction",
|
||||
"particle 2 no interaction",
|
||||
"particle 1 with interaction",
|
||||
"particle 2 with interaction",
|
||||
]
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"lightskyblue",
|
||||
"salmon",
|
||||
"salmon"
|
||||
]
|
||||
for label, color, file in zip(labels, colors, files):
|
||||
with open(file) as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
plt.plot(r[:,0], r[:,1], label=label, color=color)
|
||||
|
||||
plt.xlabel(r"x $(\mu m)$")
|
||||
plt.ylabel(r"y $(\mu m)$")
|
||||
plt.title(r"2 particles with and without interactions.")
|
||||
# plt.legend()
|
||||
# plt.show()
|
||||
plt.savefig("../latex/images/plot_2_particles_xy.pdf")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
40
src/scripts/plot_3d.py
Normal file
40
src/scripts/plot_3d.py
Normal file
@ -0,0 +1,40 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
def main():
|
||||
files = [
|
||||
"output/simulate_2_particles/no_interaction/particle_0_r.txt",
|
||||
"output/simulate_2_particles/no_interaction/particle_1_r.txt",
|
||||
"output/simulate_2_particles/with_interaction/particle_0_r.txt",
|
||||
"output/simulate_2_particles/with_interaction/particle_1_r.txt"
|
||||
]
|
||||
labels = [
|
||||
"particle 1 no interaction",
|
||||
"particle 2 no interaction",
|
||||
"particle 1 with interaction",
|
||||
"particle 2 with interaction",
|
||||
]
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"deepskyblue",
|
||||
"salmon",
|
||||
"darkred"
|
||||
]
|
||||
ax = plt.figure().add_subplot(projection="3d")
|
||||
for label, color, file in zip(labels, colors, files):
|
||||
with open(file) as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
ax.plot(r[:,0], r[:,1], r[:,2], label=label, color=color)
|
||||
|
||||
ax.set_xlabel(r"x $(\mu m)$")
|
||||
ax.set_ylabel(r"y $(\mu m)$")
|
||||
ax.set_zlabel(r"z $(\mu m)$")
|
||||
plt.title(r"2 particles with and without interactions.")
|
||||
plt.legend()
|
||||
plt.savefig("../latex/images/3d_plot.pdf")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
30
src/scripts/plot_particles_left.py
Normal file
30
src/scripts/plot_particles_left.py
Normal file
@ -0,0 +1,30 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def main():
|
||||
with open("output/time_dependent_potential/res.txt") as f:
|
||||
lines = f.readlines()
|
||||
x = []
|
||||
y1 = []
|
||||
y2 = []
|
||||
y3 = []
|
||||
for line in lines:
|
||||
l = line.strip().split(",")
|
||||
x.append(float(l[0]))
|
||||
y1.append(float(l[1]))
|
||||
y2.append(float(l[2]))
|
||||
y3.append(float(l[3]))
|
||||
|
||||
plt.plot(x,y1,label=f"amplitude: 0.1")
|
||||
plt.plot(x,y2,label=f"amplitude: 0.4")
|
||||
plt.plot(x,y3,label=f"amplitude: 0.7")
|
||||
|
||||
plt.xlabel(r"$\omega_V$ (MHz)")
|
||||
plt.ylabel(r"Fraction of particles left")
|
||||
plt.title(r"The fraction of particles left in the Penning trap "
|
||||
"after 500 microseconds for different amplitudes and frequencies")
|
||||
plt.legend()
|
||||
# plt.show()
|
||||
plt.savefig("../latex/images/particles_left.pdf")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
53
src/scripts/plot_phase_space.py
Normal file
53
src/scripts/plot_phase_space.py
Normal file
@ -0,0 +1,53 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
def main():
|
||||
directories = {
|
||||
"output/simulate_2_particles/no_interaction/",
|
||||
"output/simulate_2_particles/with_interaction/",
|
||||
}
|
||||
titles = {
|
||||
"particles without interaction",
|
||||
"particles with interaction"
|
||||
}
|
||||
files = [
|
||||
"particle_0_r.txt",
|
||||
"particle_0_v.txt",
|
||||
"particle_1_r.txt",
|
||||
"particle_1_v.txt",
|
||||
]
|
||||
labels = [
|
||||
r"particle 1 r",
|
||||
r"particle 1 v",
|
||||
r"particle 2 r",
|
||||
r"particle 2 v",
|
||||
]
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"deepskyblue",
|
||||
"salmon",
|
||||
"tomato",
|
||||
]
|
||||
fig1, axs1 = plt.subplots(2,1)
|
||||
fig2, axs2 = plt.subplots(2,1)
|
||||
for i, (dir, title) in enumerate(zip(directories, titles)):
|
||||
for label, color, file in zip(labels, colors, files):
|
||||
with open(dir+file) as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
axs1[i].plot(t, r[:,0], label=label, color=color)
|
||||
axs2[i].plot(t, r[:,2], label=label, color=color)
|
||||
|
||||
axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"z $(\mu m)$")
|
||||
|
||||
axs1[i].legend()
|
||||
axs1[i].set_title(title)
|
||||
|
||||
# plt.show()
|
||||
fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
|
||||
fig2.savefig("../latex/images/phase_space_2_particles_z.pdf")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
50
src/scripts/plot_relative_error.py
Normal file
50
src/scripts/plot_relative_error.py
Normal file
@ -0,0 +1,50 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
def main():
|
||||
directories = {
|
||||
"output/relative_error/RK4/",
|
||||
"output/relative_error/euler/",
|
||||
}
|
||||
files = [
|
||||
"4000_steps.txt",
|
||||
"8000_steps.txt",
|
||||
"16000_steps.txt",
|
||||
"32000_steps.txt",
|
||||
]
|
||||
labels = [
|
||||
r"4000 steps",
|
||||
r"8000 steps",
|
||||
r"16000 steps",
|
||||
r"32000 steps",
|
||||
]
|
||||
titles = [
|
||||
"Relative error for the RK4 method",
|
||||
"Relative error for the forward Euler method"
|
||||
]
|
||||
fig1, axs1 = plt.subplots(2,1)
|
||||
for i, (dir, title) in enumerate(zip(directories, titles)):
|
||||
max_err = []
|
||||
for label, file in zip(labels, files):
|
||||
with open(dir+file) as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([float(line.strip()) for line in lines])
|
||||
max_err.append(max(r))
|
||||
axs1[i].plot(t, r, label=label)
|
||||
|
||||
axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"relative_error $(\mu m)$")
|
||||
|
||||
|
||||
axs1[i].legend()
|
||||
axs1[i].set_title(title)
|
||||
|
||||
conv_rate = 1/3 * sum([np.log10(max_err[i+1]/max_err[i])/np.log10(.5) for i in range(3)])
|
||||
print(conv_rate)
|
||||
|
||||
plt.show()
|
||||
# fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
30
src/scripts/plot_single_particle.py
Normal file
30
src/scripts/plot_single_particle.py
Normal file
@ -0,0 +1,30 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
def z(t):
|
||||
V_0 = 25.*9.64852558 * 10**4
|
||||
m = 40.
|
||||
d = 500.
|
||||
w_z = np.sqrt((2.*V_0)/(m*d*d))
|
||||
return 20.*np.cos(w_z*t)
|
||||
|
||||
def main():
|
||||
filename = "output/simulate_single_particle/particle_0_r.txt"
|
||||
r = t = []
|
||||
with open(filename) as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
|
||||
plt.plot(t, r[:, 2], label="approximation")
|
||||
plt.plot(t, z(t), label="analytical")
|
||||
plt.xlabel(r"time $(\mu s)$")
|
||||
plt.ylabel(r"z $(\mu m)$")
|
||||
plt.title(r"Movement of a single particle in the x direction")
|
||||
plt.legend()
|
||||
# plt.savefig("../latex/images/single_particle.pdf")
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue
Block a user