Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Multiple Executions of .nb file part2

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90542] Re: Multiple Executions of .nb file part2
  • From: dh <dh at metrohm.ch>
  • Date: Sat, 12 Jul 2008 05:33:04 -0400 (EDT)
  • References: <g54op3$f50$1@smc.vnet.net>


Sorry, I just confused my private communication with David and the group 

and therefore answered to the wrong question. Here is the question and 

the answer that settels it:



Answer:

Hi David,

if you put a semicolon behind area=..; and a  //Print behind 

ParametricPlot[..] and a Print around  NeuronNumber your code will run.

Daniel





Question:

Dan,

Fun[SmV_]:=(**Code**)

I can call it with

         Fun[-80]

And it returns me output for My program with  a -80 input.



For some reason it isn't working for the larger implementation.



The follow code should generate 4 very different graphs:















         time = 2000;



databaseModel[NeuronNumber_] := (



     (* 0.628 *)

     area = 0.628



         InjectedCurrent = 0;

     currentInjectionStart = 0;

     currentInjectionFinish = 0;





     startingMembraneV = -60;









     numb = NeuronNumber;

     n0 = (numb - Mod[numb, 6^7])/6^7;

     numb = numb - (n0 * 6^7);

     n1 = (numb - Mod[numb, 6^6])/6^6;

     numb = numb - (n1 * 6^6);

     n2 = (numb - Mod[numb, 6^5])/6^5;

     numb = numb - (n2 * 6^5);

     n3 = (numb - Mod[numb, 6^4])/6^4;

     numb = numb - (n3 * 6^4);

     n4 = (numb - Mod[numb, 6^3])/6^3;

     numb = numb - (n4 * 6^3);

     n5 = (numb - Mod[numb, 6^2])/6^2;

     numb = numb - (n5 * 6^2);

     n6 = (numb - Mod[numb, 6^1])/6^1;

     numb = numb - (n6 * 6^1);

     n7 = Mod[numb, 6]/6^0;











     INaC = n0;

     ICaTC = n1;

     ICaSC = n2;

     IA = n3;

     IKCa = n4;

     IKd = n5;

     IH = n6;

     IL = n7;







     INaC = INaC*100;

     ICaTC = ICaTC*2.5;

     ICaSC = ICaSC *2;

     IA = IA *10;

     IKCa = IKCa*5;

     IKd = IKd *25;

     IH = IH*0.01;

     IL = IL*0.01;



     ic = InjectedCurrent;

     ics = currentInjectionStart;

     icf = currentInjectionFinish;

     SmV = startingMembraneV;



     PD1INam0[u_] := 1/(1 + Exp[(u + 25.5)/-5.29]);

PD1INah0[u_] := 1/(1 + Exp[(u + 48.9)/5.18]);

PD1INataum[u_] := 2.64 - 2.52/(1 + Exp[(u + 120)/-25]);

PD1INatauh[u_] := (1.34/(1 + Exp[(u + 62.9)/-10]))*(

     1.5 + 1/(1 + Exp[(u + 34.9)/3.6]));

     PD1ICaTm0[u_] := 1/(1 + Exp[(u + 27.1)/-7.2]);

PD1ICaTh0[u_] := 1/(1 + Exp[(u + 32.1)/5.5]);

     PD1ICaTtaum[u_] := 43.4 - 42.6/(1 + Exp[(u + 68.1)/-20.5]);

PD1ICaTtauh[u_] := 210 - 179.6/(1 + Exp[(u + 55)/-16.9]);

PD1ICaSm0[u_] := 1/(1 + Exp[(u + 33)/-8.1]);

PD1ICaSh0[u_] := 1/(1 + Exp[(u + 60)/6.2]);

     PD1ICaStaum[u_] := 2.8 + 14/((Exp[(u + 27)/10]) + (Exp[(u + 70)/-13]));

PD1ICaStauh[u_] := 120 + 300/((Exp[(u + 55)/9]) + (Exp[(u + 65)/-16]));

     PD1IAm0[u_] := 1/(1 + Exp[(u + 27.2)/-8.7]);

PD1IAh0[u_] := 1/(1 + Exp[(u + 56.9)/4.9]);

     PD1IAtaum[u_] := 23.2 - 20.8/(1 + Exp[(u + 32.9)/-15.2]);

PD1IAtauh[u_] := 77.2 - 58.4/(1 + Exp[(u + 38.9)/-26.5]);

PD1IKCam0[u_, x_] := (x/(x + 3))*1/(1 + Exp[(u + 28.3)/-12.6]);

     PD1IKCataum[u_] := 180.6 - 150.2/(1 + Exp[(u + 46)/-22.7]);

     PD1IKm0[u_] := 1/(1 + Exp[(u + 12.3)/-11.8]);

PD1IKtaum[u_] := 14.4 - 12.8/(1 + Exp[(u + 28.3)/-19.2]);

PD1IHm0[u_] := 1/(1 + Exp[(u + 75)/5.5]);

PD1IHtaum[u_] := 2/((Exp[(u + 169.7)/-11.6]) + (Exp[(u - 26.7)/14.3]));

PD1eca[x_] := 12.2396*Log[13000/x];

     PD1INamx0[u_] := 1/(1 + Exp[-(u + 24.7)/5.29]);

PD1INahx0[u_] := 1/(1 + Exp[(u + 48.9)/5.18]);

PD1INataumx[u_] := 1.32 - 1.26/(1 + Exp[(u + 120)/25]);

PD1INatauhx[u_] := (0.67/(1 + Exp[-(u + 62.9)/10]))*(1.5 + 1/(1 + Exp[(u +

           34.9)/3.6]));









     solution = NDSolve[{



                     PD1INam'[

                       t] == (PD1INam0[PD1v[t]] - \

PD1INam[t])*(1/PD1INataum[PD1v[t]]), PD1INam[0] == PD1INam0[SmV]*(1/

           PD1INataum[SmV]),

           PD1INah'[t] == (PD1INah0[PD1v[t]] - PD1INah[t])*(

                   1/PD1INatauh[PD1v[t]]),

               PD1INah[0] == PD1INah0[SmV]*(1/PD1INatauh[SmV]),

           PD1ICaTm'[t] == (

             PD1ICaTm0[PD1v[t]] - PD1ICaTm[t])*(1/PD1ICaTtaum[PD1v[t]]),

           PD1ICaTm[0] == PD1ICaTm0[SmV]*(1/PD1ICaTtaum[SmV]),

           PD1ICaTh'[t] == (PD1ICaTh0[PD1v[

                   t]] - PD1ICaTh[t])*(1/PD1ICaTtauh[PD1v[t]]),

           PD1ICaTh[0] == PD1ICaTh0[SmV]*(1/PD1ICaTtauh[SmV]),

           PD1ICaSm'[

             t] == (PD1ICaSm0[PD1v[t]] - \

PD1ICaSm[t])*(1/PD1ICaStaum[PD1v[t]]),

           PD1ICaSm[0] == PD1ICaSm0[SmV]*(1/PD1ICaStaum[SmV]),

           PD1ICaSh'[t] == (PD1ICaSh0[PD1v[t]] - PD1ICaSh[

                   t])*(1/PD1ICaStauh[PD1v[t]]),

           PD1ICaSh[0] == PD1ICaSh0[SmV]*(1/PD1ICaStauh[SmV]),

           PD1IAm'[t] == (PD1IAm0[PD1v[t]] - 

