diff --git a/include/simulation/velocity_distribution.h b/include/simulation/velocity_distribution.h index 434939d..10ad82c 100755 --- a/include/simulation/velocity_distribution.h +++ b/include/simulation/velocity_distribution.h @@ -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 density_field_; diff --git a/src/simulation/velocity_distribution.cpp b/src/simulation/velocity_distribution.cpp index eb72b67..5dc5959 100755 --- a/src/simulation/velocity_distribution.cpp +++ b/src/simulation/velocity_distribution.cpp @@ -37,6 +37,8 @@ VelocityDistributionFromDensityField::VelocityDistributionFromDensityField( pitchAngleBinBorders_(density_field->pitchAngleBinning()->binBorders()), theta_distribution_(std::uniform_real_distribution(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(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: [ ";