Bunch of stuff

- Add reinitialize to reuse PenningTrap instance and its particles
- Reformatting
- Refactor fraction_of_particles_left to not use simulate
This commit is contained in:
2023-10-22 03:47:23 +02:00
parent 19e35f25ec
commit eb2a985b3b
2 changed files with 92 additions and 56 deletions

View File

@@ -20,7 +20,7 @@
#include "typedefs.hpp"
#include "utils.hpp"
#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
#pragma omp declare reduction(+ : vec_3d : omp_out += omp_in) \
initializer(omp_priv = omp_orig)
/** @brief A class that simulates a Penning trap.
@@ -74,8 +74,8 @@ public:
* */
PenningTrap(
double B_0 = T,
std::function<double(double)> V_0 =
[](double t) { return 25. * V / 1000.; },
std::function<double(double)> V_0
= [](double t) { return 25. * V / 1000.; },
double d = 500., double t = 0.);
/** @brief Constructor for the PenningTrap class
@@ -88,8 +88,8 @@ public:
* */
PenningTrap(
unsigned int i, double B_0 = T,
std::function<double(double)> V_0 =
[](double t) { return 25. * V / 1000.; },
std::function<double(double)> V_0
= [](double t) { return 25. * V / 1000.; },
double d = 500., double t = 0.);
/** @brief Constructor for the PenningTrap class
@@ -102,10 +102,21 @@ public:
* */
PenningTrap(
std::vector<Particle> particles, double B_0 = T,
std::function<double(double)> V_0 =
[](double t) { return 25. * V / 1000.; },
std::function<double(double)> V_0
= [](double t) { return 25. * V / 1000.; },
double d = 500., double t = 0.);
/** @brief Give all particles new positions and velocities, and change t
* and V_0.
*
* @param V_0 The tiome dependent applied potential
* @param t The starting time
* */
void reinitialize(
std::function<double(double)> V_0
= [](double t) { return 25. * V / 1000.; },
double t = 0.);
/** @brief Add a particle to the system
*
* @param particle The particle to add to the Penning trap
@@ -151,7 +162,8 @@ public:
* */
vec_3d total_force_external(unsigned int i);
/** @brief Calculate the total force on a particle p_i from other particles.
/** @brief Calculate the total force on a particle p_i from other
* particles.
*
* @param i The index of particle p_i
*
@@ -204,7 +216,8 @@ public:
* @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",
unsigned int steps,
std::string method = "rk4",
bool particle_interaction = true);
/** @brief Simulate and calculate what fraction of particles are still