Changeset 1952

Show
Ignore:
Timestamp:
12/05/2008 11:02:20 AM (5 weeks ago)
Author:
rfranke
Message:

Update UsersGuide.ComponentDefinition with new version by Manuel Gräber

Location:
Modelica_Fluid/branches/StreamConnector/Modelica_Fluid
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/Examples/AST_BatchPlant.mo

    r1951 r1952  
    12911291              fillColor={85,170,255}, 
    12921292              fillPattern=FillPattern.Solid), 
    1293             Line(points={{-200,100},{-200,-100},{0,-100},{0,100}}, color={0,0,0}),  
    1294  
     1293            Line(points={{-200,100},{-200,-100},{0,-100},{0,100}}, color={0,0,0}), 
    12951294            Text( 
    12961295              extent={{-198,74},{0,38}}, 
     
    20522051              lineColor={0,0,0}, 
    20532052              textString=DynamicSelect(" ", realString( 
    2054                     level,  
    2055                     1,  
     2053                    level, 
     2054                    1, 
    20562055                    3))), 
    20572056            Line( 
  • Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/Volumes.mo

    r1951 r1952  
    657657            lineColor={0,0,0}, 
    658658            textString=DynamicSelect(" ", realString( 
    659                 level,  
    660                 1,  
     659                level, 
     660                1, 
    661661                3))), 
    662662          Line( 
  • Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/package.mo

    r1944 r1952  
    190190</dl> 
    191191</html> 
    192 ")); 
    193  
    194   class FluidConnectors "Fluid connectors" 
     192"),   uses(Modelica(version="3.0"))); 
     193 
     194  class BalanceEquations "Balance equations" 
    195195 
    196196    annotation (Documentation(info="<html> 
    197 <h3><font color=\"#008000\" size=5>Fluid connectors</font></h3> 
    198 <p> 
    199 In this section the design of the fluid connectors is 
    200 explained. A major design goal was that components can be arbitrarily 
    201 connected and that the important balance equations are automatically 
    202 fulfilled when 2 or more components are connected together at 
    203 one point as shown in the next figure: 
    204 </p> 
    205 <p align=\"center\"> 
    206 <img src=\"../Images/UsersGuide/MixingConnections.png\"> 
    207 </p> 
    208 <p> 
    209 In such a case the balance equations define <b>ideal mixing</b>, 
    210 i.e., the connection point has the mixing temperature if the 
    211 fluids from the three components would be ideally mixed in  
    212 an infinitely small time period. If more realistic modelling 
    213 is desired that takes into account mixing losses, an explicit 
    214 model has to be used in the connection point. 
    215 </p> 
    216 <h4><font color=\"#008000\">Single substance media</font></h4> 
    217 <p> 
    218 For a single substance medium, the connector definition in 
    219 Modelica_Fluid.Interfaces.FluidPort reduces to 
    220 </p> 
    221   
    222 <pre> 
    223   <b>connector</b> FluidPort  
    224      <b>replaceable package</b> Medium = Modelica.Media.Interfaces.PartialMedium; 
    225    
    226      <b>flow</b> Medium.MassFlowRate m_flow; 
    227               \"Mass flow rate from the connection point into the component\" 
    228    
    229      Medium.AbsolutePressure        p \"Pressure in the connection point\"; 
    230      <b>stream</b> Medium.SpecificEnthalpy h_outflow 
    231                \"Specific enthalpy close to the connection point if m_flow &lt; 0\" 
    232   <b>end</b> FluidPort; 
    233 </pre> 
    234 <p> 
    235 The first statement defines the Medium flowing through the connector. 
    236 In a medium, medium specific types such as \"Medium.AbsolutePressure\"  
    237 are defined that contain medium specific values for the min, max and 
    238 nominal attributes. Furthermore, Medium.MassFlowRate is defined as: 
    239 </p> 
    240 <pre> 
    241    <b>type</b> MassFlowRate = Modelica.SIunits.MassFlowRate( 
    242                                     quantity=\"MassFlowRate.\" + mediumName, ...); 
    243 </pre> 
    244 <p> 
    245 A Modelica translator will check that the quantity and unit attributes  
    246 of connected interfaces are identical. Therefore, an error occurs, 
    247 if connected FluidPorts do not have a medium with the same medium name. 
    248 </p> 
    249 <p> 
    250 As in all Modelica libraries, some requirements must be 
    251 fulfilled for a component, in order that the connection equations 
    252 generated by a Modelica translator from a \"connect(..)\" statement 
    253 lead to the balance equations in the particular area. 
    254 For fluid libraries, we have to first analyse the balance 
    255 equations present in a component. For one-dimensional flow 
     197<h3><font color=\"#008000\" size=5>Balance equations</font></h3> 
     198<p> 
     199For one-dimensional flow 
    256200along the coordinate \"x\", the following partial differential 
    257201equations hold  
     
    298242  
    299243<p> 
    300 <b>??? The text below is no longer correct. Needs to be adapted for the 
    301    streams connector concept ???</b> 
    302 </p> 
    303   
    304 <p> 
    305244This equation is much simpler because all terms depending 
    306245on the velocity v are removed, especially the kinetic 
     
    311250Fluid library use the <b>energy balance 2</b> equation. 
    312251</p> 
    313   
    314 <p> 
    315   
    316   
    317 Assume that 3 components are connected together at one infinitesimal 
    318 small control volume and that thermal conduction 
    319 is neglected. Under the assumption of ideal mixing, 
    320 the intensive quantities at the ports of the components and in the 
    321 small control volume are identical. Furthermore,  
    322 for the small control volume the  
    323 mass and energy balance equations from above reduce 
    324 to the following simple equations (note, that neither 
    325 mass nor energy is stored in the volume and that 
    326 m_flow1 is the mass flow rate and 
    327 H_flow1 is the enthalpy flow rate into component 1): 
    328 </p> 
    329 <table border=1 cellspacing=0 cellpadding=2> 
    330   <tr><td> Intensive quantities</td> 
    331       <td> p1=p2=p3; h1=h2=h3; T1=T2=T3; etc.</td> 
    332   <tr><td> Mass balance</td> 
    333       <td> 0 = m_flow1 + m_flow2 + m_flow3</td> 
    334   </tr> 
    335   <tr><td> Energy balance 2</td> 
    336       <td> 0 = H_flow1 + H_flow2 + H_flow3</td> 
    337   </tr> 
    338 </table> 
    339 <p> 
    340 As can be seen these are exactly also the equations 
    341 generated by a Modelica translator from the connector 
    342 definition above: Non-flow variables are identical, i.e., 
    343 p1=p2=p3, h1=h2=h3 and the flow variables sum up to zero. 
    344 Since the other intensive quantities, such as T or u, are 
    345 a function of two independent variables such as p and h,  
    346 it follows that T1=T2=T3, u1=u2=u3 etc. 
    347 </p> 
    348 <p>  
    349 A connector should have only the minimal number of variables to  
    350 describe the interface, otherwise there will be connection 
    351 restrictions in certain cases. Therefore, in the connector 
    352 no redundant variables are present, e.g., the temperature T  
    353 is not present because it can be computed from the connector 
    354 variables pressure p and specific enthalpy h (as will be 
    355 described in subsequent sections, this will not lead 
    356 to an increased computational effort, if appropriate 
    357 support by the Modelica translator is available). 
    358 </p> 
    359 <p> 
    360 The momentum equation in three dimensions reduces 
    361 to the following vector equation for the small 
    362 control volume: 
    363 </p> 
    364 <table border=1 cellspacing=0 cellpadding=2> 
    365   <tr><td> 3D momentum balance</td> 
    366       <td> 0 = m_flow1*<b>v1</b> +  
    367                m_flow2*<b>v2</b> +  
    368                m_flow3*<b>v2</b></td> 
    369   </tr> 
    370 </table> 
    371 <p> 
    372 where <b>v1</b>, <b>v2</b>, <b>v3</b> are the 
    373 velocity vectors at the ports of the 3 components. 
    374 This equation is only fulfilled in certain cases. 
    375 For example, if two pipes are connected 
    376 together along a straight line with same pipe 
    377 areas, then <b>v1</b> = <b>v2</b> and the momentum 
    378 balance can be written as: 
    379 </p> 
    380 <pre> 
    381     0 = <b>v1</b>*(m_flow1 + m_flow2) 
    382       = 0 
    383 </pre> 
    384 <p> 
    385 because the term in paranthesis is the mass balance. 
    386 </p> 
    387 <p> 
    388 In the general case, the momentum equation is not fulfilled. 
    389 In several applications, it is a useful simplification to 
    390 neglect the momentum balance for a connecting point. In such 
    391 a case, 3 and more components can be directly connected. 
    392 In other cases, e.g., gas dynamics, the momentum balance 
    393 is essential and cannot be neglected. Then, a model 
    394 has to be used in the connection point and 3 and more 
    395 components cannot be directly connected together. 
    396 </p> 
    397 <p> 
    398 To summarize, all Fluid components shall be implemented 
    399 with the <b>energy balance 2</b> form, and the mass and energy 
    400 balance are fulfilled for the infinitesimal small control 
    401 volume in a connection point. The momentum balance is only 
    402 fulfilled in certain cases.   
    403 If this is not justified, an own component has to be defined that  
    404 models the connection, including the desired form of the momentum balance. 
    405 </p> 
    406 <h4><font color=\"#008000\">Multiple substance media</font></h4> 
    407 <p> 
    408 xxx 
    409 </p> 
    410252</html> 
    411253")); 
    412   end FluidConnectors; 
     254  end BalanceEquations; 
    413255 
    414256  class UpstreamDiscretization "Upstream discretization" 
     
    516358  end UpstreamDiscretization; 
    517359 
    518   class PropertyPropagation "Property propagation" 
     360  class FluidConnectors "Fluid connectors" 
    519361 
    520362    annotation (Documentation(info="<html> 
    521 <h3><font color=\"#008000\" size=5>Property propagation</font> (no longer correct; needs to be rewritten for stream connectors)</h3> 
    522 <p> 
    523 As explained in section 
    524 <a href=\"Modelica:Modelica_Fluid.UsersGuide.ComponentDefinition.FluidConnectors\">Fluid connectors</a>, 
    525 it is possible to  
    526 connect components together in a nearly arbitrary fashion, 
    527 because every connection fulfills automatically the 
    528 balance equations. This approach has, however, one drawback: 
    529 If two components are connected together, then the medium 
    530 variables on both sides of the connector are identical. 
    531 However, due to the connector, only the two equations 
    532 </p> 
     363<h3><font color=\"#008000\" size=5>Fluid connectors</font></h3> 
     364<p> 
     365In this section the design of the fluid connectors is 
     366explained. A major design goal was that components can be arbitrarily 
     367connected and that the important balance equations are automatically 
     368fulfilled when 2 or more components are connected together at 
     369one point as shown in the next figure: 
     370</p> 
     371<p align=\"center\"> 
     372<img src=\"../Images/UsersGuide/MixingConnections.png\"> 
     373</p> 
     374<p> 
     375In such a case the balance equations define <b>ideal mixing</b>, 
     376i.e., the connection point has the mixing temperature if the 
     377fluids from the three components would be ideally mixed in  
     378an infinitely small time period. If more realistic modelling 
     379is desired that takes into account mixing losses, an explicit 
     380model has to be used in the connection point. 
     381</p> 
     382<h4><font color=\"#008000\">Single substance media</font></h4> 
     383<p> 
     384For a single substance medium, the connector definition in 
     385Modelica_Fluid.Interfaces.FluidPort reduces to 
     386</p> 
     387  
    533388<pre> 
    534    p1 = p2; 
    535    h1 = h2; 
     389  <b>connector</b> FluidPort  
     390     <b>replaceable package</b> Medium = Modelica.Media.Interfaces.PartialMedium; 
     391   
     392     <b>flow</b> Medium.MassFlowRate m_flow; 
     393              \"Mass flow rate from the connection point into the component\" 
     394   
     395     Medium.AbsolutePressure        p \"Pressure in the connection point\"; 
     396     <b>stream</b> Medium.SpecificEnthalpy h_outflow 
     397               \"Specific enthalpy close to the connection point if m_flow &lt; 0\" 
     398  <b>end</b> FluidPort; 
    536399</pre> 
    537400<p> 
    538 are present. Assume, that p,T are the independent medium variables 
    539 and that the medium properties are computed at one side of the 
    540 connections. This means, the following equations are basically 
    541 present: 
     401The first statement defines the Medium flowing through the connector. 
     402In a medium, medium specific types such as \"Medium.AbsolutePressure\"  
     403are defined that contain medium specific values for the min, max and 
     404nominal attributes. Furthermore, Medium.MassFlowRate is defined as: 
    542405</p> 
    543406<pre> 
    544     h1 = h(p1,T1); 
    545     h2 = h(p2,T2); 
    546     p1 = p2; 
    547     h1 = h2; 
     407   <b>type</b> MassFlowRate = Modelica.SIunits.MassFlowRate( 
     408                                    quantity=\"MassFlowRate.\" + mediumName, ...); 
    548409</pre> 
    549410<p> 
    550 These equations can be solved in the following way: 
    551 </p> 
     411A Modelica translator will check that the quantity and unit attributes  
     412of connected interfaces are identical. Therefore, an error occurs, 
     413if connected FluidPorts do not have a medium with the same medium name. 
     414</p> 
     415  
     416<p>  
     417A connector should have only the minimal number of variables to  
     418describe the interface, otherwise there will be connection 
     419restrictions in certain cases. Therefore, in the connector 
     420no redundant variables are present, e.g., the temperature T  
     421is not present because it can be computed from the connector 
     422variables pressure p and specific enthalpy h. 
     423</p> 
     424<h4><font color=\"#008000\">Stream connector</font></h4> 
     425<p> 
     426FluidPort is a stream connector, because some connector variables  
     427have the stream prefix. The Medium definition and the stream variables  
     428are associated with the only flow variable (m_flow) that defines a fluid  
     429stream. The Medium and the stream variables are transported with this flow  
     430variable. The stream variables h_outflow and Xi_outflow are the stream properties  
     431inside the component close to the boundary, when fluid flows out of the component  
     432into the connection point. The stream properties for the other flow direction  
     433can be inquired with the built-in operator inStream(..). The value of the stream  
     434variable corresponding to the actual flow direction can be inquired through the  
     435built-in operator actualStream(..). 
     436</p><p> 
     437Here is an example to illustrate modeling with stream connectors: 
     438</p> 
     439  
    552440<pre> 
    553     h1 := h(p1,T1) 
    554     p2 := p1; 
    555     h2 := h1; 
    556     0  := h2 - h(p2,T2);   // non-linear system of equations for T2 
     441model MixingVolume \"Volume that mixes two flows\" 
     442  replaceable package Medium = Modelica.Media.Interfaces.PartialPureSubstance; 
     443  FluidPort port_a, port_b; 
     444  parameter Modelica.SIunits.Volume V \"Volume of device\"; 
     445  Modelica.SIunits.Mass             m \"Mass in device\"; 
     446  Modelica.SIunits.Energy           U \"Inner energy in device\"; 
     447  Medium.BaseProperties medium(preferredMediumStates=true) \"Medium in the device\"; 
     448equation 
     449  // Definition of port variables 
     450  port_a.p         = medium.p; 
     451  port_b.p         = medium.p; 
     452  port_a.h_outflow = medium.h;  // The stream variable always corresponds to 
     453  port_b.h_outflow = medium.h;  // the properties of the fluid holdup 
     454  
     455  // Total quantities 
     456  m = V*medium.d; 
     457  U = m*medium.u; 
     458   // Mass and energy balance (actualStream(..) is a built-in operator for streams to 
     459  // compute the right h, depending on the flow direction) 
     460  der(m) = port_a.m_flow + port_b.m_flow; 
     461  der(U) = port_a.m_flow*actualStream(port_a.h_outflow) +  
     462           port_b.m_flow*actualStream(port_b.h_outflow); 
     463end MixingVolume; 
    557464</pre> 
    558 <p> 
    559 This means that T2 is computed by solving a non-linear system 
    560 of equations. If h1 and h2 are provided as Modelica functions, 
    561 a Modelica translator, such as Dymola, can replace 
    562 this non-linear system of equations by the equation: 
    563 </p> 
    564 <pre> 
    565    T2 := T1; 
    566 </pre> 
    567 <p> 
    568 because after alias substition there are two function calls 
    569 </p> 
    570 <pre> 
    571     h1 := h(p1,T1); 
    572     h1 := h(p1,T2); 
    573 </pre> 
    574 <p> 
    575 Since the left hand side of the function call and the first 
    576 argument are the same, the second arguments T1 and T2 must also be  
    577 identical and therefore T2 := T1. This type of analysis seems 
    578 to be only possible, if the specific enthalpy is defined as a function 
    579 of the independent medium variables. Due to this property, all 
    580 media in the Modelica.Media library define 
    581 the specific enthalpy always as a function and therefore by 
    582 appropriate tool support (as, e.g., in Dymola) no non-linear 
    583 system of equations appears and in the generated code 
    584 propagation of medium properties over a connector does not 
    585 lead to an unnecessary overhead. 
    586 </p> 
    587 </html> 
    588 ")); 
    589   end PropertyPropagation; 
     465  
     466<h4><font color=\"#008000\">Balance equations of connection point</font></h4> 
     467<p> 
     468When connecting two or more ports of the type FluidPort it is important  
     469to know that the momentum balance is not fulfilled in general, since  
     470the pressures are set equal. 
     471</p> 
     472<p> 
     473In several applications, it is a useful simplification to 
     474neglect the momentum balance for a connecting point. In such 
     475a case, 3 and more components can be directly connected. 
     476In other cases, e.g., gas dynamics, the momentum balance 
     477is essential and cannot be neglected. Then, a model 
     478has to be used in the connection point and 3 and more 
     479components cannot be directly connected together. 
     480</p></html>")); 
     481  end FluidConnectors; 
    590482 
    591483  class RegularizingCharacteristics "Regularizing characteristics" 
     
    1004896")); 
    1005897  end ValveCharacteristics; 
     898 
    1006899  end ComponentDefinition; 
    1007900