1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2012 - Scilab Enterprises - Paul Bignier
//
// This file is released under the 3-clause BSD license. See COPYING-BSD.
// Import the diagram, augment the ending time and store its compilation in Info()
loadScicos();
loadXcosLibs();
importXcosDiagram("SCI/modules/xcos/examples/solvers/ODE_Example.zcos");
Info = scicos_simulate(scs_m, "nw");
tf = 50000;
tolerances = scs_m.props.tol;
[%tcur, %cpr, alreadyran, needstart, needcompile, %state0] = Info(:);
solverName = ["LSodar", "CVode BDF/Newton", "CVode BDF/Functional", "CVode Adams/Newton", "CVode Adams/Functional", "Dormand-Prince", "Runge-Kutta", "implicit Runge-Kutta"];
disp("--------------------------------");
for solver = 0:7
disp("Time for " + solverName(solver + 1) + ":");
tolerances(6) = solver;
// Modify 'Max step size' if RK-based solver
if (solver >= 5) then tolerances(7) = 0.01; end
// Start the solver
[state, t] = scicosim(%state0, 0.0, tf, %cpr.sim, "start", tolerances);
// Run until the end
tic();
[state, t] = scicosim(state, 0.0, tf, %cpr.sim, "run", tolerances);
t = toc();
disp(t);
// End the solver
[state, t] = scicosim(state, tf, tf, %cpr.sim, "finish", tolerances);
end
disp("--------------------------------");
|