112 lines
2.5 KiB
C++
Executable File
112 lines
2.5 KiB
C++
Executable File
#include "simulation/particle.h"
|
|
#include "constants/physical_constants.h"
|
|
#include "simulation/species.h"
|
|
|
|
namespace particle {
|
|
/*
|
|
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|
Coordinate* position,
|
|
Vector* velocity)
|
|
: specie_(specie),
|
|
position_(CylinderCoordinate(*position)),
|
|
velocity_(CartesianVector(*velocity, *position)),
|
|
id_(this->last_id_),
|
|
time_alive_s_(0.),
|
|
time_in_bin_s_(0.),
|
|
interaction_counter_(0) {
|
|
last_id_++;
|
|
}
|
|
*/
|
|
|
|
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|
const Coordinate& position,
|
|
const Vector& velocity,
|
|
const double time_birth,
|
|
const double weight)
|
|
: specie_(specie),
|
|
position_(position),
|
|
velocity_(velocity, position),
|
|
id_(this->last_id_),
|
|
time_alive_s_(time_birth),
|
|
interaction_counter_(0),
|
|
weight_(weight) {
|
|
last_id_++;
|
|
}
|
|
|
|
long int Particle::last_id_ = 0;
|
|
|
|
double Particle::mass_kg() const {
|
|
return specie_->mass_kg();
|
|
}
|
|
double Particle::charge_C() const {
|
|
return specie_->charge_C();
|
|
}
|
|
|
|
void Particle::lastId(long int id) {
|
|
last_id_ = id;
|
|
}
|
|
|
|
long int Particle::lastId() {
|
|
return last_id_;
|
|
}
|
|
|
|
void Particle::velocity(const CartesianVector& new_velocity) {
|
|
velocity_ = new_velocity;
|
|
}
|
|
|
|
CartesianVector Particle::velocity() const {
|
|
return velocity_;
|
|
}
|
|
|
|
species::TrackedSpecie* Particle::specie() const {
|
|
return specie_.get();
|
|
}
|
|
|
|
void Particle::position(const Coordinate& new_position) {
|
|
position_ = CartesianCoordinate(new_position);
|
|
}
|
|
|
|
CartesianCoordinate Particle::position() const {
|
|
return position_;
|
|
}
|
|
|
|
void Particle::move(const Coordinate& distance) {
|
|
position_.add(distance);
|
|
}
|
|
|
|
double Particle::kineticEnergy_eV() const {
|
|
return mass_kg() * absoluteVelocitySquared() * UnitConversion::JouleToeV / 2.;
|
|
}
|
|
|
|
double Particle::absoluteVelocity() const {
|
|
return std::sqrt(absoluteVelocitySquared());
|
|
}
|
|
|
|
double Particle::absoluteVelocitySquared() const {
|
|
return blitz::dot(velocity_.cartesianEntries(), velocity_.cartesianEntries());
|
|
}
|
|
|
|
void Particle::increaseInteractionCounter() {
|
|
interaction_counter_++;
|
|
}
|
|
long int Particle::interactionCounter() const {
|
|
return interaction_counter_;
|
|
}
|
|
|
|
void Particle::increaseTimeAlive(double time_s) {
|
|
time_alive_s_ += time_s;
|
|
}
|
|
double Particle::timeAlive() const {
|
|
return time_alive_s_;
|
|
}
|
|
|
|
long int Particle::ID() const {
|
|
return id_;
|
|
}
|
|
|
|
double Particle::weight() const {
|
|
return weight_;
|
|
}
|
|
|
|
} // namespace particle
|