PD1IAm[t])*(1/PD1IAtaum[PD1v[t]]),



           PD1IAm[0] == PD1IAm0[SmV]*(1/PD1IAtaum[SmV]),

           PD1IAh'[t] == (PD1IAh0[PD1v[t]] - PD1IAh[t])*(

                             1/PD1IAtauh[PD1v[t]]),

                                  PD1IAh[0] == PD1IAh0[SmV]*(1/PD1IAtauh[

                         SmV]),

           PD1IKCam'[t] == (

           PD1IKCam0[PD1v[t], PD1cca[t]] - PD1IKCam[t])*(1/PD1IKCataum[

               PD1v[t]]),

           PD1IKCam[0] == PD1IKCam0[SmV, 0.5]*(1/PD1IKCataum[SmV]),

           PD1IKm'[t] == (

             PD1IKm0[PD1v[t]] - PD1IKm[t])*(1/PD1IKtaum[PD1v[t]]),

           PD1IKm[0] == PD1IKm0[SmV]*(1/PD1IKtaum[SmV]),

           PD1IHm'[

             t] == (PD1IHm0[PD1v[t]] - PD1IHm[t])*(1/PD1IHtaum[PD1v[t]]),

           PD1IHm[0] == PD1IHm0[SmV]*(1/PD1IHtaum[SmV]),



           PD1cca'[t] == (-14.96*((0*(

             PD1ICaTm[t]^3)*PD1ICaTh[t]*(PD1v[t] -

                   PD1eca[PD1cca[t]])) + 

