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.h
Go to the documentation of this file.
1 //
2 // PesticideToxicity.h
3 //
4 /*
5 *******************************************************************************************************
6 Copyright (c) 2023, Xiaodong Duan
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without modification, are permitted provided
10 that the following conditions are met:
11 
12 Redistributions of source code must retain the above copyright notice, this list of conditions and the
13 following disclaimer.
14 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
15 the following disclaimer in the documentation and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
20 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 ********************************************************************************************************
26 */
27 
28 #ifndef PesticideToxicityH
29 #define PesticideToxicityH
30 #include <numeric>
31 class TAnimal;
32 
34 {
35  protected:
37  std::vector<double> m_pest_amount_vec;
40 
41  public:
44  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);
46  void addPesticide(double a_mount, PlantProtectionProducts a_type) {m_pest_amount_vec[a_type] += a_mount;}
48  virtual void reset(void);
50  std::vector<double>* supplyPesticide(void) {return &m_pest_amount_vec;}
52  double supplyPesticide(PlantProtectionProducts a_type) {return(m_pest_amount_vec[a_type]);}
54  double supplyTotalPesticide(void) {return std::accumulate(m_pest_amount_vec.begin(), m_pest_amount_vec.end(), 0.0);}
56  void doDecay(void);
58  virtual void tick(int a_step_counter_in_a_day);
60  static void setLandscapePointer(Landscape* a_landscape) {m_ALandscape = a_landscape;}
61 };
62 
64 {
65  private:
66 
72  double m_pest_hazard;
74  void (PesticideToxicity::*m_toxicity_func_pointer)(double, double);
83 
84  public:
87  void doToxicity(double a_mass, double a_para_index);
89  void setToxicityFuncPointer(void (PesticideToxicity::*a_toxicity_func) (double, double)) {m_toxicity_func_pointer = a_toxicity_func;}
91  void setDecayFuncPointer(void (PesticideToxicity::*a_decay_func) (void)) {m_decay_func_pointer = a_decay_func;}
93  void doOverspray(void);
95  void doContact(void);
97  virtual void tick(int a_step_counter_in_a_day, double a_mass=1, double a_para_index=0);
99  std::vector<double> supplyPesticideVector(void) { return m_pest_amount_vec; }
100  void SetPesticideVector(std::vector<double> a_pest_amount_vec) { m_pest_amount_vec = a_pest_amount_vec;}
108  virtual void reset(void);
110  void eatingFromStorePest(PesticideStore* a_store, double a_eating_amount, double a_total_amount);
112  double GetTotalPest(void) {return m_total_pest_sum;}
113 };
114 
115 #endif //end PesticideToxicityH
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::supplyPesticideVector
std::vector< double > supplyPesticideVector(void)
The function to return the pesticide amount array.
Definition: PesticideToxicity.h:99
PesticideToxicity::m_my_animal_host
TAnimal * m_my_animal_host
The pointer to the host animal.
Definition: PesticideToxicity.h:68
PesticideStore::supplyTotalPesticide
double supplyTotalPesticide(void)
The function to return the total pesticide amount.
Definition: PesticideToxicity.h:54
PesticideToxicity::doOverspray
void doOverspray(void)
The function for the animal to be oversprayed when the pesticide application is happening where the a...
Definition: PesticideToxicity.cpp:165
PesticideToxicity
Definition: PesticideToxicity.h:63
PesticideStore::setLandscapePointer
static void setLandscapePointer(Landscape *a_landscape)
The function to set the static landscape pointer.
Definition: PesticideToxicity.h:60
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.
PesticideStore::addPesticide
void addPesticide(double a_mount, PlantProtectionProducts a_type)
The function to add pesticide based on the given amount and the given type.
Definition: PesticideToxicity.h:46
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
PesticideStore::reset
virtual void reset(void)
The function to reset the pesticide to zero.
Definition: PesticideToxicity.cpp:85
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::PesticideStore
PesticideStore()
Definition: PesticideToxicity.cpp:71
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
The landscape class containing all environmental and topographical data.
Definition: Landscape.h:142
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.
CfgBool
Bool configurator entry class.
Definition: Configurator.h:155
PesticideToxicity::supplyPestMortality
double supplyPestMortality(void)
The function to supply the host's mortality rate caused by pest.
Definition: PesticideToxicity.h:104
TAnimal::Supply_m_Location_y
int Supply_m_Location_y() const
Returns the ALMaSS y-coordinate.
Definition: PopulationManager.h:243
TAnimal
The base class for all ALMaSS animal classes. Includes all the functionality required to be handled b...
Definition: PopulationManager.h:200
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.
PesticideToxicity::setHostAnimalPointer
void setHostAnimalPointer(TAnimal *animal)
The function to set the host animal pointer.
Definition: PesticideToxicity.h:106
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
PesticideStore::tick
virtual void tick(int a_step_counter_in_a_day)
The function to update pesticide contamination every time step.
Definition: PesticideToxicity.cpp:105
CfgArray_Double
Definition: Configurator.h:208
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 ...
PesticideToxicity::PesticideToxicity
PesticideToxicity()
Definition: PesticideToxicity.cpp:113
PesticideStore::supplyPesticide
double supplyPesticide(PlantProtectionProducts a_type)
The function to return the pesticide amount.
Definition: PesticideToxicity.h:52
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
PesticideToxicity::SetPesticideVector
void SetPesticideVector(std::vector< double > a_pest_amount_vec)
Definition: PesticideToxicity.h:100
PesticideStore
Definition: PesticideToxicity.h:33
PesticideStore::supplyPesticide
std::vector< double > * supplyPesticide(void)
The function to return the pesticide amount array.
Definition: PesticideToxicity.h:50
PesticideToxicity::setToxicityFuncPointer
void setToxicityFuncPointer(void(PesticideToxicity::*a_toxicity_func)(double, double))
The function to set the toxicity function pointer.
Definition: PesticideToxicity.h:89
PesticideToxicity::setDecayFuncPointer
void setDecayFuncPointer(void(PesticideToxicity::*a_decay_func)(void))
The function to set the decay function pointer.
Definition: PesticideToxicity.h:91
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
CfgInt
Integer configurator entry class.
Definition: Configurator.h:102
CfgFloat
Double configurator entry class.
Definition: Configurator.h:126
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
l_pest_zero_threshold
CfgFloat l_pest_zero_threshold
The number of pesticide types used, the maximum value is 10.
CFG_CUSTOM
Definition: Configurator.h:70
PesticideToxicity::supplyPesticide
double supplyPesticide(PlantProtectionProducts a_type=ppp_1)
The function to supply the pesticide residue for the given pesticide type, the default type is 0,...
Definition: PesticideToxicity.h:102
PesticideToxicity::doContact
void doContact(void)
The function to calculate the pesticide contamination through contact.
Definition: PesticideToxicity.cpp:140
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...
PesticideToxicity::tick
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.
Definition: PesticideToxicity.cpp:179
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.
PesticideToxicity.h
ppp_1
Definition: LandscapeFarmingEnums.h:1079
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.
PesticideToxicity::GetTotalPest
double GetTotalPest(void)
Return the total pesticide.
Definition: PesticideToxicity.h:112
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.
PesticideToxicity::eatingFromStorePest
void eatingFromStorePest(PesticideStore *a_store, double a_eating_amount, double a_total_amount)
The function for eating from a store to add pesticide.
Definition: PesticideToxicity.cpp:206