filePath = Modelica_LinearSystems2.StateSpace.Analysis.analysis(ss); or filePath = Modelica_LinearSystems2.StateSpace.Analysis.analysis( ss, analyseOptions=analyseOptions, fileName, systemName, description);
This function analyzes a state space system
der(x) = A * x + B * u y = C * x + D * u x(t=0) = x0
based on its poles, i.e. the eigenvalues, and the zeros of the system. The system will be checked for stability, controllability and observability. In the case that the system is not stable stabilizability and detectability are examined. Furthermore, stability, controllability, observability, stabilizability, and detectability are indicated for each eigenvalue.
System (1) is stable if and only if all eigenvalues of the matrix A have negative real parts. The calculation of the eigenvalues is based on the LAPACK routine dgeev.
System (1) is said to be controllable if, starting from any initial state x0, the system can be driven by appropriate inputs to any final state x1 within some finite time window. Equivalent is that the eigenvalues of A-BK can arbitrarily be assigned by an appropriate choice of the matrix K.
System (1) is said to be stabilizable if all the unstable eigenvalues, i.e. all s with Re(s)>=0, of A are controllable. Therefore, a controllable system is always stabilizable. An equivalent definition of stabilizability is, that a system is said to be stabilizable if there exist a matrix K such that A-BK is stable.
System (1) is said to be observable if the (arbitrary) initial state x0 can be uniquely determined from any state x(t1), t1>0, from the knowledge of the input u(t) and output y(t). With other words, from the system's outputs it is possible to determine the behavior of the entire system. Equivalent is, that the eigenvalues of A-LC can be arbitrarily be assigned by an appropriate choice of matrix L. Observability is called the dual concept of controllability, since a system (A,B,C,D) is observable if the system (AT, CT, BT, DT) is controllable.
System (1) is said to be detectable if all the unstable eigenvalues, i.e. all s with Re(s)>=0, of A are observable. Therefore, a observable system is always detectable. An equivalent definition of detectability is, that a system is said to be detectable if there exist a matrix L such that A-LC is stable. Detectability is called the dual concept of stabilizability, since a system (A,B,C,D) is detectable if the system (AT, CT, BT, DT) is stabilizable.
The test of controllability and stabilizability is performed with the staircase algorithm which transforms the system (A,B,C,D) into the controller-Hessenberg form (AH, BH, CH, D) with AH is a block upper Hessenberg matrix and BH=[B1; 0] with triangular matrix B1 with rank(B1) = rank(B). In AH=[Ac, *,0, Anc) the eigenvalues of the matrices Ac and Anc are the controllable eigenvalues and uncontrollable eigenvalues of A respectively. The test of observability and detectability is performed by testing the system (AT, CT, BT, DT) with respect to controllability and stabilizability.
The solution x(t) of the initial value problem (1) consists of the homogeneous part (zero input response) xh(t) and the inhomogeneous part xi(t). The zero input solution is given by
xh(t) = exp(A*(t-t0))x0.
The system can also be represented as a linear combination of the modal states z,
x = Vz
i.e. the states of a similar system, with
der(z) = V-1AVz + V-1Bu
where the system matrix V-1AV is the real Jordan form. For single real eigenvectors the system is decoupled, i.e. the solution of the modal states are denoted by
zi = exp(si t)*z0i
The behavior of the modal states is determined as the solution of a linear first order differential equation for real eigenvalues. Since this behavior is well known, the behavior of the xi can at least roughly be estimated by means of the behavior of the most relevant modal states. Therefore, the contribution of the modal states to the states is computed as an indication of the original system behavior.
Generally, as described above, the states of the system can be described as linear combination of modal states and, therefore, the states can be characterized to a certain extend by the modal states if the proportions of the combination are known. Hence, for each modal state zi of the vector z the elements |vi,j|/|vi| of the corresponding right eigenvector vi indicate the proportion of zi that is contributed to the state xj. On the other hand, the composition of xi is indicated by the elements |vi,j|/|viT|, i.e. the elements |vi,j|/|viT| of the corresponding row viT of the eigenvector matrix V indicate the proportion of the state xi that is contributed by the modal state zj.
ss=StateSpace( A=[-3,2,-3,4,5,6; 0,6,7,8,9,4; 0,2,3,0,78,6; 0,1,2,2,3,3; 0,13,34,0,0,1; 0, 0,0,-17,0,0], B=[1,0; 0,1; 1,0; 0,1; 1,0; 0,1], C=[0,0,1,0,1,0; 0,1,0,0,1,1], D=[0,0; 0,0], xNames={"x1","x2","x3","x4","x5","x6"}, uNames={"u1","u2"}, yNames={"y1","y2"}); String fileName="analysis.html"; String systemName="Demonstration System"; String description="System to demonstrate the usage of Modelica_LinearSystems2.StateSpace.Analysis.analysis()" algorithm Modelica_LinearSystems2.StateSpace.Analysis.analysis( ss, fileName=fileName, systemName=systemName, description=description) // = "C:/working/directory/path/analysis.html"
The resulting report file analysis.html
summarizes the following system information.
The system Demonstration System
der(x) = A * x + B * u y = C * x + D * u
is defined by
x1 x2 x3 x4 x5 x6 u1 u2 x1 -3 2 -3 4 5 6 x1 1 0 x2 0 6 7 8 9 4 x2 0 1 A = x3 0 2 3 0 78 6 B = x3 1 0 x4 0 1 2 2 3 3 x4 0 1 x5 0 13 34 0 0 1 x5 1 0 x6 0 0 0 -17 0 0 x6 0 1 x1 x2 x3 x4 x5 x6 u1 u2 C = y1 0 0 1 0 1 0 D = y1 0 0 y2 0 1 0 0 1 1 y2 0 0
System to demonstrate the usage of Modelica_LinearSystems2.StateSpace.Analysis.analysis()
The system
is
not stable
but it is controllable
and therefore it is stabilizable.
The system is observable
and therefore it is detectable.
Eigenvalues analysis
Real eigenvalues
number | eigenvalue | T [s] | characteristics | contribution to states |
---|---|---|---|---|
1 | -4.9874e+01 | 0.0201 | stable, controllable, observable | z[1] contributes to x3 with 54.6 % z[1] contributes to x5 with 37 % |
2 | -3.0000e+00 | 0.3333 | stable, controllable, not observable | z[2] contributes to x1 with 100 % |
3 | 2.9891e+00 | 0.3346 | not stable, stabilizable, detectable | z[3] contributes to x2 with 51.9 % z[3] contributes to x1 with 23.9 % |
4 | 5.5825e+01 | 0.0179 | not stable, stabilizable, detectable | z[4] contributes to x3 with 48.4 % z[4] contributes to x5 with 32.5 % |
Conjugated complex pairs of eigenvalues
number | eigenvalue | freq. [Hz] | damping | characteristics | contribution to states |
---|---|---|---|---|---|
5/6 | 1.0299e+00 ± 6.5528e+00j | 1.0557 | -0.1553 | not stable, stabilizable, detectable | z[5/6] contribute to x6 with 35.9 % z[5/6] contribute to x2 with 20.6 % |
In the tables above, the column contribution to states lists for each eigenvalue the states to which the corresponding modal state z[i] contributes most. This information is based on the two largest absolute values of the corresponding right eigenvector (if the second large value is less than 5 % of the largest contribution, it is not shown). Note the right eigenvector vj and the left eigenvector uj of A satisfy the following relationships with regards to eigenvalue λj, state vector x and modal state vector z (ujH denotes the conjugate transpose of uj):
A * vj = λj * vj; ujH * A = λj * ujH; x = V * z; V = [v1, v2, ...] |
In the next table, for each state in the column correlation to modal states, the modal states which contribute most to the corresponding state are summarized, i.e. the state is mostly composed of these modal states This information is based on the two largest absolute values of row i of the eigenvector matrix that is associated with eigenvalue i (if the second large value is less than 5 % of the largest contribution, it is not shown). This only holds if the modal states z[i] are in the same order of magnitude. Otherwise, the listed modal states might be not the most relevant ones.
state | correlation to modal states | eigenvalue # | freq. [Hz] | damping | T [s] |
---|---|---|---|---|---|
x1 | is composed of 42.5% by z[2] | 2 | --- | --- | 0.0201 |
is composed of 35.4% by z[5/6] | 5/6 | 1.0557 | -0.1553 | --- | |
x2 | is composed of 44.2% by z[3] | 3 | --- | --- | 0.3333 |
is composed of 43.7% by z[5/6] | 5/6 | 1.0557 | -0.1553 | --- | |
x3 | is composed of 36.9% by z[1] | 1 | --- | --- | 0.3346 |
is composed of 36.3% by z[4] | 4 | --- | --- | 0.0179 | |
x4 | is composed of 88.9% by z[5/6] | 5/6 | 1.0557 | -0.1553 | --- |
is composed of 9.8% by z[4] | 4 | --- | --- | 0.0179 | |
x5 | is composed of 45.3% by z[1] | 1 | --- | --- | 0.0000 |
is composed of 44.1% by z[4] | 4 | --- | --- | 0.0179 | |
x6 | is composed of 95.7% by z[5/6] | 5/6 | 1.0557 | -0.1553 | --- |
Invariant zeros
number | invariant zero | Time constant [s] | freq. [Hz] | damping |
---|---|---|---|---|
1 | -5.4983e+01 | 0.0182 | --- | --- |
2 | -3.0000e+00 | 0.3333 | --- | --- |
3/4 | 3.2417e+00 ± 5.6548e+00j | --- | 1.0374 | -0.4973 |
function analysis import Modelica; import Modelica.Utilities.Strings; import Modelica.ComplexMath.j; import Complex; import Modelica_LinearSystems2; import Modelica_LinearSystems2.StateSpace; import Modelica_LinearSystems2.Internal.Eigenvalue; import Modelica_LinearSystems2.Internal; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.Utilities.Plot; import DymolaCommands; input StateSpace ss "State space system"; input Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printSystem = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response", dB_w = false); input String fileName = "systemReport.html" "Name of html-file that contains eigenvalue table"; input String systemName = "" "Name of system (used as heading in html file)"; input String description = "" "Description of system (used in html file)"; extends Modelica_LinearSystems2.Internal.PartialPlotFunction(defaultDiagram = Modelica_LinearSystems2.Internal.DefaultDiagramPolesAndZeros()); output String filePath "Full path name of report file"; encapsulated function printSystem "Print the state space system in html format on file" import Modelica; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.StateSpace; import Modelica_LinearSystems2; input StateSpace ss "State space system to analyze"; input String fileName = "systemAnalysis.html" "File on which the state space system is written in html format"; input String systemName = "State Space System" "Name of the state space system"; input String description = "" "Description of system (used in html file)"; input String format = ".6g" "Format of numbers (e.g. \"20.8e\")"; input Boolean htmlBasics = false "True, if text should be printed within 'html' and 'body' environment, otherwise text printed into existing file fileName" annotation( Dialog(group = "HTML format")); input Integer hSize(min = 1, max = 5) = 1 "Size of heading of printed document (=1: Title, =2: Chapter, etc.)" annotation( Dialog(group = "HTML format")); protected Integer nx = size(ss.A, 1); Integer nu = size(ss.B, 2); Integer ny = size(ss.C, 1); Integer c1 = integer(ceil(nx/2) - 1); Integer c2 = integer(ceil(ny/2) - 1); Integer dist = 2; Boolean centered = true "True, if matrices columns should be centered, otherwise right aligned"; String td_align = if centered then " <td style=\"text-align:center\">" else " <td style=\"text-align:right\">"; protected Integer hSizeOK = if hSize < 1 then 1 else if hSize > 4 then 4 else hSize; String heading = "h" + String(hSizeOK); String heading2 = "h" + String(hSizeOK + 1); String heading3 = "h" + String(hSizeOK + 2); Boolean printIndices; algorithm // --------------------------------------------------------------------------------------------------- // The correct HTML format generated with this function can be checked with following commands: // Modelica_LinearSystems2.StateSpace.Analysis.analysis.printSystem(Modelica_LinearSystems2.StateSpace(A=[2,1,1;1,1,1;1,2,2], B=[1;2.2;3], C=[2,4,6;3,8,5], D=[6;4], yNames={"y1_test","y2_test"}, xNames={"xx1","xx2","xx3"}, uNames={"u1_test"})); // Modelica_LinearSystems2.StateSpace.Analysis.analysis.printSystem(Modelica_LinearSystems2.StateSpace(A=[2, 1.43, 12, 3; 1, 1, 1, 43; 1, 3, 2, 2; 1, 1, 4.2, 1.2], B=[1, 2; 2.2, 3; 3, 1; 4, 0], C=[25, 1.4, 6.3, 1; 0.3, 8, 5, 1; 1, 3, 2, 2], D=[6, 4; 4, 2; 6, 5], yNames={"y1_test","y2_te","y3_"}, xNames={"xx1","x2","xxx3","xx4"}, uNames={"u1_test","u2_test"})); // Modelica_LinearSystems2.StateSpace.Analysis.analysis.printSystem(ss=Modelica_LinearSystems2.StateSpace.Import.fromModel("Modelica.Mechanics.Rotational.Examples.First"), description="Test file in HTML format from function printSystem."); // --------------------------------------------------------------------------------------------------- if htmlBasics then // Text should be printed into new file in HTML environment // -------------------------------------------------------- StateSpace.Analysis.analysis.printHTMLbasics(fileName, true); end if; print("<" + heading + ">System report</" + heading + ">", fileName); print("\n<" + heading2 + ">General information</" + heading2 + ">", fileName); //print("<h1>System report</h1>", fileName); //print("\n<h2>General information</h2>", fileName); if systemName == "" then else print("\n<" + heading3 + ">System name</" + heading3 + ">", fileName); //print("\n<h3>System name</h3>", fileName); print("<p>\n" + systemName + "\n</p>", fileName); end if; if description == "" then else print("\n<" + heading3 + ">Description</" + heading3 + ">", fileName); //print("\n<h3>Description</h3>", fileName); print("<p>\n" + description + "\n</p>", fileName); end if; print("\n<" + heading3 + ">Matrices</" + heading3 + ">", fileName); //print("\n<h3>Matrices</h3>", fileName); print("<p>\nThe system described in the state space representation\n</p>", fileName); print("<table style=\"font-size:10pt; font-family:Arial; border-collapse:collapse; margin: 20px 0 20px 20px\" " + "cellpadding=\"3\" border=\"0\"> ", fileName); print("<tr><td>der(x) </td> <td>=</td> <td> Ax</td> <td> +</td><td> Bu</td></tr> <tr><td> y </td> <td>=</td> <td> Cx</td> <td> + </td><td>Du</td></tr>", fileName); print("</table>\n<p>\nis defined by\n</p>", fileName); // =============================== // Print signal names and matrices (print row and column indices if at least one matrix has more as 5 elements) // =============================== printIndices := size(ss.A, 1) > 5 or size(ss.B, 2) > 5 or size(ss.C, 1) > 5; Modelica_LinearSystems2.Math.Vectors.printStringVectorInHtml(ss.uNames, "uNames", fileName = fileName, printIndices = printIndices); Modelica_LinearSystems2.Math.Vectors.printStringVectorInHtml(ss.yNames, "yNames", fileName = fileName, printIndices = printIndices); Modelica_LinearSystems2.Math.Vectors.printStringVectorInHtml(ss.xNames, "xNames", fileName = fileName, printIndices = printIndices); Modelica_LinearSystems2.Math.Matrices.printMatrixInHtml(ss.A, "A", format = format, fileName = fileName, printIndices = printIndices); Modelica_LinearSystems2.Math.Matrices.printMatrixInHtml(ss.B, "B", format = format, fileName = fileName, printIndices = printIndices); Modelica_LinearSystems2.Math.Matrices.printMatrixInHtml(ss.C, "C", format = format, fileName = fileName, printIndices = printIndices); Modelica_LinearSystems2.Math.Matrices.printMatrixInHtml(ss.D, "D", format = format, fileName = fileName, printIndices = printIndices); if ny == 0 and nu == 0 then print("<p>\n<strong>Note</strong>, that the system has neither inputs nor outputs (and therefore matrices B, C, and D are empty matrices)!\n</p>", fileName); elseif ny == 0 then print("<p>\n<strong>Note</strong>, that the system has no outputs (and therefore matrices C and D are empty matrices)!\n</p>", fileName); elseif nu == 0 then print("<p>\n<strong>Note</strong>, that the system has no inputs (and therefore matrices B and D are empty matrices)!\n</p>", fileName); end if; if htmlBasics then // Last print of HTML environment // -------------------------------------------------------- StateSpace.Analysis.analysis.printHTMLbasics(fileName, false); end if; end printSystem; encapsulated function printHead1 "Print the heading of document for characteristics in html format on file" import Modelica; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.StateSpace; input StateSpace ss; // This could be deleted sinc not used. But for reasons of beackward compatibility it is still here. input Boolean isStable; input Boolean isControllable; input Boolean isStabilizable; input Boolean isObservable; input Boolean isDetectable; input String fileName = "systemHead1.html" "File on which the information is written in html format"; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); input Boolean htmlBasics = false "True, if text should be printed within 'html' and 'body' environment, otherwise text printed into existing file fileName" annotation( Dialog(group = "HTML format")); input Integer hSize(min = 1, max = 5) = 2 "Size of heading of printed document (=1: Title, =2: Chapter, etc.)" annotation( Dialog(group = "HTML format")); protected Integer hSizeOK = if hSize < 1 then 1 else if hSize > 5 then 5 else hSize; String heading = "h" + String(hSizeOK); algorithm // --------------------------------------------------------------------------------------------------- // The correct HTML format generated with this function can be checked with following commands: // Modelica_LinearSystems2.StateSpace.Analysis.analysis.printHead1(Modelica_LinearSystems2.StateSpace(A=[2], B=[1], C=[1], D=[1]), false, false, false, true, false, htmlBasics=true, hSize=3); // --------------------------------------------------------------------------------------------------- if htmlBasics then // Text should be printed into new file in HTML environment // -------------------------------------------------------- StateSpace.Analysis.analysis.printHTMLbasics(fileName, true); end if; print("\n<" + heading + ">Characteristics</" + heading + ">\n<p>\nThe system\n</p>\n<p> is ", fileName); if analyseOptions.printControllability and analyseOptions.printObservability then print((if isStable then " " else "<strong>not</strong> ") + "stable" + "\n<br>" + (if isStable then if isControllable then "and it is " else "but it is <strong>not</strong> " else if isControllable then "but it is " else "and it is <strong>not</strong> ") + "controllable" + (if isStable then "" else "\n<br>" + (if isControllable then " and therefore it is " else if isStabilizable then " but it is " else "and is <strong>not</strong> ") + "stabilizable.") + "\n<br> The system is " + (if isObservable then " " else "<strong>not</strong> ") + "observable" + (if isStable then "" else "\n<br>" + (if isObservable then " and therefore it is " else if isDetectable then " but it is " else "and is <strong>not</strong> ") + "detectable.") + "\n<br>", fileName); elseif not analyseOptions.printObservability and analyseOptions.printControllability then print((if isStable then " " else "<strong>not</strong> ") + "stable" + "\n<br>" + (if isStable then if isControllable then "and it is " else "but it is <strong>not</strong> " else if isControllable then "but it is " else "and it is <strong>not</strong> ") + "controllable" + (if isStable then "" else "\n<br>" + (if isControllable then " and therefore it is " else if isStabilizable then " but it is " else "and is <strong>not</strong> ") + "stabilizable.") + "\n<br>", fileName); elseif not analyseOptions.printControllability and analyseOptions.printObservability then print((if isStable then " " else "<strong>not</strong> ") + "stable." + "\n<br> The system is " + (if isObservable then " " else "<strong>not</strong> ") + "observable" + (if isStable then "" else "\n<br>" + (if isObservable then " and therefore it is " else if isDetectable then " but it is " else "and is <strong>not</strong> ") + "detectable.") + "\n<br>", fileName); else print((if isStable then " " else "<strong>not</strong> ") + "stable." + "\n<br>", fileName); end if; print("</p>", fileName); if htmlBasics then // Last print of HTML environment // -------------------------------------------------------- StateSpace.Analysis.analysis.printHTMLbasics(fileName, false); end if; end printHead1; encapsulated function printHead2a "Print the heading of document for eigenvalues in html format on file" import Modelica; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.StateSpace; input String fileName = "systemHead2a.html" "File on which the information is written in html format"; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); input Boolean printTable = true "True, if the system has real eigenvalues to be printed in table"; input Integer hSize(min = 1, max = 5) = 3 "Size of heading of printed document (=1: Title, =2: Chapter, etc.)" annotation( Dialog(group = "HTML format")); protected Integer hSizeOK = if hSize < 1 then 1 else if hSize > 5 then 5 else hSize; String heading = "h" + String(hSizeOK); algorithm // --------------------------------------------------------------------------------------------------- // The correct HTML format generated with this function can be checked with following commands: // Modelica_LinearSystems2.StateSpace.Analysis.analysis.printHead2a(htmlBasics=true, hSize=3); // --------------------------------------------------------------------------------------------------- print("\n<" + heading + ">Eigenvalues analysis</" + heading + ">", fileName); //print("<p>\n<strong>Real eigenvalues</strong>\n</p>", fileName); if printTable then print("<p>The system has the following real eigenvalues.</p>", fileName); print("<table style=\"background-color:rgb(100, 100, 100); margin: 20px 0 20px 20px\" " + "cellpadding=\"3\" border=\"0\" cellspacing=\"1\">", fileName); print("<caption>Real eigenvalues</caption>", fileName); print("<tr style=\"background-color:rgb(230, 230, 230); text-align:center;\">" + "\n <td> number </td>\n <td> eigenvalue </td>\n <td> T [s] </td>\n <td> characteristics </td>", fileName); if analyseOptions.printEigenValueProperties then print(" <td> contribution to states</td>", fileName); end if; print("</tr>", fileName); else print("<p>\nThe system has no real eigenvalues.\n</p>", fileName); end if; end printHead2a; encapsulated function printHead2b "Print the heading of document for conjugated complex pairs in html format on file" import Modelica; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; input String fileName = "systemHead2b.html" "File on which the information is written in html format"; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); input Boolean printTable = true "True, if the system has complex pairs to be printed in table"; algorithm // --------------------------------------------------------------------------------------------------- // The correct HTML format generated with this function can be checked with following commands: // Modelica_LinearSystems2.StateSpace.Analysis.analysis.printHead2b(); // --------------------------------------------------------------------------------------------------- if printTable then print("<p>The system has the following complex conjugate pairs of eigenvalues.<br> </p>", fileName); print("<table style=\"background-color:rgb(100, 100, 100); margin: 20px 0 20px 20px\" " + "cellpadding=\"3\" border=\"0\" cellspacing=\"1\">", fileName); print("<caption>Complex conjugate pairs of eigenvalues</caption>", fileName); print("<tr style=\"background-color:rgb(230, 230, 230); text-align:center;\">" + "\n <td> number </td>\n <td> eigenvalue </td>\n <td> freq. [Hz] </td>\n <td> damping </td>\n <td> characteristics </td>", fileName); if analyseOptions.printEigenValueProperties then print(" <td> contribution to states</td>", fileName); end if; print("</tr>", fileName); else print("<p>\nThe system has no complex conjugate eigenvalue pairs.\n</p>", fileName); end if; end printHead2b; encapsulated function printHead3 "Print the heading of document for description in html format on file" import Modelica; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; input String fileName = "systemHead3.html" "File on which the information is written in html format"; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); algorithm print("<p>\nIn the tables above, the column <strong>contribution to states</strong> lists for each eigenvalue the states to which the" + " corresponding modal state z[i] contributes most. This information is based on the" + " two largest absolute values of the corresponding right eigenvector (if the second large value" + " is less than 5 % of the largest contribution, it is not shown). Note" + " the <strong>right eigenvector</strong> v<sub>j</sub> and the <strong>left eigenvector</strong> u<sub>j</sub> of A satisfy the" + " following relationships with regards to <strong>eigenvalue</strong> λ<sub>j</sub>," + " state vector x and modal state vector z (u<sub>j</sub><sup>H</sup> denotes the conjugate transpose of u<sub>j</sub>):" + " </p>" + " <table border=\"0\" cellspacing=\"0\" cellpadding=\"2\">" + " <tr><td width=\"50\"></td>" + "\n <td>A * v<sub>j</sub> = λ<sub>j</sub> * v<sub>j</sub>; " + " u<sub>j</sub><sup>H</sup> * A = λ<sub>j</sub> * u<sub>j</sub><sup>H</sup>; " + " x = V * z; V = [v<sub>1</sub>, v<sub>2</sub>, ...]</td>" + " </tr>" + "\n</table>" + "\n<p>" + "\nIn the next table, for each state in the column <strong>correlation to modal states</strong>, the modal" + " states z[i] which contribute most to the corresponding state are summarized, that is" + " the state is mostly composed of these modal states." + "\nThis information is based on the two largest absolute values of row i of the" + " eigenvector matrix that is associated with eigenvalue i (if the second large value" + " is less than 5 % of the largest contribution, it is not shown). This only holds" + " if the modal states z[i] are in the same order of magnitude. Otherwise, the listed modal states" + " might be not the most relevant ones.</p>", fileName); print("<table style=\"background-color:rgb(100, 100, 100); margin: 20px 0 20px 20px\" " + "cellpadding=\"3\" border=\"0\" cellspacing=\"1\">\n" + "<tr style=\"background-color:rgb(230, 230, 230); text-align:center;\">" + "\n <td> state </td>\n <td> correlation to modal states </td>\n <td> eigenvalue # </td>" + "\n <td> freq. [Hz] </td>\n <td> damping </td>\n <td> T [s] </td>\n</tr>", fileName); end printHead3; encapsulated function printHead4 "Print the heading of document for invariant zeros in html format on file" import Modelica; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.StateSpace; input String fileName = "systemHead4.html" "File on which the information is written in html format"; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); input Boolean printTable = true "True, if the system has complex pairs to be printed in table"; algorithm // --------------------------------------------------------------------------------------------------- // The correct HTML format generated with this function can be checked with following commands: // Modelica_LinearSystems2.StateSpace.Analysis.analysis.printHead4(htmlEnv=true, hSize=3); // --------------------------------------------------------------------------------------------------- if printTable then print("<p>The system has the following invariant zeros.<br> </p>", fileName); print("\n<table style=\"background-color:rgb(100, 100, 100); margin: 20px 0 20px 20px\" " + "cellpadding=\"3\" border=\"0\" cellspacing=\"1\">", fileName); print("<caption>Invariant zeros</caption>", fileName); print("<tr style=\"background-color:rgb(230, 230, 230); text-align:center;\">" + "\n <td> number </td>\n <td> invariant zero </td>\n <td> Time constant [s] </td>" + "\n <td> freq. [Hz] </td>\n <td> damping </td>\n</tr>", fileName); else print("<p>\nThe system has no invariant zeros.\n</p>", fileName); end if; end printHead4; encapsulated function printHTMLbasics "Print the html preamble or ending on file" import Modelica.Utilities.Files; import Modelica.Utilities.Streams; input String fileName = "systemReport.html" "File on which the html basics should be written"; input Boolean printBegin = false "True, if beginning of a html file should be printed, otherwise the ending" annotation( choices(checkBox = true)); algorithm if printBegin then // First print of HTML environment into new file Files.removeFile(fileName); // Following doesn't work in Dymola //Streams.print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">", fileName); Streams.print("<html>", fileName); Streams.print("<head>\n <title>Analysis of a state space system from Modelica LinearSystems2</title>\n</head>", fileName); Streams.print("<style type=\"text/css\">", fileName); Streams.print("* { font-size: 10pt; font-family: Arial,sans-serif; }", fileName); Streams.print("</style>", fileName); else // Last print of HTML environment Streams.print("</html>", fileName); end if; end printHTMLbasics; encapsulated function printTab1 "Print the table with real eigenvalues in html format on file" import Modelica; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.Internal.Eigenvalue; input Eigenvalue evSorted[:]; input Integer evIndex[size(evSorted, 1)]; input Real r_evec[size(evSorted, 1), size(evSorted, 1)]; input Real l_evec[size(evSorted, 1), size(evSorted, 1)]; input Integer nReal; input String xNames2[size(evSorted, 1)]; input String fileName; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); protected Integer nx = size(evSorted, 1); Real w; Real d; Integer i; Integer j; Integer k; String number; Real r_abs_evec[nx]; Real l_abs_evec[nx]; Integer r_maxIndex1; Integer l_maxIndex1; Integer r_maxIndex2; Integer l_maxIndex2; // Complex v_normalized[size(evSorted,1)]; Real r_abs_v_normalized; Real l_abs_v_normalized; Real r_v; Real l_v; Real r_absMax1; Real l_absMax1; Real r_absMax2; Real l_absMax2; Boolean r_two; Boolean l_two; Boolean r_first; Boolean l_first; algorithm i := 1; j := i; while i <= nReal loop // Build eigenvalue number number := String(i, minimumLength = 7, leftJustified = false); j := j + 1; // Determine largest value in eigenvector k := evIndex[i] "Index with respect to unsorted eigen values"; r_abs_evec := abs(r_evec[:, k]); l_abs_evec := abs(l_evec[:, k]); r_first := true; r_two := false; r_absMax1 := 0; r_maxIndex1 := 0; r_absMax2 := 0; r_maxIndex2 := 0; r_abs_v_normalized := Modelica.Math.Vectors.norm(r_abs_evec, 1); l_first := true; l_two := false; l_absMax1 := 0; l_maxIndex1 := 0; l_absMax2 := 0; l_maxIndex2 := 0; l_abs_v_normalized := Modelica.Math.Vectors.norm(l_abs_evec, 1); for j in 1:nx loop r_v := r_abs_evec[j]; l_v := l_abs_evec[j]; if r_first then r_first := false; r_absMax1 := r_v; r_maxIndex1 := j; elseif not r_two then r_two := true; if r_v < r_absMax1 then r_absMax2 := r_v; r_maxIndex2 := j; else r_absMax2 := r_absMax1; r_maxIndex2 := r_maxIndex1; r_absMax1 := r_v; r_maxIndex1 := j; end if; elseif r_v > r_absMax1 then r_absMax2 := r_absMax1; r_maxIndex2 := r_maxIndex1; r_absMax1 := r_v; r_maxIndex1 := j; elseif r_v > r_absMax2 then r_absMax2 := r_v; r_maxIndex2 := j; end if; if l_first then l_first := false; l_absMax1 := l_v; l_maxIndex1 := j; elseif not l_two then l_two := true; if l_v < l_absMax1 then l_absMax2 := l_v; l_maxIndex2 := j; else l_absMax2 := l_absMax1; l_maxIndex2 := l_maxIndex1; l_absMax1 := l_v; l_maxIndex1 := j; end if; elseif l_v > l_absMax1 then l_absMax2 := l_absMax1; l_maxIndex2 := l_maxIndex1; l_absMax1 := l_v; l_maxIndex1 := j; elseif l_v > l_absMax2 then l_absMax2 := l_v; l_maxIndex2 := j; end if; end for; r_absMax1 := 100*r_absMax1/r_abs_v_normalized; r_absMax2 := 100*r_absMax2/r_abs_v_normalized; if r_absMax2 < 0.05*r_absMax1 then r_two := false; end if; l_absMax1 := 100*l_absMax1/l_abs_v_normalized; l_absMax2 := 100*l_absMax2/l_abs_v_normalized; if l_absMax2 < 0.05*l_absMax1 then l_two := false; end if; // Print data for one eigen value print("<tr style=\"background-color:white\">\n <td style=\"text-align:center\"> " + number + " </td>\n <td style=\"text-align:left\"> " + String(evSorted[i].ev.re, format = "14.4e") + " </td>\n <td style=\"text-align:left\"> " + (if evSorted[i].timeConstant < 1e6 then String(evSorted[i].timeConstant, format = "9.4f") else "---") + " </td>\n <td style=\"text-align:left\"> " + (if evSorted[i].isStable then "" else "not ") + "stable, " + (if evSorted[i].isStable then (if evSorted[i].isControllable then "" else "not ") + "controllable, " else (if evSorted[i].isStabilizable then "" else "not ") + "stabilizable, ") + (if evSorted[i].isStable then (if evSorted[i].isObservable then "" else "not ") + "observable " else (if evSorted[i].isDetectable then "" else "not ") + "detectable ") + " </td>", fileName); if analyseOptions.printEigenValueProperties then print(" <td style=\"text-align:left\"> " + " z[" + String(i) + "]" + " contributes to " + xNames2[r_maxIndex1] + " with " + String(r_absMax1, format = ".3g") + " %<br>" + (if r_two then " " + " z[" + String(i) + "]" + " contributes to " + xNames2[r_maxIndex2] + " with " + String(r_absMax2, format = ".3g") + " %" else "") + " </td>", fileName); end if; print("</tr>", fileName); i := j; end while; print("</table>", fileName); end printTab1; encapsulated function printTab2 "Print the table with complex conjugate eigenvalues in html format on file" import Modelica; import Modelica.Utilities.Strings; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.Internal.Eigenvalue; input Eigenvalue evSorted[:]; input Integer evIndex[size(evSorted, 1)]; input Real r_evec[size(evSorted, 1), size(evSorted, 1)]; input Real l_evec[size(evSorted, 1), size(evSorted, 1)]; input Integer nReal; input String xNames2[size(evSorted, 1)]; input String fileName; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); protected Integer nx = size(evSorted, 1); Integer i; Integer k; String number; String number2; Integer j; Real r_abs_evec[nx]; Real l_abs_evec[nx]; Integer r_maxIndex1; Integer r_maxIndex2; Integer l_maxIndex1; Integer l_maxIndex2; Real r_abs_v_normalized; Real l_abs_v_normalized; Real r_v; Real l_v; Real r_absMax1; Real r_absMax2; Real l_absMax1; Real l_absMax2; Boolean r_two; Boolean l_two; Boolean r_first; Boolean l_first; algorithm i := nReal + 1; j := i; while i <= nx loop // Build eigenvalue number number := String(i) + "/" + String(i + 1); number2 := number; number := Strings.repeat(max(0, 7 - Strings.length(number))) + number; j := j + 2; // Determine largest value in eigenvector k := evIndex[i] "Index with respect to unsorted eigen values"; for i2 in 1:nx loop r_abs_evec[i2] := sqrt(r_evec[i2, k]^2 + r_evec[i2, k + 1]^2); l_abs_evec[i2] := sqrt(l_evec[i2, k]^2 + l_evec[i2, k + 1]^2); end for; r_first := true; r_two := false; r_absMax1 := 0; r_maxIndex1 := 0; r_absMax2 := 0; r_maxIndex2 := 0; r_abs_v_normalized := Modelica.Math.Vectors.norm(r_abs_evec, 1); l_first := true; l_two := false; l_absMax1 := 0; l_maxIndex1 := 0; l_absMax2 := 0; l_maxIndex2 := 0; l_abs_v_normalized := Modelica.Math.Vectors.norm(l_abs_evec, 1); for j in 1:nx loop r_v := r_abs_evec[j]; l_v := l_abs_evec[j]; if r_first then r_first := false; r_absMax1 := r_v; r_maxIndex1 := j; elseif not r_two then r_two := true; if r_v < r_absMax1 then r_absMax2 := r_v; r_maxIndex2 := j; else r_absMax2 := r_absMax1; r_maxIndex2 := r_maxIndex1; r_absMax1 := r_v; r_maxIndex1 := j; end if; elseif r_v > r_absMax1 then r_absMax2 := r_absMax1; r_maxIndex2 := r_maxIndex1; r_absMax1 := r_v; r_maxIndex1 := j; elseif r_v > r_absMax2 then r_absMax2 := r_v; r_maxIndex2 := j; end if; if l_first then l_first := false; l_absMax1 := l_v; l_maxIndex1 := j; elseif not l_two then l_two := true; if l_v < l_absMax1 then l_absMax2 := l_v; l_maxIndex2 := j; else l_absMax2 := l_absMax1; l_maxIndex2 := l_maxIndex1; l_absMax1 := l_v; l_maxIndex1 := j; end if; elseif l_v > l_absMax1 then l_absMax2 := l_absMax1; l_maxIndex2 := l_maxIndex1; l_absMax1 := l_v; l_maxIndex1 := j; elseif l_v > l_absMax2 then l_absMax2 := l_v; l_maxIndex2 := j; end if; end for; r_absMax1 := 100*r_absMax1/r_abs_v_normalized; r_absMax2 := 100*r_absMax2/r_abs_v_normalized; if r_absMax2 < 0.05*r_absMax1 then r_two := false; end if; l_absMax1 := 100*l_absMax1/l_abs_v_normalized; l_absMax2 := 100*l_absMax2/l_abs_v_normalized; if l_absMax2 < 0.05*l_absMax1 then l_two := false; end if; // Print data for one eigen value print("<tr style=\"background-color:white\">\n <td style=\"text-align:left\"> " + number + " </td>" + "\n <td style=\"text-align:left\"> " + String(evSorted[i].ev.re, format = "14.4e") + " ± " + String(evSorted[i].ev.im, format = "12.4e") + "j" + " </td>" + "\n <td style=\"text-align:left\"> " + String(evSorted[i].frequency, format = "9.4f") + " </td>" + "\n <td style=\"text-align:left\"> " + String(evSorted[i].damping, format = "9.4f") + " </td>" + "\n <td style=\"text-align:left\"> " + (if evSorted[i].isStable then "" else "not ") + "stable, " + (if evSorted[i].isStable then (if evSorted[i].isControllable then "" else "not ") + "controllable, " else (if evSorted[i].isStabilizable then "" else "not ") + "stabilizable, ") + (if evSorted[i].isStable then (if evSorted[i].isObservable then "" else "not ") + "observable " else (if evSorted[i].isDetectable then "" else "not ") + "detectable ") + " </td>", fileName); if analyseOptions.printEigenValueProperties then print(" <td style=\"text-align:left\"> " + " z[" + number2 + "]" + " contribute to " + xNames2[r_maxIndex1] + " with " + String(r_absMax1, format = ".3g") + " %<br>" + (if r_two then " " + " z[" + number2 + "]" + " contribute to " + xNames2[r_maxIndex2] + " with " + String(r_absMax2, format = ".3g") + " %" else "") + " </td>", fileName); end if; print("</tr>", fileName); i := j; end while; print("</table>", fileName); end printTab2; encapsulated function printTab3 "Print the table with eigenvalues in html format on file" import Modelica; import Modelica.Utilities.Strings; import Modelica.ComplexMath; import Complex; import Modelica_LinearSystems2; import Modelica_LinearSystems2.ComplexMathAdds; import Modelica.Utilities.Streams.print; import Modelica_LinearSystems2.Internal.Eigenvalue; input Eigenvalue evSorted[:]; input Complex evecComplex[:, :]; input Integer evIndex[size(evecComplex, 1)]; input Complex cev[size(evecComplex, 1)]; input Integer nReal; input String xNames2[size(evecComplex, 1)]; input String fileName; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); protected Integer nx = size(evecComplex, 1); Integer maxIndex1; Integer maxIndex2; Complex v_normalized[size(evecComplex, 1)]; Real abs_v_normalized; Real v; Real absMax1; Real absMax2; Boolean two; Boolean first; Integer j; Integer k; Integer iw1; Integer iw2; String number1; String number2; Real w1; Real w2; Real d1; Real d2; algorithm for i in 1:nx loop // Normalize i-th row of complex eigenvector matrix and determine two largest elements v_normalized := ComplexMath.Vectors.normalize(evecComplex[i, :]); first := true; two := false; absMax1 := 0; maxIndex1 := 0; absMax2 := 0; maxIndex2 := 0; j := 1; abs_v_normalized := ComplexMath.Vectors.norm(v_normalized, 1); while j <= nx loop if cev[j].im == 0 then v := abs(v_normalized[j].re); k := j; j := j + 1; else v := 2*ComplexMath.abs(v_normalized[j]); k := j; j := j + 2; end if; if first then first := false; absMax1 := v; maxIndex1 := k; elseif not two then two := true; if v < absMax1 then absMax2 := v; maxIndex2 := k; else absMax2 := absMax1; maxIndex2 := maxIndex1; absMax1 := v; maxIndex1 := k; end if; elseif v > absMax1 then absMax2 := absMax1; maxIndex2 := maxIndex1; absMax1 := v; maxIndex1 := k; elseif v > absMax2 then absMax2 := v; maxIndex2 := k; end if; end while; if abs_v_normalized > 1e-30 then absMax1 := absMax1/abs_v_normalized; absMax2 := absMax2/abs_v_normalized; end if; if absMax2 < 0.05*absMax1 then two := false; end if; // Determine frequency and number of corresponding eigenvalue (w1, d1) := ComplexMathAdds.frequency(cev[maxIndex1]); iw1 := Modelica.Math.Vectors.find(maxIndex1, evIndex); if iw1 <= nReal then number1 := String(iw1); else number1 := String(iw1) + "/" + String(iw1 + 1); end if; if two then (w2, d2) := ComplexMathAdds.frequency(cev[maxIndex2]); iw2 := Modelica.Math.Vectors.find(maxIndex2, evIndex); if iw2 <= nReal then number2 := String(iw2); else number2 := String(iw2) + "/" + String(iw2 + 1); end if; end if; if two then print("<tr style=\"background-color:white\">\n <td rowspan=2 style=\"text-align:left\"> " + xNames2[i] + " </td>" + "\n <td style=\"text-align:left\"> is composed of " + String(100*absMax1, format = "5.1f") + "% by z[" + number1 + "]</td>" + "\n <td style=\"text-align:center\"> " + number1 + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw1 <= nReal then "---" else String(w1, format = "9.4f")) + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw1 <= nReal then "---" else String(d1, format = "9.4f")) + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw1 <= nReal then String(evSorted[i].timeConstant, format = "9.4f") else "--- </td>") + "\n</tr>\n<tr style=\"background-color:white\">" + "\n <td style=\"text-align:left\"> is composed of " + String(100*absMax2, format = "5.1f") + "% by z[" + number2 + "]</td>" + "\n <td style=\"text-align:center\"> " + number2 + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw2 <= nReal then "---" else String(w2, format = "9.4f")) + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw2 <= nReal then "---" else String(d2, format = "9.4f")) + "</td>" + "\n <td style=\"text-align:center\"> " + (if (iw2 <= nReal and abs(cev[maxIndex2].re) > 1e-10) then String(1/abs(cev[maxIndex2].re), format = "9.4f") else "--- </td>\n</tr>"), fileName); else print("<tr style=\"background-color:white\">\n <td style=\"text-align:left\"> " + xNames2[i] + " </td>" + "\n <td style=\"text-align:left\"> is composed of " + String(100*absMax1, format = "5.1f") + "% by z[" + number1 + "]</td>" + "\n <td style=\"text-align:center\"> " + number1 + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw1 <= nReal then "---" else String(w1, format = "9.4f")) + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw1 <= nReal then "---" else String(d1, format = "9.4f")) + "</td>" + "\n <td style=\"text-align:center\"> " + (if iw1 <= nReal then String(evSorted[i].timeConstant, format = "9.4f") else "--- </td>\n</tr>"), fileName); end if; // print("<tr style=\"background-color:white\">\n <td style=\"text-align:left\"> " + xNames2[i] + " </td>\n <td style=\"text-align:left\"> " // + " is composed of " + String(100*absMax1, format="5.1f") + "% by z[" + // number1 + "]" + (if two then " <br>" + " " + " is composed of " + // String(100*absMax2, format="5.1f") + "% by z[" + number2 + "]" else "") + " </td> <td style=\"text-align:center\"> " // + number1 + (if two then "<br> " + number2 else Strings.repeat(9)) // + " </td> <td style=\"text-align:center\"> " + (if iw1 <= nReal then // "---" else String(w1, format="9.4f")) + (if two then "<br> " // + (if iw2 <= nReal then "---" else String(w2, format="9.4f")) else // Strings.repeat(9)) + " </td>\n <td style=\"text-align:center\"> " + // (if iw1 <= nReal then "---" else String(d1, format="9.4f")) + (if two then // "<br> " + (if iw2 <= nReal then "---" else String(d2, // format="9.4f")) else "") + " </td>\n <td style=\"text-align:center\"> " // + (if (iw1 <= nReal) then String(evSorted[i].timeConstant, format="9.4f") else // "---") + (if two then "<br> " + (if (iw2 <= nReal and abs( // cev[maxIndex2].re) > 1e-10) then String(1/abs(cev[maxIndex2].re), // format="9.4f") else "---") else "") + " </td>\n</tr> ", fileName); end for; print("</table>", fileName); end printTab3; encapsulated function printTab4 "Print the table with eigenvalues in html format on file" import Modelica; import Modelica.Utilities.Strings; import Modelica_LinearSystems2; import Modelica.Utilities.Streams.print; import Complex; input Complex systemZeros[:]; input Integer evIndex[size(systemZeros, 1)]; input Integer nReal; input String fileName; input Modelica_LinearSystems2.Internal.AnalyseOptions analyseOptions = Modelica_LinearSystems2.Internal.AnalyseOptions(plotEigenValues = true, plotInvariantZeros = true, plotStepResponse = true, plotFrequencyResponse = true, printEigenValues = true, printEigenValueProperties = true, printInvariantZeros = true, printControllability = true, printObservability = true, headingEigenValues = "Eigenvalues", headingInvariantzeros = "Invariant zeros", headingStepResponse = "Step response", headingFrequencyResponse = "Frequency response"); protected Integer nz = size(systemZeros, 1); String number; Real timeConstant; Real freq; Real damp; algorithm for i in 1:nReal loop // Build eigenvalue number number := String(i, minimumLength = 7, leftJustified = false); timeConstant := if abs(systemZeros[i].re) > 10*Modelica.Constants.eps then 1/abs(systemZeros[i].re) else 1/(10*Modelica.Constants.eps); print("<tr style=\"background-color:white\">\n <td style=\"text-align:left\"> " + number + " </td>" + "\n <td> " + String(systemZeros[i].re, format = "14.4e") + " </td>" + "\n <td> " + String(timeConstant, format = "9.4f") + " </td>" + "\n <td style=\"text-align:center\"> --- </td>" + "\n <td style=\"text-align:center\"> --- </td>\n</tr>", fileName); end for; for i in nReal + 1:2:nz loop number := String(i) + "/" + String(i + 1); number := Strings.repeat(max(0, 7 - Strings.length(number))) + number; // Determine frequency and number of corresponding zero (freq, damp) := Modelica_LinearSystems2.ComplexMathAdds.frequency(systemZeros[i]); print("<tr style=\"background-color:white\">\n <td style=\"text-align:left\"> " + number + " </td>" + "\n <td style=\"text-align:left\"> " + String(systemZeros[i].re, format = "14.4e") + " ± " + String(systemZeros[i].im, format = "12.4e") + "j </td>" + "\n <td style=\"text-align:center\"> --- </td>" + "\n <td style=\"text-align:left\"> " + String(freq, format = "9.4f") + " </td>" + "\n <td style=\"text-align:left\"> " + String(damp, format = "9.4f") + " </td>\n</tr>", fileName); end for; print("</table>\n", fileName); end printTab4; end analysis;
Name | Description |
---|---|
printSystem | Print the state space system in html format on file |
printHead1 | Print the heading of document for characteristics in html format on file |
printHead2a | Print the heading of document for eigenvalues in html format on file |
printHead2b | Print the heading of document for conjugated complex pairs in html format on file |
printHead3 | Print the heading of document for description in html format on file |
printHead4 | Print the heading of document for invariant zeros in html format on file |
printHTMLbasics | Print the html preamble or ending on file |
printTab1 | Print the table with real eigenvalues in html format on file |
printTab2 | Print the table with complex conjugate eigenvalues in html format on file |
printTab3 | Print the table with eigenvalues in html format on file |
printTab4 | Print the table with eigenvalues in html format on file |
Date | Author | Comment |
---|---|---|
2010-05-31 | Marcus Baur, DLR-RM | Realization |