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
PesticideToxicity Class Reference

#include <PesticideToxicity.h>

Inheritance diagram for PesticideToxicity:
PesticideStore

Public Member Functions

 PesticideToxicity ()
 
void doToxicity (double a_mass, double a_para_index)
 The default function to calculate the toxicity effect. More...
 
void setToxicityFuncPointer (void(PesticideToxicity::*a_toxicity_func)(double, double))
 The function to set the toxicity function pointer. More...
 
void setDecayFuncPointer (void(PesticideToxicity::*a_decay_func)(void))
 The function to set the decay function pointer. More...
 
void doOverspray (void)
 The function for the animal to be oversprayed when the pesticide application is happening where the animal is. More...
 
void doContact (void)
 The function to calculate the pesticide contamination through contact. More...
 
virtual void tick (int a_step_counter_in_a_day, double a_mass=1, double a_para_index=0)
 The function to update pesticide contamination every time step. More...
 
std::vector< double > supplyPesticideVector (void)
 The function to return the pesticide amount array. More...
 
void SetPesticideVector (std::vector< double > a_pest_amount_vec)
 
double supplyPesticide (PlantProtectionProducts a_type=ppp_1)
 The function to supply the pesticide residue for the given pesticide type, the default type is 0, i.e., single product. More...
 
double supplyPestMortality (void)
 The function to supply the host's mortality rate caused by pest. More...
 
void setHostAnimalPointer (TAnimal *animal)
 The function to set the host animal pointer. More...
 
virtual void reset (void)
 Reset PesticideToxicity class, this should be called when the host animal is dead. More...
 
void eatingFromStorePest (PesticideStore *a_store, double a_eating_amount, double a_total_amount)
 The function for eating from a store to add pesticide. More...
 
double GetTotalPest (void)
 Return the total pesticide. More...
 
- Public Member Functions inherited from PesticideStore
 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...
 
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...
 

Private Attributes

TAnimalm_my_animal_host
 The pointer to the host animal. More...
 
double m_total_pest_sum
 The summation of the total pesticide body burden. More...
 
double m_pest_hazard
 The hazard of the pesticide. More...
 
void(PesticideToxicity::* m_toxicity_func_pointer )(double, double)
 The function pointer to point the function for toxicity effect calculation. More...
 
void(PesticideToxicity::* m_decay_func_pointer )(void)
 The function pointer to point the function for decay calculation. More...
 
double m_my_animal_mortality
 The mortality rate of the host animal caused by pesticide body burden. More...
 
int m_location_previous_x
 The x-coordinate is used to remember the location from the previous time-step. More...
 
int m_location_previous_y
 The y-coordinate is used to remember the location from the previous time-step. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from PesticideStore
static void setLandscapePointer (Landscape *a_landscape)
 The function to set the static landscape pointer. More...
 
- Protected Attributes inherited from PesticideStore
std::vector< double > m_pest_amount_vec
 The vector to store the pesticide amount for each pesticide. More...
 
- Static Protected Attributes inherited from PesticideStore
static Landscapem_ALandscape = nullptr
 The static landscape pointer. More...
 

Constructor & Destructor Documentation

◆ PesticideToxicity()

Member Function Documentation

◆ doContact()

void PesticideToxicity::doContact ( void  )

The function to calculate the pesticide contamination through contact.

140  {
141  //get the host animal's current location
142  int temp_current_x = m_my_animal_host->Supply_m_Location_x();
143  int temp_current_y = m_my_animal_host->Supply_m_Location_y();
144 
145  //check whether the host animal moved to another location, if yes, apply contact
146  if(temp_current_x != m_location_previous_x || temp_current_y != m_location_previous_y){
147  double current_pest = 0;
148 
149  for (int i=0; i<l_pest_NoPPPs.value(); i++){
150 
151  //use the plant surface for contact
152  current_pest = m_ALandscape->SupplyPesticidePlantSurface(temp_current_x, temp_current_y, PlantProtectionProducts(i));
153  //Please note that the unit of current_pest is mg/m2
155  }
156 
157  }
158 
159  //record the current location as the previous location for next time step
160  m_location_previous_x = temp_current_x;
161  m_location_previous_y = temp_current_y;
162 }

References l_pest_NoPPPs, PesticideStore::m_ALandscape, m_location_previous_x, m_location_previous_y, m_my_animal_host, PesticideStore::m_pest_amount_vec, pest_contact_animal_ratio, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Landscape::SupplyPesticidePlantSurface(), CfgInt::value(), and CfgFloat::value().

Referenced by tick().

◆ doOverspray()

void PesticideToxicity::doOverspray ( void  )

