|
Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
|
Abstract base class for herbivores. More...
#include <herbivore_base.h>
Public Member Functions | |
| virtual void | eat (const ForageMass &kg_per_km2, const Digestibility &digestibility, const ForageMass &N_kg_per_km2) |
| Feed the herbivore dry matter forage. More... | |
| virtual ForageMass | get_forage_demands (const HabitatForage &available_forage) |
| Get the forage the herbivore would like to eat today. More... | |
| virtual std::string | get_output_group () const |
| The name of the HFT for aggregating output. More... | |
| virtual double | get_kg_per_km2 () const |
| Get herbivore biomass density [kg/km²]. More... | |
| virtual const Output::HerbivoreData & | get_todays_output () const |
| Read current output. More... | |
| virtual void | simulate_day (const int day, const HabitatEnvironment &environment, double &offspring) |
| Simulate daily events. More... | |
| int | get_age_days () const |
| Current age in days. More... | |
| double | get_age_years () const |
| Current age in years. More... | |
| double | get_bodyfat () const |
| Proportional body fat in empty body (fat mass/empty body mass). More... | |
| virtual double | get_bodymass () const |
| Current live weight, including fat, ingesta, blood, etc. [kg/ind]. More... | |
| double | get_bodymass_adult () const |
| Body mass at physical maturity [kg/ind]. More... | |
| double | get_conductance () const |
| Get full-body conductance [W/°C/ind]. More... | |
| double | get_fatmass () const |
| Current fat mass (pure lipids) [kg/ind]. More... | |
| const Hft & | get_hft () const |
| The herbivore functional type (HFT). More... | |
| double | get_max_fatmass () const |
| Physiological maximum of fat mass [kg/ind]. More... | |
| double | get_structural_mass () const |
| Current mass of body tissue without fat, ingesta, blood, etc. [kg/ind]. More... | |
| int | get_today () const |
| Current day of the year, as set in simulate_day(). More... | |
| Sex | get_sex () const |
| The sex of the herbivore. More... | |
Public Member Functions inherited from Fauna::HerbivoreInterface | |
| virtual | ~HerbivoreInterface ()=default |
| Virtual destructor, which will be called by derived classes. More... | |
| virtual void | eat (const ForageMass &kg_per_km2, const Digestibility &digestibility, const ForageMass &N_kg_per_km2=ForageMass(0))=0 |
| Feed the herbivore dry matter forage. More... | |
| virtual double | get_bodymass () const =0 |
| Body mass of one individual [kg/ind]. More... | |
| virtual ForageMass | get_forage_demands (const HabitatForage &available_forage)=0 |
| Get the forage the herbivore would like to eat today. More... | |
| virtual std::string | get_output_group () const =0 |
| The name of the HFT for aggregating output. More... | |
| virtual double | get_ind_per_km2 () const =0 |
| Individuals per km² More... | |
| virtual double | get_kg_per_km2 () const =0 |
| Get herbivore biomass density [kg/km²]. More... | |
| virtual const Output::HerbivoreData & | get_todays_output () const =0 |
| Read current output. More... | |
| virtual bool | is_dead () const =0 |
| Whether the herbivore object is dead. More... | |
| virtual void | kill ()=0 |
| Mark this herbivore as dead (see is_dead()). More... | |
| virtual void | simulate_day (const int day, const HabitatEnvironment &environment, double &offspring)=0 |
| Simulate daily events. More... | |
Protected Member Functions | |
| HerbivoreBase (const int age_days, const double body_condition, std::shared_ptr< const Hft > hft, const Sex sex, const ForageEnergyContent &forage_gross_energy) | |
| Establishment constructor. More... | |
| HerbivoreBase (std::shared_ptr< const Hft > hft, const Sex sex, const ForageEnergyContent &forage_gross_energy) | |
| Birth constructor. More... | |
| virtual | ~HerbivoreBase ()=default |
| Virtual destructor, which will be called by derived classes. More... | |
| virtual void | apply_mortality (const double mortality)=0 |
| Apply a fractional mortality. More... | |
| FatmassEnergyBudget & | get_energy_budget () |
| The herbivore’s energy budget object. More... | |
| const FatmassEnergyBudget & | get_energy_budget () const |
| The herbivore’s energy budget object. More... | |
| const HabitatEnvironment & | get_environment () const |
| Current abiotic conditions in the habitat. More... | |
| Output::HerbivoreData & | get_todays_output () |
| Class-internal read/write access to current output. More... | |
| bool | constant_members_match (const HerbivoreBase &other) const |
| Check whether the constant member variables match those of another object. More... | |
Private Member Functions | |
| void | apply_mortality_factors_today () |
| Calculate mortality according to user-selected mortality factors. More... | |
| std::shared_ptr< const Hft > | check_hft_pointer (std::shared_ptr< const Hft >) |
| Check whether the HFT pointer is NULL and throws an exception. More... | |
| ForageEnergyContent | get_net_energy_content (Digestibility digestibility) const |
| Get forage energy content [MJ/kgDM] using selected net energy model. More... | |
| double | get_todays_expenditure () const |
| Calculate energy expenditure as sum of given expenditure components. More... | |
| double | get_todays_offspring_proportion () const |
| Get the proportional offspring for today using selected model. More... | |
Private Attributes | |
Constants | |
| const std::shared_ptr< const Hft > | hft |
| const Sex | sex |
| const BreedingSeason | breeding_season |
| const ForageEnergyContent | forage_gross_energy |
State Variables | |
| int | age_days |
| FatmassEnergyBudget | energy_budget |
| HabitatEnvironment | environment |
| int | today |
Helper Classes | |
Body condition over the past x months (only females). | |
| PeriodAverage | body_condition_gestation |
| Output::HerbivoreData | current_output |
| GetForageDemands | get_forage_demands_per_ind |
Abstract base class for herbivores.
Calculations are generally performed per individual.
|
protected |
Establishment constructor.
| age_days | age in days |
| body_condition | Initial fat reserve as fraction of physiological maximum [kg/kg]. |
| hft | Herbivore functional type. |
| sex | The sex of the herbivore. |
| forage_gross_energy | The (constant) gross energy content for the forage types [MJ/kgDM]. See: Parameters::forage_gross_energy |
| std::invalid_argument | If hft==NULL or age_days <= 0 or body_condition not in [0,1]. |
|
protected |
Birth constructor.
Herbivores are born with Hft::body_fat_birth.
| hft | Herbivore functional type. |
| sex | The sex of the herbivore. |
| forage_gross_energy | The (constant) gross energy content for the forage types [MJ/kgDM]. See: Parameters::forage_gross_energy |
| std::invalid_argument | If hft==NULL. |
|
protectedvirtualdefault |
Virtual destructor, which will be called by derived classes.
|
protectedpure virtual |
Apply a fractional mortality.
| mortality | Fraction of individual density/count that is dying. |
| std::invalid_argument | if not 0.0≤mortality≤1.0 |
Implemented in Fauna::HerbivoreCohort.
|
private |
Calculate mortality according to user-selected mortality factors.
Calls apply_mortality(), which is implemented by child classes.
|
private |
Check whether the HFT pointer is NULL and throws an exception.
This helper function is only neededd because an exception for a NULL pointer must be thrown from the constructor. But in the initialization list there are objects that need the HFT for their own constructor. Therefore, the HFT pointer must be checked in a function first, before the HerbivoreBase constructor function body.
| std::invalid_argument | If HFT pointer is NULL. |
|
inlineprotected |
Check whether the constant member variables match those of another object.
|
virtual |
Feed the herbivore dry matter forage.
| kg_per_km2 | Dry matter forage mass [kgDM/km²]. |
| N_kg_per_km2 | Nitrogen in the forage [kgN/km²]. |
| digestibility | Proportional forage digestibility. |
| std::logic_error | If forage exceeds intake constraints of maximal foraging and digestion. |
| std::logic_error | If this herbivore is dead or has no individuals. |
| std::invalid_argument | If N_kg_per_km2 is larger than kg_per_km2 for a forage type. The nitrogen mass is only a fraction of dry matter, and there cannot be more then 100% nitrogen in the forage. |
Implements Fauna::HerbivoreInterface.
|
inline |
Current age in days.
|
inline |
Current age in years.
| double HerbivoreBase::get_bodyfat | ( | ) | const |
Proportional body fat in empty body (fat mass/empty body mass).
The current body fraction, 


