Removed deleted particles array;
resturctured debug output a bit
This commit is contained in:
@@ -64,8 +64,8 @@ class SimulationOutput {
|
||||
void writeSpectrum(DynamicDensityField* density_field, std::string path);
|
||||
void writeDensity(DynamicDensityField* density_field, std::string path);
|
||||
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
|
||||
void writeDeletedParticles(DynamicDensityField* density_field,
|
||||
std::string path);
|
||||
// void writeDeletedParticles(DynamicDensityField* density_field,
|
||||
// std::string path);
|
||||
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
|
||||
|
||||
void writeSimulationData(CurrentCollector* current_collector,
|
||||
|
||||
@@ -42,9 +42,9 @@ class DynamicDensityField : public DensityField {
|
||||
double pitch_angle,
|
||||
double weight);
|
||||
|
||||
void logDeletion(const Coordinate& position,
|
||||
double energy_eV,
|
||||
double pitch_angle);
|
||||
// void logDeletion(const Coordinate& position,
|
||||
// double energy_eV,
|
||||
// double pitch_angle);
|
||||
|
||||
// return the particle number stored in the density of this object
|
||||
double particleNumber();
|
||||
@@ -58,7 +58,7 @@ class DynamicDensityField : public DensityField {
|
||||
blitz::Array<double, 3> densityArray();
|
||||
blitz::Array<double, 4> spectrumArray();
|
||||
blitz::Array<double, 5> timeInBinArray() const;
|
||||
blitz::Array<long int, 5> deletedParticlesArray() const;
|
||||
// blitz::Array<long int, 5> deletedParticlesArray() const;
|
||||
blitz::Array<double, 3> binVolumeArray() const;
|
||||
|
||||
// return an array of the density values at the Coordinate position (only energy
|
||||
@@ -84,18 +84,21 @@ class DynamicDensityField : public DensityField {
|
||||
|
||||
void restartTimer(double time, double delta_t);
|
||||
void restartTimeInBin(blitz::Array<double, 5> time_in_bin);
|
||||
void restartDeletedParticlesArray(blitz::Array<long int, 5> deleted_particles);
|
||||
// void restartDeletedParticlesArray(blitz::Array<long int, 5> deleted_particles);
|
||||
|
||||
private:
|
||||
|
||||
void recalculateDensityArray();
|
||||
|
||||
// use ordering r, phi, z, pitch_angle, E
|
||||
// time in bin now contains the physical particle number per bin
|
||||
// (not renamed, since that would require many, many changes due to
|
||||
// renaming of the functions)
|
||||
blitz::Array<double, 5> time_in_bin_s_;
|
||||
blitz::Array<long int, 5> deleted_particles_;
|
||||
// blitz::Array<long int, 5> deleted_particles_;
|
||||
|
||||
blitz::Array<double, 5> sync_time_in_bin_s_;
|
||||
blitz::Array<long int, 5> sync_deleted_particles_;
|
||||
// blitz::Array<long int, 5> sync_deleted_particles_;
|
||||
|
||||
blitz::Array<double, 4> density_per_m3_;
|
||||
blitz::Array<double, 3> bin_volume_m3_;
|
||||
|
||||
+7
-7
@@ -108,13 +108,13 @@ void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string
|
||||
field->restartTimeInBin(time_in_bin);
|
||||
}
|
||||
|
||||
// restart deleted particles
|
||||
{
|
||||
std::string path_to_data = path + "/DeletedParticles";
|
||||
DEBUG_LEVEL_3(path_to_data);
|
||||
blitz::Array<long int, 5> deleted_particles = reader_.readD5LongInt(path_to_data);
|
||||
field->restartDeletedParticlesArray(deleted_particles);
|
||||
}
|
||||
// // restart deleted particles
|
||||
// {
|
||||
// std::string path_to_data = path + "/DeletedParticles";
|
||||
// DEBUG_LEVEL_3(path_to_data);
|
||||
// blitz::Array<long int, 5> deleted_particles = reader_.readD5LongInt(path_to_data);
|
||||
// field->restartDeletedParticlesArray(deleted_particles);
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
||||
writeDensity(density_field, path);
|
||||
DEBUG_LEVEL_3("Write time in bin.");
|
||||
writeTimeInBin(density_field, path);
|
||||
DEBUG_LEVEL_3("Write deleted particles.");
|
||||
writeDeletedParticles(density_field, path);
|
||||
// DEBUG_LEVEL_3("Write deleted particles.");
|
||||
// writeDeletedParticles(density_field, path);
|
||||
DEBUG_LEVEL_3("Write physical time.");
|
||||
writePhysicalTime(density_field, path);
|
||||
}
|
||||
@@ -262,11 +262,11 @@ void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
||||
writer.write(density_field->timeInBinArray(), path + "/TimeInBin");
|
||||
}
|
||||
|
||||
void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
||||
std::string path) {
|
||||
writer.write(density_field->deletedParticlesArray(),
|
||||
path + "/DeletedParticles");
|
||||
}
|
||||
// void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
||||
// std::string path) {
|
||||
// writer.write(density_field->deletedParticlesArray(),
|
||||
// path + "/DeletedParticles");
|
||||
// }
|
||||
|
||||
void SimulationOutput::writePhysicalTime(DynamicDensityField* density_field,
|
||||
std::string path) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -91,11 +91,11 @@ void CpuSynchronizer::synchronize(DynamicDensityField* field,
|
||||
sumToAll(field->time_in_bin_s_, field->sync_time_in_bin_s_);
|
||||
field->time_in_bin_s_ = field->sync_time_in_bin_s_;
|
||||
|
||||
sumToAll(field->deleted_particles_, field->sync_deleted_particles_);
|
||||
field->deleted_particles_ = field->sync_deleted_particles_;
|
||||
// sumToAll(field->deleted_particles_, field->sync_deleted_particles_);
|
||||
// field->deleted_particles_ = field->sync_deleted_particles_;
|
||||
if (reset) {
|
||||
density_for_drawing->time_in_bin_s_ = field->time_in_bin_s_;
|
||||
density_for_drawing->deleted_particles_ = field->deleted_particles_;
|
||||
// density_for_drawing->deleted_particles_ = field->deleted_particles_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,28 +83,28 @@ DynamicDensityField::DynamicDensityField(
|
||||
pitch_angle_binning.binIndexMax()),
|
||||
blitz::Range(energy_binning.binIndexMin(),
|
||||
energy_binning.binIndexMax()))),
|
||||
deleted_particles_(initiate5DArray<long int>(
|
||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||
position_binning.radial_binning.binIndexMax()),
|
||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||
position_binning.azimuth_binning.binIndexMax()),
|
||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||
position_binning.longitudinal_binning.binIndexMax()),
|
||||
blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||
pitch_angle_binning.binIndexMax()),
|
||||
blitz::Range(energy_binning.binIndexMin(),
|
||||
energy_binning.binIndexMax()))),
|
||||
sync_deleted_particles_(initiate5DArray<long int>(
|
||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||
position_binning.radial_binning.binIndexMax()),
|
||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||
position_binning.azimuth_binning.binIndexMax()),
|
||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||
position_binning.longitudinal_binning.binIndexMax()),
|
||||
blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||
pitch_angle_binning.binIndexMax()),
|
||||
blitz::Range(energy_binning.binIndexMin(),
|
||||
energy_binning.binIndexMax()))),
|
||||
// deleted_particles_(initiate5DArray<long int>(
|
||||
// blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||
// position_binning.radial_binning.binIndexMax()),
|
||||
// blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||
// position_binning.azimuth_binning.binIndexMax()),
|
||||
// blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||
// position_binning.longitudinal_binning.binIndexMax()),
|
||||
// blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||
// pitch_angle_binning.binIndexMax()),
|
||||
// blitz::Range(energy_binning.binIndexMin(),
|
||||
// energy_binning.binIndexMax()))),
|
||||
// sync_deleted_particles_(initiate5DArray<long int>(
|
||||
// blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||
// position_binning.radial_binning.binIndexMax()),
|
||||
// blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||
// position_binning.azimuth_binning.binIndexMax()),
|
||||
// blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||
// position_binning.longitudinal_binning.binIndexMax()),
|
||||
// blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||
// pitch_angle_binning.binIndexMax()),
|
||||
// blitz::Range(energy_binning.binIndexMin(),
|
||||
// energy_binning.binIndexMax()))),
|
||||
density_per_m3_(initiate4DArray<double>(
|
||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||
position_binning.radial_binning.binIndexMax()),
|
||||
@@ -135,11 +135,11 @@ double DynamicDensityField::density(const Coordinate& position) {
|
||||
const double time_in_bin = blitz::sum(time_in_bin_s_(
|
||||
position_bin(0), position_bin(1), position_bin(2),
|
||||
blitz::Range::all(), blitz::Range::all()));
|
||||
const long int deleted_particles = blitz::sum(deleted_particles_(
|
||||
position_bin(0), position_bin(1), position_bin(2),
|
||||
blitz::Range::all(), blitz::Range::all()));
|
||||
// const long int deleted_particles = blitz::sum(deleted_particles_(
|
||||
// position_bin(0), position_bin(1), position_bin(2),
|
||||
// blitz::Range::all(), blitz::Range::all()));
|
||||
|
||||
return (time_in_bin - deleted_particles) /
|
||||
return (time_in_bin) / //- deleted_particles) /
|
||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
||||
}
|
||||
|
||||
@@ -153,11 +153,11 @@ double DynamicDensityField::density(const Coordinate& position,
|
||||
const double time_in_bin = blitz::sum(time_in_bin_s_(
|
||||
position_bin(0), position_bin(1), position_bin(2),
|
||||
blitz::Range::all(), energy_bin));
|
||||
const long deleted_particles = blitz::sum(deleted_particles_(
|
||||
position_bin(0), position_bin(1), position_bin(2),
|
||||
blitz::Range::all(), energy_bin));
|
||||
// const long deleted_particles = blitz::sum(deleted_particles_(
|
||||
// position_bin(0), position_bin(1), position_bin(2),
|
||||
// blitz::Range::all(), energy_bin));
|
||||
|
||||
return (time_in_bin - deleted_particles) /
|
||||
return (time_in_bin) / // - deleted_particles) /
|
||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
||||
}
|
||||
|
||||
@@ -210,19 +210,19 @@ void DynamicDensityField::logMovement(const Coordinate& position,
|
||||
pitch_angle_bin, energy_bin) += weight;
|
||||
}
|
||||
|
||||
void DynamicDensityField::logDeletion(const Coordinate& position,
|
||||
double energy_eV,
|
||||
double pitch_angle) {
|
||||
// void DynamicDensityField::logDeletion(const Coordinate& position,
|
||||
// double energy_eV,
|
||||
// double pitch_angle) {
|
||||
|
||||
const blitz::TinyVector<int, 3> position_bin =
|
||||
position_binning_.bin(position.cylinderEntries());
|
||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
||||
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
||||
// const blitz::TinyVector<int, 3> position_bin =
|
||||
// position_binning_.bin(position.cylinderEntries());
|
||||
// const int energy_bin = energy_binning_.bin(energy_eV);
|
||||
// const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
||||
|
||||
deleted_particles_(position_bin(0), position_bin(1), position_bin(2), pitch_angle_bin,
|
||||
energy_bin) += 1;
|
||||
return;
|
||||
}
|
||||
// deleted_particles_(position_bin(0), position_bin(1), position_bin(2), pitch_angle_bin,
|
||||
// energy_bin) += 1;
|
||||
// return;
|
||||
// }
|
||||
|
||||
blitz::Array<double, 3> DynamicDensityField::densityArray() {
|
||||
DEBUG_LEVEL_3("recalc Density array");
|
||||
@@ -251,9 +251,9 @@ blitz::Array<double, 5> DynamicDensityField::timeInBinArray() const {
|
||||
return time_in_bin_s_;
|
||||
}
|
||||
|
||||
blitz::Array<long int, 5> DynamicDensityField::deletedParticlesArray() const {
|
||||
return deleted_particles_;
|
||||
}
|
||||
// blitz::Array<long int, 5> DynamicDensityField::deletedParticlesArray() const {
|
||||
// return deleted_particles_;
|
||||
// }
|
||||
|
||||
blitz::Array<double, 3> DynamicDensityField::binVolumeArray() const {
|
||||
return bin_volume_m3_;
|
||||
@@ -294,9 +294,9 @@ void DynamicDensityField::recalculateDensityArray() {
|
||||
// the reduction over iE (which now contains the pitch dimension)
|
||||
// blitz::Array<double, 5> temp((time_in_bin_s_(ir, iphi, iz, ipitch, iE)));
|
||||
|
||||
density_per_m3_ = blitz::sum((time_in_bin_s_(ir, iphi, iz, iE, ipitch) -
|
||||
deleted_particles_(ir, iphi, iz, iE, ipitch)), iE) /
|
||||
density_per_m3_ = blitz::sum((time_in_bin_s_(ir, iphi, iz, iE, ipitch)), iE) /
|
||||
bin_volume_m3_(ir, iphi, iz);
|
||||
//deleted_particles_(ir, iphi, iz, iE, ipitch)), iE) /
|
||||
// SimulationTimer::eventStopPoint("recalcDensityArray");
|
||||
}
|
||||
|
||||
@@ -335,10 +335,10 @@ blitz::Array<double, 1> DynamicDensityField::
|
||||
void DynamicDensityField::resetDynamicDensityField() {
|
||||
//timer_->resetTime(); // time stays global
|
||||
time_in_bin_s_ = 0.;
|
||||
deleted_particles_ = 0.;
|
||||
// deleted_particles_ = 0.;
|
||||
density_per_m3_ = 0.;
|
||||
sync_time_in_bin_s_ = 0.;
|
||||
sync_deleted_particles_ = 0.;
|
||||
// sync_deleted_particles_ = 0.;
|
||||
}
|
||||
|
||||
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
||||
@@ -363,17 +363,17 @@ void DynamicDensityField::restartTimeInBin(blitz::Array<double, 5> time_in_bin)
|
||||
time_in_bin_s_ = time_in_bin.copy().reindex(time_in_bin_s_.lbound());
|
||||
}
|
||||
|
||||
void DynamicDensityField::restartDeletedParticlesArray(
|
||||
blitz::Array<long int, 5> deleted_particles) {
|
||||
if(!blitz::all(deleted_particles_.length() == deleted_particles.length())) {
|
||||
std::stringstream out;
|
||||
out << "Expected a size of " << deleted_particles_.length();
|
||||
out << ", received a length of " << deleted_particles.length();
|
||||
out << " for deleted_particles array";
|
||||
ERROR(out.str());
|
||||
}
|
||||
deleted_particles_ = deleted_particles.copy().reindex(deleted_particles_.lbound());
|
||||
}
|
||||
// void DynamicDensityField::restartDeletedParticlesArray(
|
||||
// blitz::Array<long int, 5> deleted_particles) {
|
||||
// if(!blitz::all(deleted_particles_.length() == deleted_particles.length())) {
|
||||
// std::stringstream out;
|
||||
// out << "Expected a size of " << deleted_particles_.length();
|
||||
// out << ", received a length of " << deleted_particles.length();
|
||||
// out << " for deleted_particles array";
|
||||
// ERROR(out.str());
|
||||
// }
|
||||
// deleted_particles_ = deleted_particles.copy().reindex(deleted_particles_.lbound());
|
||||
// }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -92,11 +92,7 @@ void Injector::drawNewParticleFromDensityField(std::mt19937* engine,
|
||||
const double injection_time) {
|
||||
blitz::TinyVector<int, 5> index = specie->randomIndex()->index();
|
||||
|
||||
std::stringstream out;
|
||||
out << "drawn index: " << index;
|
||||
// DEBUG_LEVEL_1(out.str());
|
||||
const double num_part_in_bin = specie->densityForDrawing()->particleNumber(index);
|
||||
out << "\nnumber of particles (" << specie->name() << ") at index: " << num_part_in_bin;
|
||||
|
||||
if(num_part_in_bin == 0) {
|
||||
return;
|
||||
@@ -107,8 +103,6 @@ void Injector::drawNewParticleFromDensityField(std::mt19937* engine,
|
||||
specie->positionDistributionFromDensity()->drawPosition(engine,
|
||||
index(0), index(1), index(2));
|
||||
|
||||
out << "\ndrawn position: " << position.cylinderEntries();
|
||||
|
||||
DEBUG_LEVEL_3("Injected z position: " +
|
||||
std::to_string(position.cylinderEntries()(2)));
|
||||
DEBUG_LEVEL_3("Injected r position: " +
|
||||
@@ -128,8 +122,14 @@ void Injector::drawNewParticleFromDensityField(std::mt19937* engine,
|
||||
drawVelocity(index, engine, position, magnetic_field);
|
||||
}
|
||||
|
||||
#ifdef debug_level2
|
||||
std::stringstream out;
|
||||
out << "drawn index: " << index;
|
||||
out << "\nnumber of particles (" << specie->name() << ") at index: " << num_part_in_bin;
|
||||
out << "\ndrawn position: " << position.cylinderEntries();
|
||||
out << "\ndrawn velocity: " << velocity.cartesianEntries();
|
||||
DEBUG_LEVEL_2(out.str());
|
||||
#endif
|
||||
|
||||
particle::Particle drawn_particle(specie, position,
|
||||
velocity, injection_time, weight_factor*num_part_in_bin);
|
||||
|
||||
@@ -122,7 +122,8 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
|
||||
|
||||
const double time = distance_target_fixed / relative_velocity;
|
||||
// out << "\ntime before collision: " << time;
|
||||
// DEBUG_LEVEL_3(out.str());
|
||||
// if(density != 0)
|
||||
// DEBUG_LEVEL_1(out.str());
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
@@ -531,6 +531,11 @@ double Simulation::collisionTime(particle::Particle& particle, RandomNumbers* ra
|
||||
collision_times.push_back(tmp);
|
||||
}
|
||||
|
||||
auto min_iterator = std::min_element(collision_times.begin(), collision_times.end());
|
||||
|
||||
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
||||
|
||||
#ifdef debug_level3
|
||||
std::stringstream out;
|
||||
out << "collision times:\n[ ";
|
||||
|
||||
@@ -538,15 +543,11 @@ double Simulation::collisionTime(particle::Particle& particle, RandomNumbers* ra
|
||||
out << element << " ";
|
||||
}
|
||||
out << "]";
|
||||
|
||||
auto min_iterator = std::min_element(collision_times.begin(), collision_times.end());
|
||||
|
||||
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
||||
|
||||
out << "\nmin value: " << *min_iterator;
|
||||
out << "\nindexNextInteraction: " << particle.indexNextInteraction();
|
||||
|
||||
DEBUG_LEVEL_3(out.str());
|
||||
#endif
|
||||
|
||||
return *min_iterator;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,9 @@ CartesianVector VelocityDistributionFromDensityField::drawVelocity(
|
||||
|
||||
ERROR(out.str());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef debug_level2
|
||||
std::stringstream out;
|
||||
out << "left Pitchangle value: "<< pitchAngleBinBorders_[index(3)];
|
||||
out << "\nright Pitchangle value: " << pitchAngleBinBorders_[index(3)+1];
|
||||
|
||||
Reference in New Issue
Block a user