Provides functions for automation of simulation and linearization using the models of the upper layer package
This package contains functions that automate the simulation, plotting and linearization of the models under Example2.Analysis.PFVariants.
Extends from Modelica.Icons.FunctionsPackage (Icon for packages containing functions).
Name | Description |
---|---|
simulate_and_plot_ramping_pf | Simulates and plots the "Ramping_pf" model |
simulate_and_plot_inputs_pf | Simulates and plots the "RampingRandomLoadAndInput_pf" which includes random load and the designed input signal. |
linearize_KchangeLinRamping_pf | Function to linearize the model "KchangeLinRamping_pf" at any point in time. |
Simulates and plots the "Ramping_pf" model
Usage:
Sample Output:
Running the function will result in the following plot.
Extends from Modelica.Icons.Function (Icon for functions).
Simulates and plots the "RampingRandomLoadAndInput_pf" which includes random load and the designed input signal.
Usage:
Sample output:
Running the function will result in the following plot.
Note:
Please observe that running this function involves simulating the Example2.Analysis.PFVariants.RampingRandomLoadAndInput_pf model, which takes subtantially more time compared to example Example2.Analysis.PFVariants.Ramping_pf, the reason is that both random load and probing signals are added to the model which results in an additional computation burden.
This function calls the Example2.Utilities.SetupSolverSettings.On function that configures several flags to improve simulation speed, however, even by enabling these features, the simulation is time consuming.
For example, running the model using a computer with an 13th Gen Intel(R) Core(TM) i9-13900K, 3.00 GHz, processor and 128 GB DDR4 RAM, setup to use 12 cores, gave the following metrics:
Integration terminated successfully at T = 4050
CPU-time for integration : 1.17e+03 seconds
CPU-time for one grid interval : 234 milliseconds
CPU-time for initialization : 0.005 seconds
Number of result points : 959331
Number of grid points : 5001
Number of accepted steps : 9172936
Number of f-evaluations (dynamics) : 18295816
Number of crossing function evaluations : 9668298
Number of Jacobian-evaluations : 4006190
Number of model time events : 476996
Number of input time events : 0
Number of state events : 2744
Number of step events : 0
Minimum integration stepsize : 2.78e-10
Maximum integration stepsize : 0.00922
Maximum integration order : 5
Looking at the first two lines of the metrics shows that running the model for 67.5 min (4050 sec.) took 19.5 min (1.17e+03 sec.).
Naturally, using a computer with a weaker processor and lower memory will lead to longer run times.
If there is no interest to take into account the random load and probing signal, it is recommended that you run instead the function Example2.Analysis.PFVariants.AutomationFunctions.simulate_and_plot_ramping_pf, which takes substantially less time to execute.
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
corenum | Number of processor cores to use |
Function to linearize the model "KchangeLinRamping_pf" at any point in time.
Usage:
Sample Output:
Executing the function will produce the following output in the "Commands" window.
Example2.Analysis.PFVariants.AutomationFunctions.linearize_KchangeLinRamping_pf();
Setting up things...
DAE Mode is turned off.
Global optimization is disabled.
Sparse options disabled.
Number of cores reset to default:1
Starting simulation and linearization...
Declaring Modelica_LinearSystems2.StateSpace ss
System not printed since too large (only dimensions):
ss.A[52,52]
ss.B[52,2]
ss.C[1,52]
ss.D[1,2]
The linear model is in your working directory.
Open the dslin.mat file following the instructions in the documentation.
You can also analyze the linear model using Dymola, for example typing in the commands window
Modelica_LinearSystems2.StateSpace.Plot.polesAndZeros(ss, zeros=false, print=true);
will give you the polte plot shown in the Simulation tab and printed below.
Must translate function Modelica_LinearSystems2.Math.Matrices.LAPACK.dgeevx_eigenValues.
Compilation of function Modelica_LinearSystems2.Math.Matrices.LAPACK.dgeevx_eigenValues successful.
Finished
Eigenvalues
number |
eigenvalue |
time constant [s] |
freq. [Hz] |
damping |
1 |
-9.6242e+01 |
0.0104 |
--- |
--- |
2 |
-3.6655e+01 |
0.0273 |
--- |
--- |
3 |
-3.5047e+01 |
0.0285 |
--- |
--- |
4 |
-3.1561e+01 |
0.0317 |
--- |
--- |
5 |
-3.0650e+01 |
0.0326 |
--- |
--- |
6 |
-2.7641e+01 |
0.0362 |
--- |
--- |
7 |
-2.6939e+01 |
0.0371 |
--- |
--- |
8 |
-8.3670e+00 |
0.1195 |
--- |
--- |
9 |
-2.9564e+00 |
0.3383 |
--- |
--- |
10 |
-2.6309e+00 |
0.3801 |
--- |
--- |
11 |
-2.6309e+00 |
0.3801 |
--- |
--- |
12 |
-2.6309e+00 |
0.3801 |
--- |
--- |
13 |
-2.6309e+00 |
0.3801 |
--- |
--- |
14 |
-2.6253e-01 |
3.8090 |
--- |
--- |
15 |
-2.0230e-01 |
4.9432 |
--- |
--- |
16 |
-1.0029e-01 |
9.9714 |
--- |
--- |
17 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
18 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
19 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
20 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
21 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
22 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
23 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
24 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
25 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
26 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
27 |
-1.0000e-03 |
1000.0000 |
--- |
--- |
28 |
-2.0208e-11 |
49484936402.3992 |
--- |
--- |
29/30 |
-5.6534e-01 ± 6.0529e-01j |
--- |
0.1318 |
0.6826 |
31/32 |
-7.8941e-01 ± 6.8557e-01j |
--- |
0.1664 |
0.7550 |
33/34 |
-1.1437e+00 ± 8.2408e-01j |
--- |
0.2243 |
0.8113 |
35/36 |
-6.0262e+00 ± 8.5651e-01j |
--- |
0.9687 |
0.9900 |
37/38 |
-3.5830e+01 ± 1.5444e+00j |
--- |
5.7079 |
0.9991 |
39/40 |
-7.7495e+00 ± 2.2560e+00j |
--- |
1.2846 |
0.9601 |
41/42 |
-9.0151e-01 ± 2.2664e+00j |
--- |
0.3882 |
0.3696 |
43/44 |
-1.9111e+00 ± 3.2618e+00j |
--- |
0.6017 |
0.5055 |
45/46 |
-6.1276e-01 ± 4.2935e+00j |
--- |
0.6903 |
0.1413 |
47/48 |
-5.2430e-01 ± 7.7021e+00j |
--- |
1.2287 |
0.0679 |
49/50 |
-4.4286e-01 ± 1.2244e+01j |
--- |
1.9500 |
0.0361 |
51/52 |
-1.9317e+01 ± 1.5323e+01j |
--- |
3.9242 |
0.7834 |
The following pole plot is generated in the Simulation tab:
Post-processing in MATLAB:
The obtained linear model can be used in any other environment. The linear model is available in the file, dslin.mat, that will appear under your Dymola working directory. It can be loaded in MATLAB using the function:
[A,B,C,D,xName,uName,yName] = tloadlin('dslin.mat')
To use this function, add to the MATLAB workspace the directory and sub-directories under: C:\Program Files\Dymola 2024x\Mfiles
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
tlin | [s], time for linearization. |
pathToNonlinearPlantModel |