|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Help need for Differential algebraic equationsHi all,
I am new to octave and i love it the best as an open source alternative to matlab. I used lsode to solve ordinary diff equations, but now I do also have some algebraic equations to solve along. I came across this function 'dassl', which is supposed to solve differential algebraic equations, but have problems using it. This is how i use it currently and below is the error message. I have no idea what it is. Please help! ******code***** function xdot = f(x,xdot,t); %define all parameter values viz. k12, k23,f86 etc here xdot = zeros(9,1); xdot(2) = k12*x(1) - k23*x(2); xdot(3) = k23*x(2); xdot(5) = k45*x(4) - k56*x(5); xdot(6) = k56*x(5) - k67*x(6); xdot(7) = k67*x(6); x(8) = f86*x(6); x(9) = f29*x(2); endfunction; x0 = ones(9,1)'; xdot0 =zeros(9,1)'; t = linspace(0,50,50); dassl("f",x0,xdot0,t) *****output****** ***MESSAGE FROM ROUTINE DDASSL IN LIBRARY SLATEC. ***POTENTIALLY RECOVERABLE ERROR, PROG ABORTED, TRACEBACK REQUESTED * AT T = 0.000000E+00 AND STEPSIZE H = 1.594388E-05 THE ITERATION * MATRIX IS SINGULAR * ERROR NUMBER = -8 * ***END OF MESSAGE ***JOB ABORT DUE TO UNRECOVERED ERROR. 0 ERROR MESSAGE SUMMARY LIBRARY SUBROUTINE MESSAGE START NERR LEVEL COUNT SLATEC DDASSL AT T = 0.000000E+ -8 1 1 error: exception encountered in Fortran subroutine ddassl_ error: caught execution error in library function |
|
|
Re: Help need for Differential algebraic equationsOn Wed, Oct 08, 2008 at 03:22:11PM -0700, genehacker wrote:
> > I came across this function 'dassl', which is supposed to solve differential > algebraic equations, but have problems using it. This is how i use it > currently and below is the error message. I have no idea what it is. At least from 'T = 0.000000E+00' you see that dassl did not get away from time zero. I do not know algorithms for DAEs, but probably the solver will build a gradient matrix by calling your function 'f' with different values of 'x' and 'xdot' and makes some 'iteration matrix' from it. The error 'THE ITERATION MATRIX IS SINGULAR' is not surprizing, since your function 'f' seems to be wrong (see below), so that the returned value does not depend on the argument 'xdot' at all. > ******code***** > > function xdot = f(x,xdot,t); The return value has the same name as the argument 'xdot'. You should give it a different name. You should assign to it the value of the right side of your DAE, which gets zero for a solution. > %define all parameter values viz. k12, k23,f86 etc here > xdot = zeros(9,1); With the line above you have lost the values in the argument 'xdot'. Also, you do not use this argument below --- seems you actually need a solver for algebraic equations (like 'fsolve'), not differential(-algebraic) equations. Or you actually mean to solve an ODE (use 'lsode' than). Anyway, something is wrong with your code ... > xdot(2) = k12*x(1) - k23*x(2); > xdot(3) = k23*x(2); > xdot(5) = k45*x(4) - k56*x(5); > xdot(6) = k56*x(5) - k67*x(6); > xdot(7) = k67*x(6); > > x(8) = f86*x(6); > x(9) = f29*x(2); Why are you assigning to 'x' above? > endfunction; > > > x0 = ones(9,1)'; > xdot0 =zeros(9,1)'; > t = linspace(0,50,50); > dassl("f",x0,xdot0,t) > > *****output****** > > ***MESSAGE FROM ROUTINE DDASSL IN LIBRARY SLATEC. > ***POTENTIALLY RECOVERABLE ERROR, PROG ABORTED, TRACEBACK REQUESTED > * AT T = 0.000000E+00 AND STEPSIZE H = 1.594388E-05 THE ITERATION > * MATRIX IS SINGULAR > * ERROR NUMBER = -8 > * > ***END OF MESSAGE > > ***JOB ABORT DUE TO UNRECOVERED ERROR. > 0 ERROR MESSAGE SUMMARY > LIBRARY SUBROUTINE MESSAGE START NERR LEVEL COUNT > SLATEC DDASSL AT T = 0.000000E+ -8 1 1 > > error: exception encountered in Fortran subroutine ddassl_ > error: caught execution error in library function Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Help need for Differential algebraic equationsThanks for the reply Olaf. I defnitely changed the function return variable, that should be different from xdot. But i still have a problem of running a simple differential algebraic equation. I am getting the same answer, if i tried a much simpler set of equations(even though I didnot use an algebraic equation here, I intend to use it later on). [ Also, you asked why I am doing x(2) = f*x(6), thats is the type of algebraic equation i intend to use]. Is there something inherently wrong with my code? I couldnot get much help about this online.
**********code ******** function res = f(x,xdot,t); res = zeros(3,1); k12=0.1; k23=0.7; xdot(1) = -k12*x(1); xdot(2) = k12*x(1) - k23*x(2); xdot(3) = k23*x(2); endfunction; x0 = [100,0,0]; xdot0 =[-10,10,10]; t = linspace(0,50,50); [x,xdot] = dassl("f",x0,xdot0,t); *********OUTPUT********** ***MESSAGE FROM ROUTINE DDASSL IN LIBRARY SLATEC. ***POTENTIALLY RECOVERABLE ERROR, PROG ABORTED, TRACEBACK REQUESTED * AT T = 0.000000E+00 AND STEPSIZE H = 1.425756E-11 THE ITERATION * MATRIX IS SINGULAR * ERROR NUMBER = -8 * ***END OF MESSAGE ***JOB ABORT DUE TO UNRECOVERED ERROR. 0 ERROR MESSAGE SUMMARY LIBRARY SUBROUTINE MESSAGE START NERR LEVEL COUNT SLATEC DDASSL AT T = 0.000000E+ -8 1 1 error: exception encountered in Fortran subroutine ddassl_ error: caught execution error in library function |
|
|
Re: Help need for Differential algebraic equationsOn 9-Oct-2008, genehacker wrote:
| | Thanks for the reply Olaf. I defnitely changed the function return variable, | that should be different from xdot. But i still have a problem of running a | simple differential algebraic equation. I am getting the same answer, if i | tried a much simpler set of equations(even though I didnot use an algebraic | equation here, I intend to use it later on). [ Also, you asked why I am | doing x(2) = f*x(6), thats is the type of algebraic equation i intend to | use]. Is there something inherently wrong with my code? I couldnot get much | help about this online. | | **********code ******** | function res = f(x,xdot,t); | res = zeros(3,1); | k12=0.1; | k23=0.7; | | xdot(1) = -k12*x(1); | xdot(2) = k12*x(1) - k23*x(2); | xdot(3) = k23*x(2); | | endfunction; X nad XDOT are parameters to your function. Changing them has no effect. If you are solving a DAE with dassl, you should be defining a residual funtion F such that it computes RES as a function of X, XDOT, and T. Your function above simply sets RES to zero. If your function is as you show above, then it looks like an ODE, not a DAE. jwe _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Help need for Differential algebraic equationsOn 09/ott/08, at 18:09, genehacker wrote: > **********code ******** > function res = f(x,xdot,t); > res = zeros(3,1); > k12=0.1; > k23=0.7; > > xdot(1) = -k12*x(1); > xdot(2) = k12*x(1) - k23*x(2); > xdot(3) = k23*x(2); > endfunction; as it stands this function does not make much sense: whatever its input is it will always return [0 0 0].' to check, try for example running the following command multiple times: f (rand(3,1), rand(3,1), rand(1)) as xdot is not an output of the function, whatever value you assign to it will be lost when the function returns. I suggest you read the manual chapter on defining functions: http://www.gnu.org/software/octave/doc/interpreter/Functions-and-Scripts.html#Functions-and-Scripts to understand how input and output parameters are handled > x0 = [100,0,0]; > xdot0 =[-10,10,10]; > t = linspace(0,50,50); > [x,xdot] = dassl("f",x0,xdot0,t); the first sentence in the documentation of dassl reads: "-- Loadable Function: [X, XDOT, ISTATE, MSG] = dassl (FCN, X_0, XDOT_0, T, T_CRIT) Solve the set of differential-algebraic equations 0 = f (x, xdot, t)" so, put in mathematical terms, the problem you are trying to solve with this statement reads: find x(t) such that f(x,x',t) = 0 for 0<= t <= 50 as with your definition f(x,x',t) = 0 is verified for any value of x, x' and t, the problem is not well posed as ANY function x(t) is a solution. c. _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Help need for Differential algebraic equationsthanks very much for the help. now it defnitely works:)
|
| Free embeddable forum powered by Nabble | Forum Help |