69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
module;
|
|
|
|
#include <vector>
|
|
|
|
#include <mfem.hpp>
|
|
|
|
export module mean_field:model.structure.polytropic;
|
|
|
|
export import :eos.polytrope;
|
|
export import :model.structure.base;
|
|
|
|
import :utils.misc;
|
|
|
|
export namespace mean_field::models::structure {
|
|
class PolytropicStructure final {
|
|
public:
|
|
explicit PolytropicStructure(
|
|
eos::Polytrope equationOfState,
|
|
double targetMass
|
|
);
|
|
|
|
[[nodiscard]] const eos::Polytrope &equationOfState() const noexcept;
|
|
|
|
[[nodiscard]] double targetMass() const noexcept;
|
|
|
|
[[nodiscard]] StructureSeed makeInitialSeed(const StructureSeedRequest &request) const;
|
|
|
|
void validate() const;
|
|
|
|
private:
|
|
struct LaneEmdenPoint {
|
|
double coordinate{0.0};
|
|
double value{0.0};
|
|
double derivative{0.0};
|
|
};
|
|
|
|
struct LaneEmdenDerivative {
|
|
double value{0.0};
|
|
double derivative{0.0};
|
|
};
|
|
|
|
static void validateSeedRequest(const StructureSeedRequest &request);
|
|
|
|
[[nodiscard]] static LaneEmdenDerivative evaluateLaneEmdenRhs(
|
|
double coordinate,
|
|
double value,
|
|
double derivative,
|
|
double polytropicIndex
|
|
);
|
|
|
|
[[nodiscard]] static LaneEmdenPoint takeLaneEmdenStep(
|
|
const LaneEmdenPoint &point,
|
|
double step,
|
|
double polytropicIndex
|
|
);
|
|
|
|
[[nodiscard]] static std::vector<LaneEmdenPoint> solveLaneEmden(double polytropicIndex);
|
|
|
|
[[nodiscard]] static double interpolateLaneEmdenValue(
|
|
const std::vector<LaneEmdenPoint> &solution,
|
|
double coordinate,
|
|
std::size_t &lowerIndex
|
|
);
|
|
|
|
eos::Polytrope m_equationOfState;
|
|
double m_targetMass;
|
|
};
|
|
} // namespace mean_field::models::structure
|