-
Notifications
You must be signed in to change notification settings - Fork 0
/
In_Out_Migration_Functions.c
107 lines (78 loc) · 2.82 KB
/
In_Out_Migration_Functions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <MODEL.h>
double In_Mu(Parameter_Table * Table, int m, int Sp, int J, const double * y)
{
/* Input:
------
. m: Equation index
. Sp: Species
. J: Index of the population receiveing immigrants.
(K: Index of the population from which immigrants come)
. y: State vector
Output:
-------
. Mu: Total number of immigrations arriving to local popualtion J from all other
neighboring populations per unit time
*/
/* Warning: This assumes the Patch System has been previously set up */
Community ** P = Table->Patch_System;
int K;
double Mu;
int i,j, k, n;
/*
J: Index for the J-th population
K: Index for the K-th population
*/
k = m%Table->LOCAL_STATE_VARIABLES;
assert(k == Sp);
Mu = 0.0;
if(Table->TYPE_of_NETWORK == 1)
assert( Table->No_of_NEIGHBORS == P[J]->No_NEI );
for( j=0; j<P[J]->No_NEI; j++) {
K = P[J]->Patch_Connections[j];
n = k + Table->LOCAL_STATE_VARIABLES*K;
if (Table->TYPE_of_MODEL == 0 || Table->TYPE_of_MODEL == 1 )
assert(Table->Mu == P[j]->In_Migration_Vector[Sp][j]);
if (Sp == 0)
assert(Table->Mu == P[j]->In_Migration_Vector[Sp][j]);
if (Sp == 1 && Table->TYPE_of_MODEL == 2)
assert(Table->Mu_C == P[j]->In_Migration_Vector[Sp][j]);
Mu += P[J]->In_Migration_Vector[Sp][j] * y[n];
/* Mu += Table->Metapop_Connectivity_Matrix[Sp][J][K] * y[n]; */
}
return (Mu);
}
double Out_Mu_Per_Capita(Parameter_Table * Table, int Sp, int J)
{
/* Input:
------
. Sp: Species or Type
. J: Index of the population exporting individuals over all its local neighboring
populations.
Output:
-------
. Mu: Per Capita emigration rate from the J-th population over all other local population
*/
double Mu;
int j, K;
Community ** P = Table->Patch_System;
if(Table->TYPE_of_NETWORK == 1)
assert( Table->No_of_NEIGHBORS == P[J]->No_NEI );
Mu = 0.0;
for( j=0; j < P[J]->No_NEI; j++) {
K = P[J]->Patch_Connections[j];
Mu += P[J]->Out_Migration_Vector[Sp][j];
/* if(Table->TYPE_of_NETWORK == 0) */
/* Mu += Table->Metapop_Connectivity_Matrix[Sp][K][J]; */
/* else */
/* Mu += Table->Metapop_Connectivity_Matrix[Sp][J][K]; */
}
if (Table->TYPE_of_MODEL == 0 || Table->TYPE_of_MODEL == 1)
assert( (P[J]->No_NEI * Table->Mu) == Mu );
if (Table->TYPE_of_MODEL == 2) {
if (Sp == 0) assert( (P[J]->No_NEI * Table->Mu) == Mu );
else if (Sp == 1) assert( (P[J]->No_NEI * Table->Mu_C) == Mu );
else if (Sp == 2) assert( (P[J]->No_NEI * 0.0 * Table->Mu_C) == Mu );
else assert( 0.0 == Mu );
}
return (Mu);
}