Files
karl/include/simulation/velocity_distribution.h
csendlinger 753cbe31f5 Corrections to drawing the velocity of a tracked
species (dynamic density field of previous timestep);
some optimization changes
2025-10-15 14:46:27 +02:00

75 lines
2.6 KiB
C++
Executable File

#ifndef VELOCITY_DISTRIBUTION_H
#define VELOCITY_DISTRIBUTION_H
#include <memory>
#include <random>
#include "simulation/coordinates.h"
class VelocityDistributionFunction;
class VelocityDistribution {
public:
virtual CartesianVector rollVelocity(const Coordinate& position,
std::mt19937* engine) = 0;
};
class VelocityDistributionFromFunction : public VelocityDistribution {
public:
VelocityDistributionFromFunction(
std::shared_ptr<VelocityDistributionFunction> fv);
CartesianVector rollVelocity(const Coordinate& position,
std::mt19937* engine);
private:
std::shared_ptr<VelocityDistributionFunction> fv_;
};
// only applicable to TrackedSpecies (i.e. only for DynamicDensityFields)
// other density don't have any information about the velocity direction
class DynamicDensityField;
class MagneticField;
// Class to draw a velocity from the pitch angle resolved density
class VelocityDistributionFromDensityField : public VelocityDistribution {
public:
// Constructor: takes shared ptr to the DynamicDensityField object from which
// should be drawn and the mass of the species to which the density
// field belongs
VelocityDistributionFromDensityField(
std::shared_ptr<DynamicDensityField> density_field, double mass_kg);
// stub: can be implemented to return the drift velocity of the particles
// at the CylinderVector position of the density field
CartesianVector driftVelocity_ms(const CylinderVector& position);
// returns a velocity vector drawn from the energy and pitch angle distributions
// since no magnetic field is given use e_z as the direction wrt the definition
// of the pitch angle
CartesianVector rollVelocity(const Coordinate& position, std::mt19937* engine);
// returns a velocity vector drawn from the energy and pitch angle distributions
// use the given magnetic field at the provided position to determine the
// direction of velocity from the pitch angle
// the direction of the perpendicular part of the velocity vector is drawn isotropically
CartesianVector rollVelocity(const Coordinate& position, std::mt19937* engine,
std::shared_ptr<MagneticField> magnetic_field);
private:
// mass of the species of which the density field is a part of
const double mass_kg_;
std::shared_ptr<DynamicDensityField> density_field_;
// blitz::Array<double, 1> energy_values;
// blitz::Array<double, 1> mu_values;
std::vector<double> energyBinBorders_;
std::vector<double> pitchAngleBinBorders_;
std::uniform_real_distribution<double> theta_distribution_;
};
#endif /* VELOCITY_DISTRIBUTION_H */