TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
2 / 2
100.0%
Branches:
-
-%
Functions:
1 / 1
100.0%

layers/craters/ages/steady_state.h
Line Branch Exec Source
1 /// @file
2 /// @brief Crater ages on surfaces where small craters are in equilibrium.
3 #pragma once
4
5 #include "terraingen/distribution/production_surface.h"
6 #include "terraingen/distribution/size_frequency.h"
7 #include "terraingen/layers/craters/ages/age_model.h"
8
9 #include <memory>
10
11 namespace terraingen {
12
13 /// Ages of craters on a surface `ageGyr` old where small craters are in equilibrium.
14 ///
15 /// A crater's lifetime is tau(D) = n_eq(D) / n_prod(D), capped at the surface age; ages follow the
16 /// formation rate of `chronology` over [0, lifetime].
17 class SteadyStateAges final : public CraterAgeModel {
18 public:
19 /// @param productionRate A `ProductionRate` distribution, such as
20 /// `ExtendedNeukumProductionFunction`.
21 /// @param equilibrium A `Density` distribution, such as `TraskEquilibrium`.
22 /// @param ageGyr Surface age in Gyr.
23 /// @param chronology N(>=1 km) per m^2 by age, such as `NeukumLunarChronology`; ages are drawn
24 /// in proportion to its rate.
25 /// @throws std::invalid_argument for null or mismatched kinds, or an empty `chronology`.
26 /// @throws std::domain_error if `chronology` rejects `ageGyr`.
27 SteadyStateAges(std::shared_ptr<const SizeFrequencyDistribution> productionRate,
28 std::shared_ptr<const SizeFrequencyDistribution> equilibrium, double ageGyr,
29 Chronology chronology);
30
31 /// The surface age in Gyr.
32 5 double SurfaceAgeGyr() const {
33 5 return ageGyr_;
34 }
35
36 /// The equilibrium lifetime tau(D) in Gyr of craters of `diameter` metres, before capping at
37 /// the surface age.
38 /// @throws std::domain_error outside either distribution's valid range.
39 double EquilibriumLifetimeGyr(double diameter) const;
40
41 protected:
42 double LifetimeAt(double diameter) const override;
43 double SampleAgeAt(RandomStream& random, double diameter, double lifetimeGyr) const override;
44
45 private:
46 std::shared_ptr<const SizeFrequencyDistribution> productionRate_;
47 std::shared_ptr<const SizeFrequencyDistribution> equilibrium_;
48 double ageGyr_;
49 Chronology chronology_;
50 };
51
52 } // namespace terraingen
53