CVODE

This solver can be applied to following models:

  • Stiff or non-stiff models (systems having eigenfrequencies and/or time constants in a wide range).
  • Large models are computed mostly faster compared to the (ME)BDF‑solver. This is caused by the compilation of the model algorithm.

Due to the compilation process, the preparation of the calculation takes a bit longer than using the (ME)BDF‑solvers without compiled C‑code. Therefore we recommend the usage of this solver for models with fixed structure and varying parameters (e.g. in variant calculations).

For this solver, the same restrictions as for C-code export are to be considered. Please refer to the latest release notes of your SimulationX version for details.

The solver is part of the SUNDIALS Suite (see: www.llnl.gov/casc/sundials/).

Please note the license agreement of the original code:


Copyright (c) 2002, The Regents of the University of California. 
Produced at the Lawrence Livermore National Laboratory.
Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, 
           D. Shumaker, and A.G. Taylor.
UCRL-CODE-155951    (CVODE)
UCRL-CODE-155950    (CVODES)
UCRL-CODE-155952    (IDA)
UCRL-CODE-155953    (KINSOL)
All rights reserved. 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        

It was slightly changed and integrated into SimulationX by ESI ITI.

CVODE is a solver for explicit ordinary differential equations (ODE) according to . It uses either BDF or Adams formulas for integration. After pushing the button "Further Parameters…" in the dialog "Simulation Control", tab card "More" you can choose one of these methods (bStiff). The Adams method may be more efficient for non-stiff models.

As with (ME)BDF solver the maximum order of the BDF variant can be reduced. An increase often leads to a higher simulation speed when the solver works primarily with a low order. Latter can be found out easily with the Solver Debug Info vector [1]. The default value is 5.

The maximum order of the Adams variant is 12. When you choose bStiff=false this value will be set automatically by the solver and cannot be changed.

Considerably less RHS calculations, particularly for models with a sparse Jacobian matrix, and consequently an obvious decrease of computation time can be achieved by a more efficient computation of the Jacobian matrix. By default, it is enabled in the dialog "Simulation Control", tab card "More" in combination with a Sparse Matrix solver for the solution of the linear system. It can also be combined with a Gauss Method or disabled in certain circumstances (without efficient Jacobian computation).

Under "Further Parameters..." the following settings can be changed furthermore. These permit changing certain properties of the algorithms used. The default values ensure a robust behavior with good performance for most models. Changing these parameters assumes detailed knowledge of the algorithms used and should be an exception for the user.

  • A change of the parameters blockTol or blockLinSolv should be proved when the solution of block equations has been failed (see section "FAQs").
  • Events are treated as described in section Events. You can switch off the exact localization of roots of zero functions setting bZeros=false. This leads sometimes to higher simulation speed but to a loss of accuracy. State events are located later in this case.
  • The algorithms for exact localization of events can consider a hysteresis. This feature is activated by the parameter bHysterese. In this case events are located when the corresponding zero functions are different from zero by a certain value (parameter dblEpsilon). Events are located a little bit later in this case. Thus for certain models cycles during event iteration and discontinuity sticking can be avoided. dblEpsilon should not be larger than 10-8. The parameter bAdaptEpsilon controls if the size of the hysteresis for localization of events is adapted for the sensitivity of the model. The behavior of this adaptive adjustment can further be controlled by the following parameters:
    • With dblMaxEpsilon the maximum width of the hysteresis for the localization of events can be limited.
    • intAdaptThreshold is the threshold for the switching of zero functions before the adjustment of the width of the hysteresis is started.
    • dblAdaptFactor is the factor used for the adaptation of the size of the hysteresis.
    • bScaleEpsilon controls if the size of the hysteresis is scaled with the values of operands.
  • EventHandlingMode:
    • 0: Conservative: Time events (Modelica: when sample()) are approached directly by the solver. For this purpose the solver step size is decreased so that the time event is met exactly. After each time event the solver is reinitialized and afterwards continues the computation starting with small step size and method order which leads to a degradation of the performance.
    • 1: Efficient Time Event Handling: Time Events are not approached directly by the solver. Instead the solver always computes with its optimal step size. If a time event occurred during the last time step then the solution is interpolated back and the event is handled. The solver will be reinitialized only (analogously to mode 0) if the event has an impact on the continuous part of the model. Otherwise the solution will continue from the yet computed point in time. Thus the computing time is reduced, in particular for time discrete models whose outputs do not change at every sample time. This is often the case for time triggered state machines or controllers operating in limitation. However, for time discrete models influencing the continuous part of the model at every sample time this option can increase the computing time since additional calculations of the model are necessary.
    • 2: Efficient Time- and State Event Handling: State event handling is currently not available, the same behavior like option 1 is implemented.
  • By default, the minimum step size for CVODE is not limited from below. A lower limit can be set via the parameter bLimitdtMin.
  • The parameter bParJac controls if the Jacobians are computed in parallel. Parallelization reduces the computing time for models with costly model calculations and many state variables. However, the overhead caused by thread management and copying data can lead to longer computing times for smaller models.
  • By activating the option bOptimization it is possible to increase the calculating speed. Then the compiler will use the compiler option /O2. Be aware that this can result in a significant longer compile time.
  • An object file can hold up to 65,536 (216) addressable sections. Setting bBigobj=true increases the address capacity to 4,294,967,296 (232). Note: An .obj file produced with /bigobj can only be consumed by a linker that shipped in Visual C++ 2005 (or later).
  • If bIgnoreMinMax is set to true given minima/maxima for state variables are ignored.
  • strCompilerOption can be used for additional compiler options.

For details about the algorithms inside CVODE please refer to [5] and referenced papers.

Comparable to the BDF solver CVODE writes the following nine components to the vector solverInfo:

  1. Order (at time t<=tStop)
  2. Changing factor of the step size
  3. No. of RHS calculations (until time t)
  4. No. of iteration steps within one event iteration (enable Recording of Results "At least after dtProtMin (before) and after Events" necessary)
  5. No. of Jacobian matrix computations (until time t)
  6. No. of code generations (until time t) (only for Sparse Matrix solver)
  7. No. of decompositions (until time t)
  8. No. of solving the linear system (until time t)
  9. No. of discarded steps (at time t)

One can also find the total number of code generations, LU decompositions, and solutions of linear systems in the output window after the end of the simulation.