The function for the animal to be oversprayed when the pesticide application is happening where the animal is.

165  {
166  //test against the chance
168  //get the host animal's current location
169  int temp_current_x = m_my_animal_host->Supply_m_Location_x();
170  int temp_current_y = m_my_animal_host->Supply_m_Location_y();
171  //get the sprayed pesticide type
172  PlantProtectionProducts current_ppp_type = m_ALandscape->SupplySprayPesticideType(temp_current_x, temp_current_y);
173  //get the sprayed pesticide application rate
174  double current_ppp_rate = m_ALandscape->SupplySprayPesticideRate(temp_current_x, temp_current_y);
175  //add the overspray pesticide
177 }

References g_rand_uni_fnc(), PesticideStore::m_ALandscape, m_my_animal_host, PesticideStore::m_pest_amount_vec, pest_animal_overspray_chance, pest_overspray_animal_rate, pest_overspray_animal_surface, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Landscape::SupplySprayPesticideRate(), Landscape::SupplySprayPesticideType(), and CfgFloat::value().

Referenced by Osmia_Female::OnFarmEvent().

◆ doToxicity()

void PesticideToxicity::doToxicity ( double  a_mass,
double  a_para_index 
)

The default function to calculate the toxicity effect.

122  {
123  //sum all the pesticide
124  m_total_pest_sum = 0.0;
125  for (int i=0; i<l_pest_NoPPPs.value(); i++){
127  }
128 
129  //GUTS-SD model (Death Dilemma and Organism Recovery in Ecotoxicology, Roman Ashauer, 2015)
130  //calculation of the hazard rate, the background hazard rate is excluded since this will be included in the animal mortality calculation
131  double pest_diff = m_total_pest_sum/a_mass - pest_animal_effect_amount.value()[a_para_index];
132  if (pest_diff > 0){
133  double temp_hazard_rate = pest_animal_killing_rate.value()[a_para_index]*pest_diff;
134  m_pest_hazard += temp_hazard_rate;
136  }
137 
138 }

References l_pest_NoPPPs, m_my_animal_mortality, PesticideStore::m_pest_amount_vec, m_pest_hazard, m_total_pest_sum, pest_animal_effect_amount, pest_animal_killing_rate, CfgInt::value(), and CfgArray_Double::value().

Referenced by PesticideToxicity().

◆ eatingFromStorePest()

void PesticideToxicity::eatingFromStorePest ( PesticideStore a_store,
double  a_eating_amount,
double  a_total_amount 
)

The function for eating from a store to add pesticide.

206  {
207  double temp_pest = 0.0;
208  double temp_frac = a_eating_amount/a_total_amount;
209  for (int i = 0; i<l_pest_NoPPPs.value(); i++){
210  temp_pest = a_store->supplyPesticide(PlantProtectionProducts(i))*temp_frac;
211  m_pest_amount_vec[i] += temp_pest;
212  //deduce the pesticide from the store
213  a_store->addPesticide(-temp_pest, PlantProtectionProducts(i));
214  }
215 }

References PesticideStore::addPesticide(), l_pest_NoPPPs, PesticideStore::m_pest_amount_vec, PesticideStore::supplyPesticide(), and CfgInt::value().

◆ GetTotalPest()

double PesticideToxicity::GetTotalPest ( void  )
inline

Return the total pesticide.

112 {return m_total_pest_sum;}

References m_total_pest_sum.

◆ reset()

void PesticideToxicity::reset ( void  )
virtual

Reset PesticideToxicity class, this should be called when the host animal is dead.

Reimplemented from PesticideStore.

195  {
198  m_total_pest_sum = 0;
199  m_pest_hazard = 0;
201  for (int i = 0; i<l_pest_NoPPPs.value(); i++){
202  m_pest_amount_vec[i] = 0.0;
203  }
204 }

References l_pest_NoPPPs, m_location_previous_x, m_location_previous_y, m_my_animal_mortality, PesticideStore::m_pest_amount_vec, m_pest_hazard, m_total_pest_sum, and CfgInt::value().

Referenced by TAnimal::KillThis(), and PesticideToxicity().

◆ setDecayFuncPointer()

void PesticideToxicity::setDecayFuncPointer ( void(PesticideToxicity::*)(void)  a_decay_func)
inline

The function to set the decay function pointer.

91 {m_decay_func_pointer = a_decay_func;}

References m_decay_func_pointer.

◆ setHostAnimalPointer()

void PesticideToxicity::setHostAnimalPointer ( TAnimal animal)
inline

The function to set the host animal pointer.

106 {m_my_animal_host = animal;}

References m_my_animal_host.

Referenced by TAnimal::TAnimal().

◆ SetPesticideVector()

