TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
21 / 21
100.0%
Branches:
15 / 21
71.4%
Functions:
5 / 5
100.0%

distribution/neukum.cpp
Line Branch Exec Source
1 #include "terraingen/distribution/neukum.h"
2
3 #include "terraingen/distribution/power_law.h"
4
5 #include <cmath>
6 #include <memory>
7 #include <stdexcept>
8 #include <utility>
9
10 namespace terraingen {
11
12 namespace {
13
14 40047887 void CheckAge(double ageGyr) {
15
4/4
✓ Branch 0 taken 40047883 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 40047875 times.
40047887 if (!(ageGyr >= 0.0 && ageGyr <= kMaxLunarAgeGyr)) {
16
1/1
✓ Branch 2 taken 12 times.
12 throw std::domain_error("Lunar surface age must be between 0 and 4.6 Gyr");
17 }
18 40047875 }
19
20 } // namespace
21
22 40047879 double NeukumLunarChronology(double ageGyr) {
23 40047879 CheckAge(ageGyr);
24 40047869 return (5.44e-14 * std::expm1(6.93 * ageGyr) + 8.38e-4 * ageGyr) / 1e6;
25 }
26
27 8 double NeukumLunarChronologyRate(double ageGyr) {
28 8 CheckAge(ageGyr);
29 6 return (5.44e-14 * 6.93 * std::exp(6.93 * ageGyr) + 8.38e-4) / 1e6;
30 }
31
32 775 LogPolynomialSfd NeukumProductionFunction() {
33 return LogPolynomialSfd({-3.076756, -3.557528, 0.781027, 1.021521, -0.156012, -0.444058,
34 0.019977, 0.086850, -0.005874, -0.006809, 8.25e-4, 5.54e-5},
35
2/2
✓ Branch 1 taken 775 times.
✓ Branch 4 taken 775 times.
2325 DiameterRange{10.0, 300000.0}, SfdKind::ProductionRate, 1000.0, 1e6);
36 }
37
38 748 SplicedSfd ExtendedNeukumProductionFunction() {
39 748 constexpr double kJoin = 10.0;
40 748 constexpr double kSlope = 2.85;
41
2/2
✓ Branch 1 taken 748 times.
✓ Branch 4 taken 748 times.
748 auto npf = std::make_shared<LogPolynomialSfd>(NeukumProductionFunction());
42
1/1
✓ Branch 2 taken 748 times.
748 const double coefficient = npf->Cumulative(kJoin) * std::pow(kJoin, kSlope);
43
1/1
✓ Branch 1 taken 748 times.
748 auto smallCraters = std::make_shared<PowerLawSfd>(coefficient, kSlope, SfdKind::ProductionRate);
44 1496 return SplicedSfd({{2.5, std::move(smallCraters)}, {kJoin, std::move(npf)}},
45
4/6
✓ Branch 1 taken 748 times.
✓ Branch 4 taken 748 times.
✓ Branch 7 taken 1496 times.
✓ Branch 8 taken 748 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
3740 DiameterRange{2.5, 300000.0});
46
0/4
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1496 }
47
48 } // namespace terraingen
49