Group Abstract Group Abstract

Message Boards Message Boards

Avoid trouble with NDSolve and dependent variables?

Posted 8 years ago
Attachments:
POSTED BY: Isaac Lee
7 Replies

Try this code. Look at the parameters that were not described: ka, Mdm2[t], p21o.

Manipulate[k1 = 1.5; k2 = 0.001; k3 = 10.0; k4 = 0.02; k5 = 6.0; 
 k6 = 0.04; k7 = 0.005; k8 = 0.00000001; k9 = 1; k10 = 1.0; 
 k11 = 1.0; k12 = 0.0005; k13 = 1.0; k14 =  0.01; k15 = 1.0; 
 k16 = 0.01; k17 = 1; k18 = 1; k19 = 0.1; k20 = 0.01; k21 = 0.1; 
 k22 = 1.0; k23 = 0.01; k24 = 0.01; k25 = 1.0; k26 = 0.01; k27 = 1.0; 
 k28 = 100.0; k29 = 1.0; k30 = 0.01; k31 = 0.01;  k32 = 0.0001; 
 k33 = 1.0; k34 = 0.1; k35 = 1.0;  k36 = 1.0; kp = 0.0001; 
 kM = 0.00094; kW = 0.00054; kj = 0.04; jW = 1.8; kd = 0.01; 
 kdeg = 0.772; kdamp = 0.02; kA = 0.2; ki = 0.01; vm = 0.00005; 
 kWee1 = 0.0002; kin = 0.0013; k1d = 0.026; k2d = 0.0013; 
 kca = 0.004; kcm = 0.005; kwip11 = 0.00054; kwip12 = 0.04; 
 jwip1 = 1.8; kwip13 = 0.001; k1p21 = 0.0001; k2p21 = 0.135; 
 jp21 = 2; kdin1 = 0.000054; kdin2 = 0.0027; jdin1 = 0.4; 
 kdin3 = 0.135; jdin2 = 0.5; kdin4 = 0.00135; kAIP1 = 0.0011; 
 kAIP2 = 0.027; jAIP1 = 0.3; kAIP3 = 0.01; ka = 1; Mdm2[t_] := 1;
 f = {MPF, Wee1, Cdc25a, Chk1p, Chk1, Cdc25, Cdc25ps216a, preMPF, 
   P21MPF, p21, p53a , p53, Cdc25ps216, F1433};
 eq = {MPF'[t] == 
    k17*Cdc25a[t] + Cdc25ps216a[t]*preMPF[t] + k18 * P21MPF[t] - 
     k14 * MPF[t]* Wee1[t] - k19 * MPF[t]* p21[t] - k20 * MPF[t]^2,
   Cdc25a'[t] == 
    k15 * MPF[t]* Cdc25[t] + k30 * Cdc25ps216a[t] - ki * Cdc25[t] - 
     k30 * Chk1p[t] * Cdc25a[t] - k32 * Cdc25a[t],
   Chk1p'[t] == k9 * Chk1[t]*1 - k10 * Chk1p[t], 
   Chk1'[t] == k9 * Chk1p[t] - k10 * Chk1[t], 
   Cdc25'[t] == 
    ki * Cdc25[t] + vm - k15 * MPF[t]* Cdc25[t] - 
     k23 * Chk1p[t] * Cdc25[t],
   Cdc25ps216a'[t] == 
    k31 * Chk1p[t] * Cdc25a[t] + k25 * MPF[t] * Cdc25ps216[t] - 
     k30 * Cdc25ps216a[t] - k24 * Cdc25ps216a[t],
    preMPF'[t] == (k12)/(1 + k13 * p53[t]) + k14* k15* k16 - 
     k17*(Cdc25a[t] + Cdc25ps216a[t])*preMPF[t],
   P21MPF'[t] == k19*p21[t] - k18 * P21MPF[t],
   p21'[t] == 
    k1p21 + k2p21*(p53a[t]^3)/(jp21^3 + p53a[t]^3) + 
     k18 * P21MPF[t] + k16 - k22 * p21[t] - k19 * MPF[t] * p21[t],
   p53a'[t] == k1d * p53[t] - kin * p53a[t] - k2d * p53a[t],
   p53'[t] == 
    ks + k1 * (DDS * 
        Exp[-k8 * 
          t]) - (((Dego - kdeg * (DDS * Exp[-k8 * t]) - 
           DDS * Exp[-kdamp * DDS * t])) * p53[t] * Mdm2 [t])/(ka + 
        p53[t]) + kM * p53a[t] - k1d * p53[t] - k2 * p53[t],
   Cdc25ps216'[t] == 
    k23 * Chk1p[t]* Cdc25[t] - k25 * MPF[t] * Cdc25ps216[t] + 
     k24 * Cdc25ps216a[t] - k28 * F1433[t] * Cdc25ps216[t],
   F1433'[t] == 
    k26 * p53[t] + k27 - k28 * Cdc25ps216[t] * F1433[t] - 
     k29 * F1433[t],
   Wee1'[t] == kWee1 + k33 * Wee1[t] - k34 * MPF[t]* Wee1[t]};
 eq0 = {MPF[0] == MPFo,  Cdc25a[0] == Cdc25ao, Chk1p[0] == Chk1po, 
   Chk1[0] == Chk1o, Cdc25[0] == Cdc25o, 
   Cdc25ps216a[0] == Cdc25ps216ao, preMPF[0] == preMPFo,   
   P21MPF[0] == P21MPFo, p21[0] == p21o, p53a[0] == p53ao, 
   p53[0] == p53o, Cdc25ps216[0] == Cdc25ps216o, F1433[0] == F1433o, 
   Wee1[0] == Wee1o}; sol = NDSolveValue[{eq, eq0}, f, {t, 0, 8}]; 
 Plot[Evaluate[{sol[[1]][t], sol[[2]][t]} ], {t, 0, 8}, 
  PlotRange -> All, PlotLegends -> {"MPF", "Wee1"}, 
  PlotStyle -> {Green, Cyan}], {{DDS, 0, "DDS"}, 0, 
  0.008}, {{MPFo, 1, "[MPF] Initial"}, 0, 10},
 {{Cdc25ao, 1, "[Cdc25a] Initial"}, 0, 10},
 {{Chk1po, 1, "[Chk1p] Initial"}, 0, 10},
 {{Chk1o, 1, "[Chk1] Initial"}, 0, 10},
 {{Cdc25o, 1, "[Cdc25] Initial"}, 0, 10},
 {{Cdc25ps216o, 1, "[Cdc25ps21a] Initial"}, 0, 10},
 {{Cdc25ps216ao, 1, "[Cdc25ps216a] Initial"}, 0, 10},
 {{preMPFo, 1, "[preMPF] Initial"}, 0, 10},
 {{P21MPFo, 1, "[P21MPF] Initial"}, 0, 10},
 {{p53ao, 1, "[P53a] Initial"}, 0, 10},
 {{p53o, 1, "[P53] Initial"}, 0, 10}, 
 {{F1433o, 1, "[F1433] Initial"}, 0, 10},
 {{Wee1o, 1, "[Wee1] Initial"}, 0, 8}, {{p21o, 1, "[p21] Initial"}, 
  0, 10},
 {{ks, 1, "ks"}, 0, 8},
 {{Dego, 1, "Dego"}, 0, 8}]
Attachments:

I was illustrating how to set up the problem without nesting functions, so you could trouble shoot your code.

POSTED BY: Frank Kampas
Posted 8 years ago

Trouble with NDsolve and dependent variables?

POSTED BY: Isaac Lee

You have NDSolve and Plot inside Manipulate. That's what I mean by nested functions. This is an example of the approach I recommend:

f[a_?NumericQ] := 
     NDSolveValue[{x'[t] == a * x[t], x[0] == 1}, x[t], {t, 0, 1}]

Plot[Evaluate[{f[1], f[2]}], {t, 0, 1}]

Manipulate[
 Plot[Evaluate[f[tt], {t, 0, 1}, 
   PlotRange -> {{0, 1}, {0, 10}}]], {tt, 0, 2}
POSTED BY: Frank Kampas
Posted 8 years ago

How would I use the equation that uses another function for its variable?

For example, I have

p53a'[t] == k1d * p53[t] - kin * p53a[t] - k2d * p53a[t]

It uses both p53a and p53, and thus if I try to put the code as so:

f[1] := 
 NDSolveValue[{p53a'[t] == 
    k1d * p53[t] - kin * p53a[t] - k2d * p53a[t]}, p53a[0] == 1, 
  p53[0] == 1, {t, 0, 8}]


Plot[Evaluate[{ f[1] }], {t, 0 , 1}]

it will not plot since there are more dependent variables than independent!

POSTED BY: Isaac Lee

It's much easier to troubleshoot if you don't nest functions. Suggest you first set up and name your equations, check them over, then put the name inside NDSolve with definite values for the variables you want to manipulate, and then finally go to the Manipulate. You can define a function that takes numeric arguments for the solution of NDSolve and put that inside Manipulate.

POSTED BY: Frank Kampas
Posted 8 years ago

Would you be so kind as to give me an example of an unnested function? I'm not sure how to bring it out.

POSTED BY: Isaac Lee
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard