9261d19a227500ee767aa1a6da56e4715d5b0389
[scilab.git] / scilab / modules / scicos / tests / unit_tests / DDaskrN_Bouncing.dia.ref
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 // <-- ENGLISH IMPOSED -->
8 // <-- XCOS TEST -->
9 // Import diagram
10 assert_checktrue(importXcosDiagram("SCI/modules/xcos/tests/unit_tests/DDaskr_Bouncing_test.zcos"));
11 // Redefining messagebox() to avoid popup
12 prot = funcprot();
13 funcprot(0);
14 function messagebox(msg, msg_title)
15  disp(msg);
16 endfunction
17 funcprot(prot);
18 // looking for the CLOCK_f/EVTDLY_f to update period
19 for path_1=1:length(scs_m.objs)
20     if typeof(scs_m.objs(path_1))=="Block" & scs_m.objs(path_1).gui=="CLOCK_f" then
21         CLOCK_f_scs_m = scs_m.objs(path_1).model.rpar;
22         break;
23     end
24 end
25 for path_2=1:length(CLOCK_f_scs_m)
26     if typeof(CLOCK_f_scs_m.objs(path_2))=="Block" & CLOCK_f_scs_m.objs(path_2).gui=="EVTDLY_f" then
27         EVTDLY_f_blk = CLOCK_f_scs_m.objs(path_2);
28         break;
29     end
30 end
31 // Start by updating the clock block period (sampling)
32 scs_m.objs(path_1).model.rpar.objs(path_2).graphics.exprs = [string(5*(10^-3));"0"];
33 // Modify solver + run DDaskr + save results
34 scs_m.props.tol(6) = 101;      // Solver
35 //scs_m.props.tol(1) = 1.0e-10; // abstol
36 //scs_m.props.tol(2) = 1.0e-10; // reltol
37 scicos_simulate(scs_m, 'nw');  // DDaskr
38  
39  CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp 
40       ected, getting 50 50 50 50                                        
41 --------------------------------------------\
42  Main Modelica : TMPDIR/DDaskr_test2_im.mo
43
44  Flat Modelica : TMPDIR/DDaskr_test2_imf.mo
45  Simulation C code :TMPDIR/DDaskr_test2_im.c
46  
47 !Modelica blocks are reduced to a block with:             !
48 !                                                         !
49 !Number of differential states: 2                         !
50 !                                                         !
51 !Number of algebraic states: 0                            !
52 !                                                         !
53 !Number of discrete time states  : 0                      !
54 !                                                         !
55 !Number of zero-crossing surfaces: 1                      !
56 !                                                         !
57 !Number of modes  : 0                                     !
58 !                                                         !
59 !Number of inputs : 0                                     !
60 !                                                         !
61 !Number of outputs: 3                                     !
62 !                                                         !
63 !Input/output dependency:[T]                              !
64 !                                                         !
65 !Analytical Jacobian: enabled  (%Jacobian=%t)             !
66 !                                                         !
67 !Parameter embedding mode: enabled (%Modelica_ParEmb=%t)  !
68 !                                                         !
69 !                                                         !
70 !                                                         !
71 !Generated files path: TMPDIR/          !
72 !                                                         !
73 !                                                         !
74    Generate a loader file
75    Generate a Makefile
76    ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
77    ilib_gen_Make: Copy DDaskr_test2_im.c to TMPDIR
78    ilib_gen_Make: configure : Generate Makefile.
79    ilib_gen_Make: Modification of the Makefile in TMPDIR.
80    Running the Makefile
81    Generate a cleaner file
82 Shared archive loaded.
83 Link done.
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, 'nw'); // IDA
89  
90  CMSCOPE('set'): Wrong size for block parameter 'Refresh period': 2 exp 
91       ected, getting 50 50 50 50                                        
92 --------------------------------------------\
93  Main Modelica : TMPDIR/DDaskr_test2_im.mo
94
95  Flat Modelica : TMPDIR/DDaskr_test2_imf.mo
96  Simulation C code :TMPDIR/DDaskr_test2_im.c
97  
98 !Modelica blocks are reduced to a block with:             !
99 !                                                         !
100 !Number of differential states: 2                         !
101 !                                                         !
102 !Number of algebraic states: 0                            !
103 !                                                         !
104 !Number of discrete time states  : 0                      !
105 !                                                         !
106 !Number of zero-crossing surfaces: 1                      !
107 !                                                         !
108 !Number of modes  : 0                                     !
109 !                                                         !
110 !Number of inputs : 0                                     !
111 !                                                         !
112 !Number of outputs: 3                                     !
113 !                                                         !
114 !Input/output dependency:[T]                              !
115 !                                                         !
116 !Analytical Jacobian: enabled  (%Jacobian=%t)             !
117 !                                                         !
118 !Parameter embedding mode: enabled (%Modelica_ParEmb=%t)  !
119 !                                                         !
120 !                                                         !
121 !                                                         !
122 !Generated files path: TMPDIR/          !
123 !                                                         !
124 !                                                         !
125    Generate a loader file
126    Generate a Makefile
127    ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
128    ilib_gen_Make: Copy DDaskr_test2_im.c to TMPDIR
129    ilib_gen_Make: configure : Generate Makefile.
130    ilib_gen_Make: Modification of the Makefile in TMPDIR.
131    Running the Makefile
132    Generate a cleaner file
133 Shared archive loaded.
134 Link done.
135 idaval = res.values;          // Results
136 // Compare results
137 compa = abs(ddaskrval-idaval);
138 // Extract mean, standard deviation, maximum
139 mea = mean(compa);
140 [maxi, indexMaxi] = max(compa);
141 stdeviation = st_deviation(compa);
142 // Verifying closeness of the results
143 assert_checktrue(maxi <= 10^-(12));
144 assert_checktrue(mea <= 10^-(12));
145 assert_checktrue(stdeviation <= 10^-(12));