From c4ae430ffffd9b52f6459e33a48248984f378c39 Mon Sep 17 00:00:00 2001 From: csendlinger Date: Wed, 2 Jul 2025 09:54:15 +0200 Subject: [PATCH] corrected powerlaw drawing --- src/simulation/velocity_distribution.cpp | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/simulation/velocity_distribution.cpp b/src/simulation/velocity_distribution.cpp index 6285a2f..95d0be1 100755 --- a/src/simulation/velocity_distribution.cpp +++ b/src/simulation/velocity_distribution.cpp @@ -240,19 +240,23 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity( alpha = 0; } if(alpha == -1) { - energy_eV = (std::pow(2, theta_distribution_(*engine)) - 1)*energy_step - + energyBinBorders_[index(4) + 1]; -#ifdef debug - std::stringstream out; - out << "alpha = -1\n\tdrawn energy: " << energy_eV; - out << "\n\tenergy value left: " << energyBinBorders_[index(4)+1]; - out << "\n\tenergy value right: " << energyBinBorders_[index(4)+2]; - DEBUG(out.str()); -#endif + energy_eV = std::pow(energyBinBorders_[index(4) + 2] + / energyBinBorders_[index(4) + 1], theta_distribution_(*engine)) * + energyBinBorders_[index(4) + 1]; + // energy_eV = (std::pow(2, theta_distribution_(*engine)) - 1)*energy_step + // + energyBinBorders_[index(4) + 1]; +// #ifdef debug +// std::stringstream out; +// out << "alpha = -1\n\tdrawn energy: " << energy_eV; +// out << "\n\tenergy value left: " << energyBinBorders_[index(4)+1]; +// out << "\n\tenergy value right: " << energyBinBorders_[index(4)+2]; +// DEBUG(out.str()); +// #endif } else { - energy_eV = (std::pow((std::pow(2, alpha+1) - 1)* - theta_distribution_(*engine) + 1, 1/(alpha + 1)) - 1)* - energy_step + energyBinBorders_[index(4) + 1]; + double xl_alphap1 = std::pow(energyBinBorders_[index(4) + 1], alpha + 1); + double xr_alphap1 = std::pow(energyBinBorders_[index(4) + 2], alpha + 1); + energy_eV = std::pow((xr_alphap1 - xl_alphap1)* + theta_distribution_(*engine) + xl_alphap1, 1/(alpha + 1)); // #ifdef debug // std::stringstream out; // out << "alpha = "<< alpha << "\n\tdrawn energy: " << energy_eV;