help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help using odepkg


From: c.
Subject: Re: Help using odepkg
Date: Wed, 25 Jul 2012 06:45:44 +0200

Il giorno 24/lug/2012, alle ore 23.04, <address@hidden> <address@hidden> ha 
scritto:

> I'm trying to use OdePkg to solve a set of somewhat stiff
> differential equations (augmented Park's equations, in case you
> wondered).  I want to use a solver from this package in lieu of
> lsode,

If your equation is stiff you should be using DASPK rather than lsode.
http://www.gnu.org/software/octave/doc/interpreter/Differential_002dAlgebraic-Equations.html#Differential_002dAlgebraic-Equations

odepkg also has quite a few options of stiff solvers
http://octave.sourceforge.net/odepkg/overview.html#OdePkgDAESolverFunctions
http://octave.sourceforge.net/odepkg/overview.html#OdePkgIDESolverFunctions

> because they allow me to pass parameters to the function
> that produces the derivatives.  OK, I could use globals, but
> really, globals?  Shades of Fortran /COMMON/ blocks.  

You should not use globals for this, the preferred way for parametrizing 
functions is using anonymous functions, e.g.

function du = f (x, xdot, t, parameters)
  ...
endfunction

parameters = 1;

u = daspk (@(x, xdot, t) f (x, xdot, t, parameters), ...);

This is the usual way to do this in Matlab as well as in Octave:
http://www.mathworks.it/help/techdoc/math/bsgprpq-5.html#bsgprpq-8
http://www.gnu.org/software/octave/doc/interpreter/Anonymous-Functions.html

> For the
> simplified problem, I can easily calculate the derivatives
> given the time, state variables, fixed (?) inputs, and a couple
> parameter matrices that depend on the particular simulation.
> I am running Octave 3.6.2 Mingw binary distribution on a 32-bit
> Windows XP machine (also a 64-bit Win7) and I have installed
> the OdePkg 0.8.2 from Octave-Forge.
> 
> First problem: the ODE solvers all seem to be present, but none
> of the DAE or IDE solvers.  Is this because the package is a
> beta build?
your odepkg might be incorrectly installed, I am not sure how to fix this in 
windows other than reinstalling Octave, there are windows users on this list
who might be more helpful on this. 

>  I'm interested in the DAE solvers because eventually
> I will want to incorporate variable speed, and it will be more
> convenient (probably faster) to let the solver do the entire
> solution rather than solve for the derivatives separately.  Also
> they're the only ones that say they are for "stiff" equations
> (apart from the Euler Backward Difference odebwe.m).  This
> equation set has about 10:1 difference in max/min TC's, so maybe
> that's not stiff enough to worry about.
> 
> Second problem: is there a good way to include a forcing function
> U(t) without writing it inside the derivative function?  If not, 
> I could just use a piecewise-linear approximation for now.
I don't really understand this question, maybe an example would make it clearer.

> 
> Sorry for kind of vague questions.  I'll try reading the manual
> some more.
that is a good idea, start from the links provided above.

> Regards,
> Allen
c.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]