- Timestamp:
- 02/24/08 11:40:22 (6 months ago)
- Location:
- trunk/Modelica
- Files:
-
- 5 added
- 5 modified
-
Blocks/Continuous.mo (modified) (22 diffs)
-
Blocks/Math.mo (modified) (32 diffs)
-
Blocks/package.mo (modified) (8 diffs)
-
Images/Blocks/Butterworth.png (added)
-
Images/Blocks/CriticalDampingNonNormalized.png (added)
-
Images/Blocks/CriticalDampingNormalized.png (added)
-
Images/Blocks/InverseModel.png (added)
-
Images/Blocks/InverseModelSchematic.png (added)
-
Scripts/ConvertModelica_from_2.2.2_to_3.0.mos (modified) (1 diff)
-
package.mo (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modelica/Blocks/Continuous.mo
r1046 r1047 7 7 8 8 annotation ( 9 10 9 Documentation(info="<html> 11 10 <p> … … 94 93 </html> 95 94 ")); 95 96 96 block Integrator "Output the integral of the input signal" 97 97 import Modelica.Blocks.Types.Init; … … 110 110 111 111 annotation ( 112 113 112 Documentation(info="<html> 114 113 <p> … … 171 170 textString="s"), 172 171 Line(points={{-46,0},{46,0}}, color={0,0,0})})); 172 173 173 initial equation 174 174 if initType == Init.SteadyState then … … 198 198 extends Interfaces.SISO(y(start=y_start)); 199 199 annotation ( 200 201 200 Documentation(info="<html> 202 201 <p> … … 270 269 textString="s"), 271 270 Line(points={{4,0},{46,0}}, color={0,0,0})})); 271 272 272 initial equation 273 273 if initType == Init.SteadyState then … … 376 376 Rectangle(extent={{-60,60},{60,-60}}, lineColor={0,0,255}), 377 377 Line(points={{-100,0},{-60,0}}, color={0,0,255}), 378 Line(points={{60,0},{100,0}}, color={0,0,255})}) 379 ); 378 Line(points={{60,0},{100,0}}, color={0,0,255})})); 380 379 protected 381 380 parameter Boolean zeroGain = abs(k) < Modelica.Constants.eps; … … 481 480 Rectangle(extent={{-60,60},{60,-60}}, lineColor={0,0,255}), 482 481 Line(points={{-100,0},{-60,0}}, color={0,0,255}), 483 Line(points={{60,0},{100,0}}, color={0,0,255})}) 484 ); 482 Line(points={{60,0},{100,0}}, color={0,0,255})})); 485 483 initial equation 486 484 if initType == Init.SteadyState then … … 511 509 output Real yd(start=yd_start) "Derivative of y"; 512 510 annotation ( 513 514 511 Documentation(info="<HTML> 515 512 <p> … … 615 612 lineColor={0,0,0}, 616 613 textString="+1")})); 614 617 615 initial equation 618 616 if initType == Init.SteadyState then … … 646 644 output Real x(start=x_start) "State of block"; 647 645 648 annotation (defaultComponentName="PI" 649 , 646 annotation (defaultComponentName="PI", 650 647 Documentation(info=" 651 648 <HTML> … … 771 768 "Initialization")); 772 769 773 annotation (defaultComponentName="PID" 774 , 770 annotation (defaultComponentName="PID", 775 771 Icon(coordinateSystem( 776 772 preserveAspectRatio=true, … … 990 986 "Initialization")); 991 987 992 annotation (defaultComponentName="PID" 993 , 988 annotation (defaultComponentName="PID", 994 989 Icon(coordinateSystem( 995 990 preserveAspectRatio=true, … … 1323 1318 Real x_scaled[size(x,1)] "Scaled vector x"; 1324 1319 annotation ( 1325 1326 1320 Documentation(info="<html> 1327 1321 <p> … … 1337 1331 <p> 1338 1332 State variables <b>x</b> are defined according to <b>controller canonical</b> 1339 form. Initial values of the states can be set as start values of <b>x</b>. 1340 <p> 1333 form. Internally, vector <b>x</b> is scaled to improve the numerics (the states in versions before version 3.0 of the Modelica Standard Library have been not scaled). This scaling is 1334 not visible from the outside of this block because the non-scaled vector <b>x</b> 1335 is provided as output signal and the start value is with respect to the non-scaled 1336 vector <b>x</b>. 1337 Initial values of the states <b>x</b> can be set via parameter <b>x_start</b>. 1338 </p> 1339 1341 1340 <p> 1342 1341 Example: … … 1383 1382 Line(points={{-100,0},{-60,0}}, color={0,0,255}), 1384 1383 Line(points={{60,0},{100,0}}, color={0,0,255})})); 1384 1385 1385 initial equation 1386 1386 if initType == Init.SteadyState then … … 1428 1428 output Real x[size(A, 1)](start=x_start) "State vector"; 1429 1429 annotation ( 1430 1431 1430 Documentation(info="<HTML> 1432 1431 <p> … … 1504 1503 Line(points={{-100,0},{-60,0}}, color={0,0,255}), 1505 1504 Line(points={{60,0},{100,0}}, color={0,0,255})})); 1505 1506 1506 protected 1507 1507 parameter Integer nx = size(A, 1) "number of states"; … … 1625 1625 Line(points={{60,0},{100,0}}, color={0,0,255})}), 1626 1626 Documentation(info="<html> 1627 <p>This block defines the transfer function between the input u 1627 <p> 1628 This block defines the transfer function between the input u 1628 1629 and the output y as an n-th order low pass filter with <i>Butterworth</i> 1629 1630 characteristics and cut-off frequency f. It is implemented as 1630 a series of second order filters and a first order filter.</p> 1631 <p>If transients at the simulation start shall be avoided the 1632 states x1 and xr need to be initialized with the start value 1633 of the input signal and the states x2 need to be initialized 1634 with zeros.</p> 1635 <pre> 1636 y = PT21*PT22*...*PT2(n/2)*PT1 u 1637 </pre> 1638 1639 </HTML> 1631 a series of second order filters and a first order filter. 1632 Butterworth filters have the feature that the amplitude at the 1633 cut-off frequency f is 1/sqrt(2) (= 3 dB), i.e., they are 1634 always \"normalized\". Step responses of the Butterworth filter of 1635 different orders are shown in the next figure: 1636 </p> 1637 1638 <p> 1639 <img src=\"../Images/Blocks/Butterworth.png\"> 1640 </p> 1641 1642 <p> 1643 If transients at the simulation start shall be avoided, the filter 1644 should be initialized in steady state (e.g., using option 1645 initType=Modelica.Blocks.Types.Init.SteadyState). 1646 </p> 1647 1648 1649 </html> 1640 1650 ")); 1641 1651 protected … … 1721 1731 parameter Integer n=2 "Order of filter"; 1722 1732 parameter Modelica.SIunits.Frequency f(start=1) "Cut-off frequency"; 1733 parameter Boolean normalized = true 1734 "= true, if amplitude at f_cut is 3 dB, otherwise unmodified filter"; 1723 1735 parameter Modelica.Blocks.Types.Init initType=Modelica.Blocks.Types.Init.NoInit 1724 1736 "Type of initialization (1: no init, 2: steady state, 3: initial state, 4: initial output)" … … 1780 1792 extent={{-54,-6},{44,-56}}, 1781 1793 lineColor={0,0,0}, 1782 textString="( T s+ 1)"),1794 textString="(s/w + 1)"), 1783 1795 Text( 1784 1796 extent={{38,-10},{58,-30}}, … … 1789 1801 input u and the output y 1790 1802 as an n-th order filter with <i>critical damping</i> 1791 characteristics and cut-off frequency f=1/T. It is 1792 implemented as a series of first order filters.</p> 1793 <p>If transients at the simulation start shall be avoided 1794 the states x need to be initialized with the start value of 1795 the input.</p> 1803 characteristics and cut-off frequency f. It is 1804 implemented as a series of first order filters. 1805 This filter type is especially useful to filter the input of an 1806 inverse model, since the filter does not introduce any transients. 1807 </p> 1808 1809 <p> 1810 If parameter <b>normalized</b> = <b>true</b> (default), the filter 1811 is normalized such that the amplitude of the filter transfer function 1812 at the cut-off frequency f is 1/sqrt(2) (= 3 dB). Otherwise, the filter 1813 is not normalized, i.e., it is unmodified. A normalized filter is usually 1814 much better for applications, since filters of different orders are 1815 \"comparable\", whereas non-normalized filters usually require to adapt the 1816 cut-off frequency, when the order of the filter is changed. 1817 Figures of the filter step responses are shown below. 1818 Note, in versions before version 3.0 of the Modelica Standard library, 1819 the CriticalDamping filter was provided only in non-normalzed form. 1820 </p> 1821 1822 <p>If transients at the simulation start shall be avoided, the filter 1823 should be initialized in steady state (e.g., using option 1824 initType=Modelica.Blocks.Types.Init.SteadyState). 1825 </p> 1826 1827 <p> 1828 The critical damping filter is defined as 1829 </p> 1830 1796 1831 <pre> 1797 k 1798 y = ------------- * u 1799 (T * s + 1)^n 1832 α = <b>if</b> normalized <b>then</b> <b>sqrt</b>(2^(1/n) - 1) <b>else</b> 1 // frequency correction factor 1833 ω = 2*π*f/α 1834 1 1835 y = ------------- * u 1836 (s/w + 1)^n 1837 1800 1838 </pre> 1801 1839 1802 </HTML> 1840 <p> 1841 <img src=\"../Images/Blocks/CriticalDampingNormalized.png\"> 1842 </p> 1843 1844 <p> 1845 <img src=\"../Images/Blocks/CriticalDampingNonNormalized.png\"> 1846 </p> 1847 1848 </html> 1803 1849 ")); 1804 1850 protected 1805 parameter Real w=2*Modelica.Constants.pi*f; 1851 parameter Real alpha=if normalized then sqrt(2^(1/n) - 1) else 1.0 1852 "Frequency correction factor for normalized filter"; 1853 parameter Real w=2*Modelica.Constants.pi*f/alpha; 1806 1854 initial equation 1807 1855 if initType == Init.SteadyState then -
trunk/Modelica/Blocks/Math.mo
r1046 r1047 6 6 7 7 annotation ( 8 9 8 Documentation(info=" 10 9 <HTML> … … 598 597 block InverseBlockConstraints 599 598 "Construct inverse model by requiring that two inputs and two outputs are identical (replaces the previously, unbalanced, TwoInputs and TwoOutputs blocks)" 600 extends Modelica.Blocks.Interfaces.BlockIcon; 599 600 Modelica.Blocks.Interfaces.RealInput u1 "Input signal 1 (u1 = u2)" 601 annotation (Placement(transformation(extent={{-240, 602 -20},{-200,20}}, rotation=0), iconTransformation(extent={{-240,-20}, 603 {-200,20}}))); 604 Modelica.Blocks.Interfaces.RealInput u2 "Input signal 2 (u1 = u2)" 605 annotation (Placement(transformation(extent={{-140, 606 -20},{-180,20}}, rotation=0), iconTransformation(extent={{-140,-20}, 607 {-180,20}}))); 608 Modelica.Blocks.Interfaces.RealOutput y1 "Output signal 1 (y1 = y2)" 609 annotation (Placement(transformation(extent={{200,-10}, 610 {220,10}}, rotation=0), iconTransformation(extent={{200,-10},{ 611 220,10}}))); 612 Modelica.Blocks.Interfaces.RealOutput y2 "Output signal 2 (y2 = y2)" 613 annotation (Placement(transformation(extent={{10,-10}, 614 {-10,10}}, rotation=0, 615 origin={170,0}), iconTransformation(extent={{180,-10},{160,10}}))); 601 616 602 617 annotation(__Dymola_structurallyIncomplete=true, 603 Diagram(coordinateSystem(preserveAspectRatio=true, extent={{- 100,-100},{604 100,100}}),618 Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-200,-100},{ 619 200,100}}), 605 620 graphics), 606 Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100, 607 100}}), graphics={Line( 608 points={{-100,0},{-58,0},{-58,80},{-100,80}}, 621 Icon(coordinateSystem(preserveAspectRatio=true, extent={{-200,-100},{200, 622 100}}), graphics={ 623 Line( 624 points={{180,0},{200,0}}, 609 625 color={0,0,127}, 610 smooth=Smooth.None), Line( 611 points={{100,-62},{58,-62},{58,0},{100,0}}, 626 smooth=Smooth.None), 627 Line( 628 points={{-200,0},{-180,0}}, 612 629 color={0,0,127}, 613 smooth=Smooth.None)})); 614 Interfaces.RealInput u1 annotation (Placement(transformation(extent={{-140, 615 -20},{-100,20}}, rotation=0))); 616 Interfaces.RealInput u2 annotation (Placement(transformation(extent={{-140, 617 60},{-100,100}}, rotation=0))); 618 Interfaces.RealOutput y1 annotation (Placement(transformation(extent={{100, 619 -10},{120,10}}, rotation=0))); 620 Interfaces.RealOutput y2 annotation (Placement(transformation(extent={{100, 621 -70},{120,-50}}, rotation=0))); 630 smooth=Smooth.None), 631 Rectangle( 632 extent={{-190,110},{190,-110}}, 633 lineColor={135,135,135}, 634 lineThickness=0.5)}), 635 Documentation(info="<html> 636 <p> 637 Exchange input and ouput signals of a block, i.e., the previous 638 block inputs become block outputs and the previous block outputs become 639 block inputs. This block is used to construct inverse models. 640 Its usage is demonstrated in example: 641 <a href=\"Modelica://Modelica.Blocks.Examples.InverseModel\">Modelica.Blocks.Examples.InverseModel</a>. 642 </p> 643 644 <p> 645 Note, if a block shall be inverted that has several input and output blocks, 646 then this can be easily achieved by using a vector of InverseBlockConstraints 647 instances: 648 </p> 649 650 <pre> 651 InverseBlockConstraint invert[3]; // Block to be inverted has 3 input signals 652 </pre> 653 </html>")); 622 654 equation 623 655 u1 = u2; 624 656 y1 = y2; 625 657 end InverseBlockConstraints; 658 626 659 627 660 block Gain "Output the product of a gain value with the input signal" … … 636 669 rotation=0))); 637 670 annotation ( 638 639 671 Documentation(info=" 640 672 <HTML> … … 677 709 textString="k", 678 710 lineColor={0,0,255})})); 711 679 712 equation 680 713 y = k*u; … … 731 764 extent={{-90,-60},{90,60}}, 732 765 lineColor={160,160,164}, 733 textString="*K")}) 734 ); 766 textString="*K")})); 735 767 equation 736 768 y = K*u; … … 740 772 extends Interfaces.MISO; 741 773 parameter Real k[nin]=ones(nin) "Optional: sum coefficients"; 742 annotation (defaultComponentName="sum1" 743 , 774 annotation (defaultComponentName="sum1", 744 775 Documentation(info=" 745 776 <HTML> … … 801 832 extent={{80,-10},{100,10}}, rotation=0))); 802 833 annotation ( 803 804 834 Documentation(info=" 805 835 <HTML> … … 862 892 lineColor={0,0,0}, 863 893 textString="-")})); 894 864 895 equation 865 896 y = u1 - u2; … … 871 902 parameter Real k2=+1 "Gain of lower input"; 872 903 annotation ( 873 874 904 Documentation(info=" 875 905 <HTML> … … 1002 1032 rotation=0))); 1003 1033 annotation ( 1004 1005 1034 Documentation(info=" 1006 1035 <HTML> … … 1136 1165 Line(points={{-15,25.99},{15,-25.99}}, color={0,0,0}), 1137 1166 Line(points={{-15,-25.99},{15,25.99}}, color={0,0,0}), 1138 Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,255})}) 1139 ); 1167 Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,255})})); 1140 1168 1141 1169 equation … … 1204 1232 Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,255}), 1205 1233 Line(points={{-100,60},{-66,60},{-40,30}}, color={0,0,255}), 1206 Line(points={{-100,-60},{0,-60},{0,-50}}, color={0,0,255})}) 1207 ); 1234 Line(points={{-100,-60},{0,-60},{0,-50}}, color={0,0,255})})); 1208 1235 1209 1236 equation … … 1288 1315 1289 1316 </HTML> 1290 ") );1317 ")); 1291 1318 equation 1292 1319 y = abs(u); … … 1375 1402 1376 1403 </HTML> 1377 ") );1404 ")); 1378 1405 equation 1379 1406 y = sign(u); … … 1447 1474 1448 1475 </HTML> 1449 ") );1476 ")); 1450 1477 1451 1478 equation … … 1538 1565 1539 1566 </HTML> 1540 ") );1567 ")); 1541 1568 equation 1542 1569 y = Modelica.Math.sin(u); … … 1628 1655 1629 1656 </HTML> 1630 ") );1657 ")); 1631 1658 1632 1659 equation … … 1718 1745 1719 1746 </HTML> 1720 ") );1747 ")); 1721 1748 1722 1749 equation … … 1814 1841 1815 1842 </HTML> 1816 ") );1843 ")); 1817 1844 1818 1845 equation … … 1906 1933 1907 1934 </HTML> 1908 ") );1935 ")); 1909 1936 equation 1910 1937 y = Modelica.Math.acos(u); … … 1998 2025 1999 2026 </HTML> 2000 ") );2027 ")); 2001 2028 equation 2002 2029 y = Modelica.Math.atan(u); … … 2110 2137 2111 2138 </HTML> 2112 ") );2139 ")); 2113 2140 equation 2114 2141 y = Modelica.Math.atan2(u1, u2); … … 2202 2229 2203 2230 </HTML> 2204 ") );2231 ")); 2205 2232 2206 2233 equation … … 2295 2322 2296 2323 </HTML> 2297 ") );2324 ")); 2298 2325 equation 2299 2326 y = Modelica.Math.cosh(u); … … 2387 2414 2388 2415 </HTML> 2389 ") );2416 ")); 2390 2417 equation 2391 2418 y = Modelica.Math.tanh(u); … … 2477 2504 2478 2505 </HTML> 2479 ") );2506 ")); 2480 2507 2481 2508 equation … … 2576 2603 2577 2604 </HTML> 2578 ") );2605 ")); 2579 2606 equation 2580 2607 y = Modelica.Math.log(u); … … 2674 2701 2675 2702 </HTML> 2676 ") );2703 ")); 2677 2704 equation 2678 2705 y = Modelica.Math.log10(u); … … 2764 2791 2765 2792 annotation ( 2766 2767 2793 Documentation(info="<html> 2768 2794 <p> … … 2813 2839 2814 2840 annotation ( 2815 2816 2841 Documentation(info="<html> 2817 2842 <p> … … 2861 2886 2862 2887 annotation ( 2863 2864 2888 Documentation(info="<html> 2865 2889 <p> … … 2911 2935 2912 2936 annotation ( 2913 2914 2937 Documentation(info="<html> 2915 2938 <p> -
trunk/Modelica/Blocks/package.mo
r1046 r1047 8 8 9 9 annotation ( 10 11 10 Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), 12 11 graphics={ … … 97 96 extends Icons.Library; 98 97 99 model PID_Controller "Demonstrate usage of the Continuous.LimPID controller" 98 model PID_Controller 99 "Demonstrates the usage of a Continuous.LimPID controller" 100 100 extends Modelica.Icons.Example; 101 101 parameter Modelica.SIunits.Angle driveAngle=1.57 … … 254 254 end PID_Controller; 255 255 256 model InverseModel "Demonstrates the construction of an inverse model" 257 extends Modelica.Icons.Example; 258 259 Continuous.FirstOrder firstOrder1( 260 k=1, 261 T=0.3, 262 initType=Modelica.Blocks.Types.Init.SteadyState) 263 annotation (Placement(transformation(extent={{20,20},{0,40}}))); 264 Sources.Sine sine( 265 freqHz=2, 266 offset=1, 267 startTime=0.2) 268 annotation (Placement(transformation(extent={{-80,20},{-60,40}}))); 269 annotation (Diagram(coordinateSystem(preserveAspectRatio=true, extent={{ 270 -100,-100},{100,100}}), graphics), Documentation(info="<html> 271 <p> 272 This example demonstrates how to construct an inverse model in Modelica 273 (for more details see <a href=\"http://www.modelica.org/events/Conference2005/online_proceedings/Session3/Session3c3.pdf\">Looye, Thümmel, Kurze, Otter, Bals: Nonlinear Inverse Models for Control</a>). 274 </p> 275 276 <p> 277 For a linear, single input, single output system 278 </p> 279 280 <pre> 281 y = n(s)/d(s) * u // plant model 282 </pre> 283 284 <p> 285 the inverse model is derived by simply exchanging the numerator and
