./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
15 / 15
100.0%
Branches:
8 / 15
53.3%
Functions:
4 / 4
100.0%

src/distribution/neukum.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 #include "terraingen/distribution/neukum.h"
4
5 #include "terraingen/distribution/power_law.h"
6 #include "terraingen/distribution/production_surface.h"
7
8 #include <cmath>
9 #include <memory>
10 #include <utility>
11
12 namespace terraingen {
13
14 namespace {
15
16 constexpr detail::ExponentialChronology kNeukum{5.44e-14, 6.93, 8.38e-4, kMaxLunarAgeGyr,
17 "Lunar surface age must be between 0 and 4.6 Gyr"};
18
19 } // namespace
20
21 7318730 double NeukumLunarChronology(double ageGyr) {
22 7318730 return kNeukum.Count(ageGyr);
23 }
24
25 12 double NeukumLunarChronologyRate(double ageGyr) {
26 12 return kNeukum.Rate(ageGyr);
27 }
28
29 765 LogPolynomialSfd NeukumProductionFunction() {
30 765 return LogPolynomialSfd({-3.076756, -3.557528, 0.781027, 1.021521, -0.156012, -0.444058,
31 0.019977, 0.086850, -0.005874, -0.006809, 8.25e-4, 5.54e-5},
32
1/1
✓ Branch 2 taken 765 times.
765 SfdKind::ProductionRate, DiameterRange{10.0, 300000.0}, 1000.0, 1e6);
33 }
34
35 730 SplicedSfd ExtendedNeukumProductionFunction() {
36 730 constexpr double kJoin = 10.0;
37 730 constexpr double kSlope = 2.85;
38 1460 auto npf = std::make_shared<LogPolynomialSfd>(NeukumProductionFunction());
39
1/1
✓ Branch 1 taken 730 times.
730 const double coefficient = npf->Cumulative(kJoin) * std::pow(kJoin, kSlope);
40
1/1
✓ Branch 1 taken 730 times.
730 auto smallCraters = std::make_shared<PowerLawSfd>(coefficient, kSlope, SfdKind::ProductionRate);
41
4/11
✓ Branch 1 taken 730 times.
✓ Branch 4 taken 1460 times.
✓ Branch 5 taken 730 times.
✓ Branch 6 taken 1460 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
2190 return SplicedSfd({{2.5, std::move(smallCraters)}, {kJoin, std::move(npf)}}, 300000.0);
42
1/1
✓ Branch 1 taken 730 times.
1460 }
43
44 } // namespace terraingen
45