Sample program for DASSL

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Sample program for DASSL

anarang
     Hi,
     
        Can someone e-mail to me a sample program that uses DASSL (the
     differential-algebraic solver?
     
     Atul Narang
     MS H-7, Amoco Research Center
     Naperville, IL 60563
     Tel: (708) 961 6972
     E-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Sample program for DASSL

John W. Eaton-6
[hidden email] <[hidden email]> wrote:

: Can someone e-mail to me a sample program that uses DASSL (the
: differential-algebraic solver?

Here is a very simple one:

  # initial conditions

  x = [0; 0];

  xdot = [1.0; -1.0];

  # residual function

  function res = f (x, xdot, t)
    res (2) = x(1) + x(2);
    res (1) = xdot(1) - 1.0 + x(1);
  endfunction

  # vector of output times

  t = [0, logspace (-2, 0.7, 100)]';

  # solve it

  [x, xdot] = dassl ("f", x, xdot, t);

  # plot it

  plot (t, x);


jwe