Added option for initial weights in the injector
This commit is contained in:
@@ -28,7 +28,8 @@ particle::Particle Injector::rollNewParticle(
|
||||
const Coordinate& position,
|
||||
std::shared_ptr<species::TrackedSpecie> created_specie,
|
||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
||||
const double time_birth) {
|
||||
const double time_birth,
|
||||
const double weight) {
|
||||
blitz::TinyVector<double, 3> velocity =
|
||||
creation_velocity_distribution->rollVelocity(position, engine)
|
||||
.cartesianEntries();
|
||||
@@ -41,7 +42,7 @@ particle::Particle Injector::rollNewParticle(
|
||||
out << created_specie->name() << " created at time: " << time_birth << "s.";
|
||||
DEBUG_LEVEL_3(out.str());
|
||||
return particle::Particle(created_specie, position,
|
||||
CartesianVector(velocity), time_birth);
|
||||
CartesianVector(velocity), time_birth, weight);
|
||||
}
|
||||
|
||||
std::vector<particle::Particle> Injector::rollNewParticles(
|
||||
@@ -56,10 +57,13 @@ std::vector<particle::Particle> Injector::rollNewParticles(
|
||||
current_time);
|
||||
const double time_birth = injection_time(*engine);
|
||||
for (auto& injector_info : injector_infos_) {
|
||||
new_particles.push_back(
|
||||
const double weight = 1./injector_info.multiplicity;
|
||||
for (int i = 0; i < injector_info.multiplicity; i++) {
|
||||
new_particles.push_back(
|
||||
rollNewParticle(engine, position, injector_info.created_specie,
|
||||
injector_info.creation_velocity_distribution,
|
||||
time_birth));
|
||||
time_birth, weight));
|
||||
}
|
||||
}
|
||||
return new_particles;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,16 @@ Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||
const Coordinate& position,
|
||||
const Vector& velocity,
|
||||
const double time_birth)
|
||||
const double time_birth,
|
||||
const double weight)
|
||||
: specie_(specie),
|
||||
position_(position),
|
||||
velocity_(velocity, position),
|
||||
id_(this->last_id_),
|
||||
time_alive_s_(time_birth),
|
||||
time_in_bin_s_(0.),
|
||||
interaction_counter_(0) {
|
||||
interaction_counter_(0),
|
||||
weight_(weight) {
|
||||
last_id_++;
|
||||
}
|
||||
|
||||
@@ -100,7 +102,7 @@ double Particle::timeAlive() const {
|
||||
}
|
||||
|
||||
void Particle::increaseTimeInBin(double time_s) {
|
||||
time_in_bin_s_ += time_s;
|
||||
time_in_bin_s_ += time_s*weight_;
|
||||
}
|
||||
|
||||
void Particle::resetTimeInBin() {
|
||||
@@ -115,4 +117,8 @@ long int Particle::ID() const {
|
||||
return id_;
|
||||
}
|
||||
|
||||
double Particle::weight() const {
|
||||
return weight_;
|
||||
}
|
||||
|
||||
} // namespace particle
|
||||
|
||||
Reference in New Issue
Block a user