1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 // <-- ENGLISH IMPOSED -->
10 assert_checktrue(importXcosDiagram("SCI/modules/xcos/tests/unit_tests/DDaskr_Bouncing_test.zcos"));
11 // Redefining messagebox() to avoid popup
14 function messagebox(msg, msg_title)
18 Info = scicos_simulate(scs_m, list(), 'nw');
20 CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp
21 ected, getting 50 50 50 50
22 --------------------------------------------\
23 Main Modelica : TMPDIR/DDaskr_test2_im.mo
25 Flat Modelica : TMPDIR/DDaskr_test2_imf.mo
26 Simulation C code :TMPDIR/DDaskr_test2_im.c
28 !Modelica blocks are reduced to a block with: !
30 !Number of differential states: 2 !
32 !Number of algebraic states: 0 !
34 !Number of discrete time states : 0 !
36 !Number of zero-crossing surfaces: 1 !
38 !Number of modes : 0 !
40 !Number of inputs : 0 !
42 !Number of outputs: 3 !
44 !Input/output dependency:[T] !
46 !Analytical Jacobian: enabled (%Jacobian=%t) !
48 !Parameter embedding mode: enabled (%Modelica_ParEmb=%t) !
52 !Generated files path: TMPDIR/ !
55 Generate a loader file
57 ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
58 ilib_gen_Make: Copy DDaskr_test2_im.c to TMPDIR
59 ilib_gen_Make: configure : Generate Makefile.
60 ilib_gen_Make: Modification of the Makefile in TMPDIR.
62 Generate a cleaner file
63 Shared archive loaded.
65 // looking for the CLOCK_f/EVTDLY_f to update period
66 for path_1=1:length(scs_m.objs)
67 if typeof(scs_m.objs(path_1))=="Block" & scs_m.objs(path_1).gui=="CLOCK_f" then
68 CLOCK_f_scs_m = scs_m.objs(path_1).model.rpar;
72 for path_2=1:length(CLOCK_f_scs_m)
73 if typeof(CLOCK_f_scs_m.objs(path_2))=="Block" & CLOCK_f_scs_m.objs(path_2).gui=="EVTDLY_f" then
74 EVTDLY_f_blk = CLOCK_f_scs_m.objs(path_2);
78 // Start by updating the clock block period (sampling)
79 scs_m.objs(path_1).model.rpar.objs(path_2).graphics.exprs = [string(5*(10^-3));"0"];
80 // Modify solver + run DDaskr + save results
81 scs_m.props.tol(6) = 102; // Solver
82 //scs_m.props.tol(1) = 1.0e-10; // abstol
83 //scs_m.props.tol(2) = 1.0e-10; // reltol
84 scicos_simulate(scs_m, Info, 'nw'); // DDaskr
86 CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp
87 ected, getting 50 50 50 50
88 Warning : redefining function: dst . Use funcprot(0) to avoid this message
90 ddaskrval = res.values; // Results
91 time = res.time; // Time
92 // Modify solver + run IDA + save results
93 scs_m.props.tol(6) = 100; // Solver
94 scicos_simulate(scs_m, Info, 'nw'); // IDA
96 CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp
97 ected, getting 50 50 50 50
98 Warning : redefining function: dst . Use funcprot(0) to avoid this message
100 idaval = res.values; // Results
102 compa = abs(ddaskrval-idaval);
103 // Extract mean, standard deviation, maximum
105 [maxi, indexMaxi] = max(compa);
106 stdeviation = st_deviation(compa);
107 // Verifying closeness of the results
108 assert_checktrue(maxi <= 10^-(4));
109 assert_checktrue(mea <= 10^-(4));
110 assert_checktrue(stdeviation <= 10^-(4));