Applied correction to cluster formation
from karl_paper
This commit is contained in:
@@ -10,6 +10,8 @@ class Specie;
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for (radiative) cluster formation interactions (A + B --> AB) 7
|
||||||
|
// or (A + BC --> AB + C)
|
||||||
class ClusterFormation : public Interaction {
|
class ClusterFormation : public Interaction {
|
||||||
public:
|
public:
|
||||||
ClusterFormation(std::function<double(double)> cross_section,
|
ClusterFormation(std::function<double(double)> cross_section,
|
||||||
@@ -18,10 +20,27 @@ class ClusterFormation : public Interaction {
|
|||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
std::shared_ptr<species::TrackedSpecie> product_;
|
std::shared_ptr<species::TrackedSpecie> product_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for tertiary association (A + B + B --> AB + B)
|
||||||
|
class ClusterFormationTertiary : public ClusterFormation {
|
||||||
|
public:
|
||||||
|
// Constructor: takes the function describing the cross section (dependent on the energy of the incident particle)
|
||||||
|
// and a shared_ptr to the Species that is the target in the interaction
|
||||||
|
// and a shared_ptr to the TrackedSpecie that is the product of the interaction
|
||||||
|
ClusterFormationTertiary(std::function<double(double)> cross_section,
|
||||||
|
std::shared_ptr<species::Specie> target,
|
||||||
|
std::shared_ptr<species::TrackedSpecie> product);
|
||||||
|
|
||||||
|
// due to only the rate coefficients being available the cross section is
|
||||||
|
// approximated as sigma = rate_coefficient * density / velocity
|
||||||
|
// (units of the tertiary rate coefficient m^6/s)
|
||||||
|
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
|
|
||||||
#endif /* CLUSTER_FORMATION_H */
|
#endif /* CLUSTER_FORMATION_H */
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class FreeMovement : public Interaction {
|
|||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
double microscopicCrossSection(double energy_eV);
|
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
||||||
double macroscopicCrossSection(particle::Particle& particle);
|
double macroscopicCrossSection(particle::Particle& particle);
|
||||||
double drawCollisionTime(particle::Particle& particle,
|
double drawCollisionTime(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Interaction {
|
|||||||
Interaction(std::function<double(double)> cross_section,
|
Interaction(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target);
|
std::shared_ptr<species::Specie> target);
|
||||||
|
|
||||||
virtual double microscopicCrossSection(double energy_eV);
|
virtual double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
||||||
virtual double macroscopicCrossSection(particle::Particle& particle);
|
virtual double macroscopicCrossSection(particle::Particle& particle);
|
||||||
|
|
||||||
// return the time the given particle can travel in the laboratory frame
|
// return the time the given particle can travel in the laboratory frame
|
||||||
|
|||||||
@@ -224,10 +224,26 @@ void addInteractions(
|
|||||||
std::shared_ptr<species::TrackedSpecie> product =
|
std::shared_ptr<species::TrackedSpecie> product =
|
||||||
findTracked(product_name, tracked_species);
|
findTracked(product_name, tracked_species);
|
||||||
|
|
||||||
|
std::string clustering_type =
|
||||||
|
json_string(json_object_by_path(value, {"ClusteringType"}));
|
||||||
|
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
|
||||||
new interaction::ClusterFormation(cross_section, target, product)));
|
if(clustering_type == "radiative") {
|
||||||
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
|
new interaction::ClusterFormation(cross_section, target, product)));
|
||||||
|
} else if (clustering_type == "tertiary") {
|
||||||
|
SIM_INFO("Warning: tertiary clustering has been chosen. Be warned "
|
||||||
|
"that the cross section function is scaled by the density "
|
||||||
|
"of the target specie at the position of the interaction "
|
||||||
|
"(cross section function assumed to have the units m^5)");
|
||||||
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
|
new interaction::ClusterFormationTertiary(cross_section, target, product)));
|
||||||
|
} else {
|
||||||
|
ERROR("ClusteringType " + clustering_type +
|
||||||
|
": not known, choose either 'radiative' or 'tertiary'.");
|
||||||
|
}
|
||||||
} else if (type == "ChargeExchange") {
|
} else if (type == "ChargeExchange") {
|
||||||
#ifdef debug_level2
|
#ifdef debug_level2
|
||||||
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
|
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "simulation/logger.h"
|
#include "simulation/logger.h"
|
||||||
#include "simulation/velocity_distribution.h"
|
#include "simulation/velocity_distribution.h"
|
||||||
#include "constants/physical_constants.h"
|
#include "constants/physical_constants.h"
|
||||||
|
#include "simulation/density_field.h"
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
@@ -49,4 +50,18 @@ InteractionOutput ClusterFormation::performInteraction(
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClusterFormationTertiary::ClusterFormationTertiary(
|
||||||
|
std::function<double(double)> cross_section,
|
||||||
|
std::shared_ptr<species::Specie> target,
|
||||||
|
std::shared_ptr<species::TrackedSpecie> product) :
|
||||||
|
ClusterFormation(cross_section, target, product) {}
|
||||||
|
|
||||||
|
double ClusterFormationTertiary::microscopicCrossSection(double energy_eV,
|
||||||
|
const Coordinate& position) {
|
||||||
|
// SIM_INFO("Tertiary cross section.");
|
||||||
|
const double rate_over_velocity = cross_section_(energy_eV);
|
||||||
|
auto density = target_->densityField()->density(position);
|
||||||
|
return rate_over_velocity * density;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace interaction
|
} // namespace interaction
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ double ElasticScattering::drawCollisionTime(particle::Particle& particle,
|
|||||||
|
|
||||||
// out << "energy collision time: " << energy_eV;
|
// out << "energy collision time: " << energy_eV;
|
||||||
|
|
||||||
const double crosssection = microscopicCrossSection(energy_eV);
|
const double crosssection = microscopicCrossSection(energy_eV,
|
||||||
|
particle.cylinderPosition());
|
||||||
// out << "\ncross section: " << crosssection;
|
// out << "\ncross section: " << crosssection;
|
||||||
const double density = target_->densityField()->density(particle.cylinderPosition());
|
const double density = target_->densityField()->density(particle.cylinderPosition());
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ InteractionOutput FreeMovement::performInteraction(particle::Particle& particle,
|
|||||||
return InteractionOutput();
|
return InteractionOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
double FreeMovement::microscopicCrossSection(double energy_eV) {
|
double FreeMovement::microscopicCrossSection(double energy_eV,
|
||||||
|
const Coordinate& position) {
|
||||||
// returns very small number
|
// returns very small number
|
||||||
return SimConstants::minimal_cross_section;
|
return SimConstants::minimal_cross_section;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,9 +158,9 @@ double Recombination::macroscopicCrossSection(const Coordinate& position,
|
|||||||
//Simpson's rule
|
//Simpson's rule
|
||||||
const double integrated_microscopic_cross_section =
|
const double integrated_microscopic_cross_section =
|
||||||
(upper_bound - lower_bound)/6. *
|
(upper_bound - lower_bound)/6. *
|
||||||
(microscopicCrossSection(upper_bound) +
|
(microscopicCrossSection(upper_bound, position) +
|
||||||
4*microscopicCrossSection(intermediate_value) +
|
4*microscopicCrossSection(intermediate_value, position) +
|
||||||
microscopicCrossSection(lower_bound));
|
microscopicCrossSection(lower_bound, position));
|
||||||
// assumption, that the differential density is constant within a cell
|
// assumption, that the differential density is constant within a cell
|
||||||
return differential_density_value * integrated_microscopic_cross_section;
|
return differential_density_value * integrated_microscopic_cross_section;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,16 +53,19 @@ double Interaction::macroscopicCrossSection(particle::Particle& particle) {
|
|||||||
UnitConversion::JouleToeV;
|
UnitConversion::JouleToeV;
|
||||||
|
|
||||||
const double density = target_->densityField()->density(x_particle);
|
const double density = target_->densityField()->density(x_particle);
|
||||||
const double cross_section = microscopicCrossSection(kinetic_energy_eV);
|
const double cross_section = microscopicCrossSection(kinetic_energy_eV,
|
||||||
|
particle.cylinderPosition());
|
||||||
|
|
||||||
return cross_section * density;
|
return cross_section * density;
|
||||||
};
|
};
|
||||||
|
|
||||||
double Interaction::microscopicCrossSection(double energy_eV) {
|
double Interaction::microscopicCrossSection(double energy_eV,
|
||||||
|
const Coordinate& position) {
|
||||||
return cross_section_(energy_eV);
|
return cross_section_(energy_eV);
|
||||||
}
|
}
|
||||||
|
|
||||||
// think i need to include the magnetic field for it to be really correct
|
// think i need to include the magnetic field for it to be really correct
|
||||||
|
// also sets the velocity of the interaction partner
|
||||||
double Interaction::drawCollisionTime(particle::Particle& particle,
|
double Interaction::drawCollisionTime(particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
CartesianVector particle_velocity = particle.velocity();
|
CartesianVector particle_velocity = particle.velocity();
|
||||||
@@ -94,13 +97,6 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
|
|||||||
|
|
||||||
const double relative_velocity = kinematic::norm(velocity_target_fixed);
|
const double relative_velocity = kinematic::norm(velocity_target_fixed);
|
||||||
|
|
||||||
// std::stringstream out;
|
|
||||||
// out << "particle "<< particle.specie()->name() <<" velocity: "
|
|
||||||
// << particle_velocity.cartesianEntries();
|
|
||||||
// out << "\ntarget "<< target_->name() <<" velocity: "
|
|
||||||
// << target_velocity_.cartesianEntries();
|
|
||||||
// out << "\nabsolute relative velocity: " << relative_velocity;
|
|
||||||
|
|
||||||
// check if the relative velocity is smaller than an epsilon compared to the larger
|
// check if the relative velocity is smaller than an epsilon compared to the larger
|
||||||
// of the two present velocities (to avoid division by 0 if either is 0) probably
|
// of the two present velocities (to avoid division by 0 if either is 0) probably
|
||||||
// a better version possible
|
// a better version possible
|
||||||
@@ -115,15 +111,10 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
|
|||||||
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
|
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
|
||||||
UnitConversion::JouleToeV;
|
UnitConversion::JouleToeV;
|
||||||
|
|
||||||
// out << "energy collision time: " << energy_eV;
|
const double crosssection = microscopicCrossSection(energy_eV,
|
||||||
|
particle.cylinderPosition());
|
||||||
const double crosssection = microscopicCrossSection(energy_eV);
|
|
||||||
// out << "\ncross section: " << crosssection;
|
|
||||||
const double density = target_->densityField()->density(particle.cylinderPosition());
|
const double density = target_->densityField()->density(particle.cylinderPosition());
|
||||||
|
|
||||||
// out << "\ninverse mfp: " << crosssection*density << ", sigma: " << crosssection;
|
|
||||||
// out << ", density: " << density;
|
|
||||||
|
|
||||||
const double random_number = generator->rollUniform(0.,1.);
|
const double random_number = generator->rollUniform(0.,1.);
|
||||||
if (random_number == 0) {
|
if (random_number == 0) {
|
||||||
return std::numeric_limits<double>::max();
|
return std::numeric_limits<double>::max();
|
||||||
@@ -132,12 +123,7 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
|
|||||||
const double distance_target_fixed =
|
const double distance_target_fixed =
|
||||||
- 1./(crosssection * density) * log(random_number);
|
- 1./(crosssection * density) * log(random_number);
|
||||||
|
|
||||||
// out << "\ndistance in target fixed frame: " << distance_target_fixed;
|
|
||||||
|
|
||||||
const double time = distance_target_fixed / relative_velocity;
|
const double time = distance_target_fixed / relative_velocity;
|
||||||
// out << "\ntime before collision: " << time;
|
|
||||||
// if(density != 0)
|
|
||||||
// DEBUG_LEVEL_1(out.str());
|
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user