How to run the program The model is to calculate pollen dispersion, deposition and potential outcrossing Pollen”, you will see Figure 2.. Until now, you input all the input information,
Trang 1Manual of Gene Flow Model from Pollen Dispersion
1 How to run the program 2
2 Locations of concentration and deposition detectors 7
2.1 The coordinate system 7
2.2 Locations of concentration detectors 8
2.3 Location of deposition detectors 10
3 Program structure 10
3.1 Function of OnPredictionAperiod 10
3.2 Function of CalculationOfDispersion1 12
3.3 Function of FlyFromCircularSource 13
3.4 Function of OneCircularSourceGridFly 14
3.5 Function of Load3DData 15
3.6 Function of OpenGLRendering 16
4 How to adjust program parameters 23
4.1 Model precision 23
4.2 Settling speed 23
4.3 Horseweed and field plant characteristics 23
4.4 Detector size and number 23
4.5 Output graph parameters 24
4.6 Other parameters 24
5 Project Source Codes Location 24
6 References 24
Trang 21 How to run the program
The model is to calculate pollen dispersion, deposition and potential outcrossing (<2
km horizontal scale) The user can run the program using the following steps
1) To run the gene flow model from pollen dispersion, double click the file “GLDemo.exe” You will see the following window.
Figure 1.1 The gene flow model main window
2) Click menu “Prediction->Pollen”, you will see Figure 2 In this window, please select the simulation type, you may select “Single Hours” type to do the simulation for only one period, or you may select “Whole Season” type to do the simulation of whole season.
Trang 3Figure 1.2 The window of selecting simulation type
3) If you choose to do “Single Hours” simulation type, you will see the following window in Figure 3 You are asked to input the simulation date, the start simulation time and the end simulation time, then click “Ok” button to continue If you select “Whole Season” simulation type in step 2, you needn’t to input simulation time, and will go into step 4 directly Horseweed pollen is only released from August 10 to September 27 based on measured data in Tennessee in 2013.
Figure 1.3 The window of inputting simulation time
Trang 44) In this step, you need to input the field related information, see Figure 4 We provides four kinds of field types, which are “Bare Ground”, “Soybean”, “Sweet Corn” and “Grain Corn”, and we need you to input the field radius and the number of horseweed plants in the field Then click “Ok” to continue.
Figure 1.4 The window of inputting the field information
5) Then you need to input the weather data, which includes precipitation, radiation, temperature, mean wind speed and wind direction, see Figure 5 Until now, you input all the input information, you need to input the names of the files which are used to store concentration, deposition, and outcrossing output data in next steps.
Trang 5Figure 1.5 The window of inputting the weather data
6) Give the file name to save the concentration result, see Figure 6.
Figure 1.6 The window of inputting the file name for saving concentration result
7) Give another file name to save the deposition and outcrossing ratio result, see Figure 7.
Trang 6Figure 1.7 The window of inputting the file name for saving deposition result
8) Finally, you will see the result graph, see Figure 8
Figure 1.8 One result of gene flow model from pollen dispersion.
The result includes two parts: the left view shows the input information and some concentration values in the downwind direction; the right view shows five graphs, which are mean wind direction concentration graph (pollen grains/m 3 ), mean deposition graph (pollen grains/m 2 /s),
Trang 7total deposition graph (pollen grains/m ), potential outcrossing ratio graph and outcrossed seed number graph.
9) In addition, there are two output files, one is concentration result, and another is deposition and outcrossing result For the concentration output file, its format is as following.
For deposition and outcrossing output file, its format is as following
x y meanDeposition totalDeposition outcrossingRatio seedNumber
2 Locations of concentration and deposition detectors
The model implements a 3D random walk model, and uses it to simulate the horseweedpollens’ dispersion, then calculates the concentration and deposition value of horseweedpollens at some locations where the concentration and deposition detectors locate Sofirstly let’s talk about the locations of detectors Before that, the coordinate system theprogram is using is given out
2.1 The coordinate system
The coordinate system the model is using is shown in Figure 2.1 According to thisfigure, x-axis direction is from north to south, y-axis direct is from west to east Inaddition, z-axis direction is from ground to sky
Trang 8Figure 2.1 The coordinate system in horizontal plane 2.2 Locations of concentration detectors
There are totally 40x40x40 concentration detectors by default, every concentrationdetector is a cube, whose side length is 0.5m by default Their layout is shown in Figure2.2 and 2.3
Figure 2.2 shows the layout of concentration detectors in x-y coordinate plane, everycoordinate plane includes 40x40 cubes, which exactly cover the whole field region.According to the field radius, the distance between concentration cubes is different Forexample, if the field radius is 60m, then the distance between concentration cubes in xand y direction is 3m (60 x 2 / 40) And for ease of calculation, we give all the cubespositive index value As shown in Figure 2.2, the left-bottom cube’s index is (0,0), theright-top cube’s index is (39,39), so the cube at the center of the field is (20, 20)
Figure 2.2 only show a layer of concentration cubes, there are totally 40 layers in zdirection, see Figure 2.3 Every layer’s cube layout is exactly same And the distancebetween layers is 0.5m by default, which means no distance among layers since thecube’s side length is 0.5m In this case, the total height of all the layers is only40x0.5=20m In order to simulate the concentration value at higher height, the distanceamong layer can be set as bigger, for example, if this distance is set as 1m, then theconcentration value between 0m and 40m can be gotten
Trang 9
Figure 2.2 The concentration detectors' layout in horizontal surface
Figure 2.3 The 3D layout of concentration detectors
Trang 102.3 Location of deposition detectors
Firstly, the shape of deposition detector is a rectangle, whose length is 1.5m and width
is 1.5m by default The size of deposition detector can be changed according to field radius The deposition detector’s layout is exactly same as the layout of concentration cubes in horizontal plane, but there is only one layer So the total number of deposition detectors is 40x40 And the layer’s height is 1.05m by default
3 Program structure
The program uses VS2013 environment For graphs, the OpenGL classes wereused The following figure shows the general structure
Gene flow program
Simulation
Figure 3.1 The general structure of the model
3.1 Function of OnPredictionAperiod
The 3D random-walk simulation codes are in the file of “ChildFrm.cpp” Theprogram starts from function “void CChildFrame::OnPredictionAperiod()”, it is triggeredwhen the user click the menu “Prediction->Pollen” This function calls the UI interface tolet the user input the field and weather information
The flowchart for the function is:
Trang 11Figure 3.2 The flowchart for “void CChildFrame::OnPredictionAperiod()”
According to the above flowchart, the function “OnPredictionAperiod” has the
following steps:
1 Seed the random-number generator, the simulation codes use some randomnumbers generated by rand(), this step will make rand() generate different randomnumber every time when the user runs the program
2 Let user to select simulation type, there are two kinds of simulation, one is “singlehours”, which allows the user to input the simulation time period, the program willonly simulate the result in that period Another is “whole season”, which makes theprogram simulate the concentration and deposition result in whole season
3 If the user selects “Single hours”, then the user needs to input the simulationinformation, which includes simulation date, start simulation time and endsimulation time Based on the measured data in Tennessee, horseweed pollen isonly released from August 10 to September 27 in 2013, so the simulation dateshould be some day during this period If “whole season” is selected, the functionwill go to step 4 directly
4 Let user to input the field information, which includes field type, field radius andthe number of horseweed in the field
5 Let user to input weather parameters, which includes precipitation, radiation,temperature, wind speed and wind direction
6 If precipitation > 0, that means there are rain drop in that period, so no pollens arereleased, the program exits If precipitation = 0, the program will continue to askuser to input the name of the concentration result file
Trang 127 Let user to input the name of the deposition and outcrossing result file.
8 Set up the plant characteristics of horseweed and field plant by calling the function
“SetUpCanopy()”
9 Get the views for showing the result graph
10 Run the thread procedure to call the function “CalculationOfDispersion1()” whichdoes the simulations
3.2 Function of CalculationOfDispersion1
The function “CalculationOfDispersion1()” prepares the parameters, then call thesimulation function, output the result into the output file, and finally call the OpenGLclasses to show the output graphs Its flowchart for is as the follows:
Figure 3.3 The flowchart for “void CChildFrame:: CalculationOfDispersion1 ()”
1 Call the function “CalculateLUStar()” to calculate obukhov length and UStar usingthe weather parameters the user inputs
2 Calculate the wind speed above the plant, and calculate how long the horseweedpollen can fly away from the field, use this period as the simulation time period
3 Call “FlyFromCircularSource()” to do simulation with source strength 1 Since theconcentration and deposition result is directly proportional to the source strengthvalue So the program can easily get the real concentration and deposition resultwith any source strength value
4 Calculate the average source strength during the whole simulation duration Thesource strength values per minute from 08/10/2013 to 09/27/2013 measured inTennessee are saved in the big array TNHorseweedSourceStrength in the file
Trang 13“TNHorseweedSourceStrength.h” By multiplying the result with the averagesource strength value, the final concentration and deposition results are obtained.
Be worth to note, the unit of source strength in array TNHorseweedSourceStrength
is “grains/m2/min”, so we need to transfer it into “grains/m2/second” by dividing
by 60
5 Output all the concentration values into the output file
6 Set up the parameters for drawing the output graph Only the concentration value
in down wind direction will be shown So the variable “Dispersal” only saves theconcentration value in down wind direction
7 According to the deposition result got in step 4, calculate the total depositionresult, outcrossing ratio result and seed number result, and output them into theoutput file
8 Call view class to draw the output graphs
3.3 Function of FlyFromCircularSource
The function “void FlyFromCircularSource(float SourceRadius, BOOL IfFinalResult)”
in the file of “ChildFrm.cpp” does the simulations SourceRadius is the radius of thesource, which is got according to the number of horseweed plants in the field in thefunction “OnPredictionAperiod” IfFinalResult is a Boolean variable which is set to
“TRUE” to save the simulation results The following flowchart shows the function of
“FlyFromCircularSource”
Figure 3.4 The flowchart for “FlyFromCircularSource()”.
1 Firstly, initialize the residence time array and deposition accumulator array usingzero
2 According to the source radius, separate the source region radially and angularlyinto some subsectors
Trang 143 For every subsector, call the function “OneCircularSourceGridFly()” to simulatethe pollen random walk model, and get the pollen residence time and depositionaccumulator value.
4 After the simulation of all the subsectors finish, calculate the concentration anddeposition value
3.4 Function of OneCircularSourceGridFly
The function of “OneCircularSourceGridFly( float SourceGridArea , float RealX , float RealY )” implement the random walk model, and calculates the residence time anddeposition accumulator for every subsector Where the SourceGridArea is the subsectorarea where the particles were released, RealX and RealY are the coordinates of thesubsector which reflect the location of the subsector corresponding to the whole sourceregion
The flowchart for “OneCircularSourceGridFly” is as the follows:
Figure 3.5 The flowchart for “OneCircularSourceGridFly”
For every sector, the program give it a certain number of released pollen (Np, which is
320 by default) For every released pollen, we will do the following steps:
1 Set i = 0, “i” is the counter of the released pollen
Trang 152 For every pollen, calculate the initial coordinates of the pollen, the programassumes both x and y coordinates are always 0 related to the subsector But zcoordinate varies between the horseweed flower height and horseweed plantheight All pollens released from this subsector are divided into 6 groups, everygroup’s pollens have different z coordinate value between horseweed flower heightand horseweed plant height.
3 Call the function “FieldEquilibriumWind()” to calculate the wind speed and UStd,VStd and WStd in the source field since the pollen is always released from thesource field at the beginning
4 Call the function “SetLeafData()” to set the horseweed plant characteristics as thecurrent characteristics
5 Calculate Dt by calling the function “CalculateDt()”, which is the first flight time
of the pollen Every time, we check if the simulation time is out (Time Period < 0),
if yes, then go to do the next released pollen
6 Calculate the flight displacements Dx, Dy and Dz in Dt duration
7 Calculate the new coordinates of the pollen, and transfer the coordinates from thewind coordinate system into the coordinate system the program is using
8 Check if the flight path of the pollen intersects with any concentration cubes usingthe function “cube_line_intersection()”, if yes, calculate the residence time in thecorresponding cubes and save it into the array
9 Continue to check if the flight path of the pollen intersects with any depositiondetector, if yes, calculate the deposition accumulator and record it into the array
10 Check if the pollen flies away from the field, if yes, go to do the next pollen.Otherwise, set the plant characteristics according to the new location of the pollen
11 Furtherly, check if the pollen deposits on the ground or the plant, if yes, go to dothe next pollen
12 If the pollen doesn’t deposit on the ground or the plant, then it will continue to fly
So calculate the new wind speed, UStd, VStd, WStd and Dt by calling
“FieldEquilibriumWind()” and “CalculateDt()”
13 Decrease the time period by Dt, go to check if the simulation period is out
This function returns only when all the released pollens by this subsector finish itsrandom walk
Until now, the main functions of doing simulation are introduced The functions whichdraw the output graphs will be introduced next
3.5 Function of Load3DData
The function “void CGLDemoView::Load3DData( char type, DispersalArgDispersal)” is in the GLDemoView.cpp” The function transfers and grids the data forgraph show Where the Dispersal is a structure which stores the simulation results The
“type” is a parameter which was set to “C” for showing the graph
This function calls the function “void COpenGL3D::Load3DData( chartype,DispersalArg& Dispersal)” in the file “OpenGL3D.cpp” Then the function of
“Load3DMultipleMapsData( type, Dispersal)” is called which in fact does the griddingand data transferring See its following flowchart