FireSTARR
Loading...
Searching...
No Matches
SimpleFuelType.h
1/* SPDX-License-Identifier: AGPL-3.0-or-later */
2#ifndef FS_SIMPLE_FUELTYPE_H
3#define FS_SIMPLE_FUELTYPE_H
4#include "stdafx.h"
5#include "FuelType.h"
6namespace fs::simplefbp
7{
8using SimpleFuelType = fs::FuelType;
15template <int BulkDensity, int InorganicPercent, int DuffDepth>
17{
18public:
19 ~SimpleFuelBase() override = default;
28 constexpr SimpleFuelBase(
29 const FuelCodeSize& code,
30 const char* name,
31 const bool can_crown,
32 const Duff* duff_ffmc,
33 const Duff* duff_dmc
34 )
35 : FuelType(code, name, can_crown), duff_ffmc_(duff_ffmc), duff_dmc_(duff_dmc)
36 { }
37 SimpleFuelBase(SimpleFuelBase&& rhs) noexcept = delete;
38 SimpleFuelBase(const SimpleFuelBase& rhs) = delete;
39 SimpleFuelBase& operator=(SimpleFuelBase&& rhs) noexcept = delete;
40 SimpleFuelBase& operator=(const SimpleFuelBase& rhs) = delete;
44 [[nodiscard]] bool isValid() const override { return true; }
51 [[nodiscard]] MathSize crownFractionBurned(const MathSize rss, const MathSize rso)
52 const noexcept override
53 {
54 // can't burn crown if it doesn't exist
55 return cfl() > 0 ? max(0.0, 1.0 - exp(-0.230 * (rss - rso))) : 0.0;
56 }
62 [[nodiscard]] ThresholdSize probabilityPeat(const MathSize mc_fraction) const noexcept override
63 {
64 // Anderson table 1
65 constexpr auto pb = bulkDensity();
66 // Anderson table 1
67 constexpr auto fi = inorganicPercent();
68 constexpr auto pi = fi * pb;
69 // Inorganic ratio
70 constexpr auto ri = fi / (1 - fi);
71 constexpr auto const_part = -19.329 + 1.7170 * ri + 23.059 * pi;
72 // Anderson eq 1
73 return 1 / (1 + exp(17.047 * mc_fraction / (1 - fi) + const_part));
74 }
81 [[nodiscard]] ThresholdSize survivalProbability(const FwiWeather& wx) const noexcept override
82 {
83 // divide by 100 since we need moisture ratio
84 // IFERROR(((1 / (1 + EXP($G$43 + $I$43 *
85 // (Q$44 * $O$43 + $N$43)))) -
86 // (1 / (1 + EXP($G$43 + $I$43 * (2.5 * $O$43 + $N$43)))))
87 // / (1 / (1 + EXP($G$43 + $I$43 * $N$43))), 0)
88 // HACK: use same constants for all fuels because they seem to work nicer than
89 // using the ratios, but they change anyway because of the other fuel attributes
90 static const auto WFfmc = 0.25;
91 static const auto WDmc = 1.0;
92 static const auto RatioHartford = 0.5;
93 static const auto RatioFrandsen = 1.0 - RatioHartford;
94 static const auto RatioAspen = 0.5;
95 static const auto RatioFuel = 1.0 - RatioAspen;
96 const auto mc_ffmc = wx.mcFfmc() * WFfmc + WDmc;
97 static const auto McFfmcSaturated = 2.5 * WFfmc + WDmc;
98 static const auto McDmc = WDmc;
99 const auto prob_ffmc_peat = probabilityPeat(mc_ffmc);
100 const auto prob_ffmc_peat_saturated = probabilityPeat(McFfmcSaturated);
101 const auto prob_ffmc_peat_zero = probabilityPeat(McDmc);
102 const auto prob_ffmc_peat_weighted =
103 (prob_ffmc_peat - prob_ffmc_peat_saturated) / prob_ffmc_peat_zero;
104 const auto prob_ffmc = duffFfmcType()->probabilityOfSurvival(mc_ffmc * 100);
105 const auto prob_ffmc_saturated = duffFfmcType()->probabilityOfSurvival(McFfmcSaturated * 100);
106 const auto prob_ffmc_zero = duffFfmcType()->probabilityOfSurvival(McDmc);
107 const auto prob_ffmc_weighted = (prob_ffmc - prob_ffmc_saturated) / prob_ffmc_zero;
108 const auto term_otway = exp(-3.11 + 0.12 * wx.dmc.value);
109 const auto prob_otway = term_otway / (1 + term_otway);
110 const auto mc_pct = wx.mcDmcPct() * dmcRatio() + wx.mcFfmcPct() * ffmcRatio();
111 const auto prob_weight_ffmc = duffFfmcType()->probabilityOfSurvival(mc_pct);
112 const auto prob_weight_ffmc_peat = probabilityPeat(mc_pct / 100);
113 const auto prob_weight_dmc = duffDmcType()->probabilityOfSurvival(wx.mcDmcPct());
114 const auto prob_weight_dmc_peat = probabilityPeat(wx.mcDmc());
115 // chance of survival is 1 - chance of it not surviving in every fuel
116 const auto tot_prob =
117 1
118 - (1 - prob_ffmc_peat_weighted) * (1 - prob_ffmc_weighted)
119 * ((1 - prob_otway) * RatioAspen + ((1 - prob_weight_ffmc_peat) * RatioHartford + (1 - prob_weight_ffmc) * RatioFrandsen) * ((1 - prob_weight_dmc_peat) * RatioHartford + (1 - prob_weight_dmc) * RatioFrandsen) * RatioFuel);
120 return tot_prob;
121 }
126 [[nodiscard]] static constexpr MathSize bulkDensity() { return BulkDensity / 1000.0; }
131 [[nodiscard]] static constexpr MathSize inorganicPercent() { return InorganicPercent / 100.0; }
136 [[nodiscard]] static constexpr MathSize duffDepth() { return DuffDepth / 10.0; }
141 [[nodiscard]] constexpr const Duff* duffDmcType() const { return duff_dmc_; }
146 [[nodiscard]] constexpr const Duff* duffFfmcType() const { return duff_ffmc_; }
151 [[nodiscard]] static constexpr MathSize ffmcRatio() { return 1 - dmcRatio(); }
156 [[nodiscard]] static constexpr MathSize dmcRatio()
157 {
158 return (duffDepth() - DUFF_FFMC_DEPTH) / duffDepth();
159 }
160
161private:
165 const Duff* duff_ffmc_{nullptr};
169 const Duff* duff_dmc_{nullptr};
170};
174class InvalidFuel final : public FuelType
175{
176public:
177 InvalidFuel() noexcept : InvalidFuel(0, nullptr) { }
183 constexpr InvalidFuel(const FuelCodeSize& code, const char* name) noexcept
184 : FuelType(code, name, false)
185 { }
186 ~InvalidFuel() override = default;
187 InvalidFuel(const InvalidFuel& rhs) noexcept = delete;
188 InvalidFuel(InvalidFuel&& rhs) noexcept = delete;
189 InvalidFuel& operator=(const InvalidFuel& rhs) noexcept = delete;
190 InvalidFuel& operator=(InvalidFuel&& rhs) noexcept = delete;
194 [[nodiscard]] bool isValid() const override { return false; }
199 [[nodiscard]] MathSize grass_curing(const int nd, const FwiWeather& wx) const override;
204 [[nodiscard]] MathSize cbh() const override;
209 [[nodiscard]] MathSize cfl() const override;
214 [[nodiscard]] MathSize buiEffect(MathSize) const override;
219 [[nodiscard]] MathSize crownConsumption(MathSize) const override;
224 [[nodiscard]] MathSize calculateRos(int, const FwiWeather&, MathSize) const override;
229 [[nodiscard]] MathSize calculateIsf(const SpreadInfo&, MathSize) const override;
234 [[nodiscard]] MathSize surfaceFuelConsumption(const SpreadInfo&) const override;
239 [[nodiscard]] MathSize lengthToBreadth(MathSize) const override;
244 [[nodiscard]] MathSize finalRos(const SpreadInfo&, MathSize, MathSize, MathSize) const override;
249 [[nodiscard]] MathSize criticalSurfaceIntensity(const SpreadInfo&) const override;
254 [[nodiscard]] MathSize crownFractionBurned(MathSize, MathSize) const noexcept override;
259 [[nodiscard]] ThresholdSize probabilityPeat(MathSize) const noexcept override;
264 [[nodiscard]] ThresholdSize survivalProbability(const FwiWeather&) const noexcept override;
265};
266}
267#endif
An FBP fuel type.
Definition FuelType.h:42
constexpr FuelCodeSize code() const
Code for this fuel type.
Definition FuelType.h:212
virtual MathSize cfl() const =0
Crown fuel load (kg/m^2) [ST-X-3 table 8].
constexpr const char * name() const
Name of the fuel.
Definition FuelType.h:207
constexpr FuelType(const FuelCodeSize &code, const char *name, const bool can_crown) noexcept
Fuel type.
Definition FuelType.h:98
Information regarding spread within a Cell for a specific Scenario and time.
Definition FireSpread.h:40
Placeholder fuel that throws exceptions if it ever gets used.
Definition SimpleFuelType.h:175
MathSize calculateRos(int, const FwiWeather &, MathSize) const override
Throw a runtime_error.
MathSize buiEffect(MathSize) const override
Throw a runtime_error.
MathSize crownFractionBurned(MathSize, MathSize) const noexcept override
Throw a runtime_error.
MathSize lengthToBreadth(MathSize) const override
Throw a runtime_error.
constexpr InvalidFuel(const FuelCodeSize &code, const char *name) noexcept
Placeholder fuel that throws exceptions if it ever gets used.
Definition SimpleFuelType.h:183
MathSize grass_curing(const int nd, const FwiWeather &wx) const override
Throw a runtime_error.
MathSize cbh() const override
Throw a runtime_error.
ThresholdSize survivalProbability(const FwiWeather &) const noexcept override
Throw a runtime_error.
MathSize finalRos(const SpreadInfo &, MathSize, MathSize, MathSize) const override
Throw a runtime_error.
MathSize crownConsumption(MathSize) const override
Throw a runtime_error.
MathSize surfaceFuelConsumption(const SpreadInfo &) const override
Throw a runtime_error.
ThresholdSize probabilityPeat(MathSize) const noexcept override
Throw a runtime_error.
MathSize cfl() const override
Throw a runtime_error.
bool isValid() const override
Is fuel a valid fuel type.
Definition SimpleFuelType.h:194
MathSize criticalSurfaceIntensity(const SpreadInfo &) const override
Throw a runtime_error.
MathSize calculateIsf(const SpreadInfo &, MathSize) const override
Throw a runtime_error.
Base class for all FuelTypes.
Definition SimpleFuelType.h:17
static constexpr MathSize ffmcRatio()
What fraction of the duff layer should use FFMC to determine moisture.
Definition SimpleFuelType.h:151
bool isValid() const override
Is fuel a valid fuel type.
Definition SimpleFuelType.h:44
static constexpr MathSize bulkDensity()
Duff Bulk Density (kg/m^3) [Anderson table 1].
Definition SimpleFuelType.h:126
constexpr SimpleFuelBase(const FuelCodeSize &code, const char *name, const bool can_crown, const Duff *duff_ffmc, const Duff *duff_dmc)
Constructor.
Definition SimpleFuelType.h:28
ThresholdSize survivalProbability(const FwiWeather &wx) const noexcept override
Survival probability calculated using probability of ony survival based on multiple formulae.
Definition SimpleFuelType.h:81
static constexpr MathSize dmcRatio()
What fraction of the duff layer should use DMC to determine moisture.
Definition SimpleFuelType.h:156
const Duff * duff_dmc_
Type of duff deeper underground.
Definition SimpleFuelType.h:169
MathSize crownFractionBurned(const MathSize rss, const MathSize rso) const noexcept override
Crown Fraction Burned (CFB) [ST-X-3 eq 58].
Definition SimpleFuelType.h:51
static constexpr MathSize inorganicPercent()
Inorganic Percent (% / 100) [Anderson table 1].
Definition SimpleFuelType.h:131
const Duff * duff_ffmc_
Type of duff near the surface.
Definition SimpleFuelType.h:165
constexpr const Duff * duffFfmcType() const
Type of duff near the surface.
Definition SimpleFuelType.h:146
ThresholdSize probabilityPeat(const MathSize mc_fraction) const noexcept override
Calculate probability of burning [Anderson eq 1].
Definition SimpleFuelType.h:62
static constexpr MathSize duffDepth()
DuffDepth Depth of Duff layer (cm) [Anderson table 1].
Definition SimpleFuelType.h:136
constexpr const Duff * duffDmcType() const
Type of duff deeper underground.
Definition SimpleFuelType.h:141
A Weather value with calculated FWI indices.
Definition FWI.h:142
A specific type of Duff layer, and the associated smouldering coefficients.
Definition Duff.h:40
ThresholdSize probabilityOfSurvival(const MathSize mc_pct) const noexcept
Probability of survival (% / 100) [eq Ig-1].
Definition Duff.h:70