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_RLC_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 2 2 2 2
22 --------------------------------------------\
23 Main Modelica : TMPDIR/DDaskr_RLC_test_im.mo
25 Flat Modelica : TMPDIR/DDaskr_RLC_test_imf.mo
26 Simulation C code :TMPDIR/DDaskr_RLC_test_im.c
28 !Modelica blocks are reduced to a block with: !
30 !Number of differential states: 2 !
32 !Number of algebraic states: 1 !
34 !Number of discrete time states : 0 !
36 !Number of zero-crossing surfaces: 0 !
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_RLC_test_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);
79 // Start by updating the clock block period (sampling)
80 scs_m.objs(path_1).model.rpar.objs(path_2).graphics.exprs = [string(5*(10^-i));"0"];
81 // Modify solver + run DDaskr + save results
82 scs_m.props.tol(6) = 101; // Solver
83 scicos_simulate(scs_m, Info, 'nw'); // DDaskr
84 ddaskrval = res.values; // Results
85 time = res.time; // Time
86 // Modify solver + run IDA + save results
87 scs_m.props.tol(6) = 100; // Solver
88 scicos_simulate(scs_m, Info, 'nw'); // IDA
89 idaval = res.values; // Results
91 compa = abs(ddaskrval-idaval);
92 // Extract mean, standard deviation, maximum
94 [maxi, indexMaxi] = max(compa);
95 stdeviation = st_deviation(compa);
96 // Verifying closeness of the results
97 assert_checktrue(maxi <= 10^-(i+4));
98 assert_checktrue(mea <= 10^-(i+4));
99 assert_checktrue(stdeviation <= 10^-(i+4));
102 CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp
103 ected, getting 2 2 2 2
104 Warning : redefining function: dst . Use funcprot(0) to avoid this message
107 CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp
108 ected, getting 2 2 2 2
109 Warning : redefining function: dst . Use funcprot(0) to avoid this message
112 CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp
113 ected, getting 2 2 2 2
114 Warning : redefining function: dst . Use funcprot(0) to avoid this message
117 CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp
118 ected, getting 2 2 2 2
119 Warning : redefining function: dst . Use funcprot(0) to avoid this message