2
$\begingroup$

I am trying to look at the migration of "i" number of species "c" in "10" number of habitats {designated as "j"} and to study their population size as a function of time "t". I have this following system working on mathematica :

(* for nSpecies=5 and nHabitats=10 *)

k[0] = 0.9;
hk = 4;
hd = 4;
m = 0.2;
d[0] = 0.05;
di = 0.2;

s[i_] := (m + m i)/2;
k[j_] := k[0]/(1 + (j/hk));
d[j_] := d[0] + (di*j)/(hd + j);

eqs = Table[
   D[c[i, j, t], t] == 
    k[j - 1] s[i] - (k[j] s[i] + d[j]) c[i, j, t], {i, 1, 5}, {j, 0, 
    10}];

initCon = Table[c[i, j, 0] == 100000,
   {i, 1, 5}, {j, 0, 10}];

sol = DSolve[{eqs, initCon}, 
   Flatten@Table[c[i, j, t], {i, 1, 5}, {j, 0, 10}], t];

I want to write the equations for the habitat-1 and habitat-10 separately for "i" number of species.

So mathematically my system of equations look like this:

c'(i,1,t)= (q/nSpecies) - (k(1) s(i) + d(1)) c(i,1,t);

c'(i,j,t)= k(j-1) s(i) c(i,j-1,t) - (k(j) s(i) + d(j)) c(i,j,t);

c'(i,10,t)= k(9) s(i) c(i,9,t) - d(10) c(i,10,t)

I can't incorporate the equations for habitat-1 and habitat-10.

$\endgroup$
2
  • $\begingroup$ Please format your code into code blocks using four spaces to indent each line. For formatting help, click the grey question mark on the right side of the toolbar above the editing window. In addition, please reduce the problem as much as possible to a minimal example. For instance, all of the Plot Options are unnecessary and serve only to make the question harder to parse. $\endgroup$
    – march
    Commented Sep 29, 2015 at 17:23
  • $\begingroup$ As for your question, two option are to use Piecewise or If statements inside the Table which defines the equations. $\endgroup$
    – march
    Commented Sep 29, 2015 at 17:28

1 Answer 1

0
$\begingroup$

Hey I could figure out the solution myself. Any ways thanks for the response. But now I want to figure out the population size per species and total population per habitat. How should I do that? Evaluate doesn’t give me that! If anybody has any idea please post as a comment.

(* for nSpecies=5 and nHabitats=10 *)
k[0] = 0.9;
hk = 4;
hd = 4;
m = 0.5;
d[0] = 0.05;
di = 0.2;
q = 100000;


s[i_] := (m + m i)/2;
k[j_] := k[0]/(1 + (j/hk));
d[j_] := d[0] + (di*j)/(hd + j);


eq1 = Table[D[c[i, j, t], t] == q - (k[j] s[i] + d[j]) c[i, j, t], {i, 1, 
5}, {j, 1, 1}];

eq2 = Table[D[c[i, j, t], t] == 
k[j - 1] s[i] c[i, j - 1, t] - (k[j] s[i] + d[j]) c[i, j, t], {i, 
1, 5}, {j, 2, 9}];

eq3 = Table[D[c[i, j, t], t] == 
k[j - 1] s[i] c[i, j - 1, t] - d[j] c[i, j, t], {i, 1, 5}, {j, 10,
 10}];

initCon = Table[c[i, j, 0] == 0,{i, 1, 5}, {j, 1, 10}];

sol = DSolve[{eq1, eq2, eq3, initCon}, Flatten@Table[c[i, j, t], {i, 1, 5}, {j, 1, 10}], t];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.