./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
33 / 33
100.0%
Branches:
27 / 38
71.1%
Functions:
8 / 8
100.0%

src/layers/craters/degradation/diffusivities.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 #include "terraingen/layers/craters/degradation/diffusivities.h"
4
5 #include <cmath>
6 #include <stdexcept>
7 #include <utility>
8
9 namespace terraingen {
10
11 3 PowerLawDiffusivity FassettThomson2014Diffusivity() {
12 3 return {5.5, 0.0, 0.0};
13 }
14
15 28 PowerLawDiffusivity Fassett2022HartmannDiffusivity() {
16 28 return {3.6, 0.87, 5.0};
17 }
18
19 4 PowerLawDiffusivity Fassett2022TraskDiffusivity() {
20 4 return {3.1, 1.05, 5.0};
21 }
22
23 5 double FassettThomson2014DiffusionAge(double ageGyr) {
24 5 const double t = ageGyr;
25 5 const double kappaT =
26 5 (((435.83 * t - 3621.2) * t + 11204.0) * t - 16811.0) * t * t + 17546.0 * t;
27 5 return std::fmax(0.0, kappaT);
28 }
29
30 191 DiffusionAgeModel EquilibriumDiffusionAges(std::shared_ptr<const DiffusedProfile> profile,
31 FreshMorphometry fresh,
32 std::function<double(double)> lifetimeGyr,
33 double cutoffDepthRatio) {
34
6/6
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 188 times.
191 if (!profile || !fresh || !lifetimeGyr) {
35 3 throw std::invalid_argument(
36
1/1
✓ Branch 2 taken 3 times.
3 "Equilibrium diffusion ages need a diffused profile, fresh morphometry and lifetimes");
37 }
38
3/4
✓ Branch 0 taken 188 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 187 times.
188 if (!(cutoffDepthRatio > 0.0 && cutoffDepthRatio < 1.0)) {
39
1/1
✓ Branch 2 taken 1 time.
1 throw std::invalid_argument("A visibility depth ratio must be in (0, 1)");
40 }
41
2/4
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
561 return [profile = std::move(profile), fresh = std::move(fresh),
42 lifetimeGyr = std::move(lifetimeGyr),
43 cutoffDepthRatio](double diameter, double ageGyr) {
44 73596 const double cut = profile->AgeAtDepthRatio(fresh(diameter), diameter, cutoffDepthRatio);
45 73670 return cut * diameter * diameter * ageGyr / lifetimeGyr(diameter);
46
1/1
✓ Branch 1 taken 187 times.
374 };
47 }
48
49 185 DiffusionAgeModel EquilibriumDiffusionAges(std::shared_ptr<const DiffusedProfile> profile,
50 FreshMorphometry fresh,
51 std::shared_ptr<const SteadyStateAges> ages,
52 double cutoffDepthRatio) {
53
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 184 times.
185 if (!ages) {
54
1/1
✓ Branch 2 taken 1 time.
1 throw std::invalid_argument("Equilibrium diffusion ages need steady-state ages");
55 }
56
1/1
✓ Branch 1 taken 184 times.
184 return EquilibriumDiffusionAges(
57 std::move(profile), std::move(fresh),
58
2/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 284 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
668 [ages = std::move(ages)](double diameter) {
59 73601 return ages->EquilibriumLifetimeGyr(diameter);
60 },
61
3/4
✓ Branch 1 taken 184 times.
✓ Branch 4 taken 184 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 184 times.
552 cutoffDepthRatio);
62 }
63
64 std::shared_ptr<const DiffusionDegradation>
65 84 MatchedDiffusionDegradation(std::shared_ptr<const DiffusedProfile> profile, FreshMorphometry fresh,
66 std::shared_ptr<const SteadyStateAges> ages) {
67
3/6
✓ Branch 1 taken 84 times.
✓ Branch 4 taken 84 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
252 DiffusionAgeModel diffusion = EquilibriumDiffusionAges(profile, fresh, std::move(ages));
68
1/1
✓ Branch 1 taken 84 times.
84 return std::make_shared<DiffusionDegradation>(std::move(fresh), std::move(diffusion),
69 84 std::move(profile));
70 84 }
71
72 } // namespace terraingen
73