From 53ec802aa0277d62cce9b0868afe4fb96e6274b0 Mon Sep 17 00:00:00 2001
From: Paul BIGNIER
Date: Tue, 18 Dec 2012 14:40:10 +0100
Subject: [PATCH] Xcos solvers : Renamed "DormandPrice" to correct name
"DormandPrince"
Also corrected in the doc
ChangeId: Ia314f17859478068705720cba6235c682a43f5c3

scilab/CHANGES_5.4.X  2 +
scilab/modules/scicos/src/c/scicos.c  2 +
.../scicos/src/scicos_sundials/src/cvode/cvode.c  8 +
.../modules/xcos/examples/solvers/integDoPri.sce  2 +
.../modules/xcos/help/en_US/solvers/0LSodar.xml  2 +
scilab/modules/xcos/help/en_US/solvers/1CVode.xml  2 +
.../xcos/help/en_US/solvers/2RungeKutta.xml  2 +
.../xcos/help/en_US/solvers/3DormandPrice.xml  252 
.../xcos/help/en_US/solvers/3DormandPrince.xml  252 ++++++++++++++++++++
scilab/modules/xcos/help/en_US/solvers/7IDA.xml  2 +
10 files changed, 263 insertions(+), 263 deletions()
delete mode 100644 scilab/modules/xcos/help/en_US/solvers/3DormandPrice.xml
create mode 100644 scilab/modules/xcos/help/en_US/solvers/3DormandPrince.xml
diff git a/scilab/CHANGES_5.4.X b/scilab/CHANGES_5.4.X
index a660e1d..43f11e4 100644
 a/scilab/CHANGES_5.4.X
+++ b/scilab/CHANGES_5.4.X
@@ 57,7 +57,7 @@ Xcos
* Add a new ODE solver : LSodar. Automatically switches methods to efficiently solve both stiff and nonstiff problems. Includes a rootfinding feature.
* Add two new Fixedsize step ODE solvers : DormandPrice 4(5) then RungeKutta 4(5). Included in the CVode package, so benefit from the rootfinding feature.
+* Add two new Fixedsize step ODE solvers : DormandPrince 4(5) then RungeKutta 4(5). Included in the CVode package, so benefit from the rootfinding feature.
* Add an implicit Fixedsize stop ODE solver : Implicit RungeKutta 4(5). Also benefits from the CVode rootfinding feature.
diff git a/scilab/modules/scicos/src/c/scicos.c b/scilab/modules/scicos/src/c/scicos.c
index c65bbb8..6842a3e 100644
 a/scilab/modules/scicos/src/c/scicos.c