![\[
bf = \frac{FM}{SM + FM}
\]](form_28.png)
|
virtual |
Current live weight, including fat, ingesta, blood, etc. [kg/ind].
Current body mass, 


Since the empty body consists of fat mass, 

![\[
BM = SM + FM + BM * (1 - eb)
\]](form_32.png)
and simplify that to:
![\[
BM = \frac{SM + FM}{eb}
\]](form_33.png)
Implements Fauna::HerbivoreInterface.
| double HerbivoreBase::get_bodymass_adult | ( | ) | const |
Body mass at physical maturity [kg/ind].
Hft::body_mass_female for females and Hft::body_mass_male for males.
| double HerbivoreBase::get_conductance | ( | ) | const |
Get full-body conductance [W/°C/ind].
| std::logic_error | If ConductanceModel not implemented. |
|
inlineprotected |
The herbivore’s energy budget object.
|
inlineprotected |
The herbivore’s energy budget object.
|
inlineprotected |
Current abiotic conditions in the habitat.
| std::logic_error | If simulate_day() hasn’t been called yet to set the HabitatEnvironment object. |
| double HerbivoreBase::get_fatmass | ( | ) | const |
Current fat mass (pure lipids) [kg/ind].
|
virtual |
Get the forage the herbivore would like to eat today.
Call this after simulate_day().
| available_forage | Available forage in the habitat [kgDM/km²]. |
Implements Fauna::HerbivoreInterface.
|
inline |
The herbivore functional type (HFT).
|
virtual |
Get herbivore biomass density [kg/km²].
Implements Fauna::HerbivoreInterface.
| double HerbivoreBase::get_max_fatmass | ( | ) | const |
Physiological maximum of fat mass [kg/ind].
The maximum fat mass, 