void PesticideToxicity::SetPesticideVector ( std::vector< double >  a_pest_amount_vec)
inline
100 { m_pest_amount_vec = a_pest_amount_vec;}

References PesticideStore::m_pest_amount_vec.

◆ setToxicityFuncPointer()

void PesticideToxicity::setToxicityFuncPointer ( void(PesticideToxicity::*)(double, double)  a_toxicity_func)
inline

The function to set the toxicity function pointer.

89 {m_toxicity_func_pointer = a_toxicity_func;}

References m_toxicity_func_pointer.

◆ supplyPesticide()

double PesticideToxicity::supplyPesticide ( PlantProtectionProducts  a_type = ppp_1)
inline

The function to supply the pesticide residue for the given pesticide type, the default type is 0, i.e., single product.

102 {return m_pest_amount_vec[a_type];}

References PesticideStore::m_pest_amount_vec.

◆ supplyPesticideVector()

std::vector<double> PesticideToxicity::supplyPesticideVector ( void  )
inline

The function to return the pesticide amount array.

99 { return m_pest_amount_vec; }

References PesticideStore::m_pest_amount_vec.

◆ supplyPestMortality()

double PesticideToxicity::supplyPestMortality ( void  )
inline

The function to supply the host's mortality rate caused by pest.

104 {return m_my_animal_mortality;}

References m_my_animal_mortality.

Referenced by Osmia_Female::BeginStep(), and Osmia_Female::st_Develop().

◆ tick()

void PesticideToxicity::tick ( int  a_step_counter_in_a_day,
double  a_mass = 1,
double  a_para_index = 0 
)
virtual

The function to update pesticide contamination every time step.

179  {
181  //These only be done once per day even for the species with finer time step, e.g., 1 hr
182  if(a_step_counter_in_a_day == 0){
183  //first, do decay
184  (this->*m_decay_func_pointer)();
185  //second, do toxicity
186  (this->*m_toxicity_func_pointer)(a_mass, a_para_index);
187  }
188 
189  //third, check whether contact happens, contact can happen when the animal moves to a new place
191  doContact();
192  }
193 }

References cfg_pest_animal_contact_on, doContact(), l_pest_enable_pesticide_engine, m_decay_func_pointer, m_toxicity_func_pointer, and CfgBool::value().

Referenced by Osmia_Female::BeginStep().

Member Data Documentation

◆ m_decay_func_pointer

void(PesticideToxicity::* PesticideToxicity::m_decay_func_pointer) (void)
private

The function pointer to point the function for decay calculation.

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

◆ m_location_previous_x

int PesticideToxicity::m_location_previous_x
private

The x-coordinate is used to remember the location from the previous time-step.

Referenced by doContact(), and reset().

◆ m_location_previous_y

int PesticideToxicity::m_location_previous_y
private

The y-coordinate is used to remember the location from the previous time-step.

Referenced by doContact(), and reset().

◆ m_my_animal_host

TAnimal* PesticideToxicity::m_my_animal_host
private

The pointer to the host animal.

Referenced by doContact(), doOverspray(), and setHostAnimalPointer().

◆ m_my_animal_mortality

double PesticideToxicity::m_my_animal_mortality
private

The mortality rate of the host animal caused by pesticide body burden.

Referenced by doToxicity(), reset(), and supplyPestMortality().

◆ m_pest_hazard

double PesticideToxicity::m_pest_hazard
private

The hazard of the pesticide.

Referenced by doToxicity(), and reset().

◆ m_total_pest_sum

double PesticideToxicity::m_total_pest_sum
private

The summation of the total pesticide body burden.

Referenced by doToxicity(), GetTotalPest(), and reset().

◆ m_toxicity_func_pointer

void(PesticideToxicity::* PesticideToxicity::m_toxicity_func_pointer) (double, double)
private

The function pointer to point the function for toxicity effect calculation.

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


