Re: Step Info from NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg33641] Re: Step Info from NDSolve
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 4 Apr 2002 19:40:02 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <a8g34f$b2p$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, StoppingText will solve you problem. stepNo will count the steps, dt will be the step size. stepNo = 0; lastT = 0; NDSolve[{y''[t] + y[t] == 0, y[0] == 1, y'[0] == 0}, y[t], {t, 0, 10}, StoppingTest -> (If[t < 10, stepNo++; dt = t - lastT; lastT = t; Print[dt]; False, True])] Regards Jens Brian Higgins wrote: > > Hi Mathgroup, > Is there anyway to get step information (number of steps, step size) > from NDSolve during the actual integration . The application I have in > mind has the following structure: > > NDSolve[{x[t]==F[x[t],y[t],t,1],y'[t]==F[x[t],y[t],t, > 2],x[0]==x0,y[0]==y0},{x[t],y[t]},{t,0,tmax}] > > where > > F[xval_?NumericQ,yval_?NumericQ,tval_?NumericQ,eqnNum_]:= > Module[{}, some code...; > {deriv1,deriv2}[[eqnNum]]] > > Thus during integration the RHS values for x'[t] and y'[t] are found > dynamically. This works fine. > > Now what I would like to do is take some action inside the function F > depending on the step size and how many steps NDSolve has taken when F > is called. > > Is it possible to extract this information from NDSolve dynamically. > > Thanks much in advance for any help you can offer, > > Brian