33 std::vector<std::pair<vec3, vec3>> tests;
35 tests.push_back(std::make_pair(
vec3{0., 0., 0.},
vec3{0., 0., 0.}));
38 std::make_pair(
vec3{10., 0., 0.},
vec3{96.4852558, 0., 0.}));
41 std::make_pair(
vec3{10., 0., 0.},
vec3{96.4852558, 0., 0.}));
44 std::make_pair(
vec3{0., 10., 0.},
vec3{0., 96.4852558, 0.}));
47 std::make_pair(
vec3{0., 0., 10.},
vec3{0., 0., -192.9705116}));
51 std::stringstream msg;
52 for (
size_t i = 0; i < tests.size(); i++) {
53 v = tests.at(i).first;
57 msg <<
"Testing the external E field at (" << std::setprecision(2)
58 << v(0) <<
"," << v(1) <<
"," << v(2) <<
").";
71 vec3 expected{0., 0.,
T};
74 "Testing the external B field at (0,0,0)");
91 vec3 expected{-1., 0., 0.};
94 "Testing the force on a particle at (0,0,0) from a "
95 "particle at (1,0,0).");
98 expected =
vec3{0, -.024, -.032};
101 "Testing the force on a particle at (0,0,0) from a "
102 "particle at (0,3,4).");
112 vec3 expected{395.58954878, -270.15871624, -57.89115348};
115 "Testing the total external force on a particle at "
116 "(1,2,3) with velocity (3,4,5)");
127 vec3 expected{0., 0., 0.};
130 "Testing the total force of all particles on particle 0 "
131 "with only a single particle");
137 expected =
vec3().fill(-138935.333);
140 "Testing the total force of all particles on particle 0 "
141 "with 3 other particles.");
A class for simulating a Penning trap.
A class that holds attributes of a particle.
Test class for the Penning trap.
void test_force_on_particle()
Test that the force between particles gives expected results.
void test_total_force_particles()
Test that the total force of all particles on a single particle returns expected results.
void test_external_E_field()
Test that the external E field gives correct values.
void test_external_B_field()
Test that the external B field gives correct values.
void test_total_force_external()
Test that the total external force returns expected results.
A class that simulates a Penning trap.
vec3 total_force_external(uint i)
Calculate the total external force on a particle.
vec3 total_force_particles(uint i)
Calculate the total force on a particle p_i from other particles.
vec3 external_B_field(vec3 r)
Calculate B at point r.
vec3 external_E_field(vec3 r)
Calculate E at point r.
void add_particle(Particle particle)
Add a particle to the system.
vec3 force_on_particle(uint i, uint j)
Calculate the force between 2 particles.
arma::vec::fixed< 3 > vec3
Typedef for a fixed 3d arma vector.
Function prototypes and macros that are useful.
#define ASSERT(expr, msg)
A prettier assertion function.
bool close_to(arma::vec &a, arma::vec &b, double tol=1e-8)
Test if two armadillo vectors are close to each other.