+++ b/scilab/modules/scicos/src/c/scicos.c
@@ 823,7 +823,7 @@ int C2F(scicos)(double *x_in, int *xptr_in, double *z__,
{
cossim(t0);
}
 else if (C2F(cmsolver).solver == 5) /* DOPRI: Method: DormandPrice, Nonlinear solver= */
+ else if (C2F(cmsolver).solver == 5) /* DOPRI: Method: DormandPrince, Nonlinear solver= */
{
cossim(t0);
}
diff git a/scilab/modules/scicos/src/scicos_sundials/src/cvode/cvode.c b/scilab/modules/scicos/src/scicos_sundials/src/cvode/cvode.c
index 1ccc3dd..6636aab 100644
 a/scilab/modules/scicos/src/scicos_sundials/src/cvode/cvode.c
+++ b/scilab/modules/scicos/src/scicos_sundials/src/cvode/cvode.c
@@ 357,7 +357,7 @@ void *CVodeCreate(int lmm, int iter)
maxord = (lmm == CV_ADAMS) ? ADAMS_Q_MAX : BDF_Q_MAX;
 /* If DormandPrice is selected, then maxord = 8 to use the 7 extra vectors allocated (zn[2, 3, 4, 5, 6, 7, 8]) */
+ /* If DormandPrince is selected, then maxord = 8 to use the 7 extra vectors allocated (zn[2, 3, 4, 5, 6, 7, 8]) */
maxord = (lmm == CV_DOPRI) ? 8 : maxord;
/* If RungeKutta is selected, then maxord = 1 */
@@ 2403,7 +2403,7 @@ static int CVStep(CVodeMem cv_mem)
/*
* CVStepDoPri
*
 * This routine performs one internal cvode step using the DormandPrice 4(5) method, from tn to tn + h.
+ * This routine performs one internal cvode step using the DormandPrince 4(5) method, from tn to tn + h.
* Proceed to computing the K[i] coefficients, build the final solution, increment tn and return CV_SUCCESS.
*
* In order to temporarily store the results, we use tempv and ftemp.
@@ 2493,11 +2493,11 @@ static int CVStepDoPri(CVodeMem cv_mem)
/* Check for errors in the evaluations of f thanks to retval */
if (retval < 0) {
 CVProcessError(cv_mem, CV_RHSFUNC_FAIL, "DormandPrice", "CVStepDoPri", MSGCV_RHSFUNC_FAILED, tn);
+ CVProcessError(cv_mem, CV_RHSFUNC_FAIL, "DormandPrince", "CVStepDoPri", MSGCV_RHSFUNC_FAILED, tn);
return(CV_RHSFUNC_FAIL);
}
if (retval > 0) {
 CVProcessError(cv_mem, CV_FIRST_RHSFUNC_ERR, "DormandPrice", "CVStepDoPri", MSGCV_RHSFUNC_FIRST);
+ CVProcessError(cv_mem, CV_FIRST_RHSFUNC_ERR, "DormandPrince", "CVStepDoPri", MSGCV_RHSFUNC_FIRST);
return(CV_FIRST_RHSFUNC_ERR);
}
diff git a/scilab/modules/xcos/examples/solvers/integDoPri.sce b/scilab/modules/xcos/examples/solvers/integDoPri.sce
index a75698b..fae1fab 100644
 a/scilab/modules/xcos/examples/solvers/integDoPri.sce
+++ b/scilab/modules/xcos/examples/solvers/integDoPri.sce
@@ 15,7 +15,7 @@ loadXcosLibs();
importXcosDiagram("SCI/modules/xcos/examples/solvers/ODE_Example.xcos");
scs_m.props.tf = 30000;
solverName=["BDF/Newton", "BDF/Functional", "Adams/Newton", "Adams/Functional", "DormandPrice"];
+solverName=["BDF/Newton", "BDF/Functional", "Adams/Newton", "Adams/Functional", "DormandPrince"];
for solver=1:5
diff git a/scilab/modules/xcos/help/en_US/solvers/0LSodar.xml b/scilab/modules/xcos/help/en_US/solvers/0LSodar.xml
index 8601f06a..ca130ea 100644
 a/scilab/modules/xcos/help/en_US/solvers/0LSodar.xml
+++ b/scilab/modules/xcos/help/en_US/solvers/0LSodar.xml
@@ 168,7 +168,7 @@ Time for Adams / Functional :
RungeKutta 4(5)
 DormandPrice 4(5)
+ DormandPrince 4(5)
Implicit RungeKutta 4(5)
diff git a/scilab/modules/xcos/help/en_US/solvers/1CVode.xml b/scilab/modules/xcos/help/en_US/solvers/1CVode.xml
index f3d94ff..bf76d64 100644
 a/scilab/modules/xcos/help/en_US/solvers/1CVode.xml
+++ b/scilab/modules/xcos/help/en_US/solvers/1CVode.xml
@@ 262,7 +262,7 @@ Time for Adams / Functional :
RungeKutta 4(5)
 DormandPrice 4(5)
+ DormandPrince 4(5)
Implicit RungeKutta 4(5)
diff git a/scilab/modules/xcos/help/en_US/solvers/2RungeKutta.xml b/scilab/modules/xcos/help/en_US/solvers/2RungeKutta.xml
index 034fd7d..7ae6ba5 100644
 a/scilab/modules/xcos/help/en_US/solvers/2RungeKutta.xml
+++ b/scilab/modules/xcos/help/en_US/solvers/2RungeKutta.xml
@@ 225,7 +225,7 @@ Time for RungeKutta :
IDA
 DormandPrice 4(5)
+ DormandPrince 4(5)
Implicit RungeKutta 4(5)
diff git a/scilab/modules/xcos/help/en_US/solvers/3DormandPrice.xml b/scilab/modules/xcos/help/en_US/solvers/3DormandPrice.xml
deleted file mode 100644
index 51ed626..0000000
 a/scilab/modules/xcos/help/en_US/solvers/3DormandPrice.xml
+++ /dev/null
@@ 1,252 +0,0 @@




 DormandPrice 4(5)

 DormandPrice is a numerical solver providing an efficient explicit method to solve Ordinary Differential Equations (ODEs) Initial Value Problems.



 Description

 Called by xcos, DormandPrice is a numerical solver providing an efficient fixedsize step method to solve Initial Value Problems of the form :



 \begin{eqnarray}
 \dot{y} = f(t,y), \hspace{3 mm} y(t_0) = y_0, \hspace{3 mm} y \in R^N
 \end{eqnarray}



 CVode and IDA use variablesize steps for the integration.


 A drawback of that is the unpredictable computation time. With DormandPrice, we do not adapt to the complexity of the problem, but we guarantee a stable computation time.


 As of now, this method is explicit, so it is not concerned with Newton or Functional iterations, and not advised for stiff problems.


 It is an enhancement of the Euler method, which approximates

 yn+1

 by truncating the Taylor expansion.


 By convention, to use fixedsize steps, the program first computes a fitting h that approaches the simulation parameter max step size.


 An important difference of DormandPrice with the previous methods is that it computes up to the seventh derivative of y, while the others only use linear combinations of y and y'.


 Here, the next value is determined by the present value

 yn

 plus the weighted average of six increments, where each increment is the product of the size of the interval, h, and an estimated slope specified by the function f(t,y) :


 k1 is the increment based on the slope at the beginning of the interval, using

 yn

 (Euler's method),


 k2, k3, k4 and k5 are the increments based on the slope at respectively 0.2, 0.3, 0.8 and 0.9 of the interval, using combinations of each other,


 k6 is the increment based on the slope at the end, also using combinations of the other ki.




 We can see that with the ki, we progress in the derivatives of

 yn

 . In the computation of the ki, we deliberately use coefficients that yield an error in

 O(h5)

 at every step.


 So the total error is

 number of steps * O(h5)

 . And since number of steps = interval size / h by definition, the total error is in

 O(h4)

 .


 That error analysis baptized the method DormandPrice 4(5) :

 O(h5)

 per step,

 O(h4)

 in total.


 Althought the solver works fine for max step size up to

 103

 , rounding errors sometimes come into play as it approaches

 4*104

 . Indeed, the interval splitting cannot be done properly and we get capricious results.



 Examples











 The integral block returns its continuous state, we can evaluate it with DormandPrice by running the example :





 The Scilab console displays :



 Now, in the following script, we compare the time difference between DormandPrice and Sundials by running the example with the five solvers in turn :

 Open the script






 These results show that on a nonstiff problem, for relatively same precision required and forcing the same step size, DormandPrice's computational overhead (compared to RungeKutta) is significant and is close to Adams/Functional. Its error to the solution is althought much smaller than the regular RungeKutta 4(5), for a small overhead in time.


 Variablesize step ODE solvers are not appropriate for deterministic realtime applications because the computational overhead of taking a time step varies over the course of an application.



 See Also


 LSodar


 CVode


 IDA


 RungeKutta 4(5)


 Implicit RungeKutta 4(5)


 ode


 ode_discrete


 ode_root


 odedc


 impl




 Bibliography

 Journal of Computational and Applied Mathematics, Volume 15, Issue 2, 2 June 1986, Pages 203211 DormandPrice Method


 Sundials Documentation



 History


 5.4.1
 DormandPrice 4(5) solver added




diff git a/scilab/modules/xcos/help/en_US/solvers/3DormandPrince.xml b/scilab/modules/xcos/help/en_US/solvers/3DormandPrince.xml
new file mode 100644
index 0000000..8271753
 /dev/null
+++ b/scilab/modules/xcos/help/en_US/solvers/3DormandPrince.xml
@@ 0,0 +1,252 @@
+
+
+
+
+ DormandPrince 4(5)
+
+ DormandPrince is a numerical solver providing an efficient explicit method to solve Ordinary Differential Equations (ODEs) Initial Value Problems.
+
+
+
+ Description
+
+ Called by xcos, DormandPrince is a numerical solver providing an efficient fixedsize step method to solve Initial Value Problems of the form :
+
+
+
+ \begin{eqnarray}
+ \dot{y} = f(t,y), \hspace{3 mm} y(t_0) = y_0, \hspace{3 mm} y \in R^N
+ \end{eqnarray}
+
+
+
+ CVode and IDA use variablesize steps for the integration.
+
+
+ A drawback of that is the unpredictable computation time. With DormandPrince, we do not adapt to the complexity of the problem, but we guarantee a stable computation time.
+
+
+ As of now, this method is explicit, so it is not concerned with Newton or Functional iterations, and not advised for stiff problems.
+
+
+ It is an enhancement of the Euler method, which approximates
+
+ yn+1
+
+ by truncating the Taylor expansion.
+
+
+ By convention, to use fixedsize steps, the program first computes a fitting h that approaches the simulation parameter max step size.
+
+
+ An important difference of DormandPrince with the previous methods is that it computes up to the seventh derivative of y, while the others only use linear combinations of y and y'.
+
+
+ Here, the next value is determined by the present value
+
+ yn
+
+ plus the weighted average of six increments, where each increment is the product of the size of the interval, h, and an estimated slope specified by the function f(t,y) :
+
+
+ k1 is the increment based on the slope at the beginning of the interval, using
+
+ yn
+
+ (Euler's method),
+
+
+ k2, k3, k4 and k5 are the increments based on the slope at respectively 0.2, 0.3, 0.8 and 0.9 of the interval, using combinations of each other,
+
+
+ k6 is the increment based on the slope at the end, also using combinations of the other ki.
+
+
+
+
+ We can see that with the ki, we progress in the derivatives of
+
+ yn
+
+ . In the computation of the ki, we deliberately use coefficients that yield an error in
+
+ O(h5)
+
+ at every step.
+
+
+ So the total error is
+
+ number of steps * O(h5)
+
+ . And since number of steps = interval size / h by definition, the total error is in
+
+ O(h4)
+
+ .
+
+
+ That error analysis baptized the method DormandPrince 4(5) :
+
+ O(h5)
+
+ per step,
+
+ O(h4)
+
+ in total.
+
+
+ Althought the solver works fine for max step size up to
+
+ 103
+
+ , rounding errors sometimes come into play as it approaches
+
+ 4*104
+
+ . Indeed, the interval splitting cannot be done properly and we get capricious results.
+
+
+
+ Examples
+
+
+
+
+
+
+
+
+
+
+
+ The integral block returns its continuous state, we can evaluate it with DormandPrince by running the example :
+
+
+
+
+
+ The Scilab console displays :
+
+
+
+ Now, in the following script, we compare the time difference between DormandPrince and Sundials by running the example with the five solvers in turn :
+
+ Open the script
+
+
+
+
+
+
+ These results show that on a nonstiff problem, for relatively same precision required and forcing the same step size, DormandPrince's computational overhead (compared to RungeKutta) is significant and is close to Adams/Functional. Its error to the solution is althought much smaller than the regular RungeKutta 4(5), for a small overhead in time.
+
+
+ Variablesize step ODE solvers are not appropriate for deterministic realtime applications because the computational overhead of taking a time step varies over the course of an application.
+
+
+
+ See Also
+
+
+ LSodar
+
+
+ CVode
+
+
+ IDA
+
+
+ RungeKutta 4(5)
+
+
+ Implicit RungeKutta 4(5)
+
+
+ ode
+
+
+ ode_discrete
+
+
+ ode_root
+
+
+ odedc
+
+
+ impl
+
+
+
+
+ Bibliography
+
+ Journal of Computational and Applied Mathematics, Volume 15, Issue 2, 2 June 1986, Pages 203211 DormandPrince Method
+
+
+ Sundials Documentation
+
+
+
+ History
+
+
+ 5.4.1
+ DormandPrince 4(5) solver added
+
+
+
+
diff git a/scilab/modules/xcos/help/en_US/solvers/7IDA.xml b/scilab/modules/xcos/help/en_US/solvers/7IDA.xml
index 6a1da87..a86b194 100644
 a/scilab/modules/xcos/help/en_US/solvers/7IDA.xml
+++ b/scilab/modules/xcos/help/en_US/solvers/7IDA.xml
@@ 170,7 +170,7 @@ try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
RungeKutta 4(5)
 DormandPrice 4(5)
+ DormandPrince 4(5)
Implicit RungeKutta 4(5)

1.7.9.5