changed the way powerlaw drawing alpha is limited

This commit is contained in:
2025-07-09 16:38:04 +02:00
parent f5a4e63627
commit 603434e161
2 changed files with 15 additions and 1 deletions
@@ -67,6 +67,8 @@ class VelocityDistributionFromDensityField : public VelocityDistribution {
private:
// mass of the species of which the density field is a part of
const double mass_kg_;
double alpha_lower_limit;
double alpha_upper_limit;
std::shared_ptr<DynamicDensityField> density_field_;
+13 -1
View File
@@ -37,6 +37,8 @@ VelocityDistributionFromDensityField::VelocityDistributionFromDensityField(
pitchAngleBinBorders_(density_field->pitchAngleBinning()->binBorders()),
theta_distribution_(std::uniform_real_distribution<double>(0.,1.)),
mass_kg_(mass_kg) {
alpha_lower_limit = -300/std::log10(energyBinBorders_.front());
alpha_upper_limit = 300/std::log10(energyBinBorders_.back());
// necessary to include the underflow bin in the energy domain
energyBinBorders_.insert(energyBinBorders_.begin(), 0);
}
@@ -243,7 +245,8 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity(
energyBinBorders_[index(4) + 1]);
}
alpha = std::abs(alpha) > 100 ?(alpha/std::abs(alpha))*100 : alpha;
// alpha = std::abs(alpha) > 100 ?(alpha/std::abs(alpha))*100 : alpha;
alpha = std::min(std::max(alpha, alpha_lower_limit), alpha_upper_limit);
if(alpha == -1) {
energy_eV = std::pow(energyBinBorders_[index(4) + 2]
@@ -290,6 +293,15 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity(
std::stringstream out;
out << "pitchAngle: " << pitchAngle;
out << "\nenergy value: " << energy_eV;
out << "\nalpha: " << alpha;
out << "\ncurrent index: " << index;
out << "\nNl: " << density_field_->particleNumber(index);
out << "\nNl: " << density_field_->particleNumber(index +
blitz::TinyVector<int, 5>(0,0,0,0,1));
out << "\nEl: " << energyBinBorders_[index(4) + 1];
out << "\nEr: " << energyBinBorders_[index(4) + 2];
out << "\nEl^(alpha+1): " << std::pow(energyBinBorders_[index(4) + 1], alpha + 1);
out << "\nEr^(alpha+1): " << std::pow(energyBinBorders_[index(4) + 2], alpha + 1);
// out << "\nenergy values: " << energyValues;
// out << "\npitch angle values: " << pitchAngleValues;
out << "\nenergy bin borders: [ ";