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
+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;
}