Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Control Function With NDsolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19338] Re: Control Function With NDsolve
  • From: Eckhard Hennig <hennig at itwm.uni-kl.de>
  • Date: Fri, 20 Aug 1999 23:09:26 -0400
  • Organization: ITWM
  • References: <7p5dm5$127@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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
-----------------------------------------------------------






  • Prev by Date: Comments in 2-D cells yield corrupt packages
  • Next by Date: Help: How can I set the insertion cursor in a certain cell?
  • Previous by thread: Re: Control Function With NDsolve
  • Next by thread: Re: Control Function With NDsolve