| 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 < 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> |
| | 199 | For one-dimensional flow |
| 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> |
| 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> |
| | 365 | In this section the design of the fluid connectors is |
| | 366 | explained. A major design goal was that components can be arbitrarily |
| | 367 | connected and that the important balance equations are automatically |
| | 368 | fulfilled when 2 or more components are connected together at |
| | 369 | one point as shown in the next figure: |
| | 370 | </p> |
| | 371 | <p align=\"center\"> |
| | 372 | <img src=\"../Images/UsersGuide/MixingConnections.png\"> |
| | 373 | </p> |
| | 374 | <p> |
| | 375 | In such a case the balance equations define <b>ideal mixing</b>, |
| | 376 | i.e., the connection point has the mixing temperature if the |
| | 377 | fluids from the three components would be ideally mixed in |
| | 378 | an infinitely small time period. If more realistic modelling |
| | 379 | is desired that takes into account mixing losses, an explicit |
| | 380 | model has to be used in the connection point. |
| | 381 | </p> |
| | 382 | <h4><font color=\"#008000\">Single substance media</font></h4> |
| | 383 | <p> |
| | 384 | For a single substance medium, the connector definition in |
| | 385 | Modelica_Fluid.Interfaces.FluidPort reduces to |
| | 386 | </p> |
| | 387 | |
| 550 | | These equations can be solved in the following way: |
| 551 | | </p> |
| | 411 | A Modelica translator will check that the quantity and unit attributes |
| | 412 | of connected interfaces are identical. Therefore, an error occurs, |
| | 413 | if connected FluidPorts do not have a medium with the same medium name. |
| | 414 | </p> |
| | 415 | |
| | 416 | <p> |
| | 417 | A connector should have only the minimal number of variables to |
| | 418 | describe the interface, otherwise there will be connection |
| | 419 | restrictions in certain cases. Therefore, in the connector |
| | 420 | no redundant variables are present, e.g., the temperature T |
| | 421 | is not present because it can be computed from the connector |
| | 422 | variables pressure p and specific enthalpy h. |
| | 423 | </p> |
| | 424 | <h4><font color=\"#008000\">Stream connector</font></h4> |
| | 425 | <p> |
| | 426 | FluidPort is a stream connector, because some connector variables |
| | 427 | have the stream prefix. The Medium definition and the stream variables |
| | 428 | are associated with the only flow variable (m_flow) that defines a fluid |
| | 429 | stream. The Medium and the stream variables are transported with this flow |
| | 430 | variable. The stream variables h_outflow and Xi_outflow are the stream properties |
| | 431 | inside the component close to the boundary, when fluid flows out of the component |
| | 432 | into the connection point. The stream properties for the other flow direction |
| | 433 | can be inquired with the built-in operator inStream(..). The value of the stream |
| | 434 | variable corresponding to the actual flow direction can be inquired through the |
| | 435 | built-in operator actualStream(..). |
| | 436 | </p><p> |
| | 437 | Here is an example to illustrate modeling with stream connectors: |
| | 438 | </p> |
| | 439 | |
| 553 | | h1 := h(p1,T1) |
| 554 | | p2 := p1; |
| 555 | | h2 := h1; |
| 556 | | 0 := h2 - h(p2,T2); // non-linear system of equations for T2 |
| | 441 | model 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\"; |
| | 448 | equation |
| | 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); |
| | 463 | end MixingVolume; |
| 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> |
| | 468 | When connecting two or more ports of the type FluidPort it is important |
| | 469 | to know that the momentum balance is not fulfilled in general, since |
| | 470 | the pressures are set equal. |
| | 471 | </p> |
| | 472 | <p> |
| | 473 | In several applications, it is a useful simplification to |
| | 474 | neglect the momentum balance for a connecting point. In such |
| | 475 | a case, 3 and more components can be directly connected. |
| | 476 | In other cases, e.g., gas dynamics, the momentum balance |
| | 477 | is essential and cannot be neglected. Then, a model |
| | 478 | has to be used in the connection point and 3 and more |
| | 479 | components cannot be directly connected together. |
| | 480 | </p></html>")); |
| | 481 | end FluidConnectors; |