Looking to store 1 row, 8 column tables over a loop

Posted 10 years ago
5921 Views
|
3 Replies
|
0 Total Likes
|
 Clear["Global'*"]; nut = 46; khi = 25; ro2 = 3400; kmrs = 70; kisu = 1.2; kmp = 1.0;  kres = 1.25; kccc1 = 40; k23 = 16; kvp = .04; kc = 21; nc = 5; km1 = 24; nm1 = 3; km2 = 46; nm2 = 4; kv1 = 24; nv1 = 9; kv2 = 200; nv2 = 4; k32 = 18;  n32 = 9; a = .5; odec = -(a c[t]) - (    kccc1 c[t] (1 - 1/((c[t]/kv1)^nv1 + 1)))/((f3[t]/kv2)^nv2 + 1) - (    kmrs c[t])/((fs[t]/km2)^nm2 + 1) + (khi nut)/((c[t]/kc)^nc + 1);odefm = -(a fm[t]) + (kmrs c[t])/((fs[t]/km2)^nm2 + 1) - kisu fm[t] -    kmp fm[t] o2[t];odefs = kisu fm[t] - a fs[t];odemp = kmp fm[t] o2[t] - a mp[t];odeo2 = -(kmp fm[t] o2[t]) - kres fs[t] o2[t] +    ro2/((o2[t]/245)^9 + 1);odef2 = -(a f2[t]) - k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) + (   kccc1 c[t] (1 - 1/((c[t]/kv1)^nv1 + 1)))/((f3[t]/kv2)^nv2 + 1);odef3 = -(a f3[t]) + k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) -    kvp f3[t];odevp = kvp f3[t] - a vp[t];vars = {c[t], f2[t], f3[t], fm[t], fs[t], mp[t], o2[t], vp[t]};solution =   NDSolve[{Derivative[1][c][t] == odec, Derivative[1][f2][t] == odef2,     Derivative[1][f3][t] == odef3, Derivative[1][fm][t] == odefm,     Derivative[1][fs][t] == odefs, Derivative[1][mp][t] == odemp,     Derivative[1][o2][t] == odeo2, Derivative[1][vp][t] == odevp,     c[0] == 30, f2[0] == 100, f3[0] == 100, fm[0] == 50, fs[0] == 50,     mp[0] == 0, o2[0] == 100, vp[0] == 100}, vars, {t, 0, 31}];varsvars /. solution /. t -> 31So what I am trying to accomplish is to take this block of code and loop it while incrementally varying one constant in the first set of code and storing the results of vars/.solution/.t->31 to be plotted against the variation in that constant. Would a for loop, table loop, or something entirely different be more effective here?
3 Replies
Sort By:
Posted 10 years ago
 I deleted the kres term from the third line and it appears to work and match the results I was getting from manually changing kres. I'll save this one in my trick folder like you suggested a while back. Thanks Bill.
Posted 10 years ago
 If you remove thekres = 0;in the third line of your code then there is more variation in the results.With that in there I think odeo2 has already substituted 0 for kres long before you get to your NDSolve.I'm a little surprised it works at all with that in there.I don't know if there are other problems with the code.
Posted 10 years ago
 I think I'm getting somewhere with this, but I am hitting what appears to be a logic error. I enclosed the whole code that I posted earlier in a Table function and it outputs values, but the values given are all for kres=0. Any suggestions? Clear["Global'*"]; Table[nut = 46; khi = 25; ro2 = 3400; kmrs = 70; kisu = 1.2;   kmp = 1.0; kres = 0;  kccc1 = 40; k23 = 16; kvp = .04; kc = 21; nc = 5; km1 = 24; nm1 = 3;  km2 = 46; nm2 = 4; kv1 = 24; nv1 = 9; kv2 = 200; nv2 = 4; k32 = 18;   n32 = 9; a = .5;  odec = -(a c[t]) - (    kccc1 c[t] (1 - 1/((c[t]/kv1)^nv1 + 1)))/((f3[t]/kv2)^nv2 + 1) - (    kmrs c[t])/((fs[t]/km2)^nm2 + 1) + (khi nut)/((c[t]/kc)^nc + 1); odefm = -(a fm[t]) + (kmrs c[t])/((fs[t]/km2)^nm2 + 1) - kisu fm[t] -    kmp fm[t] o2[t]; odefs = kisu fm[t] - a fs[t]; odemp = kmp fm[t] o2[t] - a mp[t]; odeo2 = -(kmp fm[t] o2[t]) - kres fs[t] o2[t] +    ro2/((o2[t]/245)^9 + 1); odef2 = -(a f2[t]) - k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) + (   kccc1 c[t] (1 - 1/((c[t]/kv1)^nv1 + 1)))/((f3[t]/kv2)^nv2 + 1); odef3 = -(a f3[t]) + k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) -    kvp f3[t]; odevp = kvp f3[t] - a vp[t]; vars = {c[t], f2[t], f3[t], fm[t], fs[t], mp[t], o2[t], vp[t]}; solution =   NDSolve[{Derivative[1][c][t] == odec, Derivative[1][f2][t] == odef2,     Derivative[1][f3][t] == odef3, Derivative[1][fm][t] == odefm,     Derivative[1][fs][t] == odefs, Derivative[1][mp][t] == odemp,     Derivative[1][o2][t] == odeo2, Derivative[1][vp][t] == odevp,     c[0] == 30, f2[0] == 100, f3[0] == 100, fm[0] == 50, fs[0] == 50,     mp[0] == 0, o2[0] == 100, vp[0] == 100}, vars, {t, 0, 31}]; vars /. solution /. t -> 31, {kres, 0, 1, .25}]