11#ifndef FAUNA_GRASS_FORAGE_H
12#define FAUNA_GRASS_FORAGE_H
39 assert(sd >= 0.0 && sd >=
get_mass());
46 throw std::logic_error(
47 "Fauna::GrassForage::get_sward_density() "
48 "The grass sward density is unreasonably high (" +
49 std::to_string(sd / 1e4) +
51 "This might be because the vegetation model gave an unrealistically "
52 "low FPC value (fraction of habitat covered by grass).\n"
56 "\twhole-habitat grass density = " +
59 "Please check the vegetation model. Consider hard-setting the FPC "
60 "value to a constant (e.g. 0.8 in grassland) or a minimum (e.g. "
79 throw std::logic_error(
80 "Fauna::GrassForage::get_fpc() "
81 "Mass is zero, but FPC is not zero.");
83 throw std::logic_error(
84 "Fauna::GrassForage::get_fpc() "
85 "Mass is not zero, but FPC is zero.");
91 const double other_weight);
100 if (!(f >= 0.0 && f <= 1.0))
101 throw std::invalid_argument(
102 "Fauna::GrassForage::set_fpc() "
103 "FPC out of valid range (0.0–1.0).");
105 throw std::logic_error(
106 "Fauna::GrassForage::set_fpc() "
107 "FPC must be zero if mass is zero.");
109 throw std::logic_error(
110 "Fauna::GrassForage::set_fpc() "
111 "FPC cannot be zero if there is grass mass.");
Base class for herbivore forage in a habitat.
Definition: forage_base.h:19
double get_mass() const
Dry matter forage biomass over the whole area [kgDM/km²].
Definition: forage_base.h:32
Grass forage in a habitat.
Definition: grass_forage.h:19
double get_fpc() const
Fraction of habitat covered by grass [fractional].
Definition: grass_forage.h:77
void set_fpc(const double f)
Fraction of habitat covered by grass [fractional].
Definition: grass_forage.h:99
static constexpr double MAX_SWARD_DENSITY
Maximum imaginable real-world sward density [kgDM/km²].
Definition: grass_forage.h:24
double fpc
Definition: grass_forage.h:21
double get_sward_density() const
Dry matter forage in the area covered by grass [kgDM/km²].
Definition: grass_forage.h:36
GrassForage()
Constructor with zero values.
Definition: grass_forage.h:27
GrassForage & merge(const GrassForage &other, const double this_weight, const double other_weight)
Merge this object with another one by building (weighted) means.
Definition: grass_forage.cpp:16
Base class for all forage types.