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;
-}