|
private |
Get forage energy content [MJ/kgDM] using selected net energy model.
| digestibility | Forage digestibility (for ruminants). This will be adjusted with Hft::digestion_digestibility_multiplier for non-ruminants. |
| std::logic_error | If the net energy model is not implemented. |
|
virtual |
The name of the HFT for aggregating output.
Technically, this can be a generic identifier to aggregate output of herbivores. However, herbivores used to be aggregated only by HFT, and so this is assumed to be the HFT name until the output framework is made more flexible.
Implements Fauna::HerbivoreInterface.
|
inline |
The sex of the herbivore.
| double HerbivoreBase::get_structural_mass | ( | ) | const |
Current mass of body tissue without fat, ingesta, blood, etc. [kg/ind].
This is the body component that an ontogenetic growth curve applies to. The growth curve interpolates between the neonate structural mass and the adult structural mass.
The neonate structural mass, 





![\[
SM_{birth} = BM_{birth} * eb * (1 - bf_{birth})
\]](form_41.png)
The adult structural mass, 


![\[
SM_{ad} = BM_{ad} * eb * (1 - \frac{bf_{max}}{2})
\]](form_44.png)
| int HerbivoreBase::get_today | ( | ) | const |
Current day of the year, as set in simulate_day().
| std::logic_error | If current day not yet set by an initial call to simulate_day(). |
|
private |
Calculate energy expenditure as sum of given expenditure components.
|
private |
Get the proportional offspring for today using selected model.
Reads Hft::reproduction_model and performs calculations accordingly.
| std::logic_error | If Hft::reproduction_model is not implemented. |
|
inlineprotected |
Class-internal read/write access to current output.
|
inlinevirtual |
Read current output.
Implements Fauna::HerbivoreInterface.
|
virtual |
Simulate daily events.
Call this before get_forage_demands().
| [in] | day | Current day of year, 0=Jan. 1st. |
| [in] | environment | Current environmental conditions in the habitat. |
| [out] | offspring | Number of newborn today [ind/km²]. |
| std::invalid_argument | If day not in [0,364]. |
| std::logic_error | If this herbivore is dead. |
Implements Fauna::HerbivoreInterface.
|
private |
|
private |
Body condition is current fat mass / max. fat mass. The record spans the lenght of a potential pregnancy, counting back from current day. This object is empty for male herbivores.
|
private |
|
private |
Body condition is current fat mass / max. fat mass. The record spans the lenght of a potential pregnancy, counting back from current day. This object is empty for male herbivores.
|
private |
|
private |
|
private |
|
private |
Body condition is current fat mass / max. fat mass. The record spans the lenght of a potential pregnancy, counting back from current day. This object is empty for male herbivores.
|
private |
|
private |
|
private |