Have a look at the description in https://computation.llnl.gov/casc/sundials/documentation/kin_guide/node5.html
On Wed, 2015-05-13 at 23:04, Pileas <[email protected]> wrote: > Hello all, > > I'm trying to solve a system of equations using the Sundials package for > Julia. > > The code is the following: > > #============================ CODE starts > =======================================# > *import Sundials* > > *function sysfn(y_in, fy_in, a_in)* > * y = Sundials.asarray(y_in)* > * fy = Sundials.asarray(fy_in)* > > > *fy[1] = 34460*(y[1]/(0.6*(150)^(0.6 - 1)*20))^(1/0.4) - > 48312*20*34*(y[2]/(y[5]*0.2*20*34))^(0.2/(0.2 - 1))* > > *fy[2] = y[1]*10000000*(1 - (8/14)^1.3) + (10000000*(8/14)^(1.3) + > 10000000*(8/14)^(1.3))*y[2] -* > *34460*20*150^0.6*y[1]/(0.6*150^(0.6 - 1)*20) - (1 - > 0.67)*(y[1]*10000000*(1 - (8/14)^1.3) + y[2]*(10000000*(8/14)^(1.3)* > *+ 10000000*(8/14)^(1.3))) -14*(y[4] - y[2] - (1 - 0.67)*((y[3]*10000000*(1 > - (8/14)^1.3) + y[4]*10000000*((8/14)* > *- (8/14)^(1.3)))/(10000000*(1 - (8/14)^(1.3))) -* > *(y[1]*10000000*(1 - (8/14)^1.3) + y[2]*(10000000*(8/14)^(1.3) +* > *10000000*(8/14)^(1.3)))/(10000000 + > 10000000*(8/14)^(1.3))))*(10000000*(8/14)^(1.3))/((1.3/(1.3 - 1))*14)* > > *fy[3] = 10000000*(8/14)^(1.3) + 10000000*(8/14)^(1.3) - > (y[2]/(y[5]*0.2*20*34))^(1/(0.2 - 1))*48312* > > *fy[4] = 48262*(y[3]/(0.6*150^(0.6 - 1)*10))^(1/0.4) - > 27607*12*14*(y[4]/(y[6]*0.2*12*14))^(0.2/(0.2 - 1))* > > *fy[5] = y[3]*10000000*(1 - (8/14)^(1.3)) + 10000000*((8/14)^(1.3) - > (8/14)^(1.3))*y[3]* > * - 48262*10*150^0.6*(y[3]/(0.6*150^(0.6 - 1)*10)) - (1 - > 0.67)*(y[3]*10000000*(1 - (8/14)^(1.3)) +* > * y[4]*(10000000*(8/14)^1.3 - 10000000*(8/14)^1.3))* > > *fy[6] = 10000000*((8/14)^1.3 - (8/14)^1.3) - > (y[4]/(y[6]*0.2*12*14))^(1/(0.2 - 1))*27607* > > *return int32(0)* > *end* > > *## Initialize problem* > *neq = 6* > *kmem = Sundials.KINCreate()* > *flag = Sundials.KINSetFuncNormTol(kmem, 1.0e-8)* > *flag = Sundials.KINSetScaledStepTol(kmem, 1.0e-8)* > *flag = Sundials.KINSetMaxSetupCalls(kmem, 1)* > *y = ones(neq)* > *flag = Sundials.KINInit(kmem, sysfn, y)* > *flag = Sundials.KINDense(kmem, neq)* > *## Solve problem* > *scale = ones(neq)* > *strategy = 1 # KIN_LINESEARCH* > *flag = Sundials.KINSol(kmem,* > * y,* > * strategy,* > * scale,* > * scale)* > > *println("Solution: ", y)* > *residual = ones(6)* > *sysfn(y, residual, [1,2,3,4,5,6])* > *println("Residual: ", residual)* > > *Sundials.KINFree([kmem])* > #=================================== End of code > ========================================# > > The above code gives a solution that has some negative numbers (I do not > expect to have those) plus this error: > " Five consecutive steps have been taken that satisfy a scaled step length > test ". > > I believe that either this solution may be wrong, since in another system > that I solved I had no such an error, or that the parameters that I have > given to the system are such that give some negative prices. > > Any ideas of what this Kinsol error means? > Thanks in advance.
