Message Boards Message Boards

0
|
4304 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Difference in Solutions between Code

I have two sets of code with equal parameters, but when I run the solver for changing nut incrementally, I get different solutions than the three points in my first code. Can anyone see a difference in either my equations or constants?

Clear["Global'*"];
wterror = 
  Table[khi = 1600; ko2 = 5.4; ro2 = 100; kmrs = 650; kisu = 800; 
   kmp = .06; kros = .25; kres = 20.2;
   kccc1 = 650; k23 = 13; kvp = 0.04; kc = 30; nc = 5; kfc = 350; 
   nfc = 10; km = 80; nm = 5;
   km2 = 350; nm2 = 6; kv1 = 18; nv1 = 9; kvs = 148; nvs = 9; 
   k32 = 25; n32 = 11; volc = .65; volm = 0.1; volv = 0.25; vhi = khi;
   kmhi = 9; kmmrs = 12; vmrs = kmrs; vkccc1 = kccc1; kmccc1 = 7; 
   kmisu = 363; kmres = 5.5; a = 0.2;
   odec = -(a c[t]) - (
     vkccc1 volv c[
       t] (1 - 1/((c[t]/kv1)^nv1 + 1)) (1 - 
        1/((fs[t]/kvs)^nvs + 1)))/(volc (c[t] + kmccc1)) + (
     nut vhi)/((kmhi + nut) ((c[t]/kc)^nc + 1) ((fs[t]/kfc)^nfc + 
        1) ) - (vmrs volm c[t])/(
     volc (c[t] + kmmrs) ((c[t]/km)^nm + 1) ((fs[t]/km2)^nm2 + 1));
   oderos = kmp fm[t] o2[t] - kros ros[t] fs[t] - a ros[t];
   odefm = -(a fm[t]) + (
     vmrs c[t])/((c[t] + kmmrs) ((c[t]/km)^nm + 1) ((fs[t]/km2)^nm2 + 
        1)) - kisu fm[t]/(kmisu + fm[t]) - kmp fm[t] o2[t];
   odefs = kisu fm[t]/(kmisu + fm[t]) - kros ros[t] fs[t] - a fs[t];
   odemp = kmp fm[t] o2[t] + kros ros[t] fs[t] - a mp[t];
   odeo2 = -(kmp fm[t] o2[t]) - kres fs[t] o2[t]/(kmres + o2[t]) + 
     ko2 (ro2 - o2[t]);
   odef2 = -(a f2[t]) - k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) + (
     vkccc1 c[
       t] (1 - 1/((c[t]/kv1)^nv1 + 1)) (1 - 
        1/((fs[t]/kvs)^nvs + 1)))/(c[t] + kmccc1);
   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 = {nut, c[t], f2[t], f3[t], vp[t], fm[t], fs[t], mp[t], o2[t],
      ros[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, ros'[t] == oderos, c[0] == 30, 
      f2[0] == 100, f3[0] == 100, fm[0] == 50, fs[0] == 50, 
      mp[0] == 0, o2[0] == 100, vp[0] == 100, ros[0] == 0}, 
     vars, {t, 0, 31}];
   vars;
   vars1 = vars /. solution /. t -> 31;
   vars2 = Flatten[vars1];
   If[nut == 4, {feisomito = 480, fef3 = 1, fef3vp = 1, fefm = 33.6, 
     fefs = 334.2, femp = 48, fecell = 240}, {"nut not 4"}];
   If[nut == 46, {feisomito = 770, fef3 = 1180, fevp = 180, 
     fefm = 152.32, fefs = 213, femp = 254.1, 
     fecell = 440}, {"nut not 46"}];
   If[nut == 406, {feisomito = 775, fef3 = 1420, fevp = 100, 
     fefm = 151.2, fefs = 217.9, femp = 195.85, 
     fecell = 455}, {"nut not 406"}];
   rmsd = (1/
       5 (((vars2[[6]] - fefm)/fecell)^2 + ((vars2[[7]] - fefs)/
          fecell)^2 + ((vars2[[8]] - femp)/fecell)^2 + ((
          vars2[[4]] - fef3)/fecell)^2 + ((vars2[[5]] - fevp)/
          fecell)^2))^(1/2);
   vars3 = Join[vars2, {rmsd}];
   vars3, {nut, {4, 46, 406}}];
