Changeset 1047 for trunk

Show
Ignore:
Timestamp:
02/24/08 11:40:22 (6 months ago)
Author:
otter
Message:

- Icon of Blocks.Math.InverseBlockConstraints considerably improved
- New example model in Blocks.Examples.InverseModel to demonstrate

construction of inverse models

- New parameter "normalized" for Blocks.Continuous.CriticalDamping

to constructed normalized filters.

- Documentation of Blocks.Continuous.Butterworth/.CriticalDamping improved,

especially plots of the characteristic added

- Conversion script for normalized filter updated
- Release notes updated

Location:
trunk/Modelica
Files:
5 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/Modelica/Blocks/Continuous.mo

    r1046 r1047  
    77 
    88  annotation ( 
    9      
    109    Documentation(info="<html> 
    1110<p> 
     
    9493</html> 
    9594")); 
     95 
    9696  block Integrator "Output the integral of the input signal" 
    9797    import Modelica.Blocks.Types.Init; 
     
    110110 
    111111    annotation ( 
    112        
    113112      Documentation(info="<html> 
    114113<p> 
     
    171170            textString="s"), 
    172171          Line(points={{-46,0},{46,0}}, color={0,0,0})})); 
     172 
    173173  initial equation 
    174174    if initType == Init.SteadyState then 
     
    198198    extends Interfaces.SISO(y(start=y_start)); 
    199199    annotation ( 
    200        
    201200      Documentation(info="<html> 
    202201<p> 
     
    270269            textString="s"), 
    271270          Line(points={{4,0},{46,0}}, color={0,0,0})})); 
     271 
    272272  initial equation 
    273273    if initType == Init.SteadyState then 
     
    376376          Rectangle(extent={{-60,60},{60,-60}}, lineColor={0,0,255}), 
    377377          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})})); 
    380379  protected 
    381380    parameter Boolean zeroGain = abs(k) < Modelica.Constants.eps; 
     
    481480          Rectangle(extent={{-60,60},{60,-60}}, lineColor={0,0,255}), 
    482481          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})})); 
    485483  initial equation 
    486484    if initType == Init.SteadyState then 
     
    511509    output Real yd(start=yd_start) "Derivative of y"; 
    512510    annotation ( 
    513        
    514511      Documentation(info="<HTML> 
    515512<p> 
     
    615612            lineColor={0,0,0}, 
    616613            textString="+1")})); 
     614 
    617615  initial equation 
    618616    if initType == Init.SteadyState then 
     
    646644    output Real x(start=x_start) "State of block"; 
    647645 
    648     annotation (defaultComponentName="PI" 
    649       , 
     646    annotation (defaultComponentName="PI", 
    650647      Documentation(info=" 
    651648<HTML> 
     
    771768            "Initialization")); 
    772769 
    773     annotation (defaultComponentName="PID" 
    774       , 
     770    annotation (defaultComponentName="PID", 
    775771      Icon(coordinateSystem( 
    776772          preserveAspectRatio=true, 
     
    990986            "Initialization")); 
    991987 
    992     annotation (defaultComponentName="PID" 
    993       , 
     988    annotation (defaultComponentName="PID", 
    994989      Icon(coordinateSystem( 
    995990          preserveAspectRatio=true, 
     
    13231318    Real x_scaled[size(x,1)] "Scaled vector x"; 
    13241319    annotation ( 
    1325        
    13261320      Documentation(info="<html> 
    13271321<p> 
     
    13371331<p> 
    13381332State 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> 
     1333form. 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 
     1334not visible from the outside of this block because the non-scaled vector <b>x</b> 
     1335is provided as output signal and the start value is with respect to the non-scaled 
     1336vector <b>x</b>. 
     1337Initial values of the states <b>x</b> can be set via parameter <b>x_start</b>. 
     1338</p> 
     1339 
    13411340<p> 
    13421341Example: 
     
    13831382          Line(points={{-100,0},{-60,0}}, color={0,0,255}), 
    13841383          Line(points={{60,0},{100,0}}, color={0,0,255})})); 
     1384 
    13851385  initial equation 
    13861386    if initType == Init.SteadyState then 
     
    14281428    output Real x[size(A, 1)](start=x_start) "State vector"; 
    14291429    annotation ( 
    1430        
    14311430      Documentation(info="<HTML> 
    14321431<p> 
     
    15041503          Line(points={{-100,0},{-60,0}}, color={0,0,255}), 
    15051504          Line(points={{60,0},{100,0}}, color={0,0,255})})); 
     1505 
    15061506  protected 
    15071507    parameter Integer nx = size(A, 1) "number of states"; 
     
    16251625          Line(points={{60,0},{100,0}}, color={0,0,255})}), 
    16261626      Documentation(info="<html> 
    1627 <p>This block defines the transfer function between the input u 
     1627<p> 
     1628This block defines the transfer function between the input u 
    16281629and the output y as an n-th order low pass filter with <i>Butterworth</i> 
    16291630characteristics 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> 
     1631a series of second order filters and a first order filter. 
     1632Butterworth filters have the feature that the amplitude at the 
     1633cut-off frequency f is 1/sqrt(2) (= 3 dB), i.e., they are  
     1634always \"normalized\". Step responses of the Butterworth filter of 
     1635different orders are shown in the next figure: 
     1636</p> 
     1637 
     1638<p> 
     1639<img src=\"../Images/Blocks/Butterworth.png\"> 
     1640</p> 
     1641 
     1642<p> 
     1643If transients at the simulation start shall be avoided, the filter 
     1644should be initialized in steady state (e.g., using option 
     1645initType=Modelica.Blocks.Types.Init.SteadyState). 
     1646</p> 
     1647 
     1648 
     1649</html> 
    16401650")); 
    16411651  protected 
     
    17211731    parameter Integer n=2 "Order of filter"; 
    17221732    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"; 
    17231735    parameter Modelica.Blocks.Types.Init initType=Modelica.Blocks.Types.Init.NoInit 
    17241736      "Type of initialization (1: no init, 2: steady state, 3: initial state, 4: initial output)" 
     
    17801792            extent={{-54,-6},{44,-56}}, 
    17811793            lineColor={0,0,0}, 
    1782             textString="(T s + 1)"), 
     1794            textString="(s/w + 1)"), 
    17831795          Text( 
    17841796            extent={{38,-10},{58,-30}}, 
     
    17891801input u and the output y 
    17901802as 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> 
     1803characteristics and cut-off frequency f. It is 
     1804implemented as a series of first order filters. 
     1805This filter type is especially useful to filter the input of an 
     1806inverse model, since the filter does not introduce any transients. 
     1807</p> 
     1808 
     1809<p> 
     1810If parameter <b>normalized</b> = <b>true</b> (default), the filter 
     1811is normalized such that the amplitude of the filter transfer function 
     1812at the cut-off frequency f is 1/sqrt(2) (= 3 dB). Otherwise, the filter 
     1813is not normalized, i.e., it is unmodified. A normalized filter is usually 
     1814much better for applications, since filters of different orders are 
     1815\"comparable\", whereas non-normalized filters usually require to adapt the 
     1816cut-off frequency, when the order of the filter is changed. 
     1817Figures of the filter step responses are shown below. 
     1818Note, in versions before version 3.0 of the Modelica Standard library, 
     1819the 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 
     1823should be initialized in steady state (e.g., using option 
     1824initType=Modelica.Blocks.Types.Init.SteadyState). 
     1825</p> 
     1826 
     1827<p> 
     1828The critical damping filter is defined as 
     1829</p> 
     1830 
    17961831<pre> 
    1797                k 
    1798      y = ------------- * u 
    1799          (T * s + 1)^n 
     1832    &alpha; = <b>if</b> normalized <b>then</b> <b>sqrt</b>(2^(1/n) - 1) <b>else</b> 1 // frequency correction factor 
     1833    &omega; = 2*&pi;*f/&alpha; 
     1834              1 
     1835    y = ------------- * u 
     1836         (s/w + 1)^n 
     1837 
    18001838</pre> 
    18011839  
    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> 
    18031849")); 
    18041850  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; 
    18061854  initial equation 
    18071855    if initType == Init.SteadyState then 
  • trunk/Modelica/Blocks/Math.mo

    r1046 r1047  
    66 
    77  annotation ( 
    8      
    98    Documentation(info=" 
    109<HTML> 
     
    598597  block InverseBlockConstraints 
    599598    "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}}))); 
    601616 
    602617    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}}), 
    605620              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}}, 
    609625            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}}, 
    612629            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> 
     637Exchange input and ouput signals of a block, i.e., the previous 
     638block inputs become block outputs and the previous block outputs become 
     639block inputs. This block is used to construct inverse models. 
     640Its usage is demonstrated in example: 
     641<a href=\"Modelica://Modelica.Blocks.Examples.InverseModel\">Modelica.Blocks.Examples.InverseModel</a>. 
     642</p> 
     643 
     644<p> 
     645Note, if a block shall be inverted that has several input and output blocks, 
     646then this can be easily achieved by using a vector of InverseBlockConstraints  
     647instances: 
     648</p> 
     649 
     650<pre> 
     651   InverseBlockConstraint invert[3];  // Block to be inverted has 3 input signals 
     652</pre> 
     653</html>")); 
    622654  equation 
    623655    u1 = u2; 
    624656    y1 = y2; 
    625657  end InverseBlockConstraints; 
     658 
    626659 
    627660      block Gain "Output the product of a gain value with the input signal" 
     
    636669            rotation=0))); 
    637670        annotation ( 
    638            
    639671          Documentation(info=" 
    640672<HTML> 
     
    677709            textString="k", 
    678710            lineColor={0,0,255})})); 
     711 
    679712      equation 
    680713        y = k*u; 
     
    731764            extent={{-90,-60},{90,60}}, 
    732765            lineColor={160,160,164}, 
    733             textString="*K")}) 
    734           ); 
     766            textString="*K")})); 
    735767      equation 
    736768        y = K*u; 
     
    740772        extends Interfaces.MISO; 
    741773        parameter Real k[nin]=ones(nin) "Optional: sum coefficients"; 
    742         annotation (defaultComponentName="sum1" 
    743           , 
     774        annotation (defaultComponentName="sum1", 
    744775          Documentation(info=" 
    745776<HTML> 
     
    801832            extent={{80,-10},{100,10}}, rotation=0))); 
    802833        annotation ( 
    803            
    804834          Documentation(info=" 
    805835<HTML> 
     
    862892            lineColor={0,0,0}, 
    863893            textString="-")})); 
     894 
    864895      equation 
    865896        y = u1 - u2; 
     
    871902        parameter Real k2=+1 "Gain of lower input"; 
    872903        annotation ( 
    873            
    874904          Documentation(info=" 
    875905<HTML> 
     
    10021032            rotation=0))); 
    10031033        annotation ( 
    1004            
    10051034          Documentation(info=" 
    10061035<HTML> 
     
    11361165          Line(points={{-15,25.99},{15,-25.99}}, color={0,0,0}), 
    11371166          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})})); 
    11401168 
    11411169      equation 
     
    12041232          Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,255}), 
    12051233          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})})); 
    12081235 
    12091236      equation 
     
    12881315 
    12891316</HTML> 
    1290 ")       ); 
     1317")); 
    12911318      equation 
    12921319        y = abs(u); 
     
    13751402 
    13761403</HTML> 
    1377 ")       ); 
     1404")); 
    13781405      equation 
    13791406        y = sign(u); 
     
    14471474 
    14481475</HTML> 
    1449 ")       ); 
     1476")); 
    14501477 
    14511478      equation 
     
    15381565 
    15391566</HTML> 
    1540 ")       ); 
     1567")); 
    15411568      equation 
    15421569        y = Modelica.Math.sin(u); 
     
    16281655 
    16291656</HTML> 
    1630 ")       ); 
     1657")); 
    16311658 
    16321659      equation 
     
    17181745 
    17191746</HTML> 
    1720 ")       ); 
     1747")); 
    17211748 
    17221749      equation 
     
    18141841 
    18151842</HTML> 
    1816 ")       ); 
     1843")); 
    18171844 
    18181845      equation 
     
    19061933 
    19071934</HTML> 
    1908 ")       ); 
     1935")); 
    19091936      equation 
    19101937        y = Modelica.Math.acos(u); 
     
    19982025 
    19992026</HTML> 
    2000 ")       ); 
     2027")); 
    20012028      equation 
    20022029        y = Modelica.Math.atan(u); 
     
    21102137 
    21112138</HTML> 
    2112 ")       ); 
     2139")); 
    21132140      equation 
    21142141        y = Modelica.Math.atan2(u1, u2); 
     
    22022229 
    22032230</HTML> 
    2204 ")       ); 
     2231")); 
    22052232 
    22062233      equation 
     
    22952322 
    22962323</HTML> 
    2297 ")       ); 
     2324")); 
    22982325      equation 
    22992326        y = Modelica.Math.cosh(u); 
     
    23872414 
    23882415</HTML> 
    2389 ")       ); 
     2416")); 
    23902417      equation 
    23912418        y = Modelica.Math.tanh(u); 
     
    24772504 
    24782505</HTML> 
    2479 ")       ); 
     2506")); 
    24802507 
    24812508      equation 
     
    25762603 
    25772604</HTML> 
    2578 ")       ); 
     2605")); 
    25792606      equation 
    25802607        y = Modelica.Math.log(u); 
     
    26742701 
    26752702</HTML> 
    2676 ")       ); 
     2703")); 
    26772704      equation 
    26782705        y = Modelica.Math.log10(u); 
     
    27642791 
    27652792    annotation ( 
    2766        
    27672793      Documentation(info="<html> 
    27682794<p> 
     
    28132839 
    28142840    annotation ( 
    2815        
    28162841      Documentation(info="<html> 
    28172842<p> 
     
    28612886 
    28622887    annotation ( 
    2863        
    28642888      Documentation(info="<html> 
    28652889<p> 
     
    29112935 
    29122936    annotation ( 
    2913        
    29142937      Documentation(info="<html> 
    29152938<p> 
  • trunk/Modelica/Blocks/package.mo

    r1046 r1047  
    88 
    99annotation ( 
    10    
    1110  Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}),  
    1211      graphics={ 
     
    9796  extends Icons.Library; 
    9897 
    99   model PID_Controller "Demonstrate usage of the Continuous.LimPID controller" 
     98  model PID_Controller 
     99    "Demonstrates the usage of a Continuous.LimPID controller" 
    100100    extends Modelica.Icons.Example; 
    101101    parameter Modelica.SIunits.Angle driveAngle=1.57 
     
    254254  end PID_Controller; 
    255255 
     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> 
     272This 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> 
     277For 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> 
     285the inverse model is derived by simply exchanging the numerator and </