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 | 191 | if (!profile || !fresh || !lifetimeGyr) { | |
| 35 | 3 | throw std::invalid_argument( | |
| 36 | 3 | "Equilibrium diffusion ages need a diffused profile, fresh morphometry and lifetimes"); | |
| 37 | } | ||
| 38 | 188 | if (!(cutoffDepthRatio > 0.0 && cutoffDepthRatio < 1.0)) { | |
| 39 | 1 | throw std::invalid_argument("A visibility depth ratio must be in (0, 1)"); | |
| 40 | } | ||
| 41 | 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 | 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 | 185 | if (!ages) { | |
| 54 | 1 | throw std::invalid_argument("Equilibrium diffusion ages need steady-state ages"); | |
| 55 | } | ||
| 56 | 184 | return EquilibriumDiffusionAges( | |
| 57 | std::move(profile), std::move(fresh), | ||
| 58 | 668 | [ages = std::move(ages)](double diameter) { | |
| 59 | 73601 | return ages->EquilibriumLifetimeGyr(diameter); | |
| 60 | }, | ||
| 61 | 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 | 252 | DiffusionAgeModel diffusion = EquilibriumDiffusionAges(profile, fresh, std::move(ages)); | |
| 68 | 84 | return std::make_shared<DiffusionDegradation>(std::move(fresh), std::move(diffusion), | |
| 69 | 84 | std::move(profile)); | |
| 70 | 84 | } | |
| 71 | |||
| 72 | } // namespace terraingen | ||
| 73 |