energy drawing via powerlaw
This commit is contained in:
@@ -210,8 +210,49 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity(
|
||||
const double pitch_angle_step = pitchAngleBinBorders_[index(3) + 1]
|
||||
- pitchAngleBinBorders_[index(3)];
|
||||
|
||||
double energy_eV = energyBinBorders_[index(4) + 1]
|
||||
+ theta_distribution_(*engine)*energy_step;
|
||||
// double energy_eV = energyBinBorders_[index(4) + 1]
|
||||
// + theta_distribution_(*engine)*energy_step;
|
||||
double energy_eV;
|
||||
if(index(4) == -1) {
|
||||
// linear drawing inbetween E=0, N(0)=0 to E=Er and N(Er)=Nr
|
||||
energy_eV = energyBinBorders_[index(4) + 2]*
|
||||
std::sqrt(theta_distribution_(*engine));
|
||||
// #ifdef debug
|
||||
// std::stringstream out;
|
||||
// out << "underflow bin.\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 {
|
||||
double nl = density_field_->particleNumber(index -
|
||||
blitz::TinyVector<int, 5>(0,0,0,0,1));
|
||||
double nr = density_field_->particleNumber(index);
|
||||
double alpha = std::log(nr/nl)/std::log(energyBinBorders_[index(4) + 2]/
|
||||
energyBinBorders_[index(4) + 1]);
|
||||
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
|
||||
} 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];
|
||||
// #ifdef debug
|
||||
// std::stringstream out;
|
||||
// out << "alpha = "<< alpha << "\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
|
||||
}
|
||||
}
|
||||
|
||||
double pitchAngle = pitchAngleBinBorders_[index(3)]
|
||||
+ theta_distribution_(*engine)*pitch_angle_step;
|
||||
|
||||
Reference in New Issue
Block a user