Goose Management Model ODdox
1.02
|
#include <pesticide.h>
Public Member Functions | |
void | DailyQueueAdd (LE *a_element_sprayed, double a_amount, PlantProtectionProducts a_ppp) |
void | DiffusionMaskInitTest (void) |
bool | GetAnythingToDecay (PlantProtectionProducts a_ppp) |
Pesticide (RasterMap *a_land, Landscape *a_map) | |
bool | SavePPM (double *a_map, int a_beginx, int a_width, int a_beginy, int a_height, char *a_filename) |
double | SupplyPesticide (int a_polyref, PlantProtectionProducts a_ppp) |
double | SupplyPesticide (int a_x, int a_y, PlantProtectionProducts a_ppp) |
void | Tick (void) |
virtual | ~Pesticide (void) |
Protected Member Functions | |
void | CalcRainWashOffFactors () |
Pre-calculates the constants required for rain wash off with increasing rainfall and stores this in m_RainWashoffFactor. More... | |
void | DailyQueueClear (PlantProtectionProducts a_ppp) |
void | DailyQueueProcess (PlantProtectionProducts a_ppp) |
double | DiffusionFunction (double a_dist_meters) |
void | DiffusionMaskInit (void) |
void | DiffusionSprayPixel (int a_x, int a_limit_x, int a_y, int a_limit_y, double a_amount, double a_cover, PlantProtectionProducts a_ppp) |
bool | ElementIsWater (int a_x, int a_y) |
void | MainMapDecay (PlantProtectionProducts a_ppp) |
void | TwinMapClear (int a_minx, int a_miny, int a_maxx, int a_maxy) |
void | TwinMapDiffusion (int a_minx, int a_miny, int a_maxx, int a_maxy, double a_cover, PlantProtectionProducts a_ppp) |
void | TwinMapSpray (LE *a_element_spryaed, double a_amount, int a_minx, int a_miny, int a_maxx, int a_maxy) |
void | TwinMapSprayCorrectBorders (void) |
void | TwinMapSprayPixel (int a_large_map_x, int a_large_map_y, double a_fractional_amount) |
Protected Attributes | |
double | m_corr_x |
double | m_corr_y |
vector< vector< PesticideEvent * > > | m_daily_spray_queue |
List lists of landscape elements, which was sprayed on a given day. One for each PPP we track. More... | |
Diffusion_mask | m_diffusion_mask [4] |
Pre-calculated square diffusion map, assuming wind directions (4) Used after spraying an element in the pesticide map to determine how much of the sprayed material spreads into the surroundings. More... | |
RasterMap * | m_land |
Landscape * | m_map |
int | m_NoPPPs |
The number of active PPPs to track. More... | |
double | m_pest_daily_decay_frac |
double | m_pest_daily_decay_frac_Soil |
double | m_pest_daily_decay_frac_Veg |
unsigned int | m_pest_map_height |
The height of one map in cellsize resolution. More... | |
vector< vector< double > > | m_pest_map_main |
unsigned int | m_pest_map_size |
The total size of one map in cellsize resolution. More... | |
double * | m_pest_map_twin |
The complete pesticide map. More... | |
unsigned int | m_pest_map_width |
The width of one map in cellsize resolution. More... | |
double | m_prop |
unsigned | m_rainfallcategory |
Daily rainfall saved here * 100 to use as an index to the Pesticide::m_RainWashoffFactor array - an optimisation to stop repeated calls to Landscape::SupplyRain. More... | |
double | m_RainWashoffFactor [10000] |
a structure to hold pre-calculated pesticide rain wash off factor (Rw) More... | |
bool | m_something_to_decay [ppp_foobar] |
Speed hack. Only actually run the daily decay routine on the pesticide map if and only if we are sure that there is some pesticide anywhere on the map for us to process. More... | |
int | m_wind |
int | m_x_excess |
int | m_y_excess |
Definition at line 106 of file pesticide.h.
First determine the size of the maps we need in terms of the number of PPPs to track
For vegetation fraction, the decay is based on ln(2)/DT50
For soil fraction, the decay is based on 10^(log10(0.5) /DT50)
Definition at line 526 of file pesticide.cpp.
References CalcRainWashOffFactors(), DiffusionMaskInit(), DiffusionMaskInitTest(), l_pest_ai_half_life, l_pest_ai_half_life_Soil, l_pest_ai_half_life_Veg, l_pest_enable_pesticide_engine, l_pest_NoPPPs, m_corr_x, m_corr_y, m_daily_spray_queue, m_land, m_map, m_NoPPPs, m_pest_daily_decay_frac, m_pest_daily_decay_frac_Soil, m_pest_daily_decay_frac_Veg, m_pest_map_height, m_pest_map_main, m_pest_map_size, m_pest_map_twin, m_pest_map_width, m_prop, m_something_to_decay, m_x_excess, m_y_excess, RasterMap::MapHeight(), RasterMap::MapWidth(), PEST_GRIDAREA, PEST_GRIDSIZE, PEST_GRIDSIZE_POW2, CfgInt::value(), CfgFloat::value(), and CfgBool::value().
|
virtual |
Definition at line 621 of file pesticide.cpp.
References l_pest_enable_pesticide_engine, m_diffusion_mask, m_pest_map_twin, and CfgBool::value().
|
protected |
Pre-calculates the constants required for rain wash off with increasing rainfall and stores this in m_RainWashoffFactor.
Calculates the proportion of pesticide that is washed off the canopy for 0.1 to 10mm of rain and for 0 to 100% cover in 1% steps.
Definition at line 599 of file pesticide.cpp.
References m_RainWashoffFactor.
Referenced by Pesticide().
void Pesticide::DailyQueueAdd | ( | LE * | a_element_sprayed, |
double | a_amount, | ||
PlantProtectionProducts | a_ppp | ||
) |
Definition at line 140 of file pesticide.cpp.
References m_daily_spray_queue.
Referenced by Orchard::DoDevelopment(), OrchardBand::DoDevelopment(), Farm::ProductApplication(), and Farm::ProductApplication_DateLimited().
|
protected |
Empties and resets the pesticide action queue. On calling any event not yet carried out will be deleted.
Definition at line 131 of file pesticide.cpp.
References m_daily_spray_queue.
Referenced by Tick().
|
protected |
If we are spraying at least one field. Force the main pesticide map which forces the decay method to run tomorrow. First we add the amount in m_amount to the twin map (all squares covered with the polygon get m_amount added) using TwinMapSpray
Next this twin map is added to the main map and if necessary it is here we sort out the allocation between vegetation canopy and soil fractions. This is done by TwinMapDiffusion
Definition at line 147 of file pesticide.cpp.
References g_land, m_daily_spray_queue, m_something_to_decay, m_wind, Landscape::SupplyWindDirection(), TwinMapClear(), TwinMapDiffusion(), and TwinMapSpray().
Referenced by Tick().
|
protected |
The equation provided here is the one that determines the drift of pesticides with distance. It is important that if the drift is set to zero that the result of the equation is unity.
Definition at line 442 of file pesticide.cpp.
References l_pest_diffusion_slope, l_pest_zero_threshold, and CfgFloat::value().
Referenced by DiffusionMaskInit().
|
protected |
l_pest_diffusion_grid_count contains the number of grid points to consider e.g. 1 will be a grid of 9 squares centred at the spray point, 2 will be 25 squares (2*2+1)^2 , 3 will be 49, etc..
The proportion of the applicationcation rate assuming it was sprayed in the centre square is calculated for each surrounding square. Wind direction is taken into account and the mask is created for four wind directions and saved.
Definition at line 325 of file pesticide.cpp.
References DiffusionFunction(), l_pest_diffusion_grid_count, m_diffusion_mask, and CfgInt::value().
Referenced by Pesticide().
void Pesticide::DiffusionMaskInitTest | ( | void | ) |
Definition at line 640 of file pesticide.cpp.
References l_pest_diffusion_grid_count, m_diffusion_mask, and CfgInt::value().
Referenced by Pesticide().
|
inlineprotected |
This sprays the pesticide (a_amount) by placing this into a pesticide cell in the main map. If more detailed pesticide fate is needed then a_amount will be partitioned between soil and canopy.
First a test is made to ensure that the coordinates given are within the landscape. If not the pesticide is sprayed off world, and lost.
Partioning, if occuring, is done based on two components - the canopy and the soil. The pesticide is partioned between the two based on the asssumed vegetation cover of the crop based on Beer's Law.
Definition at line 301 of file pesticide.cpp.
References m_pest_map_main.
Referenced by TwinMapDiffusion().
|
inlineprotected |
Definition at line 263 of file pesticide.h.
References m_map, Landscape::SupplyElementType(), tole_FishFarm, tole_Freshwater, tole_Pond, tole_River, and tole_Saltwater.
Referenced by SupplyPesticide().
|
inline |
Definition at line 228 of file pesticide.h.
References m_something_to_decay.
Referenced by Landscape::SupplyPesticideDecay().
|
protected |
This is where the environmental decay takes place. Here we assume a first order decay based on a daily proportion of the cell total. If using detailed fate modelling then is calculation is more complex.
This is where the environmental decay takes place. Here we assume a first order decay based on a daily proportion of the cell total. If using detailed fate modelling then is calculation is more complex.
Definition at line 469 of file pesticide.cpp.
References g_landscape_p, l_pest_zero_threshold, m_pest_daily_decay_frac, m_pest_daily_decay_frac_Soil, m_pest_daily_decay_frac_Veg, m_pest_map_main, m_pest_map_size, m_pest_map_width, m_rainfallcategory, m_RainWashoffFactor, m_something_to_decay, PEST_GRIDSIZE_POW2, Landscape::SupplyVegCover(), and CfgFloat::value().
Referenced by Tick().
bool Pesticide::SavePPM | ( | double * | a_map, |
int | a_beginx, | ||
int | a_width, | ||
int | a_beginy, | ||
int | a_height, | ||
char * | a_filename | ||
) |
Definition at line 673 of file pesticide.cpp.
References g_msg, m_pest_map_height, m_pest_map_width, SV_UINT32, SV_UINT8, MapErrorMsg::Warn(), and WARN_FATAL.
|
inline |
Definition at line 347 of file pesticide.h.
References m_map, m_pest_map_main, and Landscape::SupplyPesticideCell().
|
inline |
a_x | the x-coord in landscape x units |
a_y | the y-coord in landscape x units |
Definition at line 329 of file pesticide.h.
References ElementIsWater(), m_pest_map_main, m_pest_map_width, and PEST_GRIDSIZE_POW2.
Referenced by Landscape::SupplyPesticide(), Landscape::SupplyPesticideP(), and Landscape::SupplyPesticideS().
void Pesticide::Tick | ( | void | ) |
Definition at line 97 of file pesticide.cpp.
References DailyQueueClear(), DailyQueueProcess(), g_land, g_weather, Weather::GetTemp(), l_pest_ai_half_life, l_pest_enable_pesticide_engine, m_NoPPPs, m_pest_daily_decay_frac, m_rainfallcategory, MainMapDecay(), ppp_1, Landscape::SupplyRain(), CfgFloat::value(), and CfgBool::value().
Referenced by Landscape::Tick().
|
protected |
Definition at line 181 of file pesticide.cpp.
References m_pest_map_twin, and m_pest_map_width.
Referenced by DailyQueueProcess().
|
protected |
Definition at line 276 of file pesticide.cpp.
References DiffusionSprayPixel(), m_diffusion_mask, m_pest_map_height, m_pest_map_twin, m_pest_map_width, and m_wind.
Referenced by DailyQueueProcess().
|
protected |
This is where the initial pesticide concentration is applied to the map. A twin of the real maps is used for spraying the amount of pesticide that is sprayed over each cell and then copied to the real one by using a 'diffusion' process to spread it out to all surrounding cells for drift.
Going through the whole landscape is very slow and unnecessary for small polygons. Since our polygons do not extend beyond the edge of the map ie do not wrap round, then we only need a measure of minx, maxx, miny, maxy. This is set up at the start of the simulation.
Definition at line 194 of file pesticide.cpp.
References RasterMap::Get(), LE::GetMapIndex(), m_land, m_prop, TwinMapSprayCorrectBorders(), and TwinMapSprayPixel().
Referenced by DailyQueueProcess().
|
protected |
Definition at line 230 of file pesticide.cpp.
References m_corr_x, m_corr_y, m_pest_map_height, m_pest_map_size, m_pest_map_twin, m_pest_map_width, m_x_excess, m_y_excess, and PEST_GRIDAREA.
Referenced by TwinMapSpray().
|
inlineprotected |
Definition at line 357 of file pesticide.h.
References m_pest_map_twin, m_pest_map_width, and PEST_GRIDSIZE_POW2.
Referenced by TwinMapSpray().
|
protected |
Definition at line 157 of file pesticide.h.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().
|
protected |
Definition at line 158 of file pesticide.h.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().
|
protected |
List lists of landscape elements, which was sprayed on a given day. One for each PPP we track.
Definition at line 200 of file pesticide.h.
Referenced by DailyQueueAdd(), DailyQueueClear(), DailyQueueProcess(), and Pesticide().
|
protected |
Pre-calculated square diffusion map, assuming wind directions (4)
Used after spraying an element in the pesticide map to determine how much of the sprayed material spreads into the surroundings.
Definition at line 197 of file pesticide.h.
Referenced by DiffusionMaskInit(), DiffusionMaskInitTest(), TwinMapDiffusion(), and ~Pesticide().
|
protected |
Definition at line 168 of file pesticide.h.
Referenced by Pesticide(), and TwinMapSpray().
|
protected |
Definition at line 171 of file pesticide.h.
Referenced by ElementIsWater(), Pesticide(), and SupplyPesticide().
|
protected |
The number of active PPPs to track.
Definition at line 149 of file pesticide.h.
Referenced by Pesticide(), and Tick().
|
protected |
Definition at line 163 of file pesticide.h.
Referenced by MainMapDecay(), Pesticide(), and Tick().
|
protected |
Definition at line 165 of file pesticide.h.
Referenced by MainMapDecay(), and Pesticide().
|
protected |
Definition at line 164 of file pesticide.h.
Referenced by MainMapDecay(), and Pesticide().
|
protected |
The height of one map in cellsize resolution.
Definition at line 188 of file pesticide.h.
Referenced by Pesticide(), SavePPM(), TwinMapDiffusion(), and TwinMapSprayCorrectBorders().
|
protected |
Definition at line 179 of file pesticide.h.
Referenced by DiffusionSprayPixel(), MainMapDecay(), Pesticide(), and SupplyPesticide().
|
protected |
The total size of one map in cellsize resolution.
Definition at line 184 of file pesticide.h.
Referenced by MainMapDecay(), Pesticide(), and TwinMapSprayCorrectBorders().
|
protected |
The complete pesticide map.
Definition at line 182 of file pesticide.h.
Referenced by Pesticide(), TwinMapClear(), TwinMapDiffusion(), TwinMapSprayCorrectBorders(), TwinMapSprayPixel(), and ~Pesticide().
|
protected |
The width of one map in cellsize resolution.
Definition at line 186 of file pesticide.h.
Referenced by MainMapDecay(), Pesticide(), SavePPM(), SupplyPesticide(), TwinMapClear(), TwinMapDiffusion(), TwinMapSprayCorrectBorders(), and TwinMapSprayPixel().
|
protected |
Definition at line 156 of file pesticide.h.
Referenced by Pesticide(), and TwinMapSpray().
|
protected |
Daily rainfall saved here * 100 to use as an index to the Pesticide::m_RainWashoffFactor array - an optimisation to stop repeated calls to Landscape::SupplyRain.
Definition at line 193 of file pesticide.h.
Referenced by MainMapDecay(), and Tick().
|
protected |
a structure to hold pre-calculated pesticide rain wash off factor (Rw)
Definition at line 191 of file pesticide.h.
Referenced by CalcRainWashOffFactors(), and MainMapDecay().
|
protected |
Speed hack. Only actually run the daily decay routine on the pesticide map if and only if we are sure that there is some pesticide anywhere on the map for us to process.
Cleared daily by MainMapDecay().
Set to true when either adding pesticide to the map, or by the MainMapDecay() method itself, when it finds remains of pesticide anywhere on the pesticide map during its run. One copy is needed for each active PPP
Definition at line 146 of file pesticide.h.
Referenced by DailyQueueProcess(), GetAnythingToDecay(), MainMapDecay(), and Pesticide().
|
protected |
Definition at line 159 of file pesticide.h.
Referenced by DailyQueueProcess(), and TwinMapDiffusion().
|
protected |
Definition at line 154 of file pesticide.h.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().
|
protected |
Definition at line 155 of file pesticide.h.
Referenced by Pesticide(), and TwinMapSprayCorrectBorders().