20sim Notes
-
Upload
girish-badgi -
Category
Documents
-
view
216 -
download
0
Transcript of 20sim Notes
-
8/6/2019 20sim Notes
1/49
-
8/6/2019 20sim Notes
2/49
-
8/6/2019 20sim Notes
3/49
-
8/6/2019 20sim Notes
4/49
-
8/6/2019 20sim Notes
5/49
-
8/6/2019 20sim Notes
6/49
-
8/6/2019 20sim Notes
7/49
-
8/6/2019 20sim Notes
8/49
-
8/6/2019 20sim Notes
9/49
-
8/6/2019 20sim Notes
10/49
-
8/6/2019 20sim Notes
11/49
-
8/6/2019 20sim Notes
12/49
-
8/6/2019 20sim Notes
13/49
-
8/6/2019 20sim Notes
14/49
-
8/6/2019 20sim Notes
15/49
-
8/6/2019 20sim Notes
16/49
-
8/6/2019 20sim Notes
17/49
-
8/6/2019 20sim Notes
18/49
-
8/6/2019 20sim Notes
19/49
-
8/6/2019 20sim Notes
20/49
-
8/6/2019 20sim Notes
21/49
-
8/6/2019 20sim Notes
22/49
-
8/6/2019 20sim Notes
23/49
-
8/6/2019 20sim Notes
24/49
-
8/6/2019 20sim Notes
25/49
-
8/6/2019 20sim Notes
26/49
-
8/6/2019 20sim Notes
27/49
-
8/6/2019 20sim Notes
28/49
-
8/6/2019 20sim Notes
29/49
-
8/6/2019 20sim Notes
30/49
-
8/6/2019 20sim Notes
31/49
-
8/6/2019 20sim Notes
32/49
-
8/6/2019 20sim Notes
33/49
-
8/6/2019 20sim Notes
34/49
-
8/6/2019 20sim Notes
35/49
-
8/6/2019 20sim Notes
36/49
-
8/6/2019 20sim Notes
37/49
-
8/6/2019 20sim Notes
38/49
-
8/6/2019 20sim Notes
39/49
-
8/6/2019 20sim Notes
40/49
-
8/6/2019 20sim Notes
41/49
-
8/6/2019 20sim Notes
42/49
-
8/6/2019 20sim Notes
43/49
-
8/6/2019 20sim Notes
44/49
-
8/6/2019 20sim Notes
45/49
-
8/6/2019 20sim Notes
46/49
-
8/6/2019 20sim Notes
47/49
-
8/6/2019 20sim Notes
48/49
will be applied to solve the differential directly. For example an equation like:output = ddt(sin(a*time))will be replaced by the following equation (applying the chain rule and using the known derivative forthe sine function):output = a*cos(a*time)Sometimes a differential cannot be solved directly. Then only the Backward-Differentiation Methodscan be used for simulation.Simulation CodeAfter compilation simulation code is generated. The equation in integral form:output = int( input - K*output )will be written as:independent state = outputindependent rate = input - K*outputand can be handled by all integration methods. The equation in differential form:ddt(output) = input - K*outputwill be written as:dependent rate = input - K*outputdependent state = outputand can only be handled by the Backward-Differentiation Methods.Order of Execution
Equations within 20-sim may be entered in random form. During compilation, 20-sim willautomatically try to rewrite equations into a correct order of execution. I.e. a form where all outputvariables are written as function of input variables and output variables of previous lines. Considerfor example the following equations:variablesreal u,z;equations
z = sin(u);u = cos(time);Here the (input) variable z is given as a function of u . Consequently u should be calculated first. Thisis exactly what 20-sim will try to do while compiling the model into simulation code. I.e. theequations will be executed as:u = cos(time);
z = sin(u);Code BlocksEquations in a code block are not reordered. A code block is a set of equations inside a statement.Suppose we have the following equations:if condition thencode block 1......elsecode block 2...
-
8/6/2019 20sim Notes
49/49
...end;To prevent incorrect executions of the if-statement, the equations of the code blocks will not beseparated. Inside a code-block, equations can are not rewritten into an new order of execution. E.g.the following equations:if time > 10 then
z = sin(u);a = z^2;u = cos(time);end;Will be not be reordered and therefore not correctly executed! To get correct code, enter codeblocks in a correct order, e.g.:if time > 10 thenu = cos(time);
z = sin(u);a = z^2;end;Prevent Order ChangesTo make all equations a code block you can use the code section . E.g.
parameters
real y = 8;variablesreal x1, x2, x3;code
x1 = time; x2 = sin(time); x3 = y*x1;Integration StepsSome integration algorithms do more calculations before generating the next output value. Thesecalculations are called minor steps, the output generation is called a major step. During a minor step,all model equations are executed. In most cases you will not notice this because only the results of the major step are shown in the simulator. There are however, exceptions. The next topic will discussthis in more detail.Show EquationsDuring processing a complete set of equations is generated of each model. To inspect theseequations or copy them for use in other programs, you have to:1. If the model was not checked before, from the Model menu select the Check CompleteModel command.2. From the Model menu select the Show Equations command. Now a window is popped upshowing all the model equations.The model equations after compiling.3. You can copy the equations by selecting select all and copy from the right mouse menu.