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_Platform_test.zcos"));
11 // Redefining messagebox() to avoid popup
14 function messagebox(msg, msg_title)
18 Info = scicos_simulate(scs_m, list(), 'nw');
19 --------------------------------------------\
20 Main Modelica : TMPDIR/DDaskr_Platform_test_im.mo
22 Flat Modelica : TMPDIR/DDaskr_Platform_test_imf.mo
23 Simulation C code :TMPDIR/DDaskr_Platform_test_im.c
25 !Modelica blocks are reduced to a block with: !
27 !Number of differential states: 4 !
29 !Number of algebraic states: 0 !
31 !Number of discrete time states : 2 !
33 !Number of zero-crossing surfaces: 1 !
35 !Number of modes : 0 !
37 !Number of inputs : 0 !
39 !Number of outputs: 3 !
41 !Input/output dependency:[T] !
43 !Analytical Jacobian: enabled (%Jacobian=%t) !
45 !Parameter embedding mode: enabled (%Modelica_ParEmb=%t) !
49 !Generated files path: TMPDIR/ !
52 Generate a loader file
54 ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
55 ilib_gen_Make: Copy DDaskr_Platform_test_im.c to TMPDIR
56 ilib_gen_Make: configure : Generate Makefile.
57 ilib_gen_Make: Modification of the Makefile in TMPDIR.
59 Generate a cleaner file
60 Shared archive loaded.
62 // looking for the CLOCK_f/EVTDLY_f to update period
63 for path_1=1:length(scs_m.objs)
64 if typeof(scs_m.objs(path_1))=="Block" & scs_m.objs(path_1).gui=="CLOCK_c" then
65 CLOCK_f_scs_m = scs_m.objs(path_1).model.rpar;
69 for path_2=1:length(CLOCK_f_scs_m)
70 if typeof(CLOCK_f_scs_m.objs(path_2))=="Block" & CLOCK_f_scs_m.objs(path_2).gui=="EVTDLY_c" then
71 EVTDLY_f_blk = CLOCK_f_scs_m.objs(path_2);
75 for i=1:3 // 'max step size' = 10^-i, precision
76 // Start by updating the clock block period (sampling)
77 scs_m.objs(path_1).model.rpar.objs(path_2).graphics.exprs = [string(5*(10^-i));"0"];
78 // Modify solver + run DDaskr + save results
79 scs_m.props.tol(6) = 101; // Solver
80 scicos_simulate(scs_m, Info, 'nw'); // DDaskr
81 ddaskrval = res.values; // Results
82 time = res.time; // Time
83 // Modify solver + run IDA + save results
84 scs_m.props.tol(6) = 100; // Solver
85 scicos_simulate(scs_m, Info, 'nw'); // IDA
86 idaval = res.values; // Results
88 compa = abs(ddaskrval-idaval);
89 // Extract mean, standard deviation, maximum
91 [maxi, indexMaxi] = max(compa);
92 stdeviation = st_deviation(compa);
93 // Verifying closeness of the results
94 assert_checktrue(maxi <= 5*10^-(i+3));
95 assert_checktrue(mea <= 5*10^-(i+3));
96 assert_checktrue(stdeviation <= 5*10^-(i+3));
98 Warning : redefining function: dst . Use funcprot(0) to avoid this message
100 Warning : redefining function: dst . Use funcprot(0) to avoid this message
102 Warning : redefining function: dst . Use funcprot(0) to avoid this message
104 Warning : redefining function: dst . Use funcprot(0) to avoid this message
106 Warning : redefining function: dst . Use funcprot(0) to avoid this message
108 Warning : redefining function: dst . Use funcprot(0) to avoid this message