Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
herbivore_base.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_HERBIVORE_BASE_H
12#define FAUNA_HERBIVORE_BASE_H
13
14#include <memory>
15#include "breeding_season.h"
16#include "environment.h"
18#include "get_forage_demands.h"
19#include "herbivore_data.h"
20#include "herbivore_interface.h"
21
22namespace Fauna {
23
25enum class Sex { Female, Male };
26
28
32 public:
33 // -------- HerbivoreInterface ----------
34 virtual void eat(const ForageMass& kg_per_km2,
35 const Digestibility& digestibility,
36 const ForageMass& N_kg_per_km2);
37 virtual ForageMass get_forage_demands(const HabitatForage& available_forage);
38 virtual std::string get_output_group() const;
39 virtual double get_kg_per_km2() const;
41 return current_output;
42 }
43 virtual void simulate_day(const int day,
45 double& offspring);
46
47 public:
49 int get_age_days() const { return age_days; }
50
52 double get_age_years() const { return age_days / 365.0; }
53
55
64 double get_bodyfat() const;
65
67
84 virtual double get_bodymass() const;
85
87
91 double get_bodymass_adult() const;
92
94
98 double get_conductance() const;
99
101
104 double get_fatmass() const;
105
107 const Hft& get_hft() const {
108 assert(hft);
109 return *hft;
110 }
111
113
128 double get_max_fatmass() const;
129
131
156 double get_structural_mass() const;
157
159
161 int get_today() const;
162
164 Sex get_sex() const { return sex; }
165
166 protected:
168
179 HerbivoreBase(const int age_days, const double body_condition,
180 std::shared_ptr<const Hft> hft, const Sex sex,
182
184
192 HerbivoreBase(std::shared_ptr<const Hft> hft, const Sex sex,
194
196 virtual ~HerbivoreBase() = default;
197
199
204 virtual void apply_mortality(const double mortality) = 0;
205
208
211
213
218
221
223 bool constant_members_match(const HerbivoreBase& other) const {
224 return sex == other.sex && hft.get() == other.hft.get() &&
227 }
228
229 private: // private member functions
231
237
239
245 std::shared_ptr<const Hft> check_hft_pointer(std::shared_ptr<const Hft>);
246
248
258
260
262 double get_todays_expenditure() const;
263
265
273 double get_todays_offspring_proportion() const;
274
275 private:
277 // pointer to const Hft; initialized first!
278 const std::shared_ptr<const Hft> hft;
279 const Sex sex;
283
287 HabitatEnvironment environment; // set in simulate_day()
288 int today; // state variables
290
293
297
301};
302
303} // namespace Fauna
304#endif // FAUNA_HERBIVORE_BASE_H
Determine erbivore breeding season.
Helper class for reproduction within a breeding season.
Definition: breeding_season.h:17
A herbivore’s energy budget with fat reserves.
Definition: fatmass_energy_budget.h:23
Function object to calculate forage demands for a herbivore.
Definition: get_forage_demands.h:26
All values for large herbivore forage in a Habitat.
Definition: habitat_forage.h:21
Abstract base class for herbivores.
Definition: herbivore_base.h:31
double get_bodymass_adult() const
Body mass at physical maturity [kg/ind].
Definition: herbivore_base.cpp:218
bool constant_members_match(const HerbivoreBase &other) const
Check whether the constant member variables match those of another object.
Definition: herbivore_base.h:223
double get_structural_mass() const
Current mass of body tissue without fat, ingesta, blood, etc. [kg/ind].
Definition: herbivore_base.cpp:306
Sex get_sex() const
The sex of the herbivore.
Definition: herbivore_base.h:164
virtual double get_bodymass() const
Current live weight, including fat, ingesta, blood, etc. [kg/ind].
Definition: herbivore_base.cpp:214
double get_todays_offspring_proportion() const
Get the proportional offspring for today using selected model.
Definition: herbivore_base.cpp:404
ForageEnergyContent get_net_energy_content(Digestibility digestibility) const
Get forage energy content [MJ/kgDM] using selected net energy model.
Definition: herbivore_base.cpp:284
virtual ForageMass get_forage_demands(const HabitatForage &available_forage)
Get the forage the herbivore would like to eat today.
Definition: herbivore_base.cpp:244
double get_todays_expenditure() const
Calculate energy expenditure as sum of given expenditure components.
Definition: herbivore_base.cpp:347
virtual void simulate_day(const int day, const HabitatEnvironment &environment, double &offspring)
Simulate daily events.
Definition: herbivore_base.cpp:445
int get_age_days() const
Current age in days.
Definition: herbivore_base.h:49
virtual std::string get_output_group() const
The name of the HFT for aggregating output.
Definition: herbivore_base.cpp:304
double get_age_years() const
Current age in years.
Definition: herbivore_base.h:52
const Sex sex
Definition: herbivore_base.h:279
FatmassEnergyBudget & get_energy_budget()
The herbivore’s energy budget object.
Definition: herbivore_base.h:207
int today
Definition: herbivore_base.h:288
void apply_mortality_factors_today()
Calculate mortality according to user-selected mortality factors.
Definition: herbivore_base.cpp:79
FatmassEnergyBudget energy_budget
Definition: herbivore_base.h:286
HabitatEnvironment environment
Definition: herbivore_base.h:287
const Hft & get_hft() const
The herbivore functional type (HFT).
Definition: herbivore_base.h:107
std::shared_ptr< const Hft > check_hft_pointer(std::shared_ptr< const Hft >)
Check whether the HFT pointer is NULL and throws an exception.
Definition: herbivore_base.cpp:199
virtual void apply_mortality(const double mortality)=0
Apply a fractional mortality.
int age_days
Definition: herbivore_base.h:285
const HabitatEnvironment & get_environment() const
Current abiotic conditions in the habitat.
Definition: herbivore_base.h:217
const std::shared_ptr< const Hft > hft
Definition: herbivore_base.h:278
Output::HerbivoreData current_output
Definition: herbivore_base.h:298
virtual void eat(const ForageMass &kg_per_km2, const Digestibility &digestibility, const ForageMass &N_kg_per_km2)
Feed the herbivore dry matter forage.
Definition: herbivore_base.cpp:155
Output::HerbivoreData & get_todays_output()
Class-internal read/write access to current output.
Definition: herbivore_base.h:220
const ForageEnergyContent forage_gross_energy
Definition: herbivore_base.h:281
virtual const Output::HerbivoreData & get_todays_output() const
Read current output.
Definition: herbivore_base.h:40
GetForageDemands get_forage_demands_per_ind
Definition: herbivore_base.h:299
double get_max_fatmass() const
Physiological maximum of fat mass [kg/ind].
Definition: herbivore_base.cpp:279
PeriodAverage body_condition_gestation
Definition: herbivore_base.h:296
double get_fatmass() const
Current fat mass (pure lipids) [kg/ind].
Definition: herbivore_base.cpp:240
double get_bodyfat() const
Proportional body fat in empty body (fat mass/empty body mass).
Definition: herbivore_base.cpp:210
virtual double get_kg_per_km2() const
Get herbivore biomass density [kg/km²].
Definition: herbivore_base.cpp:275
int get_today() const
Current day of the year, as set in simulate_day().
Definition: herbivore_base.cpp:337
double get_conductance() const
Get full-body conductance [W/°C/ind].
Definition: herbivore_base.cpp:225
const FatmassEnergyBudget & get_energy_budget() const
The herbivore’s energy budget object.
Definition: herbivore_base.h:210
virtual ~HerbivoreBase()=default
Virtual destructor, which will be called by derived classes.
const BreedingSeason breeding_season
Definition: herbivore_base.h:280
One herbivore functional type (i.e. one species).
Definition: hft.h:310
Average of a double value over a given time period.
Definition: average.h:44
Classes for abiotic conditions for herbivores.
Herbivore energy model with fat reserves and anabolism/catabolism.
Helper class to determine how much an herbivore wants to eat.
Herbivore output data.
Pure abstract class to derive any kind of herbivore from.
Definition: average.h:16
Sex
The sex of a herbivore.
Definition: herbivore_base.h:25
Variables describing the habitat that are not forage ⇒ abiotic environment.
Definition: environment.h:16
Interface for any herbivore implementation in the model.
Definition: herbivore_interface.h:35
Herbivore output data for one time unit.
Definition: herbivore_data.h:22