Added option for initial weights in the injector
This commit is contained in:
@@ -26,6 +26,7 @@ struct InjectorInfo {
|
|||||||
public:
|
public:
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie;
|
std::shared_ptr<species::TrackedSpecie> created_specie;
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
|
||||||
|
int multiplicity;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Injector {
|
class Injector {
|
||||||
@@ -51,7 +52,8 @@ class Injector {
|
|||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie,
|
std::shared_ptr<species::TrackedSpecie> created_specie,
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
||||||
const double time_birth);
|
const double time_birth,
|
||||||
|
const double weight);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* INJECTOR_H */
|
#endif /* INJECTOR_H */
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ class Particle {
|
|||||||
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
const Vector& velocity,
|
const Vector& velocity,
|
||||||
const double time_birth);
|
const double time_birth,
|
||||||
|
const double weight);
|
||||||
|
|
||||||
void position(const Coordinate& new_position);
|
void position(const Coordinate& new_position);
|
||||||
CartesianCoordinate position() const;
|
CartesianCoordinate position() const;
|
||||||
@@ -49,7 +50,11 @@ class Particle {
|
|||||||
|
|
||||||
long int ID() const;
|
long int ID() const;
|
||||||
|
|
||||||
|
double weight() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
double weight_;
|
||||||
|
|
||||||
CartesianVector velocity_;
|
CartesianVector velocity_;
|
||||||
CartesianCoordinate position_;
|
CartesianCoordinate position_;
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ std::shared_ptr<Injector> buildInjector(
|
|||||||
parameter,
|
parameter,
|
||||||
json_path_append(path_to_injector, {"CreatedSpecies", std::string(key),
|
json_path_append(path_to_injector, {"CreatedSpecies", std::string(key),
|
||||||
"CreationVelocityDistribution"}));
|
"CreationVelocityDistribution"}));
|
||||||
|
|
||||||
|
// missing a check if the value is positive
|
||||||
|
info.multiplicity = json_int(json_object_by_path(value, {"Multiplicity"}), 1);
|
||||||
injector_infos.push_back(info);
|
injector_infos.push_back(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ InteractionOutput ClusterFormation::performInteraction(
|
|||||||
const blitz::TinyVector<double, 3> v_cluster =
|
const blitz::TinyVector<double, 3> v_cluster =
|
||||||
kinematic::velocity(energy_eV, product_->mass_kg()) *
|
kinematic::velocity(energy_eV, product_->mass_kg()) *
|
||||||
v_target / kinematic::norm(v_target);
|
v_target / kinematic::norm(v_target);
|
||||||
|
// product inherits weight of the main particle (not the target, which is
|
||||||
|
// assumed to be just a density, i.e. has no weight of its own)
|
||||||
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster),
|
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster),
|
||||||
particle.timeAlive());
|
particle.timeAlive(), particle.weight());
|
||||||
|
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.add(cluster);
|
output.add(cluster);
|
||||||
|
|||||||
@@ -95,12 +95,14 @@ InteractionOutput ElectronIonization::performInteraction(
|
|||||||
|
|
||||||
|
|
||||||
const double time_birth = particle.timeAlive();
|
const double time_birth = particle.timeAlive();
|
||||||
|
const double weight_parent = particle.weight();
|
||||||
|
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.add(
|
output.add(
|
||||||
particle::Particle(electron_, x_impact, CartesianVector(v_ejected),
|
particle::Particle(electron_, x_impact, CartesianVector(v_ejected),
|
||||||
time_birth));
|
time_birth, weight_parent));
|
||||||
output.add(particle::Particle(ion_, x_impact, CartesianVector(v_target),
|
output.add(particle::Particle(ion_, x_impact, CartesianVector(v_target),
|
||||||
time_birth));
|
time_birth, weight_parent));
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ particle::Particle Injector::rollNewParticle(
|
|||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie,
|
std::shared_ptr<species::TrackedSpecie> created_specie,
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
||||||
const double time_birth) {
|
const double time_birth,
|
||||||
|
const double weight) {
|
||||||
blitz::TinyVector<double, 3> velocity =
|
blitz::TinyVector<double, 3> velocity =
|
||||||
creation_velocity_distribution->rollVelocity(position, engine)
|
creation_velocity_distribution->rollVelocity(position, engine)
|
||||||
.cartesianEntries();
|
.cartesianEntries();
|
||||||
@@ -41,7 +42,7 @@ particle::Particle Injector::rollNewParticle(
|
|||||||
out << created_specie->name() << " created at time: " << time_birth << "s.";
|
out << created_specie->name() << " created at time: " << time_birth << "s.";
|
||||||
DEBUG_LEVEL_3(out.str());
|
DEBUG_LEVEL_3(out.str());
|
||||||
return particle::Particle(created_specie, position,
|
return particle::Particle(created_specie, position,
|
||||||
CartesianVector(velocity), time_birth);
|
CartesianVector(velocity), time_birth, weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<particle::Particle> Injector::rollNewParticles(
|
std::vector<particle::Particle> Injector::rollNewParticles(
|
||||||
@@ -56,10 +57,13 @@ std::vector<particle::Particle> Injector::rollNewParticles(
|
|||||||
current_time);
|
current_time);
|
||||||
const double time_birth = injection_time(*engine);
|
const double time_birth = injection_time(*engine);
|
||||||
for (auto& injector_info : injector_infos_) {
|
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,
|
rollNewParticle(engine, position, injector_info.created_specie,
|
||||||
injector_info.creation_velocity_distribution,
|
injector_info.creation_velocity_distribution,
|
||||||
time_birth));
|
time_birth, weight));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new_particles;
|
return new_particles;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,14 +21,16 @@ Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|||||||
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
Particle::Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
const Vector& velocity,
|
const Vector& velocity,
|
||||||
const double time_birth)
|
const double time_birth,
|
||||||
|
const double weight)
|
||||||
: specie_(specie),
|
: specie_(specie),
|
||||||
position_(position),
|
position_(position),
|
||||||
velocity_(velocity, position),
|
velocity_(velocity, position),
|
||||||
id_(this->last_id_),
|
id_(this->last_id_),
|
||||||
time_alive_s_(time_birth),
|
time_alive_s_(time_birth),
|
||||||
time_in_bin_s_(0.),
|
time_in_bin_s_(0.),
|
||||||
interaction_counter_(0) {
|
interaction_counter_(0),
|
||||||
|
weight_(weight) {
|
||||||
last_id_++;
|
last_id_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +102,7 @@ double Particle::timeAlive() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Particle::increaseTimeInBin(double time_s) {
|
void Particle::increaseTimeInBin(double time_s) {
|
||||||
time_in_bin_s_ += time_s;
|
time_in_bin_s_ += time_s*weight_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Particle::resetTimeInBin() {
|
void Particle::resetTimeInBin() {
|
||||||
@@ -115,4 +117,8 @@ long int Particle::ID() const {
|
|||||||
return id_;
|
return id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Particle::weight() const {
|
||||||
|
return weight_;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace particle
|
} // namespace particle
|
||||||
|
|||||||
Reference in New Issue
Block a user