Files
karl/include/simulation/velocity_distribution_function.h
2024-12-04 17:15:04 +01:00

59 lines
2.4 KiB
C++
Executable File

#ifndef VELOCITY_DISTRIBUTION_FUNCTION_H
#define VELOCITY_DISTRIBUTION_FUNCTION_H
#include <memory>
#include <random>
#include "simulation/coordinates.h"
// defined in "simulation/energy_distribution.h"
class EnergyDistributionFunction;
// class to define minimum requirements for a VelocityDistributionFunction child class
class VelocityDistributionFunction {
public:
virtual CartesianVector rollVelocity(std::mt19937* engine) = 0;
};
// class for a velocity distribution, that has a isotropically distributed
// direction of the velocity vector and an modulus that is inferred from
// an energy distribution
class IsotropicDistribution : public VelocityDistributionFunction {
public:
// Constructor: takes a shared_ptr to an EnergyDistributionFunction that describes
// the distribution of the energy and the mass of the particle
// to transform the drawn energy to the corresponding velocity
IsotropicDistribution(std::shared_ptr<EnergyDistributionFunction> f_E,
double mass_kg);
// draw an isotropically directed velocity vector with a modulus determined by the
// EnergyDistributionFunction given at construction of the object
CartesianVector rollVelocity(std::mt19937* engine);
private:
std::shared_ptr<EnergyDistributionFunction> f_E_;
const double mass_kg_;
};
// class for a velocity distribution, that has a fixed direction of the velocity vector
// and an modulus that is inferred from an energy distribution
class DirectedDistribution : public VelocityDistributionFunction {
public:
// Constructor: takes a shared_ptr to an EnergyDistributionFunction that describes
// the distribution of the energy and the mass of the particle
// to transform the drawn energy to the corresponding velocity
// and the direction of the velocity vector
DirectedDistribution(std::shared_ptr<EnergyDistributionFunction> f_E,
double mass_kg,
const CartesianVector& direction);
// draw a directed velocity vector with a modulus determined by the
// EnergyDistributionFunction given at construction of the object
CartesianVector rollVelocity(std::mt19937* engine);
private:
std::shared_ptr<EnergyDistributionFunction> f_E_;
const blitz::TinyVector<double, 3> direction_normal_;
const double mass_kg_;
};
#endif /* VELOCITY_DISTRIBUTION_FUNCTION_H */