Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
hft.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2020 W. Traylor <wolfgang.traylor@senckenberg.de>
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
11#ifndef FAUNA_HFT_H
12#define FAUNA_HFT_H
13
14#include <array>
15#include <cmath>
16#include <memory>
17#include <set>
18#include <stdexcept>
19#include <string>
20#include <utility>
21#include <vector>
22
23namespace Fauna {
24
25// forward declarations
26class Hft;
27class Parameters;
28
30
34typedef std::vector<std::shared_ptr<const Hft> > HftList;
35
37
47 AllometryParameters(const double coefficient, const double exponent)
49
52
54 double exponent;
55
57 double calc(const double M) const { return coefficient * pow(M, exponent); }
58};
59
61
74 double exponent;
75
78
80
87 double extrapolate(const double bodymass_male_adult,
88 const double bodymass) const;
89};
90
92
93enum class ConductanceModel {
96
98
100
102};
103
105enum class DietComposer {
108};
109
111enum class DigestiveLimit {
113 None,
114
116
161
163
168
171};
172
176
190
192
204
208
212
215 Zhu2018
216};
217
219enum class ForagingLimit {
221
236
238
255};
256
258
261enum class NetEnergyModel {
264};
265
267enum class MortalityFactor {
269
271
273
274 Lifespan,
275
277
279
282};
283
287 None,
291 Linear,
294};
295
297
310class Hft {
311 public:
313
317 bool is_valid(const Parameters& params, std::string& msg) const;
318
320
323 bool is_valid(const Parameters& params) const;
324
326 std::string name = "example";
327
330
336 double body_fat_birth = 0.2;
337
339
350
353
363 double body_fat_deviation = 0.125;
364
366
372
374
384 double body_fat_maximum = 0.25;
385
387
393
403
405
417 double body_mass_empty = 0.87;
418
420
428
430
437
439
449
451
453
460
462
476 std::array<double, 3> digestion_i_g_1992_ijk = {0.034, 3.565, 0.077};
477
480
485
488
490
498
500
511 double digestion_k_fat = 0.5;
512
514
522
530 std::pair<int, int> establishment_age_range = {1, 15};
531
538
549
551 std::set<ExpenditureComponent> expenditure_components = {
553
555
565
567 std::set<ForagingLimit> foraging_limits = {};
568
570
581
584
587
595
597 std::set<MortalityFactor> mortality_factors = {
600
603
605
608
610
617
620
622
628 std::array<double, 2> reproduction_logistic = {15.0, 0.3};
629
638
640
648 bool operator==(const Hft& rhs) const { return name == rhs.name; }
649 bool operator!=(const Hft& rhs) const { return name != rhs.name; }
650 bool operator<(const Hft& rhs) const { return name < rhs.name; } // Comparison
652
653 private:
655
661 std::ostream& msg) const;
662
664
669 bool check_intake_vs_expenditure(const Parameters& params,
670 std::ostream& msg) const;
671};
672
673} // namespace Fauna
674#endif // FAUNA_HFT_H
One herbivore functional type (i.e. one species).
Definition: hft.h:310
DietComposer foraging_diet_composer
Model defining the herbivore’s diet composition.
Definition: hft.h:564
double thermoregulation_core_temperature
Body core temperature [°C].
Definition: hft.h:641
double reproduction_annual_maximum
Maximum annual reproduction rate for females (0.0–∞)
Definition: hft.h:616
double mortality_minimum_density_threshold
Minimum viable density of one HFT population (all cohorts) [frac.].
Definition: hft.h:607
std::set< MortalityFactor > mortality_factors
Ways how herbivores can die.
Definition: hft.h:597
bool operator==(const Hft &rhs) const
Definition: hft.h:648
int body_mass_male
Live body mass [kg] of an adult male individual (with average reserves).
Definition: hft.h:431
int life_history_physical_maturity_male
Age of physical maturity in years for males.
Definition: hft.h:586
double body_fat_birth
Proportional fat mass at birth [kg lipids/kg empty body].
Definition: hft.h:336
bool is_valid(const Parameters &params, std::string &msg) const
Check if all variables are okay.
Definition: hft.cpp:192
int breeding_season_start
Julian day of the beginning of the breeding season (0=Jan 1st).
Definition: hft.h:444
std::string name
Unique name of the herbivore type.
Definition: hft.h:326
double digestion_me_coefficient
Metabolizable energy coefficient (ME/DE ratio) [fractional].
Definition: hft.h:497
GivenPointAllometry expenditure_basal_rate
Allometric parameters for basal metabolic rate (BMR).
Definition: hft.h:548
int body_mass_birth
Live body weight [kg] at birth for both sexes.
Definition: hft.h:402
double body_mass_empty
Fraction of live weight minus ingesta, blood, hair, and antlers/horns.
Definition: hft.h:417
double digestion_digestibility_multiplier
Factor to change ruminant digestibility for other digestion types.
Definition: hft.h:459
int life_history_lifespan
Maximum age in years [1–∞).
Definition: hft.h:580
double mortality_adult_rate
Annual background mortality rate [0.0–1.0) after first year of life.
Definition: hft.h:594
bool operator!=(const Hft &rhs) const
Definition: hft.h:649
double foraging_half_max_intake_density
Grass density [gDM/m²] where intake is half of its maximum.
Definition: hft.h:575
double body_fat_gross_energy
Conversion factor from fat mass to net energy [MJ/kg].
Definition: hft.h:371
double digestion_fixed_fraction
Definition: hft.h:484
double body_fat_maximum
Maximum proportional fat mass [kg lipids/kg empty body].
Definition: hft.h:384
std::pair< int, int > establishment_age_range
Youngest and oldest age [years] for herbivore establishment.
Definition: hft.h:530
double expenditure_fmr_multiplier
Constant factor to convert from BMR (basal rate) to FMR (field rate).
Definition: hft.h:559
std::array< double, 2 > reproduction_logistic
Growth rate and midpoint for the logistic reproduction model.
Definition: hft.h:628
int life_history_physical_maturity_female
Age of physical maturity in years for females.
Definition: hft.h:583
double body_fat_deviation
Definition: hft.h:363
bool check_mortality_vs_reproduction(const Parameters &params, std::ostream &msg) const
Check if minimum mortality exceeds maximum reproduction.
Definition: hft.cpp:34
ReproductionModel reproduction_model
Algorithm to calculate herbivore reproduction.
Definition: hft.h:631
DigestiveLimit digestion_limit
Constraint for maximum daily forage intake.
Definition: hft.h:487
int life_history_sexual_maturity
Age of female sexual maturity in years.
Definition: hft.h:589
bool operator<(const Hft &rhs) const
Definition: hft.h:650
std::array< double, 3 > digestion_i_g_1992_ijk
Constants i, j, k for DigestiveLimit::IlliusGordon1992 (grass only).
Definition: hft.h:476
GivenPointAllometry digestion_allometric
Parameters for DigestiveLimit::Allometric.
Definition: hft.h:450
double digestion_k_fat
Coefficient (k_f) for converting metabolizable energy to fat mass [frac.].
Definition: hft.h:511
ConductanceModel thermoregulation_conductance
Algorithm to calculate whole-body conductance for thermoregulation.
Definition: hft.h:636
std::set< ExpenditureComponent > expenditure_components
Energy expenditure components, summing up to actual expenditure.
Definition: hft.h:551
double body_fat_maximum_daily_gain
Maximum rate of fat mass gain in kg fat per kg body mass per day.
Definition: hft.h:388
double body_fat_catabolism_efficiency
Efficiency for converting body fat gross energy to net energy [frac.].
Definition: hft.h:349
double establishment_density
Total population density for establishment in one habitat [ind/km²].
Definition: hft.h:533
int breeding_season_length
Length of breeding season in days.
Definition: hft.h:436
bool check_intake_vs_expenditure(const Parameters &params, std::ostream &msg) const
Check if minimum expenditure exceeds maximum energy intake.
Definition: hft.cpp:87
NetEnergyModel digestion_net_energy_model
Algorithm for forage energy content.
Definition: hft.h:524
std::set< ForagingLimit > foraging_limits
Constraints for maximum daily forage procurement.
Definition: hft.h:567
bool mortality_shift_body_condition_for_starvation
Whether to shift mean cohort body condition on starvation mortality.
Definition: hft.h:611
double mortality_juvenile_rate
Annual background mortality rate [0.0–1.0) in the first year of life.
Definition: hft.h:602
int body_mass_female
Live body mass [kg] of an adult female individual (with average reserves).
Definition: hft.h:427
double digestion_k_maintenance
Coefficient (k_m) for converting metabolizable to net energy (NE) [frac.].
Definition: hft.h:521
int reproduction_gestation_length
Duration of pregnancy [number of months].
Definition: hft.h:619
Definition: average.h:16
MortalityFactor
One way how a herbivore can die.
Definition: hft.h:267
@ StarvationThreshold
Starvation death at a minimum bodyfat threshold.
@ Lifespan
A herbivore dies if its age exceeds Hft::life_history_lifespan.
@ Background
Independent background mortality for juveniles and adults.
@ StarvationIlliusOConnor2000
Starvation death following Illius & O’Connor (2000).
DigestiveLimit
Algorithm to calculate the daily digestive capacity of a herbivore.
Definition: hft.h:111
@ IlliusGordon1992
Limit digestive limit with get_digestive_limit_illius_gordon_1992().
@ None
No digestive limit.
@ Allometric
Dry-matter ingestion is limited to a fraction of live herbivore body mass.
@ FixedFraction
Dry-matter ingestion is limited to a fixed fraction of live body mass.
std::vector< std::shared_ptr< const Hft > > HftList
List of pointers to Hft objects.
Definition: world.h:28
ReproductionModel
Algorithm to calculate herbivore reproduction time and success.
Definition: hft.h:285
@ ConstantMaximum
Use class ReproductionConstMax for reproduction.
@ Linear
Use class ReproductionLinear for reproduction.
@ Logistic
Use class ReproductionLogistic to calculate reproduction.
ConductanceModel
Selector for a function of how to calculate whole-body conductance.
Definition: hft.h:93
@ CuylerOeritsland2004
Allometric formula extrapolating from reindeer fur conductivity.
ForagingLimit
A factor limiting a herbivore’s daily forage harvesting.
Definition: hft.h:219
@ GeneralFunctionalResponse
Type-II functional response applied “on top” of all other constraints.
@ IlliusOConnor2000
Foraging is limited by a functional response towards digestion limit.
DietComposer
Model to define a herbivore’s diet in a multi-forage scenario.
Definition: hft.h:105
@ PureGrazer
Eat exclusively grass.
NetEnergyModel
How forage net energy content is calculated.
Definition: hft.h:261
@ GrossEnergyFraction
Use get_net_energy_from_gross_energy().
ExpenditureComponent
Algorithm to calculate a herbivore’s daily energy needs.
Definition: hft.h:174
@ BasalMetabolicRate
Only the allometric basal metabolic rate.
@ FieldMetabolicRate
Allometric basal metabolic rate with FMR constant multiplier.
Coefficient and exponent for an allometric relationship.
Definition: hft.h:45
AllometryParameters(const double coefficient, const double exponent)
Constructor.
Definition: hft.h:47
double exponent
Exponent e in x=c*M^e.
Definition: hft.h:54
double calc(const double M) const
Calculate the result of the formula.
Definition: hft.h:57
double coefficient
Factor c in x=c*M^e.
Definition: hft.h:51
Parameters for an allometric relationship with exponent and one point.
Definition: hft.h:72
double value_male_adult
Value if is Hft::body_mass_male.
Definition: hft.h:77
double extrapolate(const double bodymass_male_adult, const double bodymass) const
Calculate the value for a different body mass.
Definition: hft.cpp:20
double exponent
Exponent in .
Definition: hft.h:74
Parameters for the herbivory module.
Definition: parameters.h:65