Version 2, position dependent E/B, kinetic ions, boris mover, terminator
This commit is contained in:
Executable
+162
@@ -0,0 +1,162 @@
|
||||
#include "simulation/position_binning.h"
|
||||
#include "simulation/coordinates.h"
|
||||
|
||||
LowerAndUpperBoundBinning::LowerAndUpperBoundBinning(int num_bins,
|
||||
double maximum)
|
||||
: num_bins_(num_bins), stepsize_(maximum / num_bins) {}
|
||||
|
||||
int LowerAndUpperBoundBinning::bin(double position) const {
|
||||
const int bin = position / stepsize_;
|
||||
return std::max(0, std::min(bin, num_bins_ - 1));
|
||||
}
|
||||
|
||||
double LowerAndUpperBoundBinning::stepsize() const {
|
||||
return stepsize_;
|
||||
}
|
||||
|
||||
int LowerAndUpperBoundBinning::numBins() const {
|
||||
return num_bins_;
|
||||
}
|
||||
|
||||
std::vector<double> LowerAndUpperBoundBinning::binBorders() const {
|
||||
std::vector<double> bin_borders;
|
||||
for (int i = 0; i <= num_bins_; ++i) {
|
||||
bin_borders.push_back(i * stepsize_);
|
||||
}
|
||||
return bin_borders;
|
||||
}
|
||||
|
||||
int LowerAndUpperBoundBinning::binIndexMin() const {
|
||||
return 0;
|
||||
}
|
||||
int LowerAndUpperBoundBinning::binIndexMax() const {
|
||||
return num_bins_ - 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LowerBoundBinningWithOverflow::LowerBoundBinningWithOverflow(
|
||||
int num_bins_excluding_overflow,
|
||||
double maximum)
|
||||
: num_bins_(num_bins_excluding_overflow + 1),
|
||||
stepsize_(maximum / num_bins_excluding_overflow) {}
|
||||
|
||||
int LowerBoundBinningWithOverflow::bin(double position) const {
|
||||
const int bin = position / stepsize_;
|
||||
return std::max(0, std::min(bin, num_bins_ - 1));
|
||||
}
|
||||
|
||||
double LowerBoundBinningWithOverflow::stepsize() const {
|
||||
return stepsize_;
|
||||
}
|
||||
|
||||
int LowerBoundBinningWithOverflow::numBinsWithOverflow() const {
|
||||
return num_bins_;
|
||||
}
|
||||
int LowerBoundBinningWithOverflow::numBinsWithoutOverflow() const {
|
||||
return num_bins_ - 1;
|
||||
}
|
||||
std::vector<double> LowerBoundBinningWithOverflow::binBorders() const {
|
||||
std::vector<double> bin_borders;
|
||||
for (int i = 0; i <= num_bins_ - 1; ++i) {
|
||||
bin_borders.push_back(i * stepsize_);
|
||||
}
|
||||
return bin_borders;
|
||||
}
|
||||
|
||||
int LowerBoundBinningWithOverflow::binIndexMin() const {
|
||||
return 0;
|
||||
}
|
||||
int LowerBoundBinningWithOverflow::binIndexMax() const {
|
||||
return num_bins_ - 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BinningWithOverAndUnderflow::BinningWithOverAndUnderflow(
|
||||
int num_bins_excluding_overunderflow,
|
||||
double maximum)
|
||||
: num_bins_(num_bins_excluding_overunderflow + 2),
|
||||
stepsize_(maximum / num_bins_excluding_overunderflow){};
|
||||
|
||||
int BinningWithOverAndUnderflow::bin(double position) const {
|
||||
const int bin =
|
||||
position < 0 ? position / stepsize_ - 1 : position / stepsize_;
|
||||
return std::max(-1, std::min(bin, num_bins_ - 2));
|
||||
}
|
||||
|
||||
double BinningWithOverAndUnderflow::stepsize() const {
|
||||
return stepsize_;
|
||||
}
|
||||
int BinningWithOverAndUnderflow::numBinsWithOverUnderflow() const {
|
||||
return num_bins_;
|
||||
}
|
||||
int BinningWithOverAndUnderflow::numBinsWithoutOverUnderflow() const {
|
||||
return num_bins_ - 2;
|
||||
}
|
||||
|
||||
std::vector<double> BinningWithOverAndUnderflow::binBorders() const {
|
||||
std::vector<double> bin_borders;
|
||||
for (int i = 0; i <= num_bins_ - 2; ++i) {
|
||||
bin_borders.push_back(i * stepsize_);
|
||||
}
|
||||
return bin_borders;
|
||||
}
|
||||
|
||||
int BinningWithOverAndUnderflow::binIndexMin() const {
|
||||
return -1;
|
||||
}
|
||||
int BinningWithOverAndUnderflow::binIndexMax() const {
|
||||
return num_bins_ - 2;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CylinderBinning::CylinderBinning(int num_bins_radial,
|
||||
double radius,
|
||||
int num_bins_azimuthal,
|
||||
int num_bins_longitudinal,
|
||||
double height)
|
||||
: radial_binning(num_bins_radial, radius),
|
||||
azimuth_binning(num_bins_azimuthal, 2 * M_PI),
|
||||
longitudinal_binning(num_bins_longitudinal, height) {}
|
||||
|
||||
blitz::TinyVector<int, 3> CylinderBinning::bin(
|
||||
const blitz::TinyVector<double, 3>& cylinder_position) const {
|
||||
return blitz::TinyVector<int, 3>(
|
||||
radial_binning.bin(cylinder_position(0)),
|
||||
azimuth_binning.bin(cylinder_position(1)),
|
||||
longitudinal_binning.bin(cylinder_position(2)));
|
||||
}
|
||||
|
||||
blitz::TinyVector<int, 3> CylinderBinning::numBins() const {
|
||||
return blitz::TinyVector<int, 3>(
|
||||
radial_binning.numBinsWithoutOverflow(), azimuth_binning.numBins(),
|
||||
longitudinal_binning.numBinsWithoutOverUnderflow());
|
||||
}
|
||||
|
||||
blitz::TinyVector<double, 3> CylinderBinning::stepsize() const {
|
||||
return blitz::TinyVector<double, 3>(radial_binning.stepsize(),
|
||||
azimuth_binning.stepsize(),
|
||||
longitudinal_binning.stepsize());
|
||||
}
|
||||
|
||||
blitz::TinyVector<int, 3> CylinderBinning::numBinsIncludingOverUnderflow()
|
||||
const {
|
||||
return blitz::TinyVector<int, 3>(
|
||||
radial_binning.numBinsWithOverflow(), azimuth_binning.numBins(),
|
||||
longitudinal_binning.numBinsWithOverUnderflow());
|
||||
}
|
||||
blitz::TinyVector<int, 3> CylinderBinning::binIndexMin() const {
|
||||
return blitz::TinyVector<int, 3>(radial_binning.binIndexMin(),
|
||||
azimuth_binning.binIndexMin(),
|
||||
longitudinal_binning.binIndexMin());
|
||||
}
|
||||
blitz::TinyVector<int, 3> CylinderBinning::binIndexMax() const {
|
||||
return blitz::TinyVector<int, 3>(radial_binning.binIndexMax(),
|
||||
azimuth_binning.binIndexMax(),
|
||||
longitudinal_binning.binIndexMax());
|
||||
}
|
||||
Reference in New Issue
Block a user