MadonnaModel
Arial!D(.2>
B6:
I
)7{Figure 1a von Neuman neighborhood migration of material quantities}
METHOD RK4
STARTTIME = 0
STOPTIME=100
DT = 0.1
{begin and end set the index for the grid. Begin should not be changed. Changing end increases or decreases the size of the grid}
begin = 1
end = 3
{constant percentage that will migrate out of each population}
outmig_constant = .10
{birth fractions and death fractions within each population are constant and equal for this example}
birth_fraction = 0.02
death_fraction = 0.02
{These constants determine how to divide up the out_migration population among the populations they will migrate to. Corner populations have two possible moves, edge pops have three possible moves, central populations have four possible moves}
vonNeuman_corner = 1/2
vonNeuman_edge = 1/3
vonNeuman_center = 1/4
{Limit populations to non-negative values}
limit pop >= 0
{Initialize the populations in all grid squares from an external data file}
init pop[begin..end,begin..end] = #import_1a(j,i)
{Calculate the birth and death rates for each population}
br_pop[begin..end,begin..end] = birth_fraction*pop[i,j]
dr_pop[begin..end,begin..end] = death_fraction*pop[i,j]
{Calculate popuation totals}
d/dt(pop[begin..end,begin..end]) = IF((i = begin OR i = end) AND (j = begin OR j = end)) THEN
br_pop[i,j] - dr_pop[i,j] + inmigration_pop[i,j] - outmigration_pop[i,j]*(1/vonNeuman_corner)
ELSE IF (i = begin OR i = end OR j = begin OR j = end) THEN
br_pop[i,j] - dr_pop[i,j] + inmigration_pop[i,j] - outmigration_pop[i,j]*(1/vonNeuman_edge)
ELSE
br_pop[i,j] - dr_pop[i,j] + inmigration_pop[i,j] - outmigration_pop[i,j]*(1/vonNeuman_center)
{Calculate inmigration as sum of outmigrations from neighbors}
{Inmigration takes into consideration the von Neuman neighborhood.
The first four IF statments are for the four corners of the grid.
The next four IF statements are for squares at the edges of the grid, but not corners.
Then last statement is for central locations.}
inmigration_pop[begin..end,begin..end] = IF ((i = begin) AND (j = begin)) THEN
outmigration_pop[i,j+1] + outmigration_pop[i+1,j]
ELSE IF ((i = begin) AND (j = end)) THEN
outmigration_pop[i,j-1] + outmigration_pop[i+1,j]
ELSE IF ((i = end) AND (j = end)) THEN
outmigration_pop[i,j-1] + outmigration_pop[i-1,j]
ELSE IF ((i = end) AND (j = begin)) THEN
outmigration_pop[i,j+1] + outmigration_pop[i-1,j]
ELSE IF (i-1 < begin) THEN
outmigration_pop[i,j+1] + outmigration_pop[i,j-1] + outmigration_pop[i+1,j]
ELSE IF (i+1 > end) THEN
outmigration_pop[i,j+1] + outmigration_pop[i,j-1] + outmigration_pop[i-1,j]
ELSE IF (j-1 < begin) THEN
outmigration_pop[i+1,j] + outmigration_pop[i-1,j] + outmigration_pop[i,j+1]
ELSE IF (j+1 > end) THEN
outmigration_pop[i+1,j] + outmigration_pop[i-1,j] + outmigration_pop[i,j-1]
ELSE
outmigration_pop[i+1,j] + outmigration_pop[i-1,j] + outmigration_pop[i,j+1] + outmigration_pop[i,j-1]
{Calculate outmigration from each population}
{outmigration is a constant proportion of each population (outmig_constant) divided by the number of places to which the migration can go. This number of places is determined by how many von Neuman neighbors the population has}
outmigration_pop[begin..end,begin..end] = IF((i = begin OR i = end) AND (j = begin OR j = end)) THEN
pop[i,j]*outmig_constant*vonNeuman_corner
ELSE IF (i = begin OR i = end OR j = begin OR j = end) THEN
pop[i,j]*outmig_constant*vonNeuman_edge
ELSE
pop[i,j]*outmig_constant*vonNeuman_centerm8#import_data?@@@?@@@@@ AB@@@A@@88:#import_1a?@@@?B@@@9:i:u;
:};@rk4MbP?MbP?MbP?n6?|h>333??TIME%popQembr_popdr_pop%inmigration_popY outmigration_pop!)
u-10=]|
!)19AI"$&(*,.0x<@BYDmFQ
^lp
t
DHL &,2.Fjnr
z88;vu8e8Q8;8 8$B&B(B*B,;.;B