1
$\begingroup$

I have aleady looked at these two questions: Is there a CDF Player for Mathematica 10? (Yes) and Problem with NDSolve in Mathematica 9 / 10.

My problem is as follows. I am simluating neurons, which requires solving amounts of differential equations. This is no problem.

To show the results of these calculations, we made the data visible by creating Manipulates which show the results interactively. This also works perfectly.

Now we want to export these Manipulates to a CDF, for usage by people with no Mathematica knowledge. The export is all OK, but when I open the CDF there are some errors.

One of the errors is mentioned in one of the questions above, and I can remove those errors by removing the line with UndoTrackedVariables. I cannot remove the other errors, and would gladly like some help.

Relevant code:

simulate2Neurons[] := Module[
   {sol2, II, EK},
   II = 8.85;
   EK = -5;
   sol2 = First@NDSolve[
      {n1'[t] == \[Alpha]n[V1[t]] (1 - n1[t]) - \[Beta]n[V1[t]] n1[t],
       m1'[t] == \[Alpha]m[V1[t]] (1 - m1[t]) - \[Beta]m[V1[t]] m1[t],
       h1'[t] == \[Alpha]h[V1[t]] (1 - h1[t]) - \[Beta]h[V1[t]] h1[t],
       V1'[t] == 
        II - gs sq1[t] (V1[t] - ER1) - gK n1[t]^4 (V1[t] - EK) - 
         gNa m1[t]^3 h1[t] (V1[t] - ENa) - gL (V1[t] - EL),

       n2'[t] == \[Alpha]n[V2[t]] (1 - n2[t]) - \[Beta]n[V2[t]] n2[t],
       m2'[t] == \[Alpha]m[V2[t]] (1 - m2[t]) - \[Beta]m[V2[t]] m2[t],
       h2'[t] == \[Alpha]h[V2[t]] (1 - h2[t]) - \[Beta]h[V2[t]] h2[t],
       V2'[t] == 
        II - gs sq2[t] (V2[t] - ER2) - gK n2[t]^4 (V2[t] - EK) - 
         gNa m2[t]^3 h2[t] (V2[t] - ENa) - gL (V2[t] - EL),

       sq1'[
         t] == -\[Alpha] sq1[t] + \[Beta] \[Chi][V2[t]] (1 - sq1[t]),
       sq2'[
         t] == -\[Alpha] sq2[t] + \[Beta] \[Chi][V1[t]] (1 - sq2[t]),

       n1[0] == 0.35, m1[0] == 0.05, h1[0] == 0.6, V1[0] == V0[EK], 
       sq1[0] == 0,
       n2[0] == 0.25, m2[0] == 0.15, h2[0] == 0.7, V2[0] == V0[EK], 
       sq2[0] == 0}
      , {V1, V2, n1, n2, m1, m2, h1, h2, sq1, sq2}, {t, 0, 100}];
   Manipulate[
    Grid[{{Show[
        Plot[Evaluate[V1[t] /. sol2], {t, 0, 100}, 
         PlotRange -> {0, 10}],
        Graphics[{{PointSize[Large], 
           Point[{tGo, V1[t] /. sol2 /. t -> tGo}]}, White, 
          PointSize[Medium], 
          Point[{tGo, V1[t] /. sol2 /. t -> tGo}]}]],
       Show[
        Plot[Evaluate[{n1[t], m1[t], h1[t]} /. sol2], {t, 0, 100}, 
         PlotRange -> {0, 1}]
        ]},
      {Plot[Evaluate[{sq1[t], sq2[t]} /. sol2], {t, 0, 100}, 
        PlotRange -> {0, 1}],
       Plot[
        Evaluate[{\[Chi][V1[t]], \[Chi][V2[t]]} /. sol2], {t, 0, 100},
         PlotRange -> {0, 1}]},
      {, Function[{style1, style2}, GraphPlot[
          {1 -> 2, 2 -> 1}, DirectedEdges -> True, 
          VertexRenderingFunction -> ({White, EdgeForm[Black], 
              Disk[#, .1], Black, Text[#2, #1]} &),

          EdgeRenderingFunction -> ({Black, {Arrowheads[Medium], 
               If[#2[[1]] == 1, style1, style2], Arrow[#1, 0.1]}} & )
          ]][
        If[\[Chi][V1[t] /. sol2 /. t -> tGo] > 0.5, Thick, Dotted], 
        If[\[Chi][V2[t] /. sol2 /. t -> tGo] > 0.5, Thick, Dotted]]
       }}],
    {tGo, 0, 100,
     Appearance -> Open},
    SaveDefinitions -> True]
   (* Initial conditions are not equal to create interaction *)
   (* See II = 8.58 and EK = -5 *)
   ];

I have attached two images to show the usual result and the errors. Normal content Errors

Links to the images: http://i.stack.imgur.com/6cXG0.png, http://i.stack.imgur.com/KMpo7.png.

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Jan 22 '15 at 13:45
  • $\begingroup$ The second screenshot is essentially unreadable. Please replace. $\endgroup$ – bbgodfrey Jan 22 '15 at 13:45
  • $\begingroup$ Added links to the images. $\endgroup$ – Hidde Jan 22 '15 at 13:53
  • $\begingroup$ AFAIK the version 10 CDF player is due for release about now -- based on a post on wolfram community which i recall nominated second half of january (??) $\endgroup$ – Mike Honeychurch Jan 22 '15 at 23:37
  • $\begingroup$ @MikeHoneychurch That would be more than perfect. Do you recall where you found that post? $\endgroup$ – Hidde Jan 23 '15 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.