Coryab/code #10
@ -17,49 +17,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
PenningTrap::PenningTrap(double B_0, double V_0, double d, double t)
|
|
||||||
{
|
|
||||||
this->B_0 = B_0;
|
|
||||||
this->V_0 = V_0;
|
|
||||||
this->d = d;
|
|
||||||
this->t = t;
|
|
||||||
this->perturbation = [](double t) { return 1.; };
|
|
||||||
}
|
|
||||||
|
|
||||||
PenningTrap::PenningTrap(uint i, double B_0, double V_0, double d, double t)
|
|
||||||
: PenningTrap::PenningTrap(B_0, V_0, d)
|
|
||||||
{
|
|
||||||
for (size_t j = 0; j < i; j++) {
|
|
||||||
this->particles.push_back(
|
|
||||||
Particle(vec3(vec3().randn() * .1 * this->d),
|
|
||||||
vec3(vec3().randn() * .1 * this->d)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PenningTrap::PenningTrap(std::vector<Particle> particles, double B_0,
|
|
||||||
double V_0, double d, double t)
|
|
||||||
: PenningTrap::PenningTrap(B_0, V_0, d)
|
|
||||||
{
|
|
||||||
this->particles = particles;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PenningTrap::set_pertubation(double f, double omega_V)
|
|
||||||
{
|
|
||||||
this->perturbation = [f, omega_V](double t) {
|
|
||||||
return 1 + f * std::cos(omega_V * t);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void PenningTrap::reinitialize(double f, double omega_V, double t)
|
|
||||||
{
|
|
||||||
this->t = t;
|
|
||||||
this->set_pertubation(f, omega_V);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < this->particles.size(); i++) {
|
|
||||||
this->particles[i].r_vec = vec3().randn() * .1 * this->d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 PenningTrap::v_func(uint i, uint j, double dt)
|
vec3 PenningTrap::v_func(uint i, uint j, double dt)
|
||||||
{
|
{
|
||||||
switch (i) {
|
switch (i) {
|
||||||
@ -98,11 +55,6 @@ vec3 PenningTrap::r_func(uint i, uint j, double dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PenningTrap::add_particle(Particle particle)
|
|
||||||
{
|
|
||||||
this->particles.push_back(particle);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 PenningTrap::external_E_field(vec3 r)
|
vec3 PenningTrap::external_E_field(vec3 r)
|
||||||
{
|
{
|
||||||
r(2) *= -2.;
|
r(2) *= -2.;
|
||||||
@ -160,6 +112,54 @@ vec3 PenningTrap::total_force(uint i)
|
|||||||
return vec3(this->total_force_external(i) - this->total_force_particles(i));
|
return vec3(this->total_force_external(i) - this->total_force_particles(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PenningTrap::PenningTrap(double B_0, double V_0, double d, double t)
|
||||||
|
{
|
||||||
|
this->B_0 = B_0;
|
||||||
|
this->V_0 = V_0;
|
||||||
|
this->d = d;
|
||||||
|
this->t = t;
|
||||||
|
this->perturbation = [](double t) { return 1.; };
|
||||||
|
}
|
||||||
|
|
||||||
|
PenningTrap::PenningTrap(uint i, double B_0, double V_0, double d, double t)
|
||||||
|
: PenningTrap::PenningTrap(B_0, V_0, d)
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < i; j++) {
|
||||||
|
this->particles.push_back(
|
||||||
|
Particle(vec3(vec3().randn() * .1 * this->d),
|
||||||
|
vec3(vec3().randn() * .1 * this->d)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PenningTrap::PenningTrap(std::vector<Particle> particles, double B_0,
|
||||||
|
double V_0, double d, double t)
|
||||||
|
: PenningTrap::PenningTrap(B_0, V_0, d)
|
||||||
|
{
|
||||||
|
this->particles = particles;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PenningTrap::set_pertubation(double f, double omega_V)
|
||||||
|
{
|
||||||
|
this->perturbation = [f, omega_V](double t) {
|
||||||
|
return 1 + f * std::cos(omega_V * t);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void PenningTrap::reinitialize(double f, double omega_V, double t)
|
||||||
|
{
|
||||||
|
this->t = t;
|
||||||
|
this->set_pertubation(f, omega_V);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < this->particles.size(); i++) {
|
||||||
|
this->particles[i].r_vec = vec3().randn() * .1 * this->d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PenningTrap::add_particle(Particle particle)
|
||||||
|
{
|
||||||
|
this->particles.push_back(particle);
|
||||||
|
}
|
||||||
|
|
||||||
void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
|
void PenningTrap::evolve_RK4(double dt, bool particle_interaction)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user