|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Re: IDASolve() failed with flag = -4, for arather large set of equations
Sender: owner-sundials-users@... Reply-To: sundials-users@... My guess is that your problem is outside the domain for which IDA can be expected to work, by virtue of the index, and possibly (even slightly) inaccurate initial values. IDA was really designed for index-1 systems. -Alan H On Thu, 15 Oct 2009, Francesco Pasqualini wrote: > Hi Alan, > > I don't see any actual errors in what you've supplied > Great! > > > , but > > there are two questionable things: > > > uchh :D > > > 1. You have a comment about calling IDACalcIC, but no such call. > > Inconsistent IC is the most likely cause of the initial failure you > > have. > > It would be very useful to know if IDACalcIC succeeds with whatever > > you > > give for initial guesses. (It still might fail if the guesses are not > > good enough.) > > > Well, the point is that my system is likely to be not index one, I am > developing my understanding of the basics in these same time period, > so I can't be precise. My actual guess is that my systems is likely to > be in "The Hessenberg form of size three" and suspecting so, I am > following the advice of the manual "For problems that do not fall into > either of these categories, the user is responsible for passing > consistent values, or risk failure in the numerical integration. > > For the consistency of the initial conditions, at this point, I've > proceeded like that: I initialized my matlab routine, with a very > small time step so that it performs only one iteration, and then I use > the vector generated after this iteration to feed the C++ routine. > They should be consistent. > > > 2. Your iout loop appears to generate tout = 1, 1, 1, 2, 3, ... . Do > > you have some reason for the extra calls with tout = 1? > > > > That is a mistake I made, cause I've some macro defined and used in > that fragment, but in an attempt to simplify, I changed with 1.... in > fact the real number was 0.3, but actually the whole loop can be made > clearer: I must admit I've copied it from another examples :D > > I attach another implementation where the loop is 1, 2, 3, ... , 10 > and the error is still the original one. > > What do you suggest as best candidate to be the problem? > > Thank you, > Francesco > > > >> > >> > > static int resGPB(realtype time, N_Vector y, N_Vector ydot, N_Vector > resval, > void *user_data); > > int main() > { > void *mem; > N_Vector y, ydot; > N_Vector idv, avtol; > int iout, retval; > > > realtype rtol, atol, t0, tout, tret; > > y = N_VNew_Serial(NEQ); > if(check_flag((void *)y, "N_VNew_Serial", 0)) return(1); > ydot = N_VNew_Serial(NEQ); > if(check_flag((void *)ydot, "N_VNew_Serial", 0)) return(1); > > // avtol = N_VNew_Serial(NEQ); > // if(check_flag((void *)avtol, "N_VNew_Serial", 0)) return(1); > > idv = N_VNew_Serial(NEQ); > if(check_flag((void *)idv, "id", 0)) return(1); > > realtype id_vect[] = {...}; > realtype ydot_vect[] = {...}; > realtype IC[] = {...}; > > for(int i=1; i<=NEQ; i++){ > Ith(idv,i)=id_vect[i-1]; > Ith(y,i)=IC[i-1]; > Ith(ydot,i) = ydot_vect[i-1]; > > // Ith(avtol,i) = ATOL; > } > > GPBdata = (UserData) malloc(sizeof *GPBdata); > /* Set remaining inputs to IDAMalloc. */ > > t0 = 0; > rtol = 1.0e-5; > atol = 1.0e-12; > > // all IDACreate and IDAMalloc to initialize IDA. > > mem = IDACreate(); > if(check_flag((void *)mem, "IDACreate", 0)) return(1); > > // retval = IDASetUserData(mem, GPBdata); > // if(check_flag(&retval, "IDASetUserData", 1)) return(1); > > retval = IDASetId(mem, idv); > if(check_flag(&retval, "IDASetId", 1)) return(1); > > retval = IDAInit(mem, resGPB, t0, y, ydot); > if(check_flag(&retval, "IDAInit", 1)) return(1); > > > retval = IDASStolerances(mem, rtol, atol); > if(check_flag(&retval, "IDASStolerances", 1)) return(1); > > > retval = IDADense(mem, NEQ); > if(check_flag(&retval, "IDADense", 1)) return(1); > > > // retval = IDASetSuppressAlg(mem, TRUE); > // if(check_flag(&retval, "IDASetSuppressAlg", 1)) return(1); > > // Call IDACalcIC (with default options) to correct the initial > values. > > tout = RCONST(1); > > for (iout = 1; iout <= 10; iout++) { > > retval = IDASolve(mem, iout*tout, &tret, y, ydot, > IDA_NORMAL); > if(check_flag(&retval, "IDASolve", 1)) return(retval); > > PrintOutput(mem, tret, y); > > } > N_VDestroy_Serial(y); > N_VDestroy_Serial(ydot); > N_VDestroy_Serial(idv); > > IDAFree(&mem); > free(GPBdata); > > > return(0); > } > > /* > * Define the system residual function. > */ > > > static int resGPB(realtype time, N_Vector y, N_Vector ydot, N_Vector rr, > void *user_data){ > ... > } > > > ERROR > > I obtain the error > > [IDAS ERROR] IDASolve > At t = 0 and h = 0, the corrector convergence failed repeatedly or > with |h| = hmin. > SUNDIALS_ERROR: IDASolve() failed with flag = -4 > >> > > Francesco S. Pasqualini > > ---------------------------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
Re: IDASolve() failed with flag = -4, for aRandall Britten wrote:
> Hi Alan > > Isn't there a GGL example amongst the IDA examples somewhere, which I think > is an index 2 example? If I recall correctly IDA seems to solve that quite > well. Is the performance when using IDA for index 2 systems well > understood, or just a matter of trial and error? > > Regards, > Randal Randall, There are two main issues with using IDA on a DAE of index higher than 1: (i) the supplied consistent initial condition function IDACalcIC only works for index-1 systems; (ii) the stepsize selection algorithm is not designed to handle higher index systems. The idaSlCrank_dns example does indeed use the GGL (Gear-Gupta-Leimkuhler) formulation, a stabilized index two formulation of the index-3 DAE equations of motion for systems of rigid bodies. In order to solve this index-2 DAE with IDA (i.e., address the two issues above), we: (i) provide consistent initial conditions for y and y', calculated with some other method (for mechanical systems this is relatively straightforward); (ii) exclude the algebraic variables (for mechanical systems these are the Lagrange multipliers) from the integration error control estimates. (Note however that all variables are included in the convergence test for the corrector iteration.) With IDA, this can be done by calling the function IDASetSuppressAlg after the type of each variable (algebraic/differential) was specified through a call to IDASetId. For more details on using a solver like IDA on higher-index DAEs, see Brenan, Campbell, Petzold, "Numerical Solution of Initial-Value Problems in Differential-Algebraic Equations", SIAM, 1996. Best, --Radu |
|
|
Re: SPAM-LOW: Re: IDASolve() failed with flag = -4, for aFrancesco Pasqualini wrote:
> Hi Alan, > to recapitulate, your suggestion will be to use the same tricky way > adopted in matlab but with CVOde or, eventually, to find a specific > DAE solver for my kind of rather complicated DAE? > > Thank you, > Francesco > Francesco, Can you say more about your DAE? Of course, I'm not asking for all 153 equations, but rather a more compact description. What is its structure? Why do you say it's index-3? Also, what is the "tricky way" of converting it to an ODE? Is it an index reduction? An underlying ODE obtained by manually eliminating the algebraic variables? --Radu |
| Free embeddable forum powered by Nabble | Forum Help |