Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
Fauna::HerbivoreCohort Class Reference

A herbivore cohort (age-class) More...

#include <herbivore_cohort.h>

Inheritance diagram for Fauna::HerbivoreCohort:
Fauna::HerbivoreBase Fauna::HerbivoreInterface

Public Member Functions

virtual double get_ind_per_km2 () const
 Individuals per km² More...
 
virtual bool is_dead () const
 A cohort is dead if its density is zero. More...
 
virtual void kill ()
 Mark this herbivore as dead (see is_dead()). More...
 
 HerbivoreCohort (const int age_days, const double body_condition, std::shared_ptr< const Hft > hft, const Sex sex, const double ind_per_km2, const ForageEnergyContent &forage_gross_energy)
 Establishment constructor. More...
 
 HerbivoreCohort (std::shared_ptr< const Hft > hft, const Sex sex, const double ind_per_km2, const ForageEnergyContent &forage_gross_energy)
 Birth constructor. More...
 
bool is_same_age (const HerbivoreCohort &other) const
 Check if this and the other cohort are of the same age. More...
 
void merge (HerbivoreCohort &other)
 Merge another cohort into this one. More...
 
- Public Member Functions inherited from Fauna::HerbivoreBase
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::HerbivoreDataget_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 Hftget_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::HerbivoreDataget_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

virtual void apply_mortality (const double mortality)
 Apply a fractional mortality. More...
 
- Protected Member Functions inherited from Fauna::HerbivoreBase
 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...
 
FatmassEnergyBudgetget_energy_budget ()
 The herbivore’s energy budget object. More...
 
const FatmassEnergyBudgetget_energy_budget () const
 The herbivore’s energy budget object. More...
 
const HabitatEnvironmentget_environment () const
 Current abiotic conditions in the habitat. More...
 
Output::HerbivoreDataget_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 Attributes

double ind_per_km2
 

Detailed Description

A herbivore cohort (age-class)

Any state variables describe mean values across all individuals. All individuals have the same age.

See also
The Herbivore
Herbivore Cohorts

Constructor & Destructor Documentation

◆ HerbivoreCohort() [1/2]

HerbivoreCohort::HerbivoreCohort ( const int  age_days,
const double  body_condition,
std::shared_ptr< const Hft hft,
const Sex  sex,
const double  ind_per_km2,
const ForageEnergyContent forage_gross_energy 
)

Establishment constructor.

Parameters
age_daysage in days
body_conditionInitial fat reserve as fraction of physiological maximum [kg/kg].
hftHerbivore functional type.
sexThe sex of the herbivore.
forage_gross_energyThe (constant) gross energy content for the forage types [MJ/kgDM]. See: Parameters::forage_gross_energy
Exceptions
std::invalid_argumentif any parameter is invalid
Parameters
ind_per_km2Initial individual density [ind/km²]. Can be 0.0, but must not be negative.

◆ HerbivoreCohort() [2/2]

HerbivoreCohort::HerbivoreCohort ( std::shared_ptr< const Hft hft,
const Sex  sex,
const double  ind_per_km2,
const ForageEnergyContent forage_gross_energy 
)

Birth constructor.

Parameters
hftHerbivore functional type.
sexThe sex of the herbivore.
forage_gross_energyThe (constant) gross energy content for the forage types [MJ/kgDM]. See: Parameters::forage_gross_energy
Exceptions
std::invalid_argumentif any parameter is invalid
Parameters
ind_per_km2Initial individual density [ind/km²]. Can be 0.0, but must not be negative.

Member Function Documentation

◆ apply_mortality()

void HerbivoreCohort::apply_mortality ( const double  mortality)
protectedvirtual

Apply a fractional mortality.

Parameters
mortalityFraction of individual density/count that is dying.
Exceptions
std::invalid_argumentif not 0.0≤mortality≤1.0

Implements Fauna::HerbivoreBase.

◆ get_ind_per_km2()

virtual double Fauna::HerbivoreCohort::get_ind_per_km2 ( ) const
inlinevirtual

Individuals per km²

Implements Fauna::HerbivoreInterface.

◆ is_dead()

bool HerbivoreCohort::is_dead ( ) const
virtual

A cohort is dead if its density is zero.

Implements Fauna::HerbivoreInterface.

◆ is_same_age()

bool Fauna::HerbivoreCohort::is_same_age ( const HerbivoreCohort other) const
inline

Check if this and the other cohort are of the same age.

Two cohorts are considered coeval if they are in the same year of life:

  • First year: 0<=age_days<365
  • Second year: 365<=age_days<730
  • etc.

◆ kill()

virtual void Fauna::HerbivoreCohort::kill ( )
inlinevirtual

Mark this herbivore as dead (see is_dead()).

This function is needed in order to take nitrogen back from “dead” herbivores before removing them from memory.

Implements Fauna::HerbivoreInterface.

◆ merge()

void HerbivoreCohort::merge ( HerbivoreCohort other)

Merge another cohort into this one.

All state variables are averaged between the two cohorts by the weight of population density. The age in days (HerbivoreBase::age_days) will not be changed, which effectively means that the other (merged) cohort will lose the information about its precise age (in days).

Parameters
otherThe other cohort that is merged into this. The density of other will be reduced.
Exceptions
std::invalid_argumentIf fraction not in [0,1].
std::logic_errorIf the other cohort is not compatible: different age, different HFT, different gross energy, or different sex. See HerbivoreBase::constant_members_match()
See also
CohortPopulation::create_offspring_by_sex()

Member Data Documentation

◆ ind_per_km2

double Fauna::HerbivoreCohort::ind_per_km2
private

The documentation for this class was generated from the following files: