From c611fa70a23e171c7185766e6bb3f0dd25070c44 Mon Sep 17 00:00:00 2001 From: Cory Date: Fri, 29 Sep 2023 14:47:01 +0200 Subject: [PATCH] Implement total_force_particles --- src/PenningTrap.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/PenningTrap.cpp b/src/PenningTrap.cpp index f83576c..078f17d 100644 --- a/src/PenningTrap.cpp +++ b/src/PenningTrap.cpp @@ -21,6 +21,7 @@ * */ #include "PenningTrap.hpp" +#include "constants.hpp" #include #include @@ -85,7 +86,21 @@ arma::vec PenningTrap::total_force_external(int i) arma::vec PenningTrap::total_force_particles(int i) { + Particle p = this->particles.at(i); + arma::vec::fixed<3> res; + + for (int j=0; j < this->particles.size(); j++) { + if (i == j) { + continue; + } + + res += this->force_on_particle(i, j); + } + + res *= K_E*p.q/p.m; + + return res; } arma::vec PenningTrap::total_force(int i)