# Avoid trouble with NDSolve and dependent variables?

Posted 8 months ago
1058 Views
|
7 Replies
|
0 Total Likes
|
 My goal here is to MPF and Wee1 using NDsolve (and eventually with different values of DDS), but for some reason I keep getting that my dependent variables are more numerous than my equations. I'm getting very frustrated because I thought I was making sure that it would be the other way around as well as trying many other methods, but to no avail.I know this is way more code than is probably necessary... but I couldn't figure it out! Is there anyone who can help?Here's my code:(These are just constants) 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; Manipulate[ sol = NDSolve[{ 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], (* EQ for ATR'[t] is not given*) 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], (*14-3- = F1433*) F1433'[t] == k26 * p53[t] + k27 - k28 * Cdc25ps216[t] * F1433[t] - k29 * F1433[t], (**) Wee1'[t] == kWee1 + k33 * Wee1p[t] - k34 * MPF[t] * Wee1[t], (**) 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}, {MPF, Cdc25a, Chk1p, Chk1, Cdc25, Cdc25ps216a, preMPF, P21MPF, p21, Cdc25ps216, F1433, Wee1}, {t, 8}]; Plot[Evaluate[{MPF[t], Wee1[t]} /. sol], {t, 0, TFinal}, PlotRange -> All, PlotLegends -> {"[MPF], [Wee1]"}, PlotStyle -> {Green, Cyan}], {{TFinal, 5, "Time"}, 0.2, 8}, {{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}, {{ks, 1, "ks"}, 0, 8}, {{K, 1, "K"}, 0, 8}, {{Dego, 1, "Dego"}, 0, 8} ] Out[33]= Manipulate[ sol = NDSolve[{Derivative[1][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, Derivative[1][Cdc25a][t] == k15*MPF[t]*Cdc25[t] \ + k30*Cdc25ps216a[t] - ki*Cdc25[t] - k30*Chk1p[t]*Cdc25a[t] - k32*Cdc25a[t], Derivative[1][Chk1p][t] == k9*Chk1[t]*1 - k10*Chk1p[t], Derivative[1][Chk1][t] == k9*Chk1p[t] - \ k10*Chk1[t], Derivative[1][Cdc25][t] == ki*Cdc25[t] + vm - \ k15*MPF[t]*Cdc25[t] - k23*Chk1p[t]*Cdc25[t], Derivative[1][Cdc25ps216a][t] == k31*Chk1p[t]*Cdc25a[t] + k25*MPF[t]*Cdc25ps216[t] - k30*Cdc25ps216a[t] - k24*Cdc25ps216a[t], \ Derivative[1][preMPF][t] == k12/(1 + k13*P53[t]) + k14*k15*k16 - k17*(Cdc25a[t] + \ Cdc25ps216a[t])* preMPF[t], Derivative[1][P21MPF][t] == k19*p21[t] - \ k18*P21MPF[t], Derivative[1][p21][t] == k1p21 + k2p21*(p53a[t]^3/ (jp21^3 + p53a[t]^3)) + k18*P21MPF[t] + k16 - k22*p21[t] - k19*MPF[t]*p21[t], Derivative[1][p53a][t] == k1d*p53[t] - kin*p53a[t] - k2d*p53a[t], Derivative[1][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], \ Derivative[1][Cdc25ps216][t] == k23*Chk1p[t]*Cdc25[t] - k25*MPF[t]*Cdc25ps216[t] + k24*Cdc25ps216a[t] - k28*F1433[t]*Cdc25ps216[t], Derivative[1][F1433][t] == k26*p53[t] + k27 - k28*Cdc25ps216[t]* F1433[t] - k29*F1433[t], Derivative[1][Wee1][t] == kWee1 + k33*Wee1p[t] - k34*MPF[t]*Wee1[t], 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}, {MPF, Cdc25a, Chk1p, \ Chk1, Cdc25, Cdc25ps216a, preMPF, P21MPF, p21, Cdc25ps216, F1433, \ Wee1}, {t, 8}]; Plot[Evaluate[{MPF[t], Wee1[t]} /. sol], {t, 0, TFinal}, PlotRange -> All, PlotLegends -> {"[MPF], [Wee1]"}, PlotStyle -> {Green, Cyan}], {{TFinal, 5, "Time"}, 0.2, 8}, {{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}, {{ks, 1, "ks"}, 0, 8}, {{GlobalK, 1, "K"}, 0, 8}, {{Dego, 1, "Dego"}, 0, 8}] NDSolve::underdet: There are more dependent variables, {Cdc25[t],Cdc25a[t],Cdc25ps216[t],Cdc25ps216a[t],Chk1[t],Chk1p[t],F1433[t],Mdm2[t],MPF[t],p21[t],P21MPF[t],p53[t],P53[t],p53a[t],preMPF[t],Wee1[t],Wee1p[t]}, than equations, so the system is underdetermined. ReplaceAll::reps: {NDSolve[{(MPF^\[Prime])[t]==-0.01 MPF[<<1>>]^2-0.1 MPF[t] p21[t]+P21MPF[t]+(Cdc25a[<<1>>]+Cdc25ps216a[<<1>>]) preMPF[t]-0.01 MPF[t] Wee1[t],(Cdc25a^\[Prime])[t]==-0.01 Cdc25[t]-0.0001 Cdc25a[t]+0.01 Cdc25ps216a[t]-0.01 Cdc25a[t] Chk1p[t]+1. Cdc25[t] MPF[t],(Chk1p^\[Prime])[t]==Chk1[t]-1. Chk1p[t],(Chk1^\[Prime])[t]==-1. Chk1[t]+Chk1p[t],(Cdc25^\[Prime])[t]==0.00005 +0.01 Cdc25[t]-0.01 Cdc25[t] Chk1p[t]-1. Cdc25[t] MPF[t],(Cdc25ps216a^\[Prime])[t]==-0.02 Cdc25ps216a[t]+0.01 Cdc25a[t] Chk1p[t]+1. Cdc25ps216[t] MPF[t],(preMPF^\[Prime])[t]==0.0001 +0.0005/Plus[<<2>>]-(Cdc25a[<<1>>]+Cdc25ps216a[<<1>>]) preMPF[t],(P21MPF^\[Prime])[t]==0.1 p21[t]-P21MPF[t],<<12>>,preMPF[0]==1,P21MPF[0]==1,p21[0]==p21o,p53a[0]==1,p53[0]==1,Cdc25ps216[0]==1,F1433[0]==1,Wee1[0]==1},<<1>>,{t,8}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. NDSolve::dsvar: 0.00010214285714285715 cannot be used as a variable. ReplaceAll::reps: {NDSolve[{(MPF^\[Prime])[0.000102143]==-0.01 MPF[<<1>>]^2-0.1 MPF[0.000102143] p21[0.000102143]+P21MPF[0.000102143]+(Cdc25a[<<1>>]+Cdc25ps216a[<<1>>]) preMPF[0.000102143]-0.01 MPF[0.000102143] Wee1[0.000102143],(Cdc25a^\[Prime])[0.000102143]==-0.01 Cdc25[0.000102143]-0.0001 Cdc25a[0.000102143]+0.01 Cdc25ps216a[0.000102143]-0.01 Cdc25a[0.000102143] Chk1p[0.000102143]+1. Cdc25[0.000102143] MPF[0.000102143],<<24>>,F1433[0]==1,Wee1[0]==1},{MPF,Cdc25a,Chk1p,Chk1,<<4>>,p21,Cdc25ps216,F1433,Wee1},{0.000102143,8}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. NDSolve::dsvar: 0.00010214285714285715 cannot be used as a variable. ReplaceAll::reps: {NDSolve[{(MPF^\[Prime])[0.000102143]==-0.01 MPF[<<1>>]^2-0.1 MPF[0.000102143] p21[0.000102143]+P21MPF[0.000102143]+(Cdc25a[<<1>>]+Cdc25ps216a[<<1>>]) preMPF[0.000102143]-0.01 MPF[0.000102143] Wee1[0.000102143],(Cdc25a^\[Prime])[0.000102143]==-0.01 Cdc25[0.000102143]-0.0001 Cdc25a[0.000102143]+0.01 Cdc25ps216a[0.000102143]-0.01 Cdc25a[0.000102143] Chk1p[0.000102143]+1. Cdc25[0.000102143] MPF[0.000102143],<<24>>,F1433[0.]==1.,Wee1[0.]==1.},{MPF,Cdc25a,Chk1p,<<6>>,Cdc25ps216,F1433,Wee1},{0.000102143,8.}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. General::stop: Further output of ReplaceAll::reps will be suppressed during this calculation. NDSolve::dsvar: 0.10214295918367347 cannot be used as a variable. General::stop: Further output of NDSolve::dsvar will be suppressed during this calculation.e  Attachments:
7 Replies
Sort By:
Posted 8 months ago
 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 8 months 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 8 months ago
 Trouble with NDsolve and dependent variables?
Posted 8 months ago
 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 8 months 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!
 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: