Menu

Dvode - repeated convergence failure

Help
Hieu
2011-07-07
2020-05-23
  • Hieu

    Hieu - 2011-07-07

    I have this error which (I think) is similar to the previous post "DVODE-problem, too much accuracy'. I try the method recommended by Rob, however, it is still giving me the same message. Please help me resolve this issue. My codes are provided at the end. Thanks.

    DVODE-  At T (=R1) and step size H (=R2), the
           corrector convergence failed repeatedly
           or with abs(H) = HMIN
          In above,  R1 =  0.0000000000000D+00   R2 =  0.1907348632813D-09
    vode: Repeated convergence failures. (Perhaps bad Jacobian supplied or wrong choice of MF or tolerances.)
    Error information: 
    Traceback (most recent call last):
      File "case1_PyDSTool.py", line 165, in <module>
        pd1 = traj1.sample(dt=0.1)
    AttributeError: 'NoneType' object has no attribute 'sample'


    E_A =  5
    (K,Ktest,k,km,Ea,E) = get_rate_and_eq_constants(E_A)
    DSargs = PyDSTool.args(name='SingleODETest')
    DSargs.pars = { 'k0'    : k,
                    'k1'    : k,
                    'km0'   : km,
                    'km1'   : km,
                    'PPA2g' : PP,
                    'PPBg'  : PP,
                    'PPABg' : PP    }

    DSargs.fnspecs  = {'rate0': (, 'k0*PPA2g*(1-tA)*(1-tA)-km0*tA*tA '),
                       'rate1': (, 'k1*PPBg*tA-km1*PPABg*(1-tA)      ')}

    DSargs.varspecs = {'tA': '2*rate0(tA)-rate1(tA)'}

    DSargs.ics      = {'tA' : 0}

    DSargs.tdomain  =
    DSargs.tdata =
    DSargs.algparams = {'init_step':1e-4,'stiff':True}
    ode  =  PyDSTool.Generator.Vode_ODEsystem(DSargs)
    traj1 =  ode.compute('part1')
    pd1 = traj1.sample(dt=0.1)

    ode.set(algparams={'init_step':1e-2},tdata=)
    traj2 = ode.compute('part2','c')
    pd2 = traj2.sample()

    ode.set(algparams={'init_step':1e-1},tdata=)
    traj3 = ode.compute('part3','c')
    pd3 = traj3.sample()

    pd1.extend(pd2, skipMatchingIndepvar=True)
    pd1.extend(pd3, skipMatchingIndepvar=True)
    plot(pd1,pd1)
    show()

     
  • Rob Clewley

    Rob Clewley - 2011-07-07

    Please provide the values for K,Ktest,k,km,Ea,E from the function get_rate_and_eq_constants so that I can test your code.

     
  • Hieu

    Hieu - 2011-07-07

    Please change the value of E_A at the beginning to  -2.5.  With that, the values of the parameters are:
    K = 3.558e31, K = 1.588e-17
    Ktest = 8.972e-03
    E = -5, E = 2
    Ea = 0, Ea = 2.75
                 I am not sure why you need the above values, since I think only the followings matter:
    k = 4.47e2, k = 9.95e-11
    km =  1.256e-29, km = 6.27e6
    PP = 2.5e1, PP = 5e1, PP = 2.244e1

    I have just noticed that these rate constants are vast different in values. I guess this might contribute to the problem. Thanks a lot.

     
  • Rob Clewley

    Rob Clewley - 2011-07-07

    I haven't had time to run your code, but yes, having rate constants with such differing orders of magnitude is not a job for a standard integrator. But you should first try an explicit Jacobian function as indicated in that other forum discussion, and also see one of the scripts in the tests/ directory concerning VODE with a Jacobian (vode_withjac_test.py). That may help! Otherwise, try Radau and also with a Jacobian and let me know if it doesn't work.

     
  • Hieu

    Hieu - 2011-07-08

    I have it working with Radau! Thanks for your help.

     
  • Hieu

    Hieu - 2011-07-11

    I have successfully solved my ODE with Radau integrator. However, the solution is not quite accurate enough or it doesn't give me enough decimal places. How do I inrease the accuracy of Radau integrator?

     
  • Rob Clewley

    Rob Clewley - 2011-07-11

    You have a few options. You can decrease rtol and atol using the algparams 'set' option, but they are already very small by default. You can't take them much below 1e-11 or 12 and expect a stable computation. You can decrease the max step size, but the steps it's taking are probably already very small. You can check on that by sampling out the points from the trajectory, call them pts, and then finding the largest step size.

    step_sizes = pts - pts
    print max(step_sizes)

    The best option of all, that I already suggested, is that I strongly encourage you to compute the Jacobian and provide it to the solver. This could potentially greatly increase the accuracy. Ultimately, you seemed to have an *extremely* stiff system, and double precision just might not be good enough to get the accuracy you need. You would have to use a different kind of solver altogether.

     
  • Hieu

    Hieu - 2011-07-11

    I followed your advice and tried computing the Jacobian. However, I'm making a mistake somewhere and it gives me this error below. I already spent much time looking but still can't find the mistake. Please take a look for me. My code is included at the end. Thanks a lot.

    Traceback (most recent call last):
      File "case1_PyDSTool.py", line 159, in <module>
        testODE = Radau_ODEsystem(DSargs)
      File "/share/apps/PyDSTool-0.88/PyDSTool/Generator/Radau_ODEsystem.py", line 436, in __init__
        ODEsystem.__init__(self, kw)
      File "/share/apps/PyDSTool-0.88/PyDSTool/Generator/ODEsystem.py", line 51, in __init__
        kw))
      File "/share/apps/PyDSTool-0.88/PyDSTool/FuncSpec.py", line 2149, in __init__
        FuncSpec.__init__(self, kw)
      File "/share/apps/PyDSTool-0.88/PyDSTool/FuncSpec.py", line 304, in __init__
        self.generateAuxFns()
      File "/share/apps/PyDSTool-0.88/PyDSTool/FuncSpec.py", line 449, in generateAuxFns
        self._genAuxFnC()
      File "/share/apps/PyDSTool-0.88/PyDSTool/FuncSpec.py", line 1487, in _genAuxFnC
        specdict_temp[specvars.values()] = auxstr
    AttributeError: 'list' object has no attribute 'values'


    for E_A in linspace(-2.5,-0.0,50):
            (K,Ktest,k,km,Ea,E) = get_rate_and_eq_constants(E_A)
            DSargs= args(name='ODETest')

            DSargs.pars = { 'k0'    : k,
                            'k1'    : k,
                            'km0'   : km,
                            'km1'   : km,
                            'PPA2g' : PP,
                            'PPBg'  : PP,
                            'PPABg' : PP    }

            DSargs.fnspecs={'Jacobian': (,"-4*k0*PPA2g*(1-tA)-4*km0*tA-k1*PPBg-km1*PPABg"),
                            'rate0'   : (, "k0*PPA2g*(1-tA)*(1-tA)-km0*tA*tA"),
                            'rate1'   : (, "k1*PPBg*tA-km1*PPABg*(1-tA)     ")}

            DSargs.varspecs  = {"tA": "2*rate0(tA)-rate1(tA)"}
            DSargs.ics       = {'tA' : 0.}
            DSargs.tdomain   =
            DSargs.algparams = {'init_step':0.1, 'rtol':1e-10, 'atol':1e-16}
            testODE = Radau_ODEsystem(DSargs)
            traj1 =  testODE.compute('SimpleOde')
            solution = traj1.variables(1e20)
            print_output(E_A, solution)

     
  • Rob Clewley

    Rob Clewley - 2011-07-11

    Yes, this is a small bug in my code, so I appreciate the chance to fix that. On the line 1487 indicated in FuncSpec.py by the error message, the line should read:

    specdict_temp[specvars] = auxstr

    with the same indentation as it currently has. You can make that adjustment yourself and I'll post the fix in a bug release later.

    By the way, from inspection of your equations with your ICs and parameters, the use of km0 at a level of 10^-29 or even k1 at 10^-11 is essentially pointless when your other rate parameters are O(1) or larger. It means those terms cannot possibly contribute anything to your dynamics. You might want to consider mathematical analysis prior to raw simulation in this case. It's very easy to analyze this 1D system mathematically for its fixed points and their stability, even rates of attraction.

     
  • hamed marzougui

    hamed marzougui - 2020-05-23

    CAN YOU HELP ME

    IN THE EXECUTION OF THE DVODE CODE SOME ERRORS APPEAR LIKE:

    DVODE-- At current T (=R1), MXSTEP (=I1) steps

       taken on this call before reaching TOUT                                   
      In above message,  I1 =       500
      In above message,  R1 =  0.5201476811500D+00
    

    Error halt: ISTATE = -1

    BEST REGARDS

     
  • hamed marzougui

    hamed marzougui - 2020-05-23

    CAN YOU HELP ME

    IN THE EXECUTION OF THE DVODE CODE SOME ERRORS APPEAR LIKE:

    DVODE-- At current T (=R1), MXSTEP (=I1) steps

    taken on this call before reaching TOUT
    In above message, I1 = 500
    In above message, R1 = 0.5201476811500D+00

    Error halt: ISTATE = -1

    THE FORTRAN CODE IS IN THE ATTACHED FILE
    BEST REGARDS

     

Log in to post a comment.