Re: Re: NDSolve Mathematica 6 and 7
- To: mathgroup at smc.vnet.net
- Subject: [mg103376] Re: [mg103355] Re: [mg103336] NDSolve Mathematica 6 and 7
- From: Mark Perrin <m.perrin at me.com>
- Date: Fri, 18 Sep 2009 05:39:08 -0400 (EDT)
- References: <200909160946.FAA12985@smc.vnet.net>
Thank you. 1. Set markedly increased the speed of the notebook. 2. I've used Boole where I could - haven't noticed a large speed increase so far. Most of the subscripts have been removed from the notebook I am using. I noticed that I placed a slightly out of date NB in the link. However, the issue was the same with or without the subscripts. I agree they are a nuisance in Mathematica; I intend to rid myself of them now for good. While this speeds up the NB as a whole, it still runs markedly faster on Mathematica 6. Our short term solution is to perform operations in Math 6. Thanks again! Cheers, Mark P On 18/09/2009, at 5:19 AM, DrMajorBob wrote: > A few things I notice right away: > > 1) You use SetDelayed (":=") when Set ("=") would be faster. I use > SetDelayed ONLY if variables on the right hand side (a) have a value > when I'm defining the left hand side, and (b) may have a DIFFERENT > value when I USE the left hand side. You also do not need a > semicolon to suppress output after SetDelayed. You DO need it after > Set. > > 2) There are cases where I'd use Boole, not PieceWise, namely: > > istim[t_, x_] = -36 Boole[10 < t + curtime < 11 && 0 <= x < 1/20]; > > \[Alpha]h = 0.057*E^(-((V[t, x] + 80)/6.8)) Boole[V[t, x] < -40]; > > > \[Alpha]j = (-25428 E^(0.2444 V[t, x]) - > 6.948*10^-6 E^(-0.04391 V[t, x])) (V[t, x] + 37.78)/(1 + E^( > 0.311 (V[t, x] + 79.23))) Boole[V[t, x] < -40]; > > 3) If you'll ever use exact methods (DSolve rather than NDSolve, > Solve rather than NSolve, etc.), you should avoid Reals and use > Rationals instead. (As in the first Boole example above.) If you > don't need exact methods, then by all means, proceed with Reals. > > 4) In NDSolve, you've used MaxStepSize -> {1, 0.01}, but I see > nothing in documentation to support ordered pairs here. Since it > isn't documented, it can easily change or disappear from one version > to another. > > 5) In your NDSolve, all but two of the initial condition right hand > sides SEEM to be undefined because they're highlighted in blue. I > think that's only because they're subscripted, and defining, for > instance, Subscript[V, 0] leaves V undefined. But it makes finding > errors more difficult, when one can't see what is or is not defined. > (I don't use subscripts. Ever.) > > 6) Related to that, I can see how a solver might be confused by > Rprime (for instance), which is used both as a constant (with > subscript zero) and as a function name in the variable list. All > your initial conditions are like that, other than the last two. For > now, that's my best guess as to what's happening, but I admit it's > speculative. I can't test this in earlier versions, so I'm guessing. > > That's all I see at the moment. Good luck! > > Bobby > > On Thu, 17 Sep 2009 05:20:04 -0500, Mark Perrin <m.perrin at me.com> > wrote: > >> Well it is a system of partial differential equations describing a >> wave of electrical depolarisation passing through a cable. >> >> EQN1 := D[V[t, x], >> t] == -1/ >> 1 (iK1 + iKr + iKs + iNa + ibCa + ibNa + ipCa + iCaL + ipK + >> iNaCa + iNaK + istim[t, x] + ito); >> >> EQN2 := D[Xs[t, x], t] == 2.57 ((xas - Xs[t, x])/tauxs); >> >> EQN3 := D[s[t, x], t] == (sinf - s[t, x])/taus; >> >> etc. >> >> I can post the notebook here: >> >> http://dl.getdropbox.com/u/127753/cablenotebook.nb >> >> Other details: >> - running Mathematica 6 and 7 (depending on need) >> - Mac 10.6 Snow Leopard - but tested also on a windows computer >> running Mathematica 6 and 7 - same issue >> >> >> Regards, >> >> Mark P >> >> On 17/09/2009, at 12:58 AM, DrMajorBob wrote: >> >>> Send details, Mark. Details. >>> >>> Bobby >>> >>> On Wed, 16 Sep 2009 04:46:29 -0500, Mark Perrin <m.perrin at me.com> >>> wrote: >>> >>>> I was wondering if anyone could help me. I am solving a set of >>>> partial >>>> and ordinary differential equations in Mathematica 7. For the same >>>> set >>>> of equations and same expression i.e. >>>> >>>> solution = >>>> NDSolve[EQNS, STATES, {t, 0, 500}, {x, 0, 1.6}, MaxStepSize -> {1, >>>> 0.01}, >>>> MaxSteps -> Infinity, AccuracyGoal -> 5, PrecisionGoal -> 5] >>>> >>>> where EQNS are the ODEs. >>>> >>>> Mathematica 6 solves this in < 5 minutes. >>>> Mathematica 7 takes about 40-45 minutes. >>>> for the same solution. >>>> >>>> Same hardware etc. >>>> >>>> Can anyone please tell me if it is possible to speed up the >>>> solution >>>> in Mathematica 7. Why would the two be so different? >>>> >>>> Kind Regards, >>>> >>>> Patch >>>> >>> >>> >>> -- >>> DrMajorBob at yahoo.com >> >> > > > -- > DrMajorBob at yahoo.com
- References:
- NDSolve Mathematica 6 and 7
- From: Mark Perrin <m.perrin@me.com>
- NDSolve Mathematica 6 and 7