The documentation for this class was generated from the following files:
PesticideToxicity::doToxicity
void doToxicity(double a_mass, double a_para_index)
The default function to calculate the toxicity effect.
Definition: PesticideToxicity.cpp:122
TAnimal::Supply_m_Location_x
int Supply_m_Location_x() const
Returns the ALMaSS x-coordinate.
Definition: PopulationManager.h:239
PlantProtectionProducts
PlantProtectionProducts
A list ofPPP names for tracking by the Pesticide class.
Definition: LandscapeFarmingEnums.h:1077
g_rand_uni_fnc
double g_rand_uni_fnc()
Definition: ALMaSS_Random.cpp:56
PesticideToxicity::m_my_animal_host
TAnimal * m_my_animal_host
The pointer to the host animal.
Definition: PesticideToxicity.h:68
PesticideStore::addPesticide
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.
Definition: PesticideToxicity.cpp:79
Landscape::SupplySprayPesticideRate
double SupplySprayPesticideRate(int a_x, int a_y)
Gets the sprayed pesticide rate in the given location.
Definition: Landscape.cpp:1512
l_pest_enable_pesticide_engine
CfgBool l_pest_enable_pesticide_engine
Used to turn on or off the PPP functionality of ALMaSS.
PesticideToxicity::m_decay_func_pointer
void(PesticideToxicity::* m_decay_func_pointer)(void)
The function pointer to point the function for decay calculation.
Definition: PesticideToxicity.h:76
PesticideToxicity::m_total_pest_sum
double m_total_pest_sum
The summation of the total pesticide body burden.
Definition: PesticideToxicity.h:70
CfgFloat::value
double value() const
Definition: Configurator.h:142
PesticideToxicity::m_location_previous_x
int m_location_previous_x
The x-coordinate is used to remember the location from the previous time-step.
Definition: PesticideToxicity.h:80
Landscape::SupplySprayPesticideType
PlantProtectionProducts SupplySprayPesticideType(int a_x, int a_y)
Gets the sprayed pesticide type in the given location.
Definition: Landscape.cpp:1504
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
Landscape::SupplyPesticidePlantSurface
double SupplyPesticidePlantSurface(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets plant surface pesticide for a location.
Definition: Landscape.cpp:1444
pest_animal_overspray_chance
static CfgFloat pest_animal_overspray_chance("PEST_ANIMAL_OVERSPRAY_CHANCE", CFG_CUSTOM, 0.1)
The chance being oversprayed for the host animal.
cfg_pest_animal_contact_on
static CfgBool cfg_pest_animal_contact_on("PEST_ANIMAL_CONTACT_ON", CFG_CUSTOM, true)
The flag to turn on contact exposure path.
TAnimal::Supply_m_Location_y
int Supply_m_Location_y() const
Returns the ALMaSS y-coordinate.
Definition: PopulationManager.h:243
pest_animal_effect_amount
static CfgArray_Double pest_animal_effect_amount("PEST_ANIMAL_EFFECT_AMOUNT", CFG_CUSTOM, 1, vector< double >{2})
The pesticide burdon (mg/mg) threshold value starts to have effect on the animal.
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
PesticideToxicity::m_pest_hazard
double m_pest_hazard
The hazard of the pesticide.
Definition: PesticideToxicity.h:72
PesticideToxicity::m_location_previous_y
int m_location_previous_y
The y-coordinate is used to remember the location from the previous time-step.
Definition: PesticideToxicity.h:82
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
PesticideToxicity::m_toxicity_func_pointer
void(PesticideToxicity::* m_toxicity_func_pointer)(double, double)
The function pointer to point the function for toxicity effect calculation.
Definition: PesticideToxicity.h:74
PesticideStore::supplyPesticide
std::vector< double > * supplyPesticide(void)
The function to return the pesticide amount array.
Definition: PesticideToxicity.h:50
PesticideStore::m_ALandscape
static Landscape * m_ALandscape
The static landscape pointer.
Definition: PesticideToxicity.h:39
PesticideToxicity::reset
virtual void reset(void)
Reset PesticideToxicity class, this should be called when the host animal is dead.
Definition: PesticideToxicity.cpp:195
PesticideToxicity::m_my_animal_mortality
double m_my_animal_mortality
The mortality rate of the host animal caused by pesticide body burden.
Definition: PesticideToxicity.h:78
PesticideToxicity::doContact
void doContact(void)
The function to calculate the pesticide contamination through contact.
Definition: PesticideToxicity.cpp:140
pest_animal_killing_rate
static CfgArray_Double pest_animal_killing_rate("PEST_ANIMAL_KILLING_RATE", CFG_CUSTOM, 1, vector< double >{0.01})
The pesticide killing rate constant for GUTS-SD.
pest_overspray_animal_rate
static CfgFloat pest_overspray_animal_rate("PEST_OVERSPRAY_ANIMAL_RATE", CFG_CUSTOM, 0.01)
The absorption rate of the animal for overspray.
pest_contact_animal_ratio
static CfgFloat pest_contact_animal_ratio("PEST_CONTACT_ANIMAL_RATIO", CFG_CUSTOM, 0.1)
The ratio to control how much the animal will be contaminated through contact.
pest_overspray_animal_surface
static CfgFloat pest_overspray_animal_surface("PEST_OVERSPRAY_ANIMAL_SURFACE", CFG_CUSTOM, 0.01)
The surface of the animal in square meters fo the calculation of overspray.