Message Boards Message Boards

0
|
7168 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Solving a complex ODE with NDSOLVE

Posted 12 years ago
Hello community,

I am a new user of Mathematica. I am trying to NDsolveĀ  a complex heterogeneous ODE.
I want to solve for all functions (for all the n and k {n,1,nmax}, {k,1,kmax}) S$nk in terms of time, as listed at "vars" below

the hardcore commands are:
eqns = Table[{D[S$nk[n][k][t], t] == (1 - S$nk[n][k][t])*SUS$nk[n][k][t], S$nk[n][k][0] == Initiators}, {n, 1, nmax}, {k,1, kmax}];
vars = Table[S$nk[n][k][t], {n, 1, nmax}, {k, 1, kmax}];
sol = NDSolve[eqns, vars, {t, tmin, tmax}];

where SUS$nk is a function of all S$nk :
SUS$nk[n_][k_][t_] := Sum[Binomial[k, m]*(V[t])^m*(1 - V[t])^(k - m), {m, n, k}];
V[t_] := Sum[Sum[kk/z p$nnkk*S$nk[nn][kk][t], {nn, 1, nmax}], {kk, 1, kmax}];

while the Initial conditions and some extra definitions are:
 z = 4;
 nmax = 5;
 kmax = 5;
 Initiators = 0.01;
 tmin = 0;
 tmax = 40;
 P$k = (z^k Exp[-x])/k!;
 P$kk = (z^kk Exp[-x])/kk!;
 \[CurlyPhi]0 = 0.18;
\[CurlyPhi]standard = \[CurlyPhi]0/100;
P$\[CurlyPhi] = 1/(\[CurlyPhi]standard Sqrt[2 \[Pi]])*Exp[-((\[CurlyPhi] - \[CurlyPhi]0)^2/(2*\[CurlyPhi]standard^2))];
p$nk = Integrate[P$\[CurlyPhi], {\[CurlyPhi], (n - 1)/k, n/k}];
p$nnkk = Integrate[P$\[CurlyPhi], {\[CurlyPhi], (nn - 1)/kk, nn/kk}];

However, I am always getting this message:
NDSolve::dsfun: "{S$nk[1][1][t],S$nk[1][2][t],S$nk[1][3][t],S$nk[1][4][t],S$nk[1][5][t]} cannot be used as a function"

Any suggestion why this is happening? I have spent a lot of time on this, and also asked colleagues, but still...
4 Replies
Posted 12 years ago
Panagiotis,

could you please directly provide the eqns and vars you would like to use in your NDSolve evaluation?

With the code as currently given above I cannot even reproduce the exact error message you are showing, and the eqns I get are not differential equations.
Seeing the very system you would like to solve (without the steps setting it up) might help quite a bit.

Also in general it might help to simplify your notation, e.g. by using Snk11 instead of S$nk[1][1].

Peter
POSTED BY: Peter Fleck
Peter Fleck,

Thank you for your reply. I noticed that the copy-paste of the code from mathematica to here did not work correclty(!).
I fixxed that. Now, If you copy each part of the code into mathematica (starting bottoms up as I provide it) you should get the whole code. I also did this just to make sure, and I am getting ( as usual this message that I have posted).

As for the notation comment you are right. It's not pleasant, I also have a notation using the subscripts for the same code, since I though it could be the source of the errors I am getting, but I am still getting the same message.

Best Regards,
Panagiotis
Try
NDSolve[eqns, Flatten[vars], {t, tmin, tmax}, MaxSteps -> Infinity]
POSTED BY: Ilian Gachevski
YES! Thank you Ilian! No error messages!

Thank you emoticon
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract