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

A herbivore habitat independent of the LPJ-GUESS framework for testing. More...

#include <simple_habitat.h>

Inheritance diagram for Fauna::Demo::SimpleHabitat:
Fauna::Habitat

Classes

struct  Parameters
 Simulation parameters for a SimpleHabitat object. More...
 

Public Member Functions

 SimpleHabitat (const SimpleHabitat::Parameters settings, const std::string aggregation_unit)
 Constructor with simulation settings. More...
 
virtual void add_excreted_nitrogen (const double)
 
virtual const char * get_aggregation_unit () const
 A string identifier for the group of habitats whose output is aggregated. More...
 
virtual HabitatForage get_available_forage () const
 Get dry-matter biomass [kgDM/km²] that is available to herbivores to eat. More...
 
virtual HabitatEnvironment get_environment () const
 Get today’s abiotic environmental variables in the habitat. More...
 
virtual void init_day (const int today)
 Update at the start of the day. More...
 
virtual void remove_eaten_forage (const ForageMass &eaten_forage)
 Remove forage eaten by herbivores. More...
 
- Public Member Functions inherited from Fauna::Habitat
virtual ~Habitat ()
 Virtual Destructor. More...
 
virtual const char * get_aggregation_unit () const =0
 A string identifier for the group of habitats whose output is aggregated. More...
 
virtual HabitatForage get_available_forage () const =0
 Get dry-matter biomass [kgDM/km²] that is available to herbivores to eat. More...
 
virtual HabitatEnvironment get_environment () const =0
 Get today’s abiotic environmental variables in the habitat. More...
 
virtual void init_day (const int today)
 Update at the start of the day. More...
 
bool is_dead () const
 Whether kill() has been called on this object. More...
 
void kill ()
 Mark the object as dead and to be deleted. More...
 
virtual void remove_eaten_forage (const ForageMass &eaten_forage)
 Remove forage eaten by herbivores. More...
 
int get_day () const
 The current day as set by init_day(). More...
 
const Output::HabitatDataget_todays_output () const
 The current output data (read-only). More...
 

Protected Member Functions

virtual void grow_daily (const int day_of_year)
 Perform daily growth. More...
 
- Protected Member Functions inherited from Fauna::Habitat
Output::HabitatDataget_todays_output ()
 Class-internal read/write access to current output data. More...
 

Private Attributes

const std::string aggregation_unit
 
const SimpleHabitat::Parameters settings
 
double air_temperature = 0.0
 
LogisticGrass grass
 Grass in the habitat. More...
 
int simulation_month = 0
 The current simulation month, starting with zero. More...
 

Detailed Description

A herbivore habitat independent of the LPJ-GUESS framework for testing.

Constructor & Destructor Documentation

◆ SimpleHabitat()

Fauna::Demo::SimpleHabitat::SimpleHabitat ( const SimpleHabitat::Parameters  settings,
const std::string  aggregation_unit 
)
inline

Constructor with simulation settings.

Parameters
settingsSimulation settings for the vegetation model.
aggregation_unitAn arbitrary name for grouping the habitat for output.

Member Function Documentation

◆ add_excreted_nitrogen()

virtual void Fauna::Demo::SimpleHabitat::add_excreted_nitrogen ( const double  )
inlinevirtual

◆ get_aggregation_unit()

virtual const char * Fauna::Demo::SimpleHabitat::get_aggregation_unit ( ) const
inlinevirtual

A string identifier for the group of habitats whose output is aggregated.

Suppose the vegetation model works in longitude/latitude grid cells and has three habitats in each grid cell. Output shall be aggregated per grid cell. Then all habitats in each set of three have the same (unique!) aggregation unit sting identifier. This could be for instance "10.0/54.0" for a grid cell at 10° E and 54° N. It’s completely up to the vegetation model to define a convention for the aggregation unit identifiers.

You should avoid leading or trailing whitespaces and take care that you don’t include a character that is used as a field separator in the output table. Also, the string should not be empty.

The output of this function should not change within the lifetime of one class instance: One Habitat object shall not change into another aggregation unit.

Implements Fauna::Habitat.

◆ get_available_forage()

virtual HabitatForage Fauna::Demo::SimpleHabitat::get_available_forage ( ) const
inlinevirtual

Get dry-matter biomass [kgDM/km²] that is available to herbivores to eat.

Exceptions
std::logic_errorIf this object is dead.

Implements Fauna::Habitat.

◆ get_environment()

HabitatEnvironment SimpleHabitat::get_environment ( ) const
virtual

Get today’s abiotic environmental variables in the habitat.

Exceptions
std::logic_errorIf this object is dead.

Implements Fauna::Habitat.

◆ grow_daily()

virtual void Fauna::Demo::SimpleHabitat::grow_daily ( const int  day_of_year)
inlineprotectedvirtual

Perform daily growth.

Parameters
day_of_yearJanuary 1st = 0

◆ init_day()

void SimpleHabitat::init_day ( const int  today)
virtual

Update at the start of the day.

Call this once every day from the framework. When overwriting this in derived classes, make sure to call this parent function first.

Parameters
todayDay of the year (0 ≙ Jan 1st).
Exceptions
std::invalid_argumentIf not 0<=today<=364.
std::logic_errorIf this object is dead.

Reimplemented from Fauna::Habitat.

◆ remove_eaten_forage()

void SimpleHabitat::remove_eaten_forage ( const ForageMass eaten_forage)
virtual

Remove forage eaten by herbivores.

The base class implements only adding the eaten forage to the output. Any derived class should call this (the parent‘s) function and do forage removal afterwards.

Note
It is the vegetation model’s responsibility to recycle nutrients (e.g. nitrogen). Even though the herbivore model counts the amount of ingested nitrogen, it does not close the nutrient cycle by returning nitrogen to the vegetation. The implementation of this function could directly put eaten nitrogen into the soil, thereby ignoring the (short) time herbivores retain nitrogen in their digestive tract and their body tissue.
Parameters
eaten_forageDry matter leaf forage [kgDM/km²], must not exceed available forage.
Exceptions
std::logic_errorIf eaten_forage exceeds available forage (to be implemented in derived classes).
std::logic_errorIf this object is dead.

Reimplemented from Fauna::Habitat.

Member Data Documentation

◆ aggregation_unit

const std::string Fauna::Demo::SimpleHabitat::aggregation_unit
private

◆ air_temperature

double Fauna::Demo::SimpleHabitat::air_temperature = 0.0
private

Air temperature in °C, as read from SimpleHabitat::Parameters::air_temperature.

◆ grass

LogisticGrass Fauna::Demo::SimpleHabitat::grass
private

Grass in the habitat.

◆ settings

const SimpleHabitat::Parameters Fauna::Demo::SimpleHabitat::settings
private

◆ simulation_month

int Fauna::Demo::SimpleHabitat::simulation_month = 0
private

The current simulation month, starting with zero.

We need this to address the current value in SimpleHabitat::Parameters::air_temperature.


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