Applied correction to cluster formation

from karl_paper
This commit is contained in:
2025-09-09 10:42:17 +02:00
parent bea8751f1d
commit c57dd44dde
9 changed files with 69 additions and 31 deletions
+20 -1
View File
@@ -10,6 +10,8 @@ class Specie;
namespace interaction {
// class for (radiative) cluster formation interactions (A + B --> AB) 7
// or (A + BC --> AB + C)
class ClusterFormation : public Interaction {
public:
ClusterFormation(std::function<double(double)> cross_section,
@@ -18,10 +20,27 @@ class ClusterFormation : public Interaction {
InteractionOutput performInteraction(particle::Particle& particle,
RandomNumbers* generator);
private:
protected:
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
#endif /* CLUSTER_FORMATION_H */
+1 -1
View File
@@ -13,7 +13,7 @@ class FreeMovement : public Interaction {
InteractionOutput performInteraction(particle::Particle& particle,
RandomNumbers* generator);
double microscopicCrossSection(double energy_eV);
double microscopicCrossSection(double energy_eV, const Coordinate& position);
double macroscopicCrossSection(particle::Particle& particle);
double drawCollisionTime(particle::Particle& particle,
RandomNumbers* generator);
+1 -1
View File
@@ -30,7 +30,7 @@ class Interaction {
Interaction(std::function<double(double)> cross_section,
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);
// return the time the given particle can travel in the laboratory frame
+18 -2
View File
@@ -224,10 +224,26 @@ void addInteractions(
std::shared_ptr<species::TrackedSpecie> product =
findTracked(product_name, tracked_species);
std::string clustering_type =
json_string(json_object_by_path(value, {"ClusteringType"}));
std::function<double(double)> cross_section =
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") {
#ifdef debug_level2
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
+15
View File
@@ -5,6 +5,7 @@
#include "simulation/logger.h"
#include "simulation/velocity_distribution.h"
#include "constants/physical_constants.h"
#include "simulation/density_field.h"
namespace interaction {
@@ -49,4 +50,18 @@ InteractionOutput ClusterFormation::performInteraction(
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
+2 -1
View File
@@ -100,7 +100,8 @@ double ElasticScattering::drawCollisionTime(particle::Particle& particle,
// out << "energy collision time: " << energy_eV;
const double crosssection = microscopicCrossSection(energy_eV);
const double crosssection = microscopicCrossSection(energy_eV,
particle.cylinderPosition());
// out << "\ncross section: " << crosssection;
const double density = target_->densityField()->density(particle.cylinderPosition());
+2 -1
View File
@@ -17,7 +17,8 @@ InteractionOutput FreeMovement::performInteraction(particle::Particle& particle,
return InteractionOutput();
}
double FreeMovement::microscopicCrossSection(double energy_eV) {
double FreeMovement::microscopicCrossSection(double energy_eV,
const Coordinate& position) {
// returns very small number
return SimConstants::minimal_cross_section;
}
+3 -3
View File
@@ -158,9 +158,9 @@ double Recombination::macroscopicCrossSection(const Coordinate& position,
//Simpson's rule
const double integrated_microscopic_cross_section =
(upper_bound - lower_bound)/6. *
(microscopicCrossSection(upper_bound) +
4*microscopicCrossSection(intermediate_value) +
microscopicCrossSection(lower_bound));
(microscopicCrossSection(upper_bound, position) +
4*microscopicCrossSection(intermediate_value, position) +
microscopicCrossSection(lower_bound, position));
// assumption, that the differential density is constant within a cell
return differential_density_value * integrated_microscopic_cross_section;
}
+7 -21
View File
@@ -53,16 +53,19 @@ double Interaction::macroscopicCrossSection(particle::Particle& particle) {
UnitConversion::JouleToeV;
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;
};
double Interaction::microscopicCrossSection(double energy_eV) {
double Interaction::microscopicCrossSection(double energy_eV,
const Coordinate& position) {
return cross_section_(energy_eV);
}
// 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,
RandomNumbers* generator) {
CartesianVector particle_velocity = particle.velocity();
@@ -94,13 +97,6 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
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
// of the two present velocities (to avoid division by 0 if either is 0) probably
// a better version possible
@@ -115,15 +111,10 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
UnitConversion::JouleToeV;
// out << "energy collision time: " << energy_eV;
const double crosssection = microscopicCrossSection(energy_eV);
// out << "\ncross section: " << crosssection;
const double crosssection = microscopicCrossSection(energy_eV,
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.);
if (random_number == 0) {
return std::numeric_limits<double>::max();
@@ -132,12 +123,7 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
const double distance_target_fixed =
- 1./(crosssection * density) * log(random_number);
// out << "\ndistance in target fixed frame: " << distance_target_fixed;
const double time = distance_target_fixed / relative_velocity;
// out << "\ntime before collision: " << time;
// if(density != 0)
// DEBUG_LEVEL_1(out.str());
return time;
}