MathGroup Archive 1999

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

Search the Archive

Re: Control Function With NDsolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19419] Re: Control Function With NDsolve
  • From: Don Paddleford <don-paddleford at worldnet.att.net>
  • Date: Mon, 23 Aug 1999 13:57:25 -0400
  • Organization: AT&T WorldNet Services
  • References: <7p5dm5$127@smc.vnet.net> <7pl53k$c74@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Eckhard Hennig wrote:
> 
> Don Paddleford schrieb in Nachricht <7p5dm5$127 at smc.vnet.net>...
> >In solving a control type dif eq with NDSolve I have the following
> >question. Suppose the eq is of the following simplified form
> >
> > y'[t]==a*f[y[t]]-b*y[t]
> > y[0]==0
> >
> >How to define f so that it starts at f=1, and changes to f=0 when y
> >reaches ymax, and then changes back to f=1 when y reaches ymin, and so
> >on in oscilatory fashion?
> >
> 
> Don,
> 
> you can define such a function as follows. Note that it is important to
> define the pattern for f such that it applies only to numeric arguments.
> Otherwise, f[y[t]] would be evaluated prematurely in In[3].
> 
> In[1]:= f[y_Real] :=
>           If[(y > ymax && fval == 1) || (y < ymin && fval == 0),
>              fval = 1 - fval,
>              fval]
> 
> In[2]:= ymax = 0.9; ymin = 0.1; a = 1; b = 1;
> 
> In[3]:= eqs = {y'[t] == a*f[y[t]] - b*y[t], y[0] == 0};
> 
> In[4]:= fval = 1; NDSolve[eqs, y[t], {t, 0, 10}];
> 
> In[5]:= y1[t_] = y[t] /. First[%];
> 
> In[6]:= Plot[y1[t], {t, 0, 10}, PlotRange->All]
> 
> -- Eckhard
> 
> -----------------------------------------------------------
> Dipl.-Ing. Eckhard Hennig      mailto:hennig at itwm.uni-kl.de
> Institut fuer Techno- und Wirtschaftsmathematik e.V. (ITWM)
> Erwin-Schroedinger-Strasse,  67663 Kaiserslautern,  Germany
>   Voice: +49-(0)631-205-3126    Fax: +49-(0)631-205-4139
>     http://www.itwm.uni-kl.de/as/employees/hennig.html
> 
>      ITWM - Makers of Analog Insydes for Mathematica
>         http://www.itwm.uni-kl.de/as/products/ai
> -----------------------------------------------------------


Eckhard,

Thanks for the reply. Your suggestion worked perfectly and is exactly 
what I needed for both, this question, and another I posted several days 
later on the same subject.

Don


  • Prev by Date: Re: AxesLabel with greek letter
  • Next by Date: Re: Re: incompatibilities between releases of Mathematica (was: Mathematica Link for Excel and Excel 2000)
  • Previous by thread: Re: Control Function With NDsolve
  • Next by thread: Re: Control Function With NDsolve