isuerror = Table[kisu = 0; a = 0.05;
   odec = -(a c[t]) - (
     vkccc1 volv c[
       t] (1 - 1/((c[t]/kv1)^nv1 + 1)) (1 - 
        1/((fs[t]/kvs)^nvs + 1)))/(volc (c[t] + kmccc1)) + (
     nut vhi)/((kmhi + nut) ((c[t]/kc)^nc + 1) ((fs[t]/kfc)^nfc + 
        1) ) - (vmrs volm c[t])/(
     volc (c[t] + kmmrs) ((c[t]/km)^nm + 1) ((fs[t]/km2)^nm2 + 1));
   oderos = kmp fm[t] o2[t] - kros ros[t] fs[t] - a ros[t];
   odefm = -(a fm[t]) + (
     vmrs c[t])/((c[t] + kmmrs) ((c[t]/km)^nm + 1) ((fs[t]/km2)^nm2 + 
        1)) - kisu fm[t]/(kmisu + fm[t]) - kmp fm[t] o2[t];
   odefs = kisu fm[t]/(kmisu + fm[t]) - kros ros[t] fs[t] - a fs[t];
   odemp = kmp fm[t] o2[t] + kros ros[t] fs[t] - a mp[t];
   odeo2 = -(kmp fm[t] o2[t]) - kres fs[t] o2[t]/(kmres + o2[t]) + 
     ko2 (ro2 - o2[t]);
   odef2 = -(a f2[t]) - k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) + (
     vkccc1 c[
       t] (1 - 1/((c[t]/kv1)^nv1 + 1)) (1 - 
        1/((fs[t]/kvs)^nvs + 1)))/(c[t] + kmccc1);
   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 = {nut, c[t], f2[t], f3[t], vp[t], fm[t], fs[t], mp[t], o2[t],
      ros[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, ros'[t] == oderos, c[0] == 30, 
      f2[0] == 100, f3[0] == 100, fm[0] == 50, fs[0] == 50, 
      mp[0] == 0, o2[0] == 100, vp[0] == 100, ros[0] == 0}, 
     vars, {t, 0, 31}];
   vars;
   vars1 = vars /. solution /. t -> 31;
   vars2 = Flatten[vars1];
   If[nut == 26, {fef3 = 1; fevp = 1; fefm = 445, fefs = 178, 
     femp = 8277, feisomito = 8900, fecell = 1000}, "nut not 26"];
   If[nut == 46, {fef3 = 1; fevp = 1; fefm = 370, fefs = 1, 
     femp = 7030, feisomito = 7400, fecell = 1000}, "nut not 46"];
   rmsd = (1/
       5 (((vars2[[6]] - fefm)/fecell)^2 + ((vars2[[7]] - fefs)/
          fecell)^2 + ((vars2[[8]] - femp)/fecell)^2 + ((
          vars2[[4]] - fef3)/fecell)^2 + ((vars2[[5]] - fevp)/
          fecell)^2))^(1/2);
   vars3 = Join[vars2, {rmsd}];
   vars3, {nut, {46}}];
totaltable = Join[wterror, isuerror]
wtavg = Mean[wterror[[All, -1]]]
iscavg = Mean[isuerror[[All, -1]]]
totalavg = 1/6 (wtavg + 3 iscavg)

Clear["Global'*"];
mediamod = 
 Table[khi = 1600; ko2 = 5.4; ro2 = 100; kmrs = 650; kisu = 800; 
  kmp = .06; kros = .25; kres = 20.2;
  kccc1 = 650; k23 = 13; kvp = 0.04; kc = 30; nc = 5; kfc = 350; 
  nfc = 10; km = 80; nm = 5;
  km2 = 350; nm2 = 6; kv1 = 18; nv1 = 9; kvs = 148; nvs = 9; k32 = 25;
   n32 = 11; volc = .65; volm = 0.1; volv = 0.25; vhi = khi;
  kmhi = 9; kmmrs = 12; vmrs = kmrs; vkccc1 = kccc1; kmccc1 = 7; 
  kmisu = 363; kmres = 5.5; a = 0.2;
  odec = -(a c[t]) - (
    vkccc1 volv c[
      t] (1 - 1/((c[t]/kv1)^nv1 + 1)) (1 - 1/((fs[t]/kvs)^nvs + 1)))/(
    volc (c[t] + kmccc1)) + (
    nut vhi)/((kmhi + nut) ((c[t]/kc)^nc + 1) ((fs[t]/kfc)^nfc + 
       1) ) - (vmrs volm c[t])/(
    volc (c[t] + kmmrs) ((c[t]/km)^nm + 1) ((fs[t]/km2)^nm2 + 1));
  oderos = kmp fm[t] o2[t] - kros ros[t] fs[t] - a ros[t];
  odefm = -(a fm[t]) + (
    vmrs c[t])/((c[t] + kmmrs) ((c[t]/km)^nm + 1) ((fs[t]/km2)^nm2 + 
       1)) - kisu fm[t] - kmp fm[t] o2[t];
  odefs = kisu fm[t] - kros ros[t] fs[t] - a fs[t];
  odemp = kmp fm[t] o2[t] + kros ros[t] fs[t] - a mp[t];
  odeo2 = -(kmp fm[t] o2[t]) - kres fs[t] o2[t] + ko2 (ro2 - o2[t]);
  odef2 = -(a f2[t]) - k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) + (
    vkccc1 c[
      t] (1 - 1/((c[t]/kv1)^nv1 + 1)) (1 - 
       1/((fs[t]/kvs)^nvs + 1)))/(c[t] + kmccc1);
  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 = {nut, c[t], f2[t], f3[t], vp[t], fm[t], fs[t], mp[t], o2[t], 
    ros[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, ros'[t] == oderos, c[0] == 30, 
     f2[0] == 100, f3[0] == 100, fm[0] == 50, fs[0] == 50, mp[0] == 0,
      o2[0] == 100, vp[0] == 100, ros[0] == 0}, vars, {t, 0, 31}];
  vars;
  vars1 = vars /. solution /. t -> 31;
  vars2 = Flatten[vars1];
  vars2, {nut, 4, 406, 1}]

To be clear about it, I am only examining the first three lines of code from the first set, and comparing to the corresponding nut values in the second.

POSTED BY: Josh Wofford

Nevermind, found a difference in the equations, so problem solved.

POSTED BY: Josh Wofford
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