FireSTARR
Loading...
Searching...
No Matches
Duff.h
1/* Copyright (c) Queen's Printer for Ontario, 2020. */
2/* Copyright (c) His Majesty the King in Right of Canada as represented by the Minister of Natural Resources, 2025. */
3
4/* SPDX-License-Identifier: AGPL-3.0-or-later */
5
6#pragma once
7#include "LookupTable.h"
8namespace fs::fuel
9{
37template <int Ash, int Rho, int B0, int B1, int B2, int B3>
38class DuffType;
42class Duff
43{
44public:
45 virtual ~Duff() = default;
46 Duff(const Duff& rhs) noexcept = delete;
47 Duff(Duff&& rhs) noexcept = delete;
48 Duff& operator=(const Duff& rhs) noexcept = delete;
49 Duff& operator=(Duff&& rhs) noexcept = delete;
55 [[nodiscard]] constexpr bool operator==(const Duff& rhs) const
56 {
57 // HACK: only equivalent if identical
58 return this == &rhs;
59 }
65 [[nodiscard]] constexpr bool operator!=(const Duff& rhs) const
66 {
67 return !operator==(rhs);
68 }
74 [[nodiscard]] virtual ThresholdSize probabilityOfSurvival(MathSize mc_pct) const noexcept = 0;
75 // /**
76 // * \brief Feather moss (upper) [Frandsen table 2/3]
77 // */
78 // static const DuffType<172, 464, 139873, -3296, 4904, 568> FeatherMossUpper;
79 // /**
80 // * \brief Feather moss (lower) [Frandsen table 2/3]
81 // */
82 // static const DuffType<191, 389, 132628, -1167, 3308, -2604> FeatherMossLower;
86 static const DuffType<124, 218, -88306, -608, 8095, 2735> SphagnumUpper;
87 // /**
88 // * \brief Sphagnum (lower) [Frandsen table 2/3]
89 // */
90 // static const DuffType<567, 1190, 3273347, -37655, -87849, 26684> SphagnumLower;
94 static const DuffType<181, 427, 90970, -1040, 1165, -646> FeatherMoss;
98 static const DuffType<261, 563, 80359, -393, -591, -340> Reindeer;
99 // /**
100 // * \brief Sedge meadow (upper) [Frandsen table 2/3]
101 // */
102 // static const DuffType<233, 694, 398477, -1800, -3727, -1874> SedgeMeadowUpper;
103 // /**
104 // * \brief Sedge meadow (lower) [Frandsen table 2/3]
105 // */
106 // static const DuffType<449, 915, 290818, -2059, -2319, -420> SedgeMeadowLower;
110 static const DuffType<359, 1220, 3325604, -12220, -21024, -12619> WhiteSpruce;
114 static const DuffType<94, 2220, -198198, -1169, 10414, 782> Peat;
118 static const DuffType<349, 2030, 372276, -1876, -2833, -951> PeatMuck;
119 // /**
120 // * \brief Sedge meadow (Seney) [Frandsen table 2/3]
121 // */
122 // static const DuffType<354, 1830, 71813, -1413, -1253, 390> SedgeMeadowSeney;
126 static const DuffType<365, 1900, 451778, -3227, -3644, -362> PineSeney;
130 static const DuffType<307, 1160, 586921, -2737, -5413, -1246> SprucePine;
131 // /**
132 // * \brief Grass/sedge marsh [Frandsen table 2/3]
133 // */
134 // static const DuffType<352, 1200, 2362934, -8423, -25097, -4902> GrassSedgeMarsh;
135 // /**
136 // * \brief Southern pine duff [Frandsen table 2/3]
137 // */
138 // static const DuffType<680, 1120, 586921, -2737, -5413, -1246> SouthernPine;
139 // /**
140 // * \brief Hardwood swamp (upper) [Frandsen table 2/3]
141 // */
142 // static const DuffType<182, 1380, 336907, -2946, -3002, -4040> HardwoodSwamp;
143 // coefficients aren't defined in the table these came from
144 // static const DuffType Pocosin;
145 // static const DuffType SwampForest;
146 // static const DuffType Flatwoods;
147protected:
148 Duff() = default;
149};
153template <int Ash, int Rho, int B0, int B1, int B2, int B3>
154class DuffType final
155 : public Duff
156{
157public:
158 DuffType() = default;
159 ~DuffType() override = default;
160 DuffType(const DuffType& rhs) noexcept = delete;
161 DuffType(DuffType&& rhs) noexcept = delete;
162 DuffType& operator=(const DuffType& rhs) noexcept = delete;
163 DuffType& operator=(DuffType&& rhs) noexcept = delete;
169 [[nodiscard]] ThresholdSize probabilityOfSurvival(const MathSize mc_pct) const noexcept override
170 {
171 return probability_of_survival_(mc_pct);
172 }
177 [[nodiscard]] static constexpr MathSize ash()
178 {
179 return Ash / 10.0;
180 }
185 [[nodiscard]] static constexpr MathSize rho()
186 {
187 return Rho / 10.0;
188 }
193 [[nodiscard]] static constexpr MathSize b0()
194 {
195 return B0 / 10000.0;
196 }
201 [[nodiscard]] static constexpr MathSize b1()
202 {
203 return B1 / 10000.0;
204 }
209 [[nodiscard]] static constexpr MathSize b2()
210 {
211 return B2 / 10000.0;
212 }
217 [[nodiscard]] static constexpr MathSize b3()
218 {
219 return B3 / 10000.0;
220 }
221private:
225 static constexpr auto ConstantPart = b0() + b2() * ash() + b3() * rho();
231 [[nodiscard]] static ThresholdSize
232 duffFunction(const MathSize mc_pct) noexcept
233 {
234 const auto d = 1 + exp(-(b1() * mc_pct + ConstantPart));
235 if (0 == d)
236 {
237 return 1.0;
238 }
239 return 1.0 / d;
240 }
247};
248}
A specific type of Duff layer, and the associated smouldering coefficients.
Definition Duff.h:156
static ThresholdSize duffFunction(const MathSize mc_pct) noexcept
Ignition Probability (% / 100) [eq Ig-1].
Definition Duff.h:232
static constexpr MathSize b0()
B_0 [table 2].
Definition Duff.h:193
static constexpr MathSize rho()
Organic bulk density (kg/m^3)
Definition Duff.h:185
static constexpr MathSize b1()
B_1 [table 2].
Definition Duff.h:201
static constexpr MathSize ash()
Inorganic content, percentage oven dry weight.
Definition Duff.h:177
ThresholdSize probabilityOfSurvival(const MathSize mc_pct) const noexcept override
Probability of survival (% / 100) [eq Ig-1].
Definition Duff.h:169
static constexpr MathSize b2()
B_2 [table 2].
Definition Duff.h:209
util::LookupTable<&duffFunction > probability_of_survival_
Ignition Probability (% / 100) [eq Ig-1].
Definition Duff.h:246
static constexpr MathSize b3()
B_3 [table 2].
Definition Duff.h:217
static constexpr auto ConstantPart
Constant part of ignition probability equation [eq Ig-1].
Definition Duff.h:225
Base class for DuffType.
Definition Duff.h:43
static const DuffType< 94, 2220, -198198, -1169, 10414, 782 > Peat
Peat [Frandsen table 2/3].
Definition Duff.h:114
constexpr bool operator!=(const Duff &rhs) const
Inequality operator.
Definition Duff.h:65
static const DuffType< 359, 1220, 3325604, -12220, -21024, -12619 > WhiteSpruce
Sedge meadow (upper) [Frandsen table 2/3].
Definition Duff.h:110
static const DuffType< 349, 2030, 372276, -1876, -2833, -951 > PeatMuck
Peat muck [Frandsen table 2/3].
Definition Duff.h:118
constexpr bool operator==(const Duff &rhs) const
Equality operator.
Definition Duff.h:55
Duff()=default
Grass/sedge marsh [Frandsen table 2/3].
virtual ThresholdSize probabilityOfSurvival(MathSize mc_pct) const noexcept=0
Survival probability calculated using probability of ony survival based on multiple formulae.
static const DuffType< 365, 1900, 451778, -3227, -3644, -362 > PineSeney
Sedge meadow (Seney) [Frandsen table 2/3].
Definition Duff.h:126
static const DuffType< 181, 427, 90970, -1040, 1165, -646 > FeatherMoss
Sphagnum (lower) [Frandsen table 2/3].
Definition Duff.h:94
static const DuffType< 307, 1160, 586921, -2737, -5413, -1246 > SprucePine
Spruce/pine duff [Frandsen table 2/3].
Definition Duff.h:130
static const DuffType< 124, 218, -88306, -608, 8095, 2735 > SphagnumUpper
Feather moss (upper) [Frandsen table 2/3].
Definition Duff.h:86
static const DuffType< 261, 563, 80359, -393, -591, -340 > Reindeer
Reindeer/feather [Frandsen table 2/3].
Definition Duff.h:98
A table initialized using the given function ranging over the number of digits and precision.
Definition LookupTable.h:20