Loading [MathJax]/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PesticideStore Class Reference

#include <PesticideToxicity.h>

Inheritance diagram for PesticideStore:
PesticideToxicity

Public Member Functions

 PesticideStore ()
 
void addPesticide (double eating_amount, double amount_per_square, double(Landscape::*a_supply_pest_func_pointer)(int, int, PlantProtectionProducts), int loc_x, int loc_y)
 The function to add pesticide based on the eating amount and the amount of food per square meter. More...
 
void addPesticide (double a_mount, PlantProtectionProducts a_type)
 The function to add pesticide based on the given amount and the given type. More...
 
virtual void reset (void)
 The function to reset the pesticide to zero. More...
 
std::vector< double > * supplyPesticide (void)
 The function to return the pesticide amount array. More...
 
double supplyPesticide (PlantProtectionProducts a_type)
 The function to return the pesticide amount. More...
 
double supplyTotalPesticide (void)
 The function to return the total pesticide amount. More...
 
void doDecay (void)
 The default fuction to decay the pesticide body burden. More...
 
virtual void tick (int a_step_counter_in_a_day)
 The function to update pesticide contamination every time step. More...
 

Static Public Member Functions

static void setLandscapePointer (Landscape *a_landscape)
 The function to set the static landscape pointer. More...
 

Protected Attributes

std::vector< double > m_pest_amount_vec
 The vector to store the pesticide amount for each pesticide. More...
 

Static Protected Attributes

static Landscapem_ALandscape = nullptr
 The static landscape pointer. More...
 

Constructor & Destructor Documentation

◆ PesticideStore()

PesticideStore::PesticideStore ( )
71  {
74  for (int i = 0; i<l_pest_NoPPPs.value(); i++){
75  m_pest_amount_vec[i] = 0.0;
76  }
77 }

References l_pest_enable_pesticide_engine, l_pest_NoPPPs, m_pest_amount_vec, CfgInt::value(), and CfgBool::value().

Member Function Documentation

◆ addPesticide() [1/2]

void PesticideStore::addPesticide ( double  a_mount,
PlantProtectionProducts  a_type 
)
inline

The function to add pesticide based on the given amount and the given type.

46 {m_pest_amount_vec[a_type] += a_mount;}

References m_pest_amount_vec.

◆ addPesticide() [2/2]

void PesticideStore::addPesticide ( double  eating_amount,
double  amount_per_square,
double(Landscape::*)(int, int, PlantProtectionProducts a_supply_pest_func_pointer,
int  loc_x,
int  loc_y 
)

The function to add pesticide based on the eating amount and the amount of food per square meter.

79  {
80  for (int i = 0; i<l_pest_NoPPPs.value(); i++){
81  m_pest_amount_vec[i] += (m_ALandscape->*a_supply_pest_func_pointer)(loc_x, loc_y, PlantProtectionProducts(i));
82  }
83 }

References l_pest_NoPPPs, m_ALandscape, m_pest_amount_vec, and CfgInt::value().

Referenced by PesticideToxicity::eatingFromStorePest(), and Osmia_Female::st_ReproductiveBehaviour().

◆ doDecay()

void PesticideStore::doDecay ( void  )

The default fuction to decay the pesticide body burden.

91  {
92 
93  for (int i = 0; i<l_pest_NoPPPs.value(); i++){
94  if(m_pest_amount_vec[i] > 0){
96  }
97 
99  m_pest_amount_vec[i] = 0.0;
100  }
101  }
102 
103 }

References l_pest_NoPPPs, l_pest_zero_threshold, m_pest_amount_vec, pest_decay_rate_animal, CfgInt::value(), CfgFloat::value(), and CfgArray_Double::value().

Referenced by PesticideToxicity::PesticideToxicity(), and tick().

◆ reset()

void PesticideStore::reset ( void  )
virtual

The function to reset the pesticide to zero.

Reimplemented in PesticideToxicity.

85  {
86  for (int i = 0; i<l_pest_NoPPPs.value(); i++){
87  m_pest_amount_vec[i] = 0.0;
88  }
89 }

References l_pest_NoPPPs, m_pest_amount_vec, and CfgInt::value().

◆ setLandscapePointer()

static void PesticideStore::setLandscapePointer ( Landscape a_landscape)
inlinestatic

The function to set the static landscape pointer.

60 {m_ALandscape = a_landscape;}

References m_ALandscape.

Referenced by Population_Manager_Base::Population_Manager_Base().

◆ supplyPesticide() [1/2]

double PesticideStore::supplyPesticide ( PlantProtectionProducts  a_type)
inline

The function to return the pesticide amount.

52 {return(m_pest_amount_vec[a_type]);}

References m_pest_amount_vec.

◆ supplyPesticide() [2/2]

std::vector<double>* PesticideStore::supplyPesticide ( void  )
inline

The function to return the pesticide amount array.

50 {return &m_pest_amount_vec;}

References m_pest_amount_vec.

Referenced by PesticideToxicity::eatingFromStorePest().

◆ supplyTotalPesticide()

double PesticideStore::supplyTotalPesticide ( void  )
inline

The function to return the total pesticide amount.

54 {return std::accumulate(m_pest_amount_vec.begin(), m_pest_amount_vec.end(), 0.0);}

References m_pest_amount_vec.

Referenced by Osmia_Female::BeginStep().

◆ tick()

void PesticideStore::tick ( int  a_step_counter_in_a_day)
virtual

The function to update pesticide contamination every time step.

105  {
107  //These only be done once per day even for the species with finer time step, e.g., 1 hr
108  if(a_step_counter_in_a_day == 0){
109  doDecay();
110  }
111 }

References doDecay(), l_pest_enable_pesticide_engine, and CfgBool::value().

Member Data Documentation

◆ m_ALandscape

Landscape * PesticideStore::m_ALandscape = nullptr
staticprotected

◆ m_pest_amount_vec


The documentation for this class was generated from the following files:
PlantProtectionProducts
PlantProtectionProducts
A list ofPPP names for tracking by the Pesticide class.
Definition: LandscapeFarmingEnums.h:1077
l_pest_enable_pesticide_engine
CfgBool l_pest_enable_pesticide_engine
Used to turn on or off the PPP functionality of ALMaSS.
CfgFloat::value
double value() const
Definition: Configurator.h:142
PesticideStore::doDecay
void doDecay(void)
The default fuction to decay the pesticide body burden.
Definition: PesticideToxicity.cpp:91
CfgBool::value
bool value() const
Definition: Configurator.h:164
PesticideStore::m_pest_amount_vec
std::vector< double > m_pest_amount_vec
The vector to store the pesticide amount for each pesticide.
Definition: PesticideToxicity.h:37
l_pest_NoPPPs
CfgInt l_pest_NoPPPs
The number of active Plant Protection Products to be tracked - a performance penalty if enabled with ...
CfgInt::value
int value() const
Definition: Configurator.h:116
CfgArray_Double::value
std::vector< double > value() const
Definition: Configurator.h:219
PesticideStore::m_ALandscape
static Landscape * m_ALandscape
The static landscape pointer.
Definition: PesticideToxicity.h:39
l_pest_zero_threshold
CfgFloat l_pest_zero_threshold
The number of pesticide types used, the maximum value is 10.
pest_decay_rate_animal
static CfgArray_Double pest_decay_rate_animal("PEST_DECAY_RATE_ANIMAL", CFG_CUSTOM, 10, vector< double >{0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9})
The decay rate of the pesticide body burden. The length of this vector maximum number of supported pe...