(2*(PD1ICaSm[t]^3)*PD1ICaSh[t]*(PD1v[

                     t] - PD1eca[PD1cca[t]]))) -

                      PD1cca[t] + 0.05)*(1/200), PD1cca[0] == 0.05,











           PD1v'[t] == -1*((0

                       + 1*INaC*(PD1INam[t]^3)*PD1INah[t]*(PD1v[t] - 50)

                       + 1*ICaTC*(

           PD1ICaTm[t]^3)*PD1ICaTh[t]*(PD1v[t] - PD1eca[PD1cca[t]])

                       + 1*

                             ICaSC*(PD1ICaSm[t]^3)*PD1ICaSh[t]*(PD1v[t] -

                                 PD1eca[PD1cca[t]])

                       + 1*IA*(PD1IAm[t]^3)*PD1IAh[t]*(PD1v[t] + 80)

                       + 1*IKCa*(PD1IKCam[t]^4)*(PD1v[t] + 80)

                       + 1*IKd*(PD1IKm[t]^4)*(PD1v[t] + 80)

                       + 1*IH*PD1IHm[t]*(PD1v[t] + 20)

                       + 1*IL*(PD1v[t] + 50)

                     )

                   - (

                     If[t < ics, 0, If[t > icf, 0, 1]]*ic

                     ))

               *(area),

           PD1v[0] == SmV



           },



         {PD1v, PD1INam, PD1INah, PD1IKm, PD1IKCam, PD1IAm, PD1IAh, 

PD1ICaTm,

                   PD1ICaTh, PD1ICaSm, PD1ICaSh, PD1IHm, PD1cca}, {

                     t, 0, time}, Method -> Automatic, MaxSteps -> 

Infinity];

     NeuronNumber

       (*ParametricPlot[Evaluate[{t, PD1v[t]} /. solution], {t, 0, time}, \

PlotPoints -> time, PlotRange -> {SmV, 20},

            PlotLabel -> "Model'

             s Soma", AxesLabel -> {"Time (ms)", "Voltage (mV)"}];*)



       ParametricPlot[Evaluate[{t,

         PD1v[t]} /. solution], {t, 0, time}, PlotPoints ->

            time, PlotRange -> {-80, 60}, PlotLabel -> NeuronNumber, 

AxesLabel \

-> {"Time (ms)", "Voltage (mV)"}];



     )



m = {{0}, {287978}, {295701}, {296048}};





Do[databaseModel[m[[i, 1]]], {i, 4}]

databaseModel[295701]

databaseModel[295701]









the graphs should all be different but they are coming out as flat 

lines. I have played around with this but cannot get it too output as it 

should. I wondered if this is something to do with the variables not 

reseting. If you try the code without the function the 4 executions come 

out as in the attached .jpg.



Thank you for your help with this. I am a biologist working on some 

Neural simulations and am not prepared for things not running smoothly. 

I find the tutorials and books can only take you so far.



Yours



David Fourie













-- 



Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at metrohm.com>

Internet:<http://www.metrohm.com>




  • Prev by Date: Re: What does FullForm[ ] actually do?
  • Next by Date: Re: ListPlot still ignores SetOptions[] command
  • Previous by thread: Re: Multiple Executions of .nb file part2
  • Next by thread: Glitch in Exporting PDFs from Mathematica to Illustrator, one solution