Removed possibility of Nphi > 1
This commit is contained in:
Binary file not shown.
@@ -10,8 +10,8 @@
|
|||||||
namespace generator {
|
namespace generator {
|
||||||
std::shared_ptr<VectorField> buildVectorField(json_t* object);
|
std::shared_ptr<VectorField> buildVectorField(json_t* object);
|
||||||
std::string readAbsoluteFilename(json_t* object);
|
std::string readAbsoluteFilename(json_t* object);
|
||||||
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component);
|
blitz::Array<double, 2> readComponentFromFile(json_t* object, int component);
|
||||||
blitz::Array<double, 3> readFromFile(json_t* object);
|
blitz::Array<double, 2> readFromFile(json_t* object);
|
||||||
} // namespace generator
|
} // namespace generator
|
||||||
|
|
||||||
#endif /* VECTOR_FIELD_GENERATOR_H */
|
#endif /* VECTOR_FIELD_GENERATOR_H */
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class RearWall : public Electrode {
|
|||||||
bool isOnElectrode(const Coordinate& position);
|
bool isOnElectrode(const Coordinate& position);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// for (r,z) axially density
|
||||||
class PoissonSolver {
|
class PoissonSolver {
|
||||||
public:
|
public:
|
||||||
PoissonSolver(GlobalBoundary bottom_boundary,
|
PoissonSolver(GlobalBoundary bottom_boundary,
|
||||||
@@ -57,12 +58,12 @@ class PoissonSolver {
|
|||||||
int num_cycles,
|
int num_cycles,
|
||||||
bool do_solver);
|
bool do_solver);
|
||||||
|
|
||||||
void solvePotential(const blitz::Array<double, 3> charge_density);
|
void solvePotential(const blitz::Array<double, 2> charge_density);
|
||||||
blitz::Array<double, 3> potential();
|
blitz::Array<double, 2> potential();
|
||||||
std::shared_ptr<VectorField> staticElectricField();
|
std::shared_ptr<VectorField> staticElectricField();
|
||||||
const CylinderBinning* densityBinning();
|
const CylinderBinning* densityBinning();
|
||||||
|
|
||||||
void setPotential(blitz::Array<double, 3>& potential);
|
void setPotential(blitz::Array<double, 2>& potential);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalBoundary bottom_boundary_;
|
GlobalBoundary bottom_boundary_;
|
||||||
@@ -78,13 +79,13 @@ class PoissonSolver {
|
|||||||
// density binning defined on the cell centers, potential defined
|
// density binning defined on the cell centers, potential defined
|
||||||
// such that it exists on the cell edges so that the azimuthal
|
// such that it exists on the cell edges so that the azimuthal
|
||||||
// position is the same as the one of the density binning
|
// position is the same as the one of the density binning
|
||||||
blitz::Array<PotentialGridPoint, 3> potential_; //unit V
|
blitz::Array<PotentialGridPoint, 2> potential_; //unit V
|
||||||
|
|
||||||
blitz::Array<double, 3> interpolateDensityToPotentialGrid(
|
blitz::Array<double, 2> interpolateDensityToPotentialGrid(
|
||||||
const blitz::Array<double, 3> charge_density);
|
const blitz::Array<double, 2> charge_density);
|
||||||
|
|
||||||
void solverIteration(const blitz::Array<double, 3>& interpolated_density);
|
void solverIteration(const blitz::Array<double, 2>& interpolated_density);
|
||||||
bool converged(const blitz::Array<double, 3>& interpolated_density);
|
bool converged(const blitz::Array<double, 2>& interpolated_density);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Electrodes can only be dirichlet boundary conditions
|
// Electrodes can only be dirichlet boundary conditions
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class CpuSynchronizer {
|
|||||||
/*
|
/*
|
||||||
sums delta = * - last_sync_* to last_sync_* over all CPUs
|
sums delta = * - last_sync_* to last_sync_* over all CPUs
|
||||||
*/
|
*/
|
||||||
void sumToAll(blitz::Array<double, 4>& array,
|
|
||||||
blitz::Array<double, 4>& last_sync_array);
|
|
||||||
void sumToAll(blitz::Array<double, 3>& array,
|
void sumToAll(blitz::Array<double, 3>& array,
|
||||||
blitz::Array<double, 3>& last_sync_array);
|
blitz::Array<double, 3>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<long int, 4>& array,
|
void sumToAll(blitz::Array<long int, 4>& array,
|
||||||
@@ -45,9 +43,11 @@ class CpuSynchronizer {
|
|||||||
|
|
||||||
// array has to be the delta of the timestep
|
// array has to be the delta of the timestep
|
||||||
void sumToAll(blitz::Array<double, 5>& array);
|
void sumToAll(blitz::Array<double, 5>& array);
|
||||||
|
void sumToAll(blitz::Array<double, 4>& array);
|
||||||
|
|
||||||
// collect data to rank 0 functions
|
// collect data to rank 0 functions
|
||||||
void sumToRoot(blitz::Array<double, 3>& array);
|
void sumToRoot(blitz::Array<double, 3>& array);
|
||||||
|
void sumToRoot(blitz::Array<double, 2>& array);
|
||||||
void sumToRoot(long int& value);
|
void sumToRoot(long int& value);
|
||||||
void sumToRoot(double& value);
|
void sumToRoot(double& value);
|
||||||
|
|
||||||
|
|||||||
@@ -14,20 +14,20 @@ class CurrentCollector {
|
|||||||
|
|
||||||
void collect(particle::Particle* particle, const Coordinate& old_position);
|
void collect(particle::Particle* particle, const Coordinate& old_position);
|
||||||
|
|
||||||
blitz::Array<double, 3> negativeCrossingsInR() const;
|
blitz::Array<double, 2> negativeCrossingsInR() const;
|
||||||
blitz::Array<double, 3> positiveCrossingsInR() const;
|
blitz::Array<double, 2> positiveCrossingsInR() const;
|
||||||
blitz::Array<double, 3> areaInR() const;
|
blitz::Array<double, 2> areaInR() const;
|
||||||
blitz::Array<double, 3> currentInR() const;
|
blitz::Array<double, 2> currentInR() const;
|
||||||
|
|
||||||
blitz::Array<double, 3> negativeCrossingsInPhi() const;
|
blitz::Array<double, 2> negativeCrossingsInPhi() const;
|
||||||
blitz::Array<double, 3> positiveCrossingsInPhi() const;
|
blitz::Array<double, 2> positiveCrossingsInPhi() const;
|
||||||
blitz::Array<double, 3> areaInPhi() const;
|
blitz::Array<double, 2> areaInPhi() const;
|
||||||
blitz::Array<double, 3> currentInPhi() const;
|
blitz::Array<double, 2> currentInPhi() const;
|
||||||
|
|
||||||
blitz::Array<double, 3> negativeCrossingsInZ() const;
|
blitz::Array<double, 2> negativeCrossingsInZ() const;
|
||||||
blitz::Array<double, 3> positiveCrossingsInZ() const;
|
blitz::Array<double, 2> positiveCrossingsInZ() const;
|
||||||
blitz::Array<double, 3> areaInZ() const;
|
blitz::Array<double, 2> areaInZ() const;
|
||||||
blitz::Array<double, 3> currentInZ() const;
|
blitz::Array<double, 2> currentInZ() const;
|
||||||
|
|
||||||
double physicalTime() const;
|
double physicalTime() const;
|
||||||
|
|
||||||
@@ -36,39 +36,39 @@ class CurrentCollector {
|
|||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void collectRadialMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectRadialMovement(const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight);
|
const double weight);
|
||||||
void collectLongitudinalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectLongitudinalMovement(const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight);
|
const double weight);
|
||||||
void collectAzimuthalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectAzimuthalMovement(const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight);
|
const double weight);
|
||||||
|
|
||||||
blitz::Array<double, 3> createAreaLongitudinal(
|
blitz::Array<double, 2> createAreaLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 3> createCrossingsLongitudinal(
|
blitz::Array<double, 2> createCrossingsLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 3> createAreaRadial(
|
blitz::Array<double, 2> createAreaRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 3> createCrossingsRadial(
|
blitz::Array<double, 2> createCrossingsRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 3> createAreaAzimuthal(
|
blitz::Array<double, 2> createAreaAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 3> createCrossingsAzimuthal(
|
blitz::Array<double, 2> createCrossingsAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 3> z_negative_crossings;
|
blitz::Array<double, 2> z_negative_crossings;
|
||||||
blitz::Array<double, 3> z_positive_crossings;
|
blitz::Array<double, 2> z_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 3> phi_negative_crossings;
|
blitz::Array<double, 2> phi_negative_crossings;
|
||||||
blitz::Array<double, 3> phi_positive_crossings;
|
blitz::Array<double, 2> phi_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 3> r_negative_crossings;
|
blitz::Array<double, 2> r_negative_crossings;
|
||||||
blitz::Array<double, 3> r_positive_crossings;
|
blitz::Array<double, 2> r_positive_crossings;
|
||||||
|
|
||||||
// blitz::Array<double, 3> sync_z_negative_crossings;
|
// blitz::Array<double, 3> sync_z_negative_crossings;
|
||||||
// blitz::Array<double, 3> sync_z_positive_crossings;
|
// blitz::Array<double, 3> sync_z_positive_crossings;
|
||||||
@@ -79,9 +79,9 @@ class CurrentCollector {
|
|||||||
// blitz::Array<double, 3> sync_r_negative_crossings;
|
// blitz::Array<double, 3> sync_r_negative_crossings;
|
||||||
// blitz::Array<double, 3> sync_r_positive_crossings;
|
// blitz::Array<double, 3> sync_r_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 3> collector_areas_r;
|
blitz::Array<double, 2> collector_areas_r;
|
||||||
blitz::Array<double, 3> collector_areas_phi;
|
blitz::Array<double, 2> collector_areas_phi;
|
||||||
blitz::Array<double, 3> collector_areas_z;
|
blitz::Array<double, 2> collector_areas_z;
|
||||||
|
|
||||||
CylinderBinning position_binning_;
|
CylinderBinning position_binning_;
|
||||||
std::shared_ptr<Timer> timer_;
|
std::shared_ptr<Timer> timer_;
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ class DynamicDensityField : public DensityField {
|
|||||||
// of the pitch angle binning
|
// of the pitch angle binning
|
||||||
bool changedPitchAngleBin(double old_pitch_angle, double new_pitch_angle) const;
|
bool changedPitchAngleBin(double old_pitch_angle, double new_pitch_angle) const;
|
||||||
|
|
||||||
blitz::Array<double, 3> densityArray();
|
blitz::Array<double, 2> densityArray();
|
||||||
blitz::Array<double, 4> spectrumArray();
|
blitz::Array<double, 3> spectrumArray();
|
||||||
blitz::Array<double, 5> timeInBinArray() const;
|
blitz::Array<double, 4> numberInBinArray() const;
|
||||||
blitz::Array<double, 3> binVolumeArray() const;
|
blitz::Array<double, 2> binVolumeArray() const;
|
||||||
|
|
||||||
// return an array of the density values at the Coordinate position (only energy
|
// return an array of the density values at the Coordinate position (only energy
|
||||||
// direction left); over and underflow bin are removed
|
// direction left); over and underflow bin are removed
|
||||||
@@ -58,7 +58,7 @@ class DynamicDensityField : public DensityField {
|
|||||||
|
|
||||||
// return an array of the time in bin at the Coordinate position and the energy
|
// return an array of the time in bin at the Coordinate position and the energy
|
||||||
// energy_eV (only pitch angle direction left); over and underflow bin are removed
|
// energy_eV (only pitch angle direction left); over and underflow bin are removed
|
||||||
blitz::Array<double, 1> sliceTimeInBinArray(const Coordinate& position,
|
blitz::Array<double, 1> sliceNumberInBinArray(const Coordinate& position,
|
||||||
double energy_eV) const;
|
double energy_eV) const;
|
||||||
|
|
||||||
const EnergyBinning* energyBinning() const;
|
const EnergyBinning* energyBinning() const;
|
||||||
@@ -73,21 +73,19 @@ class DynamicDensityField : public DensityField {
|
|||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
void restartTimer(double time, double delta_t);
|
void restartTimer(double time, double delta_t);
|
||||||
void restartTimeInBin(blitz::Array<double, 5> time_in_bin);
|
void restartNumberInBin(blitz::Array<double, 4> number_in_bin);
|
||||||
|
|
||||||
void recalculateDensityArray();
|
void recalculateDensityArray();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// use ordering r, phi, z, pitch_angle, E
|
// use ordering r, z, pitch_angle, E.
|
||||||
// time in bin now contains the physical particle number per bin
|
// Full symmetry in azimuthal direction -> no phi resolution
|
||||||
// (not renamed, since that would require many, many changes due to
|
blitz::Array<double, 4> number_in_bin_;
|
||||||
// renaming of the functions)
|
blitz::Array<double, 4> sync_number_in_bin_;
|
||||||
blitz::Array<double, 5> time_in_bin_s_;
|
|
||||||
blitz::Array<double, 5> sync_time_in_bin_s_;
|
|
||||||
|
|
||||||
blitz::Array<double, 4> density_per_m3_;
|
blitz::Array<double, 3> density_per_m3_;
|
||||||
blitz::Array<double, 3> bin_volume_m3_;
|
blitz::Array<double, 2> bin_volume_m3_;
|
||||||
|
|
||||||
const CylinderBinning position_binning_;
|
const CylinderBinning position_binning_;
|
||||||
const EnergyBinning energy_binning_;
|
const EnergyBinning energy_binning_;
|
||||||
|
|||||||
@@ -60,21 +60,19 @@ class CylinderBinning {
|
|||||||
public:
|
public:
|
||||||
CylinderBinning(int num_bins_radial,
|
CylinderBinning(int num_bins_radial,
|
||||||
double radius,
|
double radius,
|
||||||
int num_bins_azimuthal,
|
|
||||||
int num_bins_longitudinal,
|
int num_bins_longitudinal,
|
||||||
double height);
|
double height);
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> bin(
|
blitz::TinyVector<int, 2> bin(
|
||||||
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
||||||
blitz::TinyVector<double, 3> stepsize() const;
|
blitz::TinyVector<double, 2> stepsize() const;
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> numBins() const;
|
blitz::TinyVector<int, 2> numBins() const;
|
||||||
blitz::TinyVector<int, 3> numBinsIncludingOverUnderflow() const;
|
blitz::TinyVector<int, 2> numBinsIncludingOverUnderflow() const;
|
||||||
blitz::TinyVector<int, 3> binIndexMin() const;
|
blitz::TinyVector<int, 2> binIndexMin() const;
|
||||||
blitz::TinyVector<int, 3> binIndexMax() const;
|
blitz::TinyVector<int, 2> binIndexMax() const;
|
||||||
|
|
||||||
const LowerBoundBinningWithOverflow radial_binning;
|
const LowerBoundBinningWithOverflow radial_binning;
|
||||||
const LowerAndUpperBoundBinning azimuth_binning;
|
|
||||||
const BinningWithOverAndUnderflow longitudinal_binning;
|
const BinningWithOverAndUnderflow longitudinal_binning;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class Simulation {
|
|||||||
RandomNumbers* random,
|
RandomNumbers* random,
|
||||||
std::vector<double>& macroscopic_cross_sections_m);
|
std::vector<double>& macroscopic_cross_sections_m);
|
||||||
|
|
||||||
blitz::Array<double,3> chargedensity();
|
blitz::Array<double,2> chargedensity();
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
||||||
tracked_species_;
|
tracked_species_;
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class VectorField {
|
|||||||
|
|
||||||
class VectorFieldFromArray : public VectorField {
|
class VectorFieldFromArray : public VectorField {
|
||||||
public:
|
public:
|
||||||
VectorFieldFromArray(const blitz::Array<double, 3>& radial_component,
|
VectorFieldFromArray(const blitz::Array<double, 2>& radial_component,
|
||||||
const blitz::Array<double, 3>& azimuthal_component,
|
const blitz::Array<double, 2>& azimuthal_component,
|
||||||
const blitz::Array<double, 3>& longitudial_component,
|
const blitz::Array<double, 2>& longitudial_component,
|
||||||
double radius,
|
double radius,
|
||||||
double length);
|
double length);
|
||||||
|
|
||||||
@@ -24,12 +24,12 @@ class VectorFieldFromArray : public VectorField {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// todo: make sure we use fast axis on z to reduce access time
|
// todo: make sure we use fast axis on z to reduce access time
|
||||||
const blitz::Array<double, 3> Fr_;
|
const blitz::Array<double, 2> Fr_;
|
||||||
const blitz::Array<double, 3> Fphi_;
|
const blitz::Array<double, 2> Fphi_;
|
||||||
const blitz::Array<double, 3> Fz_;
|
const blitz::Array<double, 2> Fz_;
|
||||||
|
|
||||||
CylinderBinning binning_;
|
CylinderBinning binning_;
|
||||||
CylinderVector value(const blitz::TinyVector<int, 3>& bin) const;
|
CylinderVector value(const blitz::TinyVector<int, 2>& bin) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VectorFieldConstant : public VectorField {
|
class VectorFieldConstant : public VectorField {
|
||||||
|
|||||||
+3
-3
@@ -139,8 +139,8 @@ void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string
|
|||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3(path_to_data);
|
DEBUG_LEVEL_3(path_to_data);
|
||||||
#endif
|
#endif
|
||||||
blitz::Array<double, 5> time_in_bin = reader_.readD5Double(path_to_data);
|
blitz::Array<double, 4> number_in_bin = reader_.readD4Double(path_to_data);
|
||||||
field->restartTimeInBin(time_in_bin);
|
field->restartNumberInBin(number_in_bin);
|
||||||
field->recalculateDensityArray();
|
field->recalculateDensityArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ void Restart::restartPoissonSolver(PoissonSolver* solver) {
|
|||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3(path);
|
DEBUG_LEVEL_3(path);
|
||||||
#endif
|
#endif
|
||||||
blitz::Array<double, 3> potential = reader_.readD3Double(path);
|
blitz::Array<double, 2> potential = reader_.readD2Double(path);
|
||||||
solver->setPotential(potential);
|
solver->setPotential(potential);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ void SimulationOutput::writeDensity(DynamicDensityField* density_field,
|
|||||||
|
|
||||||
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->timeInBinArray(), path + "/TimeInBin");
|
writer.write(density_field->numberInBinArray(), path + "/TimeInBin");
|
||||||
}
|
}
|
||||||
|
|
||||||
// void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
// void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
||||||
@@ -385,10 +385,6 @@ void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
|||||||
density_field->positionBinning()->radial_binning.binBorders();
|
density_field->positionBinning()->radial_binning.binBorders();
|
||||||
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
||||||
|
|
||||||
std::vector<double> azimuth_bin_borders =
|
|
||||||
density_field->positionBinning()->azimuth_binning.binBorders();
|
|
||||||
writer.write(azimuth_bin_borders, path_to_bin_borders + "/azimuth");
|
|
||||||
|
|
||||||
std::vector<double> longitudinal_bin_borders =
|
std::vector<double> longitudinal_bin_borders =
|
||||||
density_field->positionBinning()->longitudinal_binning.binBorders();
|
density_field->positionBinning()->longitudinal_binning.binBorders();
|
||||||
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
||||||
@@ -397,12 +393,11 @@ void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
|||||||
// write num bins
|
// write num bins
|
||||||
{
|
{
|
||||||
std::string path_to_num_bins = path_to_field + "/NumBins";
|
std::string path_to_num_bins = path_to_field + "/NumBins";
|
||||||
blitz::TinyVector<int, 4> num_bins = density_field->spectrumArray().extent();
|
blitz::TinyVector<int, 3> num_bins = density_field->spectrumArray().extent();
|
||||||
|
|
||||||
writer.write(num_bins(0), path_to_num_bins + "/energy");
|
writer.write(num_bins(0), path_to_num_bins + "/radial");
|
||||||
writer.write(num_bins(1), path_to_num_bins + "/radial");
|
writer.write(num_bins(1), path_to_num_bins + "/longitudinal");
|
||||||
writer.write(num_bins(2), path_to_num_bins + "/azimuthal");
|
writer.write(num_bins(2), path_to_num_bins + "/energy");
|
||||||
writer.write(num_bins(3), path_to_num_bins + "/longitudinal");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,10 +418,6 @@ void SimulationOutput::writeMetaData(PoissonSolver* poisson_solver,
|
|||||||
poisson_solver->densityBinning()->radial_binning.binBorders();
|
poisson_solver->densityBinning()->radial_binning.binBorders();
|
||||||
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
||||||
|
|
||||||
std::vector<double> azimuth_bin_borders =
|
|
||||||
poisson_solver->densityBinning()->azimuth_binning.binBorders();
|
|
||||||
writer.write(azimuth_bin_borders, path_to_bin_borders + "/azimuth");
|
|
||||||
|
|
||||||
std::vector<double> longitudinal_bin_borders =
|
std::vector<double> longitudinal_bin_borders =
|
||||||
poisson_solver->densityBinning()->longitudinal_binning.binBorders();
|
poisson_solver->densityBinning()->longitudinal_binning.binBorders();
|
||||||
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
||||||
@@ -448,12 +439,11 @@ void SimulationOutput::writeBinVolumes(DynamicDensityField* density_field,
|
|||||||
void SimulationOutput::writeNumBins(DynamicDensityField* density_field,
|
void SimulationOutput::writeNumBins(DynamicDensityField* density_field,
|
||||||
std::string path_to_field) {
|
std::string path_to_field) {
|
||||||
std::string path_to_num_bins = path_to_field + "/NumBins";
|
std::string path_to_num_bins = path_to_field + "/NumBins";
|
||||||
blitz::TinyVector<int, 4> num_bins = density_field->spectrumArray().extent();
|
blitz::TinyVector<int, 3> num_bins = density_field->spectrumArray().extent();
|
||||||
|
|
||||||
writer.write(num_bins(0), path_to_num_bins + "/energy");
|
writer.write(num_bins(0), path_to_num_bins + "/radial");
|
||||||
writer.write(num_bins(1), path_to_num_bins + "/radial");
|
writer.write(num_bins(1), path_to_num_bins + "/longitudinal");
|
||||||
writer.write(num_bins(2), path_to_num_bins + "/azimuthal");
|
writer.write(num_bins(2), path_to_num_bins + "/energy");
|
||||||
writer.write(num_bins(3), path_to_num_bins + "/longitudinal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
||||||
@@ -468,10 +458,6 @@ void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
|||||||
density_field->positionBinning()->radial_binning.binBorders();
|
density_field->positionBinning()->radial_binning.binBorders();
|
||||||
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
||||||
|
|
||||||
std::vector<double> azimuth_bin_borders =
|
|
||||||
density_field->positionBinning()->azimuth_binning.binBorders();
|
|
||||||
writer.write(azimuth_bin_borders, path_to_bin_borders + "/azimuth");
|
|
||||||
|
|
||||||
std::vector<double> longitudinal_bin_borders =
|
std::vector<double> longitudinal_bin_borders =
|
||||||
density_field->positionBinning()->longitudinal_binning.binBorders();
|
density_field->positionBinning()->longitudinal_binning.binBorders();
|
||||||
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
json_read_length(json_object_by_path(radial, {"MaxRadius"}), "m");
|
json_read_length(json_object_by_path(radial, {"MaxRadius"}), "m");
|
||||||
ASSERT_POSITIVE(&max_radius, "Radius must be positive");
|
ASSERT_POSITIVE(&max_radius, "Radius must be positive");
|
||||||
|
|
||||||
json_t* azimuthal = json_object_by_path(object, {"Azimuthal"});
|
|
||||||
int number_of_bins_azimuthal =
|
|
||||||
json_int(json_object_by_path(azimuthal, {"NumberOfBins"}));
|
|
||||||
ASSERT_POSITIVE(&number_of_bins_azimuthal,
|
|
||||||
"Number of Bins must be positive");
|
|
||||||
|
|
||||||
json_t* longitudinal = json_object_by_path(object, {"Longitudinal"});
|
json_t* longitudinal = json_object_by_path(object, {"Longitudinal"});
|
||||||
int number_of_bins_longitudinal =
|
int number_of_bins_longitudinal =
|
||||||
json_int(json_object_by_path(longitudinal, {"NumberOfBins"}));
|
json_int(json_object_by_path(longitudinal, {"NumberOfBins"}));
|
||||||
@@ -41,8 +35,6 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("with number of bins radial: " +
|
DEBUG_LEVEL_3("with number of bins radial: " +
|
||||||
std::to_string(number_of_bins_radial));
|
std::to_string(number_of_bins_radial));
|
||||||
DEBUG_LEVEL_3("with number of bins azimuthal: " +
|
|
||||||
std::to_string(number_of_bins_azimuthal));
|
|
||||||
DEBUG_LEVEL_3("with number of bins longitudinal: " +
|
DEBUG_LEVEL_3("with number of bins longitudinal: " +
|
||||||
std::to_string(number_of_bins_longitudinal));
|
std::to_string(number_of_bins_longitudinal));
|
||||||
DEBUG_LEVEL_3("with radius: " + std::to_string(max_radius) + " m");
|
DEBUG_LEVEL_3("with radius: " + std::to_string(max_radius) + " m");
|
||||||
@@ -50,11 +42,10 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return CylinderBinning(number_of_bins_radial, max_radius,
|
return CylinderBinning(number_of_bins_radial, max_radius,
|
||||||
number_of_bins_azimuthal,
|
|
||||||
number_of_bins_longitudinal, max_length);
|
number_of_bins_longitudinal, max_length);
|
||||||
} else {
|
} else {
|
||||||
ERROR("This position binning is not implemented.");
|
ERROR("This position binning is not implemented.");
|
||||||
return CylinderBinning(0, 0, 0, 0, 0);
|
return CylinderBinning(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,23 +32,23 @@ std::string readAbsoluteFilename(json_t* object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> readFromFile(json_t* object) {
|
blitz::Array<double, 2> readFromFile(json_t* object) {
|
||||||
std::string absolute_filename =
|
std::string absolute_filename =
|
||||||
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
||||||
std::string key = json_string(json_object_by_path(object, {"Key"}));
|
std::string key = json_string(json_object_by_path(object, {"Key"}));
|
||||||
|
|
||||||
Hdf5Reader reader(absolute_filename);
|
Hdf5Reader reader(absolute_filename);
|
||||||
return reader.readD3Double(key);
|
return reader.readD2Double(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component) {
|
blitz::Array<double, 2> readComponentFromFile(json_t* object, int component) {
|
||||||
std::string absolute_filename =
|
std::string absolute_filename =
|
||||||
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
||||||
std::string key = json_string(
|
std::string key = json_string(
|
||||||
json_array_get(json_object_by_path(object, {"Keys"}), component));
|
json_array_get(json_object_by_path(object, {"Keys"}), component));
|
||||||
|
|
||||||
Hdf5Reader reader(absolute_filename);
|
Hdf5Reader reader(absolute_filename);
|
||||||
return reader.readD3Double(key);
|
return reader.readD2Double(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
||||||
@@ -75,15 +75,15 @@ std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
|||||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFromArray");
|
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFromArray");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
blitz::Array<double, 3> v_radial = readComponentFromFile(
|
blitz::Array<double, 2> v_radial = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
0);
|
0);
|
||||||
blitz::Array<double, 3> v_azimuthal = readComponentFromFile(
|
blitz::Array<double, 2> v_azimuthal = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
1);
|
1);
|
||||||
blitz::Array<double, 3> v_longitudinal = readComponentFromFile(
|
blitz::Array<double, 2> v_longitudinal = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
2);
|
2);
|
||||||
|
|||||||
@@ -22,73 +22,66 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
hull_boundary_(hull_boundary),
|
hull_boundary_(hull_boundary),
|
||||||
geometry_(geometry),
|
geometry_(geometry),
|
||||||
density_binning_(density_binning),
|
density_binning_(density_binning),
|
||||||
potential_(blitz::Array<PotentialGridPoint, 3>(
|
potential_(blitz::Array<PotentialGridPoint, 2>(
|
||||||
blitz::Range(density_binning.binIndexMin()(0),
|
blitz::Range(density_binning.binIndexMin()(0),
|
||||||
density_binning.binIndexMax()(0)),
|
density_binning.binIndexMax()(0)),
|
||||||
blitz::Range(density_binning.binIndexMin()(1),
|
blitz::Range(density_binning.binIndexMin()(1) + 1,
|
||||||
density_binning.binIndexMax()(1)), // the azimuthal direction is periodic
|
density_binning.binIndexMax()(1)))),
|
||||||
blitz::Range(density_binning.binIndexMin()(2) + 1,
|
|
||||||
density_binning.binIndexMax()(2)))),
|
|
||||||
electrodes_(electrodes),
|
electrodes_(electrodes),
|
||||||
target_accuracy_(target_accuracy),
|
target_accuracy_(target_accuracy),
|
||||||
num_cycles_(num_cycles),
|
num_cycles_(num_cycles),
|
||||||
do_solver_(do_solver) {
|
do_solver_(do_solver) {
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
||||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for (int k = potential_.lbound(2); k <= potential_.ubound(2);
|
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
||||||
++k) {
|
i * stepsize(0), 0, j * stepsize(1)));
|
||||||
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
|
||||||
i * stepsize(0), j * stepsize(1), k * stepsize(2)));
|
|
||||||
|
|
||||||
switch(geometry_->isWhere(position)) {
|
switch(geometry_->isWhere(position)) {
|
||||||
case GeometryPositioning::bottom:
|
case GeometryPositioning::bottom:
|
||||||
potential_(i,j,k) = {bottom_boundary_.type, bottom_boundary_.boundary_value};
|
potential_(i,j) = {bottom_boundary_.type, bottom_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::top:
|
case GeometryPositioning::top:
|
||||||
potential_(i,j,k) = {top_boundary_.type, top_boundary_.boundary_value};
|
potential_(i,j) = {top_boundary_.type, top_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::hull:
|
case GeometryPositioning::hull:
|
||||||
potential_(i,j,k) = {hull_boundary_.type, hull_boundary_.boundary_value};
|
potential_(i,j) = {hull_boundary_.type, hull_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::inside:
|
case GeometryPositioning::inside:
|
||||||
potential_(i,j,k) = {BoundaryType::no_boundary, 0.};
|
potential_(i,j) = {BoundaryType::no_boundary, 0.};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// include position in output
|
// include position in output
|
||||||
ERROR("Something went terribly wrong. Position is nowhere.");
|
ERROR("Something went terribly wrong. Position is nowhere.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (auto& electrode : electrodes_) {
|
for (auto& electrode : electrodes_) {
|
||||||
if (electrode->isOnElectrode(position)) {
|
if (electrode->isOnElectrode(position)) {
|
||||||
potential_(i,j,k).type = BoundaryType::dirichlet;
|
potential_(i,j).type = BoundaryType::dirichlet;
|
||||||
potential_(i,j,k).value = electrode->electrodePotential();
|
potential_(i,j).value = electrode->electrodePotential();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> zero_chargedensity(
|
blitz::Array<double, 2> zero_chargedensity(
|
||||||
blitz::Range(density_binning.binIndexMin()(0),
|
blitz::Range(density_binning.binIndexMin()(0),
|
||||||
density_binning.binIndexMax()(0)),
|
density_binning.binIndexMax()(0)),
|
||||||
blitz::Range(density_binning.binIndexMin()(1),
|
blitz::Range(density_binning.binIndexMin()(1),
|
||||||
density_binning.binIndexMax()(1)),
|
density_binning.binIndexMax()(1)));
|
||||||
blitz::Range(density_binning.binIndexMin()(2),
|
|
||||||
density_binning.binIndexMax()(2)));
|
|
||||||
zero_chargedensity = 0.;
|
zero_chargedensity = 0.;
|
||||||
solvePotential(zero_chargedensity);
|
solvePotential(zero_chargedensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solvePotential(
|
void PoissonSolver::solvePotential(
|
||||||
const blitz::Array<double, 3> charge_density) {
|
const blitz::Array<double, 2> charge_density) {
|
||||||
if (!(do_solver_)) {
|
if (!(do_solver_)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
||||||
#endif
|
#endif
|
||||||
blitz::Array<double, 3> interpolated_density =
|
blitz::Array<double, 2> interpolated_density =
|
||||||
interpolateDensityToPotentialGrid(charge_density);
|
interpolateDensityToPotentialGrid(charge_density);
|
||||||
int it = 1;
|
int it = 1;
|
||||||
do {
|
do {
|
||||||
@@ -106,61 +99,45 @@ void PoissonSolver::solvePotential(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solverIteration(
|
void PoissonSolver::solverIteration(
|
||||||
const blitz::Array<double, 3>& interpolated_density) {
|
const blitz::Array<double, 2>& interpolated_density) {
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
||||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
||||||
const double dth_sq = stepsize(1)*stepsize(1); // shorthand
|
const double dz_sq = stepsize(1)*stepsize(1); // shorthand
|
||||||
const double dz_sq = stepsize(2)*stepsize(2); // shorthand
|
|
||||||
|
|
||||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for (int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
//rewrite with a switch-case
|
||||||
//rewrite with a switch-case
|
if (potential_(i, j).type == BoundaryType::dirichlet) {
|
||||||
if (potential_(i, j, k).type == BoundaryType::dirichlet) {
|
potential_(i, j).value = potential_(i, j).value;
|
||||||
potential_(i, j, k).value = potential_(i, j, k).value;
|
} else if (potential_(i, j).type == BoundaryType::neumann_to_top) {
|
||||||
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_top) {
|
potential_(i, j).value = potential_(i, j-1).value
|
||||||
potential_(i, j, k).value = potential_(i, j, k - 1).value
|
+ top_boundary_.boundary_value * stepsize(1);
|
||||||
+ top_boundary_.boundary_value * stepsize(2);
|
} else if (potential_(i, j).type == BoundaryType::neumann_to_bottom) {
|
||||||
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_bottom) {
|
potential_(i, j).value = potential_(i, j + 1).value
|
||||||
potential_(i, j, k).value = potential_(i, j, k + 1).value
|
- bottom_boundary_.boundary_value * stepsize(1);
|
||||||
- bottom_boundary_.boundary_value * stepsize(2);
|
} else if (potential_(i, j).type == BoundaryType::neumann_to_hull) {
|
||||||
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_hull) {
|
potential_(i, j).value = potential_(i - 1, j).value
|
||||||
potential_(i, j, k).value = potential_(i - 1, j, k).value
|
+ hull_boundary_.boundary_value * stepsize(0);
|
||||||
+ hull_boundary_.boundary_value * stepsize(0);
|
} else if (i == 0) {
|
||||||
} else if (i == 0) {
|
// special calculation for r=0
|
||||||
// special calculation for r=0
|
const double scaling_factor = 4 / dr_sq + 2 / dz_sq;
|
||||||
const int jmirror = (j<potential_.extent(1)/2) ? j+potential_.extent(1)/2
|
potential_(i, j).value =
|
||||||
: j-potential_.extent(1)/2;
|
(1 / scaling_factor) *
|
||||||
const double scaling_factor = 4 / dr_sq + 2 / dz_sq;
|
((4 / dr_sq) * (potential_(i + 1, j).value) +
|
||||||
potential_(i, j, k).value =
|
(1 / dz_sq) * (potential_(i, j + 1).value +
|
||||||
(1 / scaling_factor) *
|
potential_(i, j - 1).value) +
|
||||||
((2 / dr_sq) * (potential_(i + 1, j, k).value +
|
interpolated_density(i, j)/SI::eps0);
|
||||||
potential_(i + 1, jmirror, k).value) +
|
|
||||||
(1 / dz_sq) * (potential_(i, j, k + 1).value +
|
|
||||||
potential_(i, j, k - 1).value) +
|
|
||||||
interpolated_density(i, j, k)/SI::eps0);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const int jp1 = j + 1 > potential_.ubound(1)
|
const double scaling_factor = 2 / dr_sq + 2 / dz_sq;
|
||||||
? potential_.lbound(1)
|
|
||||||
: j + 1; // j+1 with periodic guard
|
|
||||||
const int jm1 = j - 1 < potential_.lbound(1)
|
|
||||||
? potential_.ubound(1)
|
|
||||||
: j - 1; // j-1 with periodic guard
|
|
||||||
|
|
||||||
const double scaling_factor = 2 / dr_sq + 2 / dz_sq +
|
potential_(i, j).value =
|
||||||
2 / (i*i * dr_sq * dth_sq);
|
(1 / scaling_factor) *
|
||||||
|
((1 / dr_sq * (1 + 1. / (2. * i))) * potential_(i + 1, j).value +
|
||||||
potential_(i, j, k).value =
|
(1 / dr_sq * (1 - 1. / (2. * i))) * potential_(i - 1, j).value +
|
||||||
(1 / scaling_factor) *
|
(1 / dz_sq) * (potential_(i, j + 1).value +
|
||||||
((1 / dr_sq * (1 + 1. / (2. * i))) * potential_(i + 1, j, k).value +
|
potential_(i, j - 1).value) +
|
||||||
(1 / dr_sq * (1 - 1. / (2. * i))) * potential_(i - 1, j, k).value +
|
interpolated_density(i, j)/SI::eps0);
|
||||||
(1 / (i*i * dr_sq * dth_sq)) *
|
|
||||||
(potential_(i, jp1, k).value + potential_(i, jm1, k).value) +
|
|
||||||
(1 / dz_sq) * (potential_(i, j, k + 1).value +
|
|
||||||
potential_(i, j, k - 1).value) +
|
|
||||||
interpolated_density(i, j, k)/SI::eps0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,11 +146,10 @@ void PoissonSolver::solverIteration(
|
|||||||
//as of now does not check for inner cells with dirichlet or neumann
|
//as of now does not check for inner cells with dirichlet or neumann
|
||||||
//boundary, probably needs to be added (or the "electrodes" removed)
|
//boundary, probably needs to be added (or the "electrodes" removed)
|
||||||
bool PoissonSolver::converged(
|
bool PoissonSolver::converged(
|
||||||
const blitz::Array<double, 3>& interpolated_density) {
|
const blitz::Array<double, 2>& interpolated_density) {
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
||||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
||||||
const double dth_sq = stepsize(1)*stepsize(1); // shorthand
|
const double dz_sq = stepsize(1)*stepsize(1); // shorthand
|
||||||
const double dz_sq = stepsize(2)*stepsize(2); // shorthand
|
|
||||||
|
|
||||||
double cumulated_quadradic_difference = 0.;
|
double cumulated_quadradic_difference = 0.;
|
||||||
double normalized_difference = 0.;
|
double normalized_difference = 0.;
|
||||||
@@ -181,64 +157,44 @@ bool PoissonSolver::converged(
|
|||||||
|
|
||||||
for (int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for (int k = potential_.lbound(2) + 1; k <= potential_.ubound(2) - 1;
|
if(potential_(i,j).type != BoundaryType::no_boundary) {
|
||||||
++k) {
|
continue;
|
||||||
if(potential_(i,j,k).type != BoundaryType::no_boundary) {
|
}
|
||||||
continue;
|
if (i == 0) {
|
||||||
|
// special calculation for r=0
|
||||||
|
const double difference = interpolated_density(i,j)/SI::eps0 +
|
||||||
|
4*(potential_(i+1,j).value - potential_(i,j).value)/dr_sq +
|
||||||
|
(potential_(i,j+1).value - 2*potential_(i,j).value +
|
||||||
|
potential_(i,j-1).value)/dz_sq;
|
||||||
|
|
||||||
|
cumulated_quadradic_difference += difference*difference;
|
||||||
|
|
||||||
|
if(fabs(difference) > maximum_difference) {
|
||||||
|
maximum_difference = fabs(difference);
|
||||||
}
|
}
|
||||||
if (i == 0) {
|
|
||||||
// special calculation for r=0
|
|
||||||
//Note: the value \phi_{i,j+Nj/2,k} as the replacement of
|
|
||||||
// \phi_{i-1,j,k} is only correct if Nj is even otherwise the mirrored point
|
|
||||||
// lies inbetween two known values; additionally not sure if this calculation
|
|
||||||
// is correct at all (would definitely be fine for cylindrical symmetric calc.)
|
|
||||||
const int jmirror = (j<potential_.extent(1)/2) ? j+potential_.extent(1)/2
|
|
||||||
: j-potential_.extent(1)/2;
|
|
||||||
const double difference = interpolated_density(i,j,k)/SI::eps0 +
|
|
||||||
2*(potential_(i+1,j,k).value - 2*potential_(i,j,k).value +
|
|
||||||
potential_(i+1,jmirror,k).value)/dr_sq +
|
|
||||||
(potential_(i,j,k+1).value - 2*potential_(i,j,k).value +
|
|
||||||
potential_(i,j,k-1).value)/dz_sq;
|
|
||||||
|
|
||||||
cumulated_quadradic_difference += difference*difference;
|
} else {
|
||||||
|
const double difference = interpolated_density(i,j)/SI::eps0 +
|
||||||
|
(potential_(i+1,j).value - 2*potential_(i,j).value +
|
||||||
|
potential_(i-1,j).value)/dr_sq +
|
||||||
|
(potential_(i+1,j).value - potential_(i-1,j).value)/
|
||||||
|
(2*i*dr_sq) +
|
||||||
|
(potential_(i,j+1).value - 2*potential_(i,j).value +
|
||||||
|
potential_(i,j-1).value)/dz_sq;
|
||||||
|
|
||||||
if(fabs(difference) > maximum_difference) {
|
cumulated_quadradic_difference += difference*difference;
|
||||||
maximum_difference = fabs(difference);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
if(fabs(difference) > maximum_difference) {
|
||||||
const int jp1 = j + 1 > potential_.ubound(1)
|
maximum_difference = fabs(difference);
|
||||||
? potential_.lbound(1)
|
|
||||||
: j + 1; // j+1 with periodic guard
|
|
||||||
const int jm1 = j - 1 < potential_.lbound(1)
|
|
||||||
? potential_.ubound(1)
|
|
||||||
: j - 1; // j-1 with periodic guard
|
|
||||||
|
|
||||||
const double difference = interpolated_density(i,j,k)/SI::eps0 +
|
|
||||||
(potential_(i+1,j,k).value - 2*potential_(i,j,k).value +
|
|
||||||
potential_(i-1,j,k).value)/dr_sq +
|
|
||||||
(potential_(i+1,j,k).value - potential_(i-1,j,k).value)/
|
|
||||||
(2*i*dr_sq) +
|
|
||||||
(potential_(i,jp1,k).value - 2*potential_(i,j,k).value +
|
|
||||||
potential_(i,jm1,k).value)/(i*i*dr_sq*dth_sq) +
|
|
||||||
(potential_(i,j,k+1).value - 2*potential_(i,j,k).value +
|
|
||||||
potential_(i,j,k-1).value)/dz_sq;
|
|
||||||
|
|
||||||
cumulated_quadradic_difference += difference*difference;
|
|
||||||
|
|
||||||
if(fabs(difference) > maximum_difference) {
|
|
||||||
maximum_difference = fabs(difference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int nr = potential_.extent(0) - 1;
|
const int nr = potential_.extent(0) - 1;
|
||||||
const int nth = potential_.extent(1);
|
const int nz = potential_.extent(1) - 2;
|
||||||
const int nz = potential_.extent(2) - 2;
|
|
||||||
|
|
||||||
normalized_difference =
|
normalized_difference =
|
||||||
std::sqrt(cumulated_quadradic_difference / (nr * nth * nz));
|
std::sqrt(cumulated_quadradic_difference / (nr * nz));
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
DEBUG_LEVEL_0("Poisson solver reached a normalized difference of: " +
|
DEBUG_LEVEL_0("Poisson solver reached a normalized difference of: " +
|
||||||
std::to_string(normalized_difference));
|
std::to_string(normalized_difference));
|
||||||
@@ -254,37 +210,33 @@ bool PoissonSolver::converged(
|
|||||||
return normalized_difference < target_accuracy_;
|
return normalized_difference < target_accuracy_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> PoissonSolver::potential() {
|
blitz::Array<double, 2> PoissonSolver::potential() {
|
||||||
// there might be a better way to do this... (if one can do array.memberValue without
|
// there might be a better way to do this... (if one can do array.memberValue without
|
||||||
// explicitely looping)
|
// explicitely looping)
|
||||||
blitz::Array<double, 3> potentialValues(potential_.lbound(), potential_.extent());
|
blitz::Array<double, 2> potentialValues(potential_.lbound(), potential_.extent());
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Extracting potential values");
|
DEBUG_LEVEL_3("Extracting potential values");
|
||||||
#endif
|
#endif
|
||||||
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
potentialValues(i,j) = potential_(i,j).value;
|
||||||
potentialValues(i,j,k) = potential_(i,j,k).value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return potentialValues;
|
return potentialValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
blitz::Array<double, 2> PoissonSolver::interpolateDensityToPotentialGrid(
|
||||||
const blitz::Array<double, 3> density) {
|
const blitz::Array<double, 2> density) {
|
||||||
// adapted from the external poisson solver (SDS: \\lsdf02.urz.uni-heidelberg.de\SD19H002\karl\src\tools\analysis_jkellerer)
|
// adapted from the external poisson solver (SDS: \\lsdf02.urz.uni-heidelberg.de\SD19H002\karl\src\tools\analysis_jkellerer)
|
||||||
blitz::Array<double, 3> interpolatedDensity(potential_.lbound(), potential_.extent());
|
blitz::Array<double, 2> interpolatedDensity(potential_.lbound(), potential_.extent());
|
||||||
interpolatedDensity = 0.;
|
interpolatedDensity = 0.;
|
||||||
|
|
||||||
//center values
|
//center values
|
||||||
for(int i = potential_.lbound(0)+1; i <= potential_.ubound(0); ++i) {
|
for(int i = potential_.lbound(0)+1; i <= potential_.ubound(0); ++i) {
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
interpolatedDensity(i, j) = (
|
||||||
interpolatedDensity(i, j, k) = (
|
density(i-1, j-1) + density(i, j-1) +
|
||||||
density(i-1, j , k-1) + density(i, j , k-1) +
|
density(i-1, j ) + density(i, j ))/4.;
|
||||||
density(i-1, j , k ) + density(i, j , k ))/4.;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,17 +244,12 @@ blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
|||||||
//values for r=0; charge density has to be single valued at r=0
|
//values for r=0; charge density has to be single valued at r=0
|
||||||
//therefore all elements in the j index have to be the same
|
//therefore all elements in the j index have to be the same
|
||||||
fixedIndex = potential_.lbound(0);
|
fixedIndex = potential_.lbound(0);
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for(int k = potential_.lbound(1)+1; k <= potential_.ubound(1)-1; ++k) {
|
||||||
for(int k = potential_.lbound(2)+1; k <= potential_.ubound(2)-1; ++k) {
|
//might not work that way, would need a dummy variable otherwise
|
||||||
//might not work that way, would need a dummy variable otherwise
|
interpolatedDensity(potential_.lbound(0), k) =
|
||||||
interpolatedDensity(potential_.lbound(0), blitz::Range::all(), k) +=
|
(density(fixedIndex, k-1) + density(fixedIndex, k))/2.;
|
||||||
(density(fixedIndex, j, k-1) + density(fixedIndex, j, k))/2.;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//might not work that way (if not needs a loop)
|
|
||||||
interpolatedDensity(fixedIndex, blitz::Range::all(), blitz::Range::all()) /=
|
|
||||||
potential_.extent(1);
|
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Max Value in interpolated density array: " +
|
DEBUG_LEVEL_3("Max Value in interpolated density array: " +
|
||||||
std::to_string(blitz::max(interpolatedDensity)));
|
std::to_string(blitz::max(interpolatedDensity)));
|
||||||
@@ -313,60 +260,41 @@ blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
||||||
blitz::TinyVector<int,3> Eextent = potential_.extent() -
|
blitz::TinyVector<int,2> Eextent = potential_.extent() -
|
||||||
blitz::TinyVector<int,3>(1,0,1);
|
blitz::TinyVector<int,2>(1,1);
|
||||||
blitz::Array<double, 3> Er(potential_.lbound(), Eextent);
|
blitz::Array<double, 2> Er(potential_.lbound(), Eextent);
|
||||||
blitz::Array<double, 3> Ephi(potential_.lbound(), Eextent);
|
blitz::Array<double, 2> Ephi(potential_.lbound(), Eextent);
|
||||||
blitz::Array<double, 3> Ez(potential_.lbound(), Eextent);
|
blitz::Array<double, 2> Ez(potential_.lbound(), Eextent);
|
||||||
|
|
||||||
Ephi = 0.;
|
Ephi = 0.;
|
||||||
//do calculation of E from the potential and interpolation to
|
//do calculation of E from the potential and interpolation to
|
||||||
//cell center at the same time
|
//cell center at the same time
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
|
||||||
int jp = (j+1 > potential_.ubound(1)) ? potential_.lbound(1) : j+1;
|
|
||||||
int jm = (j-1 < potential_.lbound(1)) ? potential_.ubound(1) : j-1;
|
|
||||||
for(int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
|
||||||
for(int k = potential_.lbound(2); k < potential_.ubound(2); ++k) {
|
|
||||||
Er(i,j,k) = -(potential_(i+1,j,k ).value -
|
|
||||||
potential_(i ,j,k ).value +
|
|
||||||
potential_(i+1,j,k+1).value -
|
|
||||||
potential_(i ,j,k+1).value)
|
|
||||||
/(2*stepsize(0));
|
|
||||||
|
|
||||||
Ez(i,j,k) = -(potential_(i ,j,k+1).value -
|
for(int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
||||||
potential_(i ,j,k ).value +
|
for(int k = potential_.lbound(1); k < potential_.ubound(1); ++k) {
|
||||||
potential_(i+1,j,k+1).value -
|
Er(i,k) = -(potential_(i+1,k ).value -
|
||||||
potential_(i+1,j,k ).value)
|
potential_(i ,k ).value +
|
||||||
/(2*stepsize(2));
|
potential_(i+1,k+1).value -
|
||||||
|
potential_(i ,k+1).value ) /(2*stepsize(0));
|
||||||
|
|
||||||
if(i==potential_.lbound(0)) {
|
Ez(i,k) = -(potential_(i ,k+1).value -
|
||||||
Ephi(i,j,k) = -(
|
potential_(i ,k ).value +
|
||||||
potential_(i+1,jp,k ).value - potential_(i+1,jm,k ).value +
|
potential_(i+1,k+1).value -
|
||||||
potential_(i+1,jp,k+1).value - potential_(i+1,jm,k+1).value)
|
potential_(i+1,k ).value )/(2*stepsize(1));
|
||||||
/((i+1)*stepsize(0)*stepsize(2))/4.;
|
|
||||||
} else {
|
|
||||||
Ephi(i,j,k) = -(
|
|
||||||
(potential_(i ,jp,k ).value - potential_(i ,jm,k ).value +
|
|
||||||
potential_(i ,jp,k+1).value - potential_(i ,jm,k+1).value)
|
|
||||||
/(i*stepsize(0)) +
|
|
||||||
(potential_(i+1,jp,k ).value - potential_(i+1,jm,k ).value +
|
|
||||||
potential_(i+1,jp,k+1).value - potential_(i+1,jm,k+1).value)
|
|
||||||
/((i+1)*stepsize(0)) )/(4.*stepsize(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::shared_ptr<VectorField>(
|
return std::shared_ptr<VectorField>(
|
||||||
new VectorFieldFromArray(Er, Ephi, Ez,
|
new VectorFieldFromArray(Er, Ephi, Ez,
|
||||||
Eextent(0)*stepsize(0), Eextent(2)*stepsize(2)));
|
Eextent(0)*stepsize(0), Eextent(1)*stepsize(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CylinderBinning* PoissonSolver::densityBinning() {
|
const CylinderBinning* PoissonSolver::densityBinning() {
|
||||||
return &density_binning_;
|
return &density_binning_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::setPotential(blitz::Array<double, 3>& potential) {
|
void PoissonSolver::setPotential(blitz::Array<double, 2>& potential) {
|
||||||
// check if the loaded potential has the same size as the potential
|
// check if the loaded potential has the same size as the potential
|
||||||
// specified by the json file
|
// specified by the json file
|
||||||
if(!blitz::all(potential.length() == potential_.length())) {
|
if(!blitz::all(potential.length() == potential_.length())) {
|
||||||
@@ -381,13 +309,10 @@ void PoissonSolver::setPotential(blitz::Array<double, 3>& potential) {
|
|||||||
// while the parameter array is most likely starting from 0)
|
// while the parameter array is most likely starting from 0)
|
||||||
const int i_offset = potential.lbound(0) - potential_.lbound(0);
|
const int i_offset = potential.lbound(0) - potential_.lbound(0);
|
||||||
const int j_offset = potential.lbound(1) - potential_.lbound(1);
|
const int j_offset = potential.lbound(1) - potential_.lbound(1);
|
||||||
const int k_offset = potential.lbound(2) - potential_.lbound(2);
|
|
||||||
|
|
||||||
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
potential_(i,j).value = potential(i + i_offset,j + j_offset);
|
||||||
potential_(i,j,k).value = potential(i + i_offset,j + j_offset,k + k_offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,10 @@
|
|||||||
#include "simulation/species.h"
|
#include "simulation/species.h"
|
||||||
#include "simulation/mpi_communication.h"
|
#include "simulation/mpi_communication.h"
|
||||||
|
|
||||||
void CpuSynchronizer::sumToAll(blitz::Array<double, 4>& array,
|
void CpuSynchronizer::sumToAll(blitz::Array<double, 4>& array) {
|
||||||
blitz::Array<double, 4>& last_sync_array) {
|
|
||||||
int size = array.size();
|
int size = array.size();
|
||||||
blitz::Array<double, 4> delta(array.extent());
|
MPI_Allreduce(MPI_IN_PLACE, array.data(), size, MPI_DOUBLE,
|
||||||
delta = array - last_sync_array;
|
|
||||||
MPI_Allreduce(MPI_IN_PLACE, delta.data(), size, MPI_DOUBLE,
|
|
||||||
MPI_SUM, MPI_COMM_WORLD);
|
MPI_SUM, MPI_COMM_WORLD);
|
||||||
last_sync_array += delta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array) {
|
void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array) {
|
||||||
@@ -77,6 +73,14 @@ void CpuSynchronizer::sumToRoot(blitz::Array<double, 3>& array) {
|
|||||||
MPI_Reduce(array.data(), nullptr, size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
MPI_Reduce(array.data(), nullptr, size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CpuSynchronizer::sumToRoot(blitz::Array<double, 2>& array) {
|
||||||
|
int size = array.size();
|
||||||
|
if(MpiCommunication::mpi_rank == root)
|
||||||
|
MPI_Reduce(MPI_IN_PLACE, array.data(), size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
||||||
|
else
|
||||||
|
MPI_Reduce(array.data(), nullptr, size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
||||||
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::sumToRoot(long int& value) {
|
void CpuSynchronizer::sumToRoot(long int& value) {
|
||||||
int size = 1;
|
int size = 1;
|
||||||
if(MpiCommunication::mpi_rank == root) {
|
if(MpiCommunication::mpi_rank == root) {
|
||||||
@@ -110,8 +114,8 @@ void CpuSynchronizer::synchronize(Timer* timer, Timer* last_sync_timer) {
|
|||||||
// array storing the previous timestep
|
// array storing the previous timestep
|
||||||
void CpuSynchronizer::synchronize(DynamicDensityField* field) {
|
void CpuSynchronizer::synchronize(DynamicDensityField* field) {
|
||||||
if (field) {
|
if (field) {
|
||||||
sumToAll(field->sync_time_in_bin_s_);
|
sumToAll(field->sync_number_in_bin_);
|
||||||
field->time_in_bin_s_ = field->sync_time_in_bin_s_;
|
field->number_in_bin_ = field->sync_number_in_bin_;
|
||||||
field->recalculateDensityArray();
|
field->recalculateDensityArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,17 +21,16 @@ CurrentCollector::CurrentCollector(const CylinderBinning& position_binning,
|
|||||||
// sync_phi_positive_crossings(createCrossingsAzimuthal(position_binning))
|
// sync_phi_positive_crossings(createCrossingsAzimuthal(position_binning))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createAreaLongitudinal(
|
blitz::Array<double, 2> CurrentCollector::createAreaLongitudinal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> area_z(
|
blitz::Array<double, 2> area_z(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(0, bin_index_max(1)));
|
||||||
blitz::Range(0, bin_index_max(2)));
|
|
||||||
|
|
||||||
for (int ir = 0; ir <= area_z.ubound(0); ++ir) {
|
for (int ir = 0; ir <= area_z.ubound(0); ++ir) {
|
||||||
const double dr = position_binning.stepsize()(0);
|
const double dr = position_binning.stepsize()(0);
|
||||||
@@ -39,106 +38,100 @@ blitz::Array<double, 3> CurrentCollector::createAreaLongitudinal(
|
|||||||
const double r2 = (ir + 1) * dr;
|
const double r2 = (ir + 1) * dr;
|
||||||
// const double area_element =
|
// const double area_element =
|
||||||
// (std::pow(r2, 2) - std::pow(r1, 2)) * M_PI / (area_z.extent(1));
|
// (std::pow(r2, 2) - std::pow(r1, 2)) * M_PI / (area_z.extent(1));
|
||||||
const double area_element =
|
const double area_element = (r2*r2 - r1*r1) * M_PI;
|
||||||
(r2*r2 - r1*r1) * M_PI / (area_z.extent(1));
|
area_z(ir, blitz::Range::all()) = area_element;
|
||||||
area_z(ir, blitz::Range::all(), blitz::Range::all()) = area_element;
|
|
||||||
}
|
}
|
||||||
return area_z;
|
return area_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createCrossingsLongitudinal(
|
blitz::Array<double, 2> CurrentCollector::createCrossingsLongitudinal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> crossings_longitudinal(
|
blitz::Array<double, 2> crossings_longitudinal(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(0, bin_index_max(1)));
|
||||||
blitz::Range(0, bin_index_max(2)));
|
|
||||||
crossings_longitudinal = 0.;
|
crossings_longitudinal = 0.;
|
||||||
return crossings_longitudinal;
|
return crossings_longitudinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createAreaRadial(
|
blitz::Array<double, 2> CurrentCollector::createAreaRadial(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> area_r(
|
blitz::Array<double, 2> area_r(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
|
|
||||||
for (int ir = 0; ir <= area_r.ubound(0); ++ir) {
|
for (int ir = 0; ir <= area_r.ubound(0); ++ir) {
|
||||||
const double dr = position_binning.stepsize()(0);
|
const double dr = position_binning.stepsize()(0);
|
||||||
const double dz = position_binning.stepsize()(2);
|
const double dz = position_binning.stepsize()(1);
|
||||||
const double r = (ir + 1) * dr;
|
const double r = (ir + 1) * dr;
|
||||||
const double area_element = (2 * M_PI * r) / area_r.extent(1) * dz;
|
const double area_element = (2 * M_PI * r) * dz;
|
||||||
|
|
||||||
area_r(ir, blitz::Range::all(), blitz::Range::all()) = area_element;
|
area_r(ir, blitz::Range::all()) = area_element;
|
||||||
}
|
}
|
||||||
return area_r;
|
return area_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createCrossingsRadial(
|
blitz::Array<double, 2> CurrentCollector::createCrossingsRadial(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> crossings_radial(
|
blitz::Array<double, 2> crossings_radial(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
crossings_radial = 0.;
|
crossings_radial = 0.;
|
||||||
return crossings_radial;
|
return crossings_radial;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createAreaAzimuthal(
|
blitz::Array<double, 2> CurrentCollector::createAreaAzimuthal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> area_phi(
|
blitz::Array<double, 2> area_phi(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
|
|
||||||
const double dr = position_binning.stepsize()(0);
|
const double dr = position_binning.stepsize()(0);
|
||||||
const double dz = position_binning.stepsize()(2);
|
const double dz = position_binning.stepsize()(1);
|
||||||
const double area_element = dr * dz;
|
const double area_element = dr * dz;
|
||||||
area_phi(blitz::Range::all(), blitz::Range::all(), blitz::Range::all()) =
|
area_phi(blitz::Range::all(), blitz::Range::all()) =
|
||||||
area_element;
|
area_element;
|
||||||
return area_phi;
|
return area_phi;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createCrossingsAzimuthal(
|
blitz::Array<double, 2> CurrentCollector::createCrossingsAzimuthal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> crossings_azimuthal(
|
blitz::Array<double, 2> crossings_azimuthal(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
crossings_azimuthal = 0;
|
crossings_azimuthal = 0;
|
||||||
return crossings_azimuthal;
|
return crossings_azimuthal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentCollector::collect(particle::Particle* particle,
|
void CurrentCollector::collect(particle::Particle* particle,
|
||||||
const Coordinate& old_position) {
|
const Coordinate& old_position) {
|
||||||
blitz::TinyVector<int, 3> bin_old =
|
blitz::TinyVector<int, 2> bin_old =
|
||||||
position_binning_.bin(old_position.cylinderEntries());
|
position_binning_.bin(old_position.cylinderEntries());
|
||||||
blitz::TinyVector<int, 3> bin_new =
|
blitz::TinyVector<int, 2> bin_new =
|
||||||
position_binning_.bin(particle->cylinderPosition().cylinderEntries());
|
position_binning_.bin(particle->cylinderPosition().cylinderEntries());
|
||||||
|
|
||||||
const double weight = particle->weight();
|
const double weight = particle->weight();
|
||||||
@@ -149,108 +142,103 @@ void CurrentCollector::collect(particle::Particle* particle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CurrentCollector::collectRadialMovement(
|
void CurrentCollector::collectRadialMovement(
|
||||||
const blitz::TinyVector<int, 3>& bin_old,
|
const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight) {
|
const double weight) {
|
||||||
if (bin_new(0) < bin_old(0)) {
|
if (bin_new(0) < bin_old(0)) {
|
||||||
r_negative_crossings(bin_new(0), bin_old(1), bin_old(2)) += weight;
|
r_negative_crossings(bin_new(0), bin_old(1)) += weight;
|
||||||
} else if (bin_new(0) > bin_old(0)) {
|
} else if (bin_new(0) > bin_old(0)) {
|
||||||
r_positive_crossings(bin_new(0) - 1, bin_old(1), bin_old(2)) += weight;
|
r_positive_crossings(bin_new(0) - 1, bin_old(1)) += weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CurrentCollector::collectLongitudinalMovement(
|
void CurrentCollector::collectLongitudinalMovement(
|
||||||
const blitz::TinyVector<int, 3>& bin_old,
|
const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight) {
|
const double weight) {
|
||||||
if (bin_new(2) < bin_old(2)) {
|
if (bin_new(1) < bin_old(1)) {
|
||||||
z_negative_crossings(bin_old(0), bin_old(1), bin_new(2) + 1) += weight;
|
z_negative_crossings(bin_old(0), bin_new(1) + 1) += weight;
|
||||||
} else if (bin_new(2) > bin_old(2)) {
|
} else if (bin_new(1) > bin_old(1)) {
|
||||||
z_positive_crossings(bin_old(0), bin_old(1), bin_new(2)) += weight;
|
z_positive_crossings(bin_old(0), bin_old(1)) += weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// does not work!
|
||||||
void CurrentCollector::collectAzimuthalMovement(
|
void CurrentCollector::collectAzimuthalMovement(
|
||||||
const blitz::TinyVector<int, 3>& bin_old,
|
const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight) {
|
const double weight) {
|
||||||
if ((bin_new(1) < bin_old(1)) ||
|
if ((bin_new(1) < bin_old(1)) ||
|
||||||
((bin_old(1) == 0) &&
|
((bin_old(1) == 0) &&
|
||||||
(bin_new(1) == position_binning_.binIndexMax()(1)))) {
|
(bin_new(1) == position_binning_.binIndexMax()(1)))) {
|
||||||
phi_negative_crossings(bin_old(0), bin_new(1), bin_old(2)) += weight;
|
phi_negative_crossings(bin_old(0), bin_new(1)) += weight;
|
||||||
} else if ((bin_new(1) > bin_old(1)) ||
|
} else if ((bin_new(1) > bin_old(1)) ||
|
||||||
((bin_old(1) == position_binning_.binIndexMax()(1)) &&
|
((bin_old(1) == position_binning_.binIndexMax()(1)) &&
|
||||||
(bin_new(1) == 0))) {
|
(bin_new(1) == 0))) {
|
||||||
phi_positive_crossings(bin_old(0), bin_new(1) - 1, bin_old(2)) += weight;
|
phi_positive_crossings(bin_old(0), bin_new(1) - 1) += weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::negativeCrossingsInZ() const {
|
blitz::Array<double, 2> CurrentCollector::negativeCrossingsInZ() const {
|
||||||
return z_negative_crossings;
|
return z_negative_crossings;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::positiveCrossingsInZ() const {
|
blitz::Array<double, 2> CurrentCollector::positiveCrossingsInZ() const {
|
||||||
return z_positive_crossings;
|
return z_positive_crossings;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::negativeCrossingsInPhi() const {
|
blitz::Array<double, 2> CurrentCollector::negativeCrossingsInPhi() const {
|
||||||
return phi_negative_crossings;
|
return phi_negative_crossings;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::positiveCrossingsInPhi() const {
|
blitz::Array<double, 2> CurrentCollector::positiveCrossingsInPhi() const {
|
||||||
return phi_positive_crossings;
|
return phi_positive_crossings;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::negativeCrossingsInR() const {
|
blitz::Array<double, 2> CurrentCollector::negativeCrossingsInR() const {
|
||||||
return r_negative_crossings;
|
return r_negative_crossings;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::positiveCrossingsInR() const {
|
blitz::Array<double, 2> CurrentCollector::positiveCrossingsInR() const {
|
||||||
return r_positive_crossings;
|
return r_positive_crossings;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::areaInR() const {
|
blitz::Array<double, 2> CurrentCollector::areaInR() const {
|
||||||
return collector_areas_r;
|
return collector_areas_r;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::areaInPhi() const {
|
blitz::Array<double, 2> CurrentCollector::areaInPhi() const {
|
||||||
return collector_areas_phi;
|
return collector_areas_phi;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::areaInZ() const {
|
blitz::Array<double, 2> CurrentCollector::areaInZ() const {
|
||||||
return collector_areas_z;
|
return collector_areas_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::currentInZ() const {
|
blitz::Array<double, 2> CurrentCollector::currentInZ() const {
|
||||||
blitz::Array<double, 3> current_in_z = z_positive_crossings.copy();
|
blitz::Array<double, 2> current_in_z = z_positive_crossings.copy();
|
||||||
current_in_z(blitz::Range::all(), blitz::Range::all(), blitz::Range::all()) =
|
current_in_z(blitz::Range::all(), blitz::Range::all()) =
|
||||||
(z_positive_crossings(blitz::Range::all(), blitz::Range::all(),
|
(z_positive_crossings(blitz::Range::all(), blitz::Range::all()) -
|
||||||
blitz::Range::all()) -
|
z_negative_crossings(blitz::Range::all(), blitz::Range::all())) /
|
||||||
z_negative_crossings(blitz::Range::all(), blitz::Range::all(),
|
|
||||||
blitz::Range::all())) /
|
|
||||||
(physicalTime() * collector_areas_z(blitz::Range::all(),
|
(physicalTime() * collector_areas_z(blitz::Range::all(),
|
||||||
blitz::Range::all(),
|
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
return current_in_z;
|
return current_in_z;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::currentInPhi() const {
|
|
||||||
blitz::Array<double, 3> current_in_phi = phi_positive_crossings.copy();
|
// does not work due to wrong phi_{positive/negative}_crossings
|
||||||
current_in_phi(blitz::Range::all(), blitz::Range::all(),
|
blitz::Array<double, 2> CurrentCollector::currentInPhi() const {
|
||||||
blitz::Range::all()) =
|
blitz::Array<double, 2> current_in_phi = phi_positive_crossings.copy();
|
||||||
(phi_positive_crossings(blitz::Range::all(), blitz::Range::all(),
|
current_in_phi(blitz::Range::all(), blitz::Range::all()) =
|
||||||
blitz::Range::all()) -
|
(phi_positive_crossings(blitz::Range::all(), blitz::Range::all()) -
|
||||||
phi_negative_crossings(blitz::Range::all(), blitz::Range::all(),
|
phi_negative_crossings(blitz::Range::all(), blitz::Range::all())) /
|
||||||
blitz::Range::all())) /
|
|
||||||
(physicalTime() * collector_areas_phi(blitz::Range::all(),
|
(physicalTime() * collector_areas_phi(blitz::Range::all(),
|
||||||
blitz::Range::all(),
|
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
return current_in_phi;
|
return current_in_phi;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::currentInR() const {
|
|
||||||
blitz::Array<double, 3> current_in_r = r_positive_crossings.copy();
|
blitz::Array<double, 2> CurrentCollector::currentInR() const {
|
||||||
current_in_r(blitz::Range::all(), blitz::Range::all(), blitz::Range::all()) =
|
blitz::Array<double, 2> current_in_r = r_positive_crossings.copy();
|
||||||
(r_positive_crossings(blitz::Range::all(), blitz::Range::all(),
|
current_in_r(blitz::Range::all(), blitz::Range::all()) =
|
||||||
blitz::Range::all()) -
|
(r_positive_crossings(blitz::Range::all(), blitz::Range::all()) -
|
||||||
r_negative_crossings(blitz::Range::all(), blitz::Range::all(),
|
r_negative_crossings(blitz::Range::all(), blitz::Range::all())) /
|
||||||
blitz::Range::all())) /
|
|
||||||
(physicalTime() * collector_areas_r(blitz::Range::all(),
|
(physicalTime() * collector_areas_r(blitz::Range::all(),
|
||||||
blitz::Range::all(),
|
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
return current_in_r;
|
return current_in_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
double CurrentCollector::physicalTime() const {
|
double CurrentCollector::physicalTime() const {
|
||||||
return timer_->getDeltaT();
|
return timer_->getDeltaT();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,20 @@
|
|||||||
#include "tools/simulation_time.h"
|
#include "tools/simulation_time.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
blitz::Array<T, 4> initiate4DArray(blitz::Range radial,
|
blitz::Array<T, 3> initiate3DArray(blitz::Range radial,
|
||||||
blitz::Range phi,
|
|
||||||
blitz::Range longitudinal,
|
blitz::Range longitudinal,
|
||||||
blitz::Range energy) {
|
blitz::Range energy) {
|
||||||
blitz::Array<T, 4> data(radial, phi, longitudinal, energy);
|
blitz::Array<T, 3> data(radial, longitudinal, energy);
|
||||||
|
data = static_cast<T>(0);
|
||||||
|
return data.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
blitz::Array<T, 4> initiate4DArray(blitz::Range radial,
|
||||||
|
blitz::Range longitudinal,
|
||||||
|
blitz::Range energy,
|
||||||
|
blitz::Range pitchangle) {
|
||||||
|
blitz::Array<T, 4> data(radial, longitudinal, energy, pitchangle);
|
||||||
data = static_cast<T>(0);
|
data = static_cast<T>(0);
|
||||||
return data.copy();
|
return data.copy();
|
||||||
}
|
}
|
||||||
@@ -29,24 +38,23 @@ blitz::Array<T, 5> initiate5DArray(blitz::Range radial,
|
|||||||
return data.copy();
|
return data.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> initiateVolumeArray(
|
blitz::Array<double, 2> initiateVolumeArray(
|
||||||
blitz::Range radial,
|
blitz::Range radial,
|
||||||
blitz::Range phi,
|
|
||||||
blitz::Range longitudinal,
|
blitz::Range longitudinal,
|
||||||
const blitz::TinyVector<double, 3>& position_spacing) {
|
const blitz::TinyVector<double, 2>& position_spacing) {
|
||||||
blitz::Array<double, 3> volume(radial, phi, longitudinal);
|
blitz::Array<double, 2> volume(radial, longitudinal);
|
||||||
|
|
||||||
for (int ir = 0; ir <= volume.ubound(0); ++ir) {
|
for (int ir = 0; ir <= volume.ubound(0); ++ir) {
|
||||||
const double r1 = ir * position_spacing(0);
|
const double r1 = ir * position_spacing(0);
|
||||||
const double r2 = (ir + 1) * position_spacing(0);
|
const double r2 = (ir + 1) * position_spacing(0);
|
||||||
for (int iz = volume.lbound(2); iz <= volume.ubound(2); ++iz) {
|
for (int iz = volume.lbound(1); iz <= volume.ubound(1); ++iz) {
|
||||||
const double z1 = iz * position_spacing(2);
|
const double z1 = iz * position_spacing(1);
|
||||||
const double z2 = (iz + 1) * position_spacing(2);
|
const double z2 = (iz + 1) * position_spacing(1);
|
||||||
|
|
||||||
const double bin_volume =
|
const double bin_volume =
|
||||||
M_PI * ((r2*r2) - (r1*r1)) * (z2 - z1) / phi.length();
|
M_PI * ((r2*r2) - (r1*r1)) * (z2 - z1);
|
||||||
|
|
||||||
volume(ir, blitz::Range::all(), iz) = bin_volume;
|
volume(ir, iz) = bin_volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return volume.copy();
|
return volume.copy();
|
||||||
@@ -61,33 +69,27 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
energy_binning_(energy_binning),
|
energy_binning_(energy_binning),
|
||||||
pitch_angle_binning_(pitch_angle_binning),
|
pitch_angle_binning_(pitch_angle_binning),
|
||||||
timer_(timer),
|
timer_(timer),
|
||||||
time_in_bin_s_(initiate5DArray<double>(
|
number_in_bin_(initiate4DArray<double>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
blitz::Range(pitch_angle_binning.binIndexMin(),
|
blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||||
pitch_angle_binning.binIndexMax()),
|
pitch_angle_binning.binIndexMax()),
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
blitz::Range(energy_binning.binIndexMin(),
|
||||||
energy_binning.binIndexMax()))),
|
energy_binning.binIndexMax()))),
|
||||||
sync_time_in_bin_s_(initiate5DArray<double>(
|
sync_number_in_bin_(initiate4DArray<double>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
blitz::Range(pitch_angle_binning.binIndexMin(),
|
blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||||
pitch_angle_binning.binIndexMax()),
|
pitch_angle_binning.binIndexMax()),
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
blitz::Range(energy_binning.binIndexMin(),
|
||||||
energy_binning.binIndexMax()))),
|
energy_binning.binIndexMax()))),
|
||||||
density_per_m3_(initiate4DArray<double>(
|
density_per_m3_(initiate3DArray<double>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
blitz::Range(energy_binning.binIndexMin(),
|
||||||
@@ -95,8 +97,6 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
bin_volume_m3_(initiateVolumeArray(
|
bin_volume_m3_(initiateVolumeArray(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
position_binning.stepsize())) {
|
position_binning.stepsize())) {
|
||||||
@@ -106,7 +106,7 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
}
|
}
|
||||||
|
|
||||||
double DynamicDensityField::density(const Coordinate& position) {
|
double DynamicDensityField::density(const Coordinate& position) {
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
#ifdef debug_level1
|
#ifdef debug_level1
|
||||||
@@ -117,7 +117,7 @@ double DynamicDensityField::density(const Coordinate& position) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return blitz::sum(density_per_m3_(position_bin(0), position_bin(1), position_bin(2),
|
return blitz::sum(density_per_m3_(position_bin(0), position_bin(1),
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
|
|
||||||
/*/
|
/*/
|
||||||
@@ -136,33 +136,31 @@ double DynamicDensityField::density(const Coordinate& position) {
|
|||||||
|
|
||||||
double DynamicDensityField::density(const Coordinate& position,
|
double DynamicDensityField::density(const Coordinate& position,
|
||||||
double energy_eV) {
|
double energy_eV) {
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
const int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
// const double t = timer_->getDeltaT();
|
// const double t = timer_->getDeltaT();
|
||||||
const double time_in_bin = blitz::sum(time_in_bin_s_(
|
const double number_in_bin = blitz::sum(number_in_bin_(
|
||||||
position_bin(0), position_bin(1), position_bin(2),
|
position_bin(0), position_bin(1), blitz::Range::all(), energy_bin));
|
||||||
blitz::Range::all(), energy_bin));
|
|
||||||
// const long deleted_particles = blitz::sum(deleted_particles_(
|
// const long deleted_particles = blitz::sum(deleted_particles_(
|
||||||
// position_bin(0), position_bin(1), position_bin(2),
|
// position_bin(0), position_bin(1), position_bin(2),
|
||||||
// blitz::Range::all(), energy_bin));
|
// blitz::Range::all(), energy_bin));
|
||||||
|
|
||||||
return (time_in_bin) / // - deleted_particles) /
|
return (number_in_bin) / // - deleted_particles) /
|
||||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
bin_volume_m3_(position_bin(0), position_bin(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicDensityField::changedPositionBin(
|
bool DynamicDensityField::changedPositionBin(
|
||||||
const Coordinate& old_position,
|
const Coordinate& old_position,
|
||||||
const Coordinate& new_position) const {
|
const Coordinate& new_position) const {
|
||||||
const blitz::TinyVector<int, 3> old_bin =
|
const blitz::TinyVector<int, 2> old_bin =
|
||||||
position_binning_.bin(old_position.cylinderEntries());
|
position_binning_.bin(old_position.cylinderEntries());
|
||||||
|
|
||||||
const blitz::TinyVector<int, 3> new_bin =
|
const blitz::TinyVector<int, 2> new_bin =
|
||||||
position_binning_.bin(new_position.cylinderEntries());
|
position_binning_.bin(new_position.cylinderEntries());
|
||||||
|
|
||||||
return !((old_bin(0) == new_bin(0)) && (old_bin(1) == new_bin(1)) &&
|
return !((old_bin(0) == new_bin(0)) && (old_bin(1) == new_bin(1)));
|
||||||
(old_bin(2) == new_bin(2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicDensityField::changedEnergyBin(double old_energy_eV,
|
bool DynamicDensityField::changedEnergyBin(double old_energy_eV,
|
||||||
@@ -194,50 +192,48 @@ void DynamicDensityField::logMovement(const Coordinate& position,
|
|||||||
double pitch_angle,
|
double pitch_angle,
|
||||||
double weight) {
|
double weight) {
|
||||||
|
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
const int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
||||||
|
|
||||||
sync_time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
sync_number_in_bin_(position_bin(0), position_bin(1),
|
||||||
pitch_angle_bin, energy_bin) += weight;
|
pitch_angle_bin, energy_bin) += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> DynamicDensityField::densityArray() {
|
blitz::Array<double, 2> DynamicDensityField::densityArray() {
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("recalc Density array");
|
DEBUG_LEVEL_3("recalc Density array");
|
||||||
#endif
|
#endif
|
||||||
// recalculated after a timestep reset (as of now hope that's enough and works correctly)
|
// recalculated after a timestep reset (as of now hope that's enough and works correctly)
|
||||||
// recalculateDensityArray();
|
// recalculateDensityArray();
|
||||||
|
|
||||||
blitz::TinyVector<int,3> lowerbound(density_per_m3_.lbound(0),
|
blitz::TinyVector<int,2> lowerbound(density_per_m3_.lbound(0),
|
||||||
density_per_m3_.lbound(1),
|
density_per_m3_.lbound(1));
|
||||||
density_per_m3_.lbound(2));
|
blitz::TinyVector<int,2> extent(density_per_m3_.extent(0),
|
||||||
blitz::TinyVector<int,3> extent(density_per_m3_.extent(0),
|
density_per_m3_.extent(1));
|
||||||
density_per_m3_.extent(1),
|
blitz::Array<double, 2> density(lowerbound, extent);
|
||||||
density_per_m3_.extent(2));
|
|
||||||
blitz::Array<double, 3> density(lowerbound, extent);
|
|
||||||
|
|
||||||
blitz::fourthIndex iE;
|
blitz::thirdIndex iE;
|
||||||
// DEBUG_LEVEL_3("density sum");
|
// DEBUG_LEVEL_3("density sum");
|
||||||
density = blitz::sum(density_per_m3_, iE);
|
density = blitz::sum(density_per_m3_, iE);
|
||||||
return density.copy();
|
return density.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 4> DynamicDensityField::spectrumArray() {
|
blitz::Array<double, 3> DynamicDensityField::spectrumArray() {
|
||||||
// recalculateDensityArray();
|
// recalculateDensityArray();
|
||||||
return density_per_m3_;
|
return density_per_m3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 5> DynamicDensityField::timeInBinArray() const {
|
blitz::Array<double, 4> DynamicDensityField::numberInBinArray() const {
|
||||||
return time_in_bin_s_;
|
return number_in_bin_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// blitz::Array<long int, 5> DynamicDensityField::deletedParticlesArray() const {
|
// blitz::Array<long int, 5> DynamicDensityField::deletedParticlesArray() const {
|
||||||
// return deleted_particles_;
|
// return deleted_particles_;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
blitz::Array<double, 3> DynamicDensityField::binVolumeArray() const {
|
blitz::Array<double, 2> DynamicDensityField::binVolumeArray() const {
|
||||||
return bin_volume_m3_;
|
return bin_volume_m3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,18 +260,17 @@ double DynamicDensityField::timeResolution() const {
|
|||||||
void DynamicDensityField::recalculateDensityArray() {
|
void DynamicDensityField::recalculateDensityArray() {
|
||||||
// SimulationTimer::eventStartPoint("recalcDensityArray");
|
// SimulationTimer::eventStartPoint("recalcDensityArray");
|
||||||
blitz::firstIndex ir;
|
blitz::firstIndex ir;
|
||||||
blitz::secondIndex iphi;
|
blitz::secondIndex iz;
|
||||||
blitz::thirdIndex iz;
|
blitz::thirdIndex ipitch;
|
||||||
blitz::fourthIndex ipitch;
|
blitz::fourthIndex iE;
|
||||||
blitz::fifthIndex iE;
|
|
||||||
|
|
||||||
// reduction only seems to work for the last dimension (iE)
|
// reduction only seems to work for the last dimension (iE)
|
||||||
// -> first reorder (by exchanging iE and ipitch) and afterwards doing
|
// -> first reorder (by exchanging iE and ipitch) and afterwards doing
|
||||||
// the reduction over iE (which now contains the pitch dimension)
|
// the reduction over iE (which now contains the pitch dimension)
|
||||||
// blitz::Array<double, 5> temp((time_in_bin_s_(ir, iphi, iz, ipitch, iE)));
|
// 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)), iE) /
|
density_per_m3_ = blitz::sum((number_in_bin_(ir, iz, iE, ipitch)), iE) /
|
||||||
bin_volume_m3_(ir, iphi, iz);
|
bin_volume_m3_(ir, iz);
|
||||||
// SimulationTimer::eventStopPoint("recalcDensityArray");
|
// SimulationTimer::eventStopPoint("recalcDensityArray");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +278,7 @@ void DynamicDensityField::recalculateDensityArray() {
|
|||||||
// particle number
|
// particle number
|
||||||
blitz::Array<double, 1> DynamicDensityField::sliceSpectrumArray(
|
blitz::Array<double, 1> DynamicDensityField::sliceSpectrumArray(
|
||||||
const Coordinate& position) const {
|
const Coordinate& position) const {
|
||||||
blitz::TinyVector<int, 3> position_bin =
|
blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
// blitz::Array<double, 4> check = density_per_m3_.copy();
|
// blitz::Array<double, 4> check = density_per_m3_.copy();
|
||||||
@@ -292,25 +287,25 @@ blitz::Array<double, 1> DynamicDensityField::sliceSpectrumArray(
|
|||||||
// ERROR("splice specturm array: check failed.");
|
// ERROR("splice specturm array: check failed.");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return density_per_m3_(position_bin(0), position_bin(1), position_bin(2),
|
return density_per_m3_(position_bin(0), position_bin(1),
|
||||||
blitz::Range(energy_binning_.binIndexMin(),
|
blitz::Range(energy_binning_.binIndexMin(),
|
||||||
energy_binning_.binIndexMax()-1));
|
energy_binning_.binIndexMax()-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 1> DynamicDensityField::sliceTimeInBinArray(
|
blitz::Array<double, 1> DynamicDensityField::sliceNumberInBinArray(
|
||||||
const Coordinate& position, double energy_eV) const {
|
const Coordinate& position, double energy_eV) const {
|
||||||
blitz::TinyVector<int, 3> position_bin =
|
blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
int energy_bin = energy_binning_.bin(energy_eV);
|
int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
|
|
||||||
return time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
return number_in_bin_(position_bin(0), position_bin(1),
|
||||||
blitz::Range(0, pitch_angle_binning_.binIndexMax()-1),
|
blitz::Range(0, pitch_angle_binning_.binIndexMax()-1),
|
||||||
energy_bin);
|
energy_bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// resets the field that logs the new density
|
// resets the field that logs the new density
|
||||||
void DynamicDensityField::resetDynamicDensityField() {
|
void DynamicDensityField::resetDynamicDensityField() {
|
||||||
sync_time_in_bin_s_ = 0.;
|
sync_number_in_bin_ = 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
||||||
@@ -324,15 +319,15 @@ void DynamicDensityField::restartTimer(double time, double delta_t) {
|
|||||||
timer_->setDeltaT(delta_t);
|
timer_->setDeltaT(delta_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityField::restartTimeInBin(blitz::Array<double, 5> time_in_bin) {
|
void DynamicDensityField::restartNumberInBin(blitz::Array<double, 4> number_in_bin) {
|
||||||
if(!blitz::all(time_in_bin_s_.length() == time_in_bin.length())) {
|
if(!blitz::all(number_in_bin_.length() == number_in_bin.length())) {
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "Expected a size of " << time_in_bin_s_.length();
|
out << "Expected a size of " << number_in_bin_.length();
|
||||||
out << ", received a length of " << time_in_bin.length();
|
out << ", received a length of " << number_in_bin.length();
|
||||||
out << " for time_in_bin array";
|
out << " for time_in_bin array";
|
||||||
ERROR(out.str());
|
ERROR(out.str());
|
||||||
}
|
}
|
||||||
time_in_bin_s_ = time_in_bin.copy().reindex(time_in_bin_s_.lbound());
|
number_in_bin_ = number_in_bin.copy().reindex(number_in_bin_.lbound());
|
||||||
}
|
}
|
||||||
|
|
||||||
// void DynamicDensityField::restartDeletedParticlesArray(
|
// void DynamicDensityField::restartDeletedParticlesArray(
|
||||||
|
|||||||
@@ -117,46 +117,40 @@ int BinningWithOverAndUnderflow::binIndexMax() const {
|
|||||||
|
|
||||||
CylinderBinning::CylinderBinning(int num_bins_radial,
|
CylinderBinning::CylinderBinning(int num_bins_radial,
|
||||||
double radius,
|
double radius,
|
||||||
int num_bins_azimuthal,
|
|
||||||
int num_bins_longitudinal,
|
int num_bins_longitudinal,
|
||||||
double height)
|
double height)
|
||||||
: radial_binning(num_bins_radial, radius),
|
: radial_binning(num_bins_radial, radius),
|
||||||
azimuth_binning(num_bins_azimuthal, 2 * M_PI),
|
|
||||||
longitudinal_binning(num_bins_longitudinal, height) {}
|
longitudinal_binning(num_bins_longitudinal, height) {}
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::bin(
|
blitz::TinyVector<int, 2> CylinderBinning::bin(
|
||||||
const blitz::TinyVector<double, 3>& cylinder_position) const {
|
const blitz::TinyVector<double, 3>& cylinder_position) const {
|
||||||
return blitz::TinyVector<int, 3>(
|
return blitz::TinyVector<int, 2>(
|
||||||
radial_binning.bin(cylinder_position(0)),
|
radial_binning.bin(cylinder_position(0)),
|
||||||
azimuth_binning.bin(cylinder_position(1)),
|
|
||||||
longitudinal_binning.bin(cylinder_position(2)));
|
longitudinal_binning.bin(cylinder_position(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::numBins() const {
|
blitz::TinyVector<int, 2> CylinderBinning::numBins() const {
|
||||||
return blitz::TinyVector<int, 3>(
|
return blitz::TinyVector<int, 2>(
|
||||||
radial_binning.numBinsWithoutOverflow(), azimuth_binning.numBins(),
|
radial_binning.numBinsWithoutOverflow(),
|
||||||
longitudinal_binning.numBinsWithoutOverUnderflow());
|
longitudinal_binning.numBinsWithoutOverUnderflow());
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> CylinderBinning::stepsize() const {
|
blitz::TinyVector<double, 2> CylinderBinning::stepsize() const {
|
||||||
return blitz::TinyVector<double, 3>(radial_binning.stepsize(),
|
return blitz::TinyVector<double, 2>(radial_binning.stepsize(),
|
||||||
azimuth_binning.stepsize(),
|
|
||||||
longitudinal_binning.stepsize());
|
longitudinal_binning.stepsize());
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::numBinsIncludingOverUnderflow()
|
blitz::TinyVector<int, 2> CylinderBinning::numBinsIncludingOverUnderflow()
|
||||||
const {
|
const {
|
||||||
return blitz::TinyVector<int, 3>(
|
return blitz::TinyVector<int, 2>(
|
||||||
radial_binning.numBinsWithOverflow(), azimuth_binning.numBins(),
|
radial_binning.numBinsWithOverflow(),
|
||||||
longitudinal_binning.numBinsWithOverUnderflow());
|
longitudinal_binning.numBinsWithOverUnderflow());
|
||||||
}
|
}
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::binIndexMin() const {
|
blitz::TinyVector<int, 2> CylinderBinning::binIndexMin() const {
|
||||||
return blitz::TinyVector<int, 3>(radial_binning.binIndexMin(),
|
return blitz::TinyVector<int, 2>(radial_binning.binIndexMin(),
|
||||||
azimuth_binning.binIndexMin(),
|
|
||||||
longitudinal_binning.binIndexMin());
|
longitudinal_binning.binIndexMin());
|
||||||
}
|
}
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::binIndexMax() const {
|
blitz::TinyVector<int, 2> CylinderBinning::binIndexMax() const {
|
||||||
return blitz::TinyVector<int, 3>(radial_binning.binIndexMax(),
|
return blitz::TinyVector<int, 2>(radial_binning.binIndexMax(),
|
||||||
azimuth_binning.binIndexMax(),
|
|
||||||
longitudinal_binning.binIndexMax());
|
longitudinal_binning.binIndexMax());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,8 +188,8 @@ void Simulation::start() {
|
|||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timestep));
|
DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timestep));
|
||||||
DEBUG_LEVEL_1("Leftover events this timestep: " +
|
// DEBUG_LEVEL_1("Leftover events this timestep: " +
|
||||||
std::to_string(leftover_events_time_resolution));
|
// std::to_string(leftover_events_time_resolution));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
@@ -557,7 +557,7 @@ void Simulation::collisionTime(particle::Particle& particle, RandomNumbers* rand
|
|||||||
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
||||||
particle.timeUntilCollision(*min_iterator);
|
particle.timeUntilCollision(*min_iterator);
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug_level1
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "collision times ";
|
out << "collision times ";
|
||||||
out << particle.specie()->name() <<":\n[ ";
|
out << particle.specie()->name() <<":\n[ ";
|
||||||
@@ -604,7 +604,7 @@ interaction::InteractionOutput Simulation::interact(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//maybe put that into the poisson solver
|
//maybe put that into the poisson solver
|
||||||
blitz::Array<double,3> Simulation::chargedensity() {
|
blitz::Array<double,2> Simulation::chargedensity() {
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Initialize chargedensity Array");
|
DEBUG_LEVEL_3("Initialize chargedensity Array");
|
||||||
#endif
|
#endif
|
||||||
@@ -619,9 +619,9 @@ blitz::Array<double,3> Simulation::chargedensity() {
|
|||||||
if(!firstTracked)
|
if(!firstTracked)
|
||||||
ERROR("Extracted pointer is null.");
|
ERROR("Extracted pointer is null.");
|
||||||
|
|
||||||
blitz::Array<double,3> init = firstTracked->
|
blitz::Array<double,2> init = firstTracked->
|
||||||
dynamicDensityField()->densityArray();
|
dynamicDensityField()->densityArray();
|
||||||
blitz::Array<double, 3> chargeden(init.lbound(), init.extent());
|
blitz::Array<double, 2> chargeden(init.lbound(), init.extent());
|
||||||
chargeden = 0.;
|
chargeden = 0.;
|
||||||
|
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
VectorFieldFromArray::VectorFieldFromArray(
|
VectorFieldFromArray::VectorFieldFromArray(
|
||||||
const blitz::Array<double, 3>& radial_component,
|
const blitz::Array<double, 2>& radial_component,
|
||||||
const blitz::Array<double, 3>& azimuthal_component,
|
const blitz::Array<double, 2>& azimuthal_component,
|
||||||
const blitz::Array<double, 3>& longitudial_component,
|
const blitz::Array<double, 2>& longitudial_component,
|
||||||
double radius,
|
double radius,
|
||||||
double length)
|
double length)
|
||||||
: Fr_(radial_component.copy()),
|
: Fr_(radial_component.copy()),
|
||||||
@@ -14,17 +14,16 @@ VectorFieldFromArray::VectorFieldFromArray(
|
|||||||
binning_(CylinderBinning(radial_component.extent(0),
|
binning_(CylinderBinning(radial_component.extent(0),
|
||||||
radius,
|
radius,
|
||||||
radial_component.extent(1),
|
radial_component.extent(1),
|
||||||
radial_component.extent(2),
|
|
||||||
length)) {}
|
length)) {}
|
||||||
|
|
||||||
CylinderVector VectorFieldFromArray::value(const Coordinate& coordinate) const {
|
CylinderVector VectorFieldFromArray::value(const Coordinate& coordinate) const {
|
||||||
const blitz::TinyVector<int, 3> bin =
|
const blitz::TinyVector<int, 2> bin =
|
||||||
binning_.bin(coordinate.cylinderEntries());
|
binning_.bin(coordinate.cylinderEntries());
|
||||||
return value(bin);
|
return value(bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
CylinderVector VectorFieldFromArray::value(
|
CylinderVector VectorFieldFromArray::value(
|
||||||
const blitz::TinyVector<int, 3>& bin) const {
|
const blitz::TinyVector<int, 2>& bin) const {
|
||||||
if (Fr_.isInRange(bin)) {
|
if (Fr_.isInRange(bin)) {
|
||||||
return CylinderVector(
|
return CylinderVector(
|
||||||
blitz::TinyVector<double, 3>(Fr_(bin), Fphi_(bin), Fz_(bin)));
|
blitz::TinyVector<double, 3>(Fr_(bin), Fphi_(bin), Fz_(bin)));
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
|||||||
|
|
||||||
// SIM_INFO("set mu values");
|
// SIM_INFO("set mu values");
|
||||||
|
|
||||||
const blitz::Array<double, 1> mu_values = density_field_->sliceTimeInBinArray(position, energy_eV);
|
const blitz::Array<double, 1> mu_values = density_field_->sliceNumberInBinArray(position, energy_eV);
|
||||||
|
|
||||||
// std::cout << mu_values;
|
// std::cout << mu_values;
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
|||||||
// draw pitch angle from DynamicDensityField
|
// draw pitch angle from DynamicDensityField
|
||||||
|
|
||||||
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
||||||
sliceTimeInBinArray(position, energy_eV);
|
sliceNumberInBinArray(position, energy_eV);
|
||||||
|
|
||||||
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
||||||
pitchAngleBinBorders_.begin(),
|
pitchAngleBinBorders_.begin(),
|
||||||
|
|||||||
Reference in New Issue
Block a user