Removed deleted particles array;
resturctured debug output a bit
This commit is contained in:
@@ -19,96 +19,96 @@ InteractionOutput Recombination::performInteraction(
|
||||
RandomNumbers* generator) {
|
||||
DEBUG_LEVEL_3("Perform recombination.");
|
||||
|
||||
std::vector<double> macroscopic_bin_cross_sections_m;
|
||||
const int number_energy_bins = recombination_target_->dynamicDensityField()
|
||||
->energyBinning()->binIndexMax();
|
||||
std::vector<double> energyBinBorders = recombination_target_->
|
||||
dynamicDensityField()->energyBinning()->binBorders();
|
||||
// std::vector<double> macroscopic_bin_cross_sections_m;
|
||||
// const int number_energy_bins = recombination_target_->dynamicDensityField()
|
||||
// ->energyBinning()->binIndexMax();
|
||||
// std::vector<double> energyBinBorders = recombination_target_->
|
||||
// dynamicDensityField()->energyBinning()->binBorders();
|
||||
|
||||
if(recombination_target_->type() == species::ImplementedSpecies::electron) {
|
||||
for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
||||
macroscopic_bin_cross_sections_m.push_back(
|
||||
macroscopicCrossSection(particle.position(), bin));
|
||||
}
|
||||
} else {
|
||||
const blitz::TinyVector<double, 3> v_particle =
|
||||
particle.velocity().cartesianEntries();
|
||||
// if(recombination_target_->type() == species::ImplementedSpecies::electron) {
|
||||
// for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
||||
// macroscopic_bin_cross_sections_m.push_back(
|
||||
// macroscopicCrossSection(particle.position(), bin));
|
||||
// }
|
||||
// } else {
|
||||
// const blitz::TinyVector<double, 3> v_particle =
|
||||
// particle.velocity().cartesianEntries();
|
||||
|
||||
if(!recombination_target_->driftVelocity()) {
|
||||
ERROR(recombination_target_->name() + ": does not have a drift velocity!");
|
||||
}
|
||||
// if(!recombination_target_->driftVelocity()) {
|
||||
// ERROR(recombination_target_->name() + ": does not have a drift velocity!");
|
||||
// }
|
||||
|
||||
const blitz::TinyVector<double, 3> v_partner =
|
||||
recombination_target_->driftVelocity()
|
||||
->driftVelocity(particle.position()).cartesianEntries();
|
||||
// const blitz::TinyVector<double, 3> v_partner =
|
||||
// recombination_target_->driftVelocity()
|
||||
// ->driftVelocity(particle.position()).cartesianEntries();
|
||||
|
||||
const blitz::TinyVector<double, 3> velocity_target_fixed =
|
||||
kinematic::velocityTargetFixed(v_particle, v_partner, particle.mass_kg(),
|
||||
recombination_target_->mass_kg());
|
||||
// const blitz::TinyVector<double, 3> velocity_target_fixed =
|
||||
// kinematic::velocityTargetFixed(v_particle, v_partner, particle.mass_kg(),
|
||||
// recombination_target_->mass_kg());
|
||||
|
||||
const double kinetic_energy_eV =
|
||||
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg()) *
|
||||
UnitConversion::JouleToeV;
|
||||
// const double kinetic_energy_eV =
|
||||
// kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg()) *
|
||||
// UnitConversion::JouleToeV;
|
||||
|
||||
|
||||
double energy_eV_bin_center;
|
||||
for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
||||
energy_eV_bin_center = (energyBinBorders[bin] + energyBinBorders[bin+1])/2.;
|
||||
macroscopic_bin_cross_sections_m.push_back(
|
||||
microscopicCrossSection(kinetic_energy_eV) *
|
||||
recombination_target_->dynamicDensityField()
|
||||
->density(particle.position(), energy_eV_bin_center));
|
||||
}
|
||||
}
|
||||
// double energy_eV_bin_center;
|
||||
// for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
||||
// energy_eV_bin_center = (energyBinBorders[bin] + energyBinBorders[bin+1])/2.;
|
||||
// macroscopic_bin_cross_sections_m.push_back(
|
||||
// microscopicCrossSection(kinetic_energy_eV) *
|
||||
// recombination_target_->dynamicDensityField()
|
||||
// ->density(particle.position(), energy_eV_bin_center));
|
||||
// }
|
||||
// }
|
||||
|
||||
const double total_macroscopic_cross_section_m =
|
||||
std::accumulate(macroscopic_bin_cross_sections_m.begin(),
|
||||
macroscopic_bin_cross_sections_m.end(), 0.0);
|
||||
// const double total_macroscopic_cross_section_m =
|
||||
// std::accumulate(macroscopic_bin_cross_sections_m.begin(),
|
||||
// macroscopic_bin_cross_sections_m.end(), 0.0);
|
||||
|
||||
if(total_macroscopic_cross_section_m <= 0.) {
|
||||
ERROR("Total cross section is " +
|
||||
std::to_string(total_macroscopic_cross_section_m) +
|
||||
". But recombination was chosen.");
|
||||
}
|
||||
// if(total_macroscopic_cross_section_m <= 0.) {
|
||||
// ERROR("Total cross section is " +
|
||||
// std::to_string(total_macroscopic_cross_section_m) +
|
||||
// ". But recombination was chosen.");
|
||||
// }
|
||||
|
||||
std::discrete_distribution<int> energy_bin_decider(
|
||||
macroscopic_bin_cross_sections_m.begin(),
|
||||
macroscopic_bin_cross_sections_m.end());
|
||||
// std::discrete_distribution<int> energy_bin_decider(
|
||||
// macroscopic_bin_cross_sections_m.begin(),
|
||||
// macroscopic_bin_cross_sections_m.end());
|
||||
|
||||
const int energy_bin = energy_bin_decider(*(generator->engine()));
|
||||
const double energy_eV = (energyBinBorders[energy_bin] +
|
||||
energyBinBorders[energy_bin+1]) / 2.;
|
||||
// const int energy_bin = energy_bin_decider(*(generator->engine()));
|
||||
// const double energy_eV = (energyBinBorders[energy_bin] +
|
||||
// energyBinBorders[energy_bin+1]) / 2.;
|
||||
|
||||
blitz::TinyVector<double, 3> position_bins = recombination_target_->dynamicDensityField()
|
||||
->positionBinning()->bin(particle.position().cylinderEntries());
|
||||
// blitz::TinyVector<double, 3> position_bins = recombination_target_->dynamicDensityField()
|
||||
// ->positionBinning()->bin(particle.position().cylinderEntries());
|
||||
|
||||
const blitz::Array<double, 1> mu_distribution =
|
||||
recombination_target_->dynamicDensityField()
|
||||
->timeInBinArray()(position_bins(0),
|
||||
position_bins(1),
|
||||
position_bins(2),
|
||||
blitz::Range::all(),
|
||||
energy_bin);
|
||||
// const blitz::Array<double, 1> mu_distribution =
|
||||
// recombination_target_->dynamicDensityField()
|
||||
// ->timeInBinArray()(position_bins(0),
|
||||
// position_bins(1),
|
||||
// position_bins(2),
|
||||
// blitz::Range::all(),
|
||||
// energy_bin);
|
||||
|
||||
std::vector<double> mu_borders = recombination_target_->dynamicDensityField()
|
||||
->pitchAngleBinning()->binBorders();
|
||||
// std::vector<double> mu_borders = recombination_target_->dynamicDensityField()
|
||||
// ->pitchAngleBinning()->binBorders();
|
||||
|
||||
std::discrete_distribution<int> mu_bin_decider(mu_distribution.begin(),
|
||||
mu_distribution.end());
|
||||
// std::discrete_distribution<int> mu_bin_decider(mu_distribution.begin(),
|
||||
// mu_distribution.end());
|
||||
|
||||
const int mu_bin = mu_bin_decider(*(generator->engine()));
|
||||
// const int mu_bin = mu_bin_decider(*(generator->engine()));
|
||||
|
||||
if((mu_bin == 0) || (mu_bin == mu_distribution.size()-1)) {
|
||||
ERROR("Recombination: drawn mu is from over- or underflow bin!");
|
||||
std::stringstream out;
|
||||
out << "mu distribution values: n";
|
||||
out << mu_distribution;
|
||||
DEBUG_LEVEL_3(out.str());
|
||||
}
|
||||
const double mu = (mu_borders[mu_bin - 1] + mu_borders[mu_bin])/2.;
|
||||
// if((mu_bin == 0) || (mu_bin == mu_distribution.size()-1)) {
|
||||
// ERROR("Recombination: drawn mu is from over- or underflow bin!");
|
||||
// std::stringstream out;
|
||||
// out << "mu distribution values: n";
|
||||
// out << mu_distribution;
|
||||
// DEBUG_LEVEL_3(out.str());
|
||||
// }
|
||||
// const double mu = (mu_borders[mu_bin - 1] + mu_borders[mu_bin])/2.;
|
||||
|
||||
recombination_target_->dynamicDensityField()->logDeletion(particle.position(),
|
||||
energy_eV, mu);
|
||||
// recombination_target_->dynamicDensityField()->logDeletion(particle.position(),
|
||||
// energy_eV, mu);
|
||||
|
||||
InteractionOutput output;
|
||||
output.deleteCurrentParticle(true);
|
||||
|
||||
Reference in New Issue
Block a user