Changeset 1949

Show
Ignore:
Timestamp:
12/05/2008 06:48:56 AM (5 weeks ago)
Author:
rfranke
Message:

Pipes
- cleaning of DistributedPipe code
- bug fix for lumpedPressure option of DistributedPipe
- add init and dynamics parameters to PressureDrop models
- use new DistributedPipe in HeatExchangers

add clean.bat for removal of intermediate files
add Test/TestComponents/Pipes/StaticPipe.mo

Location:
Modelica_Fluid/branches/StreamConnector/Modelica_Fluid
Files:
2 added
7 modified

Legend:

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

    r1946 r1949  
    382382                         annotation (Placement(transformation(extent={{-100, 
    383383              -140},{-60,-100}}, rotation=0))); 
    384     Modelica_Fluid.Pipes.LumpedPipe_Old pipeB1B2( 
     384    Modelica_Fluid.Pipes.ToBeRemoved.LumpedPipe_Old pipeB1B2( 
    385385      redeclare package Medium = BatchMedium, 
    386386      length=1, 
     
    447447          extent={{-10,10},{10,-10}}, 
    448448          rotation=90))); 
    449     Modelica_Fluid.Pipes.LumpedPipe_Old pipePump1B1( 
     449    Modelica_Fluid.Pipes.ToBeRemoved.LumpedPipe_Old pipePump1B1( 
    450450      redeclare package Medium = BatchMedium, 
    451451      length=1, 
     
    458458          extent={{-10,10},{10,-10}}, 
    459459          rotation=90))); 
    460     Modelica_Fluid.Pipes.LumpedPipe_Old pipePump2B2( 
     460    Modelica_Fluid.Pipes.ToBeRemoved.LumpedPipe_Old pipePump2B2( 
    461461      redeclare package Medium = BatchMedium, 
    462462      length=1, 
  • Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/HeatExchangers.mo

    r1945 r1949  
    323323 
    324324    //Pressure drop and heat transfer 
    325     replaceable package WallFriction_1 =  
    326         Modelica_Fluid.PressureLosses.BaseClasses.WallFriction.QuadraticTurbulent 
     325    replaceable model PressureDrop_1 =  
     326        Modelica_Fluid.Pipes.BaseClasses.PressureDrop.QuadraticTurbulentFlow  
    327327      constrainedby 
    328       Modelica_Fluid.PressureLosses.BaseClasses.WallFriction.PartialWallFriction 
    329       "Characteristic of wall friction"                                                            annotation(choicesAllMatching, Dialog(tab="General", group="Fluid 1")); 
    330     replaceable package WallFriction_2 =  
    331         Modelica_Fluid.PressureLosses.BaseClasses.WallFriction.QuadraticTurbulent 
     328      Modelica_Fluid.Pipes.BaseClasses.PressureDrop.PartialPipePressureDrop 
     329      "Characteristic of wall friction"                                                                                                   annotation(choicesAllMatching, Dialog(tab="General", group="Fluid 1")); 
     330    replaceable model PressureDrop_2 =  
     331        Modelica_Fluid.Pipes.BaseClasses.PressureDrop.QuadraticTurbulentFlow  
    332332      constrainedby 
    333       Modelica_Fluid.PressureLosses.BaseClasses.WallFriction.PartialWallFriction 
    334       "Characteristic of wall friction"                                                            annotation(choicesAllMatching, Dialog(tab="General", group="Fluid 2")); 
     333      Modelica_Fluid.Pipes.BaseClasses.PressureDrop.PartialPipePressureDrop 
     334      "Characteristic of wall friction"                                                                                                   annotation(choicesAllMatching, Dialog(tab="General", group="Fluid 2")); 
    335335    parameter SI.Length roughness_1=2.5e-5 
    336336      "Absolute roughness of pipe (default = smooth steel pipe)" annotation(Dialog(tab="General", group="Fluid 1")); 
    337337    parameter SI.Length roughness_2=2.5e-5 
    338338      "Absolute roughness of pipe (default = smooth steel pipe)" annotation(Dialog(tab="General", group="Fluid 2")); 
    339     parameter SI.DynamicViscosity eta_nominal_1=Medium_1.dynamicViscosity(Medium_1.setState_pTX(Medium_1.p_default, Medium_1.T_default, Medium_1.X_default)) 
    340       "Nominal dynamic viscosity (e.g. eta_liquidWater = 1e-3, eta_air = 1.8e-5)" 
    341                                                                                              annotation(Dialog(tab="Advanced", group="Fluid 1", enable=use_eta_nominal)); 
    342     parameter SI.DynamicViscosity eta_nominal_2=Medium_2.dynamicViscosity(Medium_2.setState_pTX(Medium_2.p_default, Medium_2.T_default, Medium_2.X_default)) 
    343       "Nominal dynamic viscosity (e.g. eta_liquidWater = 1e-3, eta_air = 1.8e-5)" 
    344                                                                                          annotation(Dialog(tab="Advanced", group="Fluid 2", enable=use_eta_nominal)); 
    345     parameter SI.Density d_nominal_1 = Medium_1.density_pTX(Medium_1.p_default, Medium_1.T_default, Medium_1.X_default) 
    346       "Nominal density (e.g. d_liquidWater = 995, d_air = 1.2)"  
    347        annotation(Dialog(tab="Advanced", group="Fluid 1", enable=use_eta_nominal)); 
    348     parameter SI.Density d_nominal_2 = Medium_1.density_pTX(Medium_2.p_default, Medium_2.T_default, Medium_2.X_default) 
    349       "Nominal density (e.g. d_liquidWater = 995, d_air = 1.2)"  
    350        annotation(Dialog(tab="Advanced", group="Fluid 2", enable=use_eta_nominal)); 
    351     parameter Boolean use_eta_nominal=false 
    352       "= true, if eta_ and d_nominal are used, otherwise computed from media" annotation(Evaluate=true, Dialog(tab="Advanced", group="Pressure loss")); 
     339  /* 
     340  parameter Boolean use_nominal=false  
     341    "= true, if eta_ and d_nominal are used, otherwise computed from media" annotation(Evaluate=true, Dialog(tab="Advanced", group="Pressure drop")); 
     342  parameter SI.DynamicViscosity eta_nominal_1=Medium_1.dynamicViscosity(Medium_1.setState_pTX(Medium_1.p_default, Medium_1.T_default, Medium_1.X_default))  
     343    "Nominal dynamic viscosity (e.g. eta_liquidWater = 1e-3, eta_air = 1.8e-5)" 
     344                                                                                           annotation(Dialog(tab="Advanced", group="Fluid 1", enable=use_nominal)); 
     345  parameter SI.DynamicViscosity eta_nominal_2=Medium_2.dynamicViscosity(Medium_2.setState_pTX(Medium_2.p_default, Medium_2.T_default, Medium_2.X_default))  
     346    "Nominal dynamic viscosity (e.g. eta_liquidWater = 1e-3, eta_air = 1.8e-5)" 
     347                                                                                       annotation(Dialog(tab="Advanced", group="Fluid 2", enable=use_nominal)); 
     348  parameter SI.Density d_nominal_1 = Medium_1.density_pTX(Medium_1.p_default, Medium_1.T_default, Medium_1.X_default)  
     349    "Nominal density (e.g. d_liquidWater = 995, d_air = 1.2)"  
     350     annotation(Dialog(tab="Advanced", group="Fluid 1", enable=use_nominal)); 
     351  parameter SI.Density d_nominal_2 = Medium_1.density_pTX(Medium_2.p_default, Medium_2.T_default, Medium_2.X_default)  
     352    "Nominal density (e.g. d_liquidWater = 995, d_air = 1.2)"  
     353     annotation(Dialog(tab="Advanced", group="Fluid 2", enable=use_nominal)); 
     354*/ 
    353355    //Display variables 
    354356    SI.HeatFlowRate Q_flow_1 "Total heat flow rate of pipe 1"; 
    355357    SI.HeatFlowRate Q_flow_2 "Total heat flow rate of pipe 2"; 
    356358 
    357     Modelica_Fluid.Pipes.DistributedPipe_Old pipe_1( 
     359    Modelica_Fluid.Pipes.DistributedPipe pipe_1( 
    358360      redeclare package Medium = Medium_1, 
    359361      isCircular=false, 
     
    372374      perimeter=perimeter_1, 
    373375      crossArea=crossArea_1, 
    374       redeclare package WallFriction = WallFriction_1, 
    375376      roughness=roughness_1, 
    376       use_eta_nominal=use_eta_nominal, 
     377      redeclare model PressureDrop = PressureDrop_1)   annotation (Placement(transformation(extent={{-40,-80}, 
     378              {20,-20}},        rotation=0))); 
     379  /* 
     380      (use_nominal=use_nominal, 
    377381      eta_nominal=eta_nominal_1, 
    378       d_nominal=d_nominal_1)   annotation (Placement(transformation(extent={{-40,-80}, 
    379               {20,-20}},        rotation=0))); 
    380  
    381     Modelica_Fluid.Pipes.DistributedPipe_Old pipe_2( 
     382      d_nominal=d_nominal_1) 
     383*/ 
     384 
     385    Modelica_Fluid.Pipes.DistributedPipe pipe_2( 
    382386      redeclare package Medium = Medium_2, 
    383387      nNodes=nNodes, 
     
    398402      p_a_start=p_a_start1, 
    399403      p_b_start=p_b_start2, 
    400       redeclare package WallFriction = WallFriction_2, 
    401404      roughness=roughness_2, 
    402       use_eta_nominal=use_eta_nominal, 
    403       eta_nominal=eta_nominal_2, 
    404       d_nominal=d_nominal_2, 
    405       show_Re=false)  
     405      redeclare model PressureDrop = PressureDrop_2)  
    406406                annotation (Placement(transformation(extent={{20,88},{-40,28}}, 
    407407            rotation=0))); 
     408  /* 
     409      (use_nominal=use_nominal, 
     410      eta_nominal=eta_nominal_2, 
     411      d_nominal=d_nominal_2) 
     412*/ 
    408413    annotation (Diagram(coordinateSystem(preserveAspectRatio=true,  extent={{-100, 
    409414              -100},{100,100}}, 
  • Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/Pipes.mo

    <
    r1946 r1949  
    1313                   Medium.setState_phX(port_b.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow))}, 
    1414            final allowFlowReversal=allowFlowReversal, 
     15            final dynamicsType=Modelica_Fluid.Types.Dynamics.SteadyState, 
     16            final initType=Modelica_Fluid.Types.Init.SteadyState, 
    1517            final p_a_start=p_a_start, 
    1618            final p_b_start=p_b_start, 
     
    188190 
    189191    // Discretization 
    190     parameter Integer nNodes(min=1)=1 "Number of discrete flow volumes"; 
     192    parameter Integer nNodes(min=1)=1 "Number of discrete flow volumes"  
     193      annotation(Dialog(tab="Advanced"),Evaluate=true); 
    191194 
    192195    parameter Types.ModelStructure modelStructure=Types.ModelStructure.a_v_b 
    193       "Determines whether flow or volume models are present at the ports"                              annotation(Evaluate=true); 
     196      "Determines whether flow or volume models are present at the ports"  
     197      annotation(Dialog(tab="Advanced"), Evaluate=true); 
    194198 
    195199    parameter Boolean lumpedPressure=false 
    196       "=true to lump all pressure nodes into one"  
    197       annotation(Dialog(tab="Advanced", group="Pressure drop"),Evaluate=true); 
     200      "=true to lump all pressure states into one"  
     201      annotation(Dialog(tab="Advanced"),Evaluate=true); 
     202    final parameter Integer nFlows=if lumpedPressure then nFlowsLumped else nFlowsDistributed 
     203      "number of flow models in pressureDrop"; 
     204    final parameter Integer nFlowsDistributed=if modelStructure==Types.ModelStructure.a_v_b then n+1 else if (modelStructure==Types.ModelStructure.a_vb or modelStructure==Types.ModelStructure.av_b) then n else n-1; 
     205    final parameter Integer nFlowsLumped=if modelStructure==Types.ModelStructure.a_v_b then 2 else if (modelStructure==Types.ModelStructure.a_vb or modelStructure==Types.ModelStructure.av_b) then 1 else 0; 
    198206    final parameter Integer iLumped=integer(n/2)+1 
    199       "Index of control volume that representative state"                   annotation(Evaluate=true); 
    200     final parameter Integer nFlowsLumped=if modelStructure==Types.ModelStructure.a_v_b then 2 else if (modelStructure==Types.ModelStructure.a_vb or modelStructure==Types.ModelStructure.av_b) then 1 else 0; 
    201     final parameter Integer nFlowsDistributed=if modelStructure==Types.ModelStructure.a_v_b then n+1 else if (modelStructure==Types.ModelStructure.a_vb or modelStructure==Types.ModelStructure.av_b) then n else n-1; 
    202     final parameter Integer nFlows=if lumpedPressure then nFlowsLumped else nFlowsDistributed; 
     207      "Index of control volume with representative state if lumpedPressure"  
     208      annotation(Evaluate=true); 
    203209 
    204210    // Advanced model options 
    205211    parameter Boolean use_approxPortProperties=false 
    206       "=true, port properties for pressure drop correlation are taken from neighboring control volume" 
    207       annotation(Dialog(tab="Advanced", group="Pressure drop"),Evaluate=true); 
     212      "=true to take port properties for pressure drops from internal control volumes" 
     213      annotation(Dialog(tab="Advanced"),Evaluate=true); 
    208214    Medium.ThermodynamicState state_a "state defined by volume outside port_a"; 
    209215    Medium.ThermodynamicState state_b "state defined by volume outside port_b"; 
     
    211217      "state vector for pressureDrop model"; 
    212218 
     219    // Pressure drop model 
    213220    replaceable PressureDrop pressureDrop( 
    214221            redeclare final package Medium = Medium, 
     
    216223            state=flowState, 
    217224            final allowFlowReversal=allowFlowReversal, 
     225            final dynamicsType=dynamicsType, 
     226            final initType=initType, 
    218227            final p_a_start=p_a_start, 
    219228            final p_b_start=p_b_start, 
     
    229238 
    230239    // Flow quantities 
    231     Medium.MassFlowRate[n+1] m_flow(each min=if allowFlowReversal then -Modelica.Constants.inf else  
    232                 0, each start=m_flow_start) 
     240    Medium.MassFlowRate[n+1] m_flow( 
     241       each min=if allowFlowReversal then -Modelica.Constants.inf else 0, 
     242       each start=m_flow_start) 
    233243      "Mass flow rates of fluid across segment boundaries"; 
    234244    Medium.MassFlowRate[n+1, Medium.nXi] mXi_flow 
     
    268278 
    269279    // Source/sink terms for mass and energy balances 
    270     fluidVolume=fill(V/nNodes, n); 
     280    fluidVolume=fill(V/n, n); 
    271281    Ws_flow=zeros(n); 
    272282    for i in 1:n loop 
    273283      ms_flow[i] = m_flow[i] - m_flow[i + 1]; 
    274284      msXi_flow[i, :] = mXi_flow[i, :] - mXi_flow[i + 1, :]; 
    275     end for; 
    276     for i in 1:n loop 
    277285      Hs_flow[i] = H_flow[i] - H_flow[i + 1]; 
    278286    end for; 
     
    289297 
    290298    // Boundary conditions 
    291     port_a.h_outflow = medium[1].h; 
    292     port_b.h_outflow = medium[nNodes].h; 
    293299    port_a.m_flow    = m_flow[1]; 
    294300    port_b.m_flow    = -m_flow[n + 1]; 
     301    port_a.h_outflow = medium[1].h; 
     302    port_b.h_outflow = medium[n].h; 
     303    port_a.Xi_outflow = medium[1].Xi; 
     304    port_b.Xi_outflow = medium[n].Xi; 
    295305    port_a.C_outflow = inStream(port_b.C_outflow); 
    296306    port_b.C_outflow = inStream(port_a.C_outflow); 
     
    301311    else 
    302312      state_a = Medium.setState_phX(port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow)); 
    303       state_b = Medium.setState_phX(port_a.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow)); 
     313      state_b = Medium.setState_phX(port_b.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow)); 
    304314    end if; 
    305315 
     
    307317      fill(medium[1].p, n-1) = medium[2:n].p; 
    308318      if modelStructure == ModelStructure.a_v_b then 
     319        m_flow[1] = pressureDrop.m_flow[1]; 
    309320        flowState[1] = state_a; 
    310321        flowState[2] = medium[iLumped].state; 
    311322        flowState[3] = state_b; 
     323        m_flow[n+1] = pressureDrop.m_flow[2]; 
    312324      elseif modelStructure == ModelStructure.av_b then 
     325        port_a.p = medium[1].p; 
    313326        flowState[1] = medium[iLumped].state; 
    314327        flowState[2] = state_b; 
     328        m_flow[n+1] = pressureDrop.m_flow[1]; 
    315329      elseif modelStructure == ModelStructure.a_vb then 
     330        m_flow[1] = pressureDrop.m_flow[1]; 
    316331        flowState[1] = state_a; 
    317332        flowState[2] = medium[iLumped].state; 
     333        port_b.p = medium[n].p; 
    318334      else // avb 
     335        port_a.p = medium[1].p; 
    319336        flowState[1] = medium[iLumped].state; 
     337        port_b.p = medium[n].p; 
    320338      end if; 
    321       m_flow[1] = pressureDrop.m_flow[1]; 
    322       m_flow[n+1] = pressureDrop.m_flow[nFlows]; 
    323339    else 
    324340      if modelStructure == ModelStructure.a_v_b then 
     
    428444  end DistributedPipe; 
    429445 
    430   model StaticPipe_Old 
    431     "Basic pipe flow model without storage of mass or energy" 
    432     extends Modelica_Fluid.Pipes.BaseClasses.PartialPipe_Old( 
    433        redeclare model HeatTransfer=BaseClasses.HeatTransfer.PipeHT_ideal); 
    434     PressureLosses.WallFrictionAndGravity wallFriction( 
    435       redeclare package Medium = Medium, 
    436       allowFlowReversal=allowFlowReversal, 
    437       redeclare package WallFriction = WallFriction, 
    438       roughness=roughness, 
    439       eta_nominal=eta_nominal, 
    440       d_nominal=d_nominal, 
    441       dp_small=dp_small, 
    442       m_flow_start=m_flow_start, 
    443       compute_T=false, 
    444       show_Re=show_Re, 
    445       from_dp=from_dp, 
    446       diameter=diameter_h, 
    447       reg_m_flow_small=m_flow_small, 
    448       m_flow_small=m_flow_small, 
    449       dp_start=(p_a_start - p_b_start), 
    450       length=length, 
    451       height_ab=height_ab, 
    452       use_nominal=use_eta_nominal or use_d_nominal)  
    453       annotation (Placement(transformation(extent={{-10,-10},{10,10}}, 
    454             rotation=0))); 
    455   equation 
    456     connect(port_a, wallFriction.port_a) annotation (Line( 
    457         points={{-100,0},{-10,0}}, 
    458         color={0,127,255}, 
    459         smooth=Smooth.None)); 
    460     connect(wallFriction.port_b, port_b) annotation (Line( 
    461         points={{10,0},{100,0}}, 
    462         color={0,127,255}, 
    463         smooth=Smooth.None)); 
    464     annotation (defaultComponentName="pipe", Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100, 
    465               -100},{100,100}}),      graphics)); 
    466   end StaticPipe_Old; 
    467  
    468   model LumpedPipe_Old 
    469     // Assumptions 
    470     parameter Modelica_Fluid.Types.Dynamics dynamicsType=system.dynamicsType 
    471       "Dynamics option"  
    472       annotation(Evaluate=true, Dialog(tab = "Assumptions")); 
    473  
    474     // Initialization 
    475     parameter Types.Init initType=system.initType "Initialization option"  
    476       annotation(Evaluate=true, Dialog(tab = "Initialization")); 
    477  
    478     // Extend here to get right ordering in parameter box 
    479     extends Modelica_Fluid.Pipes.BaseClasses.PartialPipe_Old; 
    480  
    481      //Initialization 
    482     parameter Boolean use_T_start=true "Use T_start if true, otherwise h_start" 
    483        annotation(Evaluate=true, Dialog(tab = "Initialization")); 
    484     parameter Medium.Temperature T_start=if use_T_start then system.T_start else  
    485                 Medium.temperature_phX( 
    486           (p_a_start + p_b_start)/2, 
    487           h_start, 
    488           X_start) "Start value of temperature"  
    489       annotation(Evaluate=true, Dialog(tab = "Initialization", enable = use_T_start)); 
    490     parameter Medium.SpecificEnthalpy h_start=if use_T_start then  
    491           Medium.specificEnthalpy_pTX( 
    492           (p_a_start + p_b_start)/2, 
    493           T_start, 
    494           X_start) else Medium.h_default "Start value of specific enthalpy"  
    495       annotation(Evaluate=true, Dialog(tab = "Initialization", enable = not use_T_start)); 
    496     parameter Medium.MassFraction X_start[Medium.nX]=Medium.X_default 
    497       "Start value of mass fractions m_i/m"  
    498       annotation (Dialog(tab="Initialization", enable=Medium.nXi > 0)); 
    499  
    500     replaceable HeatTransfer heatTransfer( 
    501       redeclare final package Medium = Medium, 
    502       final n=1, 
    503       diameter=4*crossArea/perimeter, 
    504       area=perimeter*length, 
    505       final crossArea=crossArea, 
    506       final length=length, 
    507       state={volume.medium.state}, 
    508       m_flow = {0.5*(port_a.m_flow - port_b.m_flow)}, 
    509       final useFluidHeatPort=true) "Edit heat transfer parameters"  
    510       annotation (editButton=true, Placement(transformation(extent={{-20,0},{20,40}},   rotation=0))); 
    511  
    512     Modelica_Fluid.PressureLosses.WallFrictionAndGravity wallFriction1( 
    513       redeclare package Medium = Medium, 
    514       allowFlowReversal=allowFlowReversal, 
    515       redeclare package WallFriction = WallFriction, 
    516       length=length/2, 
    517       height_ab=height_ab/2, 
    518       roughness=roughness, 
    519       eta_nominal=eta_nominal, 
    520       d_nominal=d_nominal, 
    521       dp_small=dp_small, 
    522       dp_start = (p_a_start - p_b_start)/2, 
    523       m_flow_start = m_flow_start, 
    524       compute_T=false, 
    525       show_Re=show_Re, 
    526       from_dp=from_dp, 
    527       diameter=diameter_h, 
    528       reg_m_flow_small=m_flow_small, 
    529       m_flow_small=m_flow_small, 
    530       use_nominal=use_eta_nominal or use_d_nominal)  
    531       annotation (Placement(transformation(extent={{-60,-30},{-40,-10}}, 
    532             rotation=0))); 
    533     Modelica_Fluid.Volumes.Volume volume( 
    534       redeclare package Medium = Medium, 
    535       initType=initType, 
    536       p_start=(p_a_start+p_b_start)/2, 
    537       use_T_start=use_T_start, 
    538       T_start=T_start, 
    539       h_start=h_start, 
    540       X_start=X_start, 
    541       dynamicsType=dynamicsType, 
    542       V=V, 
    543       nPorts=2, 
    544       portDiameters={0,0}, 
    545       neglectPortDiameters=true)  
    546       annotation (Placement(transformation(extent={{-10,-30},{10,-10}},rotation= 
    547              0))); 
    548     Modelica_Fluid.PressureLosses.WallFrictionAndGravity wallFriction2( 
    549       redeclare package Medium = Medium, 
    550       allowFlowReversal=allowFlowReversal, 
    551       redeclare package WallFriction = WallFriction, 
    552       length=length/2, 
    553       height_ab=height_ab/2, 
    554       roughness=roughness, 
    555       eta_nominal=eta_nominal, 
    556       d_nominal=d_nominal, 
    557       dp_small=dp_small, 
    558       dp_start = (p_a_start - p_b_start)/2, 
    559       m_flow_start = m_flow_start, 
    560       compute_T=false, 
    561       show_Re=show_Re, 
    562       from_dp=from_dp, 
    563       m_flow_small=m_flow_small, 
    564       diameter=diameter_h, 
    565       reg_m_flow_small=m_flow_small, 
    566       use_nominal=use_eta_nominal or use_d_nominal)  
    567                                     annotation (Placement(transformation(extent={{40,-30}, 
    568               {60,-10}},         rotation=0))); 
    569     Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort  
    570       annotation (Placement(transformation(extent={{-10,44},{10,64}}, rotation= 
    571               0))); 
    572   equation 
    573     connect(wallFriction1.port_a, port_a)  
    574       annotation (Line(points={{-60,-20},{-80,-20},{-80,0},{-100,0}}, 
    575                                                   color={0,127,255})); 
    576     connect(wallFriction2.port_b, port_b)  
    577       annotation (Line(points={{60,-20},{80,-20},{80,0},{100,0}}, 
    578                                                 color={0,127,255})); 
    579     connect(heatPort, heatTransfer.wallHeatPort[1]) annotation (Line( 
    580         points={{0,54},{0,34}}, 
    581         color={191,0,0}, 
    582         smooth=Smooth.None)); 
    583     connect(heatTransfer.fluidHeatPort[1], volume.heatPort) annotation (Line( 
    584         points={{0,8},{0,-10.2}}, 
    585         color={191,0,0}, 
    586         smooth=Smooth.None)); 
    587     annotation (defaultComponentName="pipe",Icon(coordinateSystem( 
    588           preserveAspectRatio=false, 
    589           extent={{-100,-100},{100,100}}, 
    590           grid={1,1}), graphics={Ellipse( 
    591             extent={{-10,10},{10,-10}}, 
    592             lineColor={0,0,0}, 
    593             fillColor={0,0,0}, 
    594             fillPattern=FillPattern.Solid)}),Documentation(info="<html> 
    595 <p> 
    596 Simple pipe model consisting of one volume,  
    597 wall friction (with different friction correlations) 
    598 and gravity effect. This model is mostly used to demonstrate how 
    599 to build up more detailed models from the basic components. 
    600 Note, if the \"heatPort\" is not connected, then the pipe 
    601 is totally insulated (= no thermal flow from the fluid to the 
    602 pipe wall/environment). 
    603 </p> 
    604 </html>"), 
    605       Diagram(coordinateSystem( 
    606           preserveAspectRatio=true, 
    607           extent={{-100,-100},{100,100}}, 
    608           grid={1,1}), graphics)); 
    609     connect(wallFriction1.port_b, volume.ports[1]) annotation (Line( 
    610         points={{-40,-20},{-25,-20},{-25,-40},{0,-40},{0,-28}}, 
    611         color={0,127,255}, 
    612         smooth=Smooth.None)); 
    613     connect(wallFriction2.port_a, volume.ports[2]) annotation (Line( 
    614         points={{40,-20},{24,-20},{24,-40},{0,-40},{0,-32}}, 
    615         color={0,127,255}, 
    616         smooth=Smooth.None)); 
    617   end LumpedPipe_Old; 
    618  
    619  model DistributedPipeLumpedPressure_Old 
    620     "Distributed pipe model with lumped pressure state" 
    621     import Modelica_Fluid.Types.ModelStructure; 
    622    extends Modelica_Fluid.Pipes.BaseClasses.PartialDistributedFlow_Old( 
    623      Qs_flow=heatTransfer.Q_flow, 
    624      final port_a_exposesState = (modelStructure == ModelStructure.av_b) or (modelStructure == ModelStructure.avb), 
    625      final port_b_exposesState = (modelStructure == ModelStructure.a_vb) or (modelStructure == ModelStructure.avb)); 
    626  
    627    parameter Types.ModelStructure modelStructure=Types.ModelStructure.a_v_b 
    628       "Determines whether flow or volume models are present at the ports"                             annotation(Evaluate=true); 
    629  
    630    final parameter Integer nl=integer(n/2)+1 
    631       "Number of control volume that contains single pressure state"                  annotation(Evaluate=true); 
    632  
    633    final parameter SI.Pressure[2] dp_start = {p_a_start - p_start[nl], p_start[nl] - p_b_start}; 
    634    SI.Pressure[2] dp(start=dp_start) 
    635       "Pressure difference across staggered grid"; 
    636  
    637    SI.ReynoldsNumber[n+1] Re=Modelica_Fluid.Utilities.ReynoldsNumber_m_flow( 
    638        m_flow, 
    639        (cat(1, {eta_a}, eta) + cat(1, eta, {eta_b}))*0.5, 
    640        diameter) if                                                                                              show_Re 
    641       "Reynolds number of pipe flow"; 
    642    HeatTransfer heatTransfer( 
    643      redeclare final package Medium = Medium, 
    644      final n=nNodes, 
    645      diameter=4*crossArea/perimeter, 
    646      area=perimeter*length, 
    647      final crossArea=crossArea, 
    648      final length=length, 
    649      state=medium.state, 
    650      m_flow = 0.5*(m_flow[1:n]+m_flow[2:n+1])) "Edit heat transfer parameters"  
    651              annotation (Placement(transformation(extent={{-20,-5},{20,35}},  rotation=0))); 
    652  
    653    SI.Length[2] dlength "discretized length for pressure drop"; 
    654    SI.Length[2] dheight_ab "discretized height_ab for static head"; 
    655  
    656   protected 
    657    SI.DynamicViscosity eta_a=if not WallFriction.use_eta then 1.e-10 else (if  
    658        use_eta_nominal then eta_nominal else (if use_approxPortProperties then Medium.dynamicViscosity(medium[1].state) else Medium.dynamicViscosity(Medium.setState_phX(port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow))))); 
    659    SI.DynamicViscosity eta_b=if not WallFriction.use_eta then 1.e-10 else (if use_eta_nominal then eta_nominal else (if use_approxPortProperties then Medium.dynamicViscosity(medium[n].state) else Medium.dynamicViscosity(Medium.setState_phX(port_b.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow))))); 
    660  
    661  equation 
    662    // Only one connection allowed to a port to avoid unwanted ideal mixing 
    663    assert(cardinality(port_a) <= 1 or (modelStructure == ModelStructure.a_vb) or (modelStructure == ModelStructure.a_v_b)," 
    664 port_a exposing volume with selected modelStructure shall at most be connected to one component. 
    665 If two or more connections are present, ideal mixing takes 
    666 place with these connections which is usually not the intention 
    667 of the modeller. Use a Junctions.MultiPort. 
    668 "); 
    669    assert(cardinality(port_b) <= 1 or (modelStructure == ModelStructure.av_b) or (modelStructure == ModelStructure.a_v_b)," 
    670 port_b exposing volume with selected modelStructure shall at most be connected to one component. 
    671 If two or more connections are present, ideal mixing takes 
    672 place with these connections which is usually not the intention 
    673 of the modeller. Use a Junctions.MultiPort. 
    674 "); 
    675  
    676    Ws_flow=zeros(n); 
    677    fluidVolume=ones(n)*V/n; 
    678  
    679    //Momentum Balance, dp contains contributions from acceleration, gravitational and friction effects 
    680    //two momentum balances, one on each side of pressure state 
    681    dp = {port_a.p - p[nl], p[nl] - port_b.p}; 
    682    //lumped pressure 
    683    p[1]*ones(n-1) = p[2:n]; 
    684  
    685    if modelStructure == ModelStructure.a_v_b then 
    686      dlength[1] = ((integer(n/2) + 1)*2 - 1)/(2*n)*length; 
    687      dlength[2] = (2*n - (integer(n/2) + 1)*2 + 1)/(2*n)*length; 
    688    elseif modelStructure == ModelStructure.av_b then 
    689      dlength = {0, length}; 
    690    elseif modelStructure == ModelStructure.a_vb then 
    691      dlength = {length, 0}; 
    692    else // avb 
    693      dlength = {0, 0}; 
    694    end if; 
    695    dheight_ab = dlength/length*height_ab; 
    696  
    697   if from_dp and not WallFriction.dp_is_zero then 
    698     if port_a_exposesState then 
    699       port_a.p = p[1]; 
    700     else 
    701       m_flow[1] = WallFriction.massFlowRate_dp_staticHead( 
    702         dp[1], 
    703         d_a, 
    704         d_b, 
    705         eta_a, 
    706         eta_b, 
    707         dlength[1], 
    708         diameter_h, 
    709         dheight_ab[1]*system.g, 
    710         roughness, 
    711         dp_small); 
    712     end if; 
    713     if port_b_exposesState then 
    714       port_b.p = p[n]; 
    715     else 
    716       m_flow[n + 1] = WallFriction.massFlowRate_dp_staticHead( 
    717         dp[2], 
    718         d_a, 
    719         d_b, 
    720         eta_a, 
    721         eta_b, 
    722         dlength[2], 
    723         diameter_h, 
    724         dheight_ab[2]*system.g, 
    725         roughness, 
    726         dp_small); 
    727      end if; 
    728   else 
    729     if port_a_exposesState then 
    730       port_a.p = p[1]; 
    731     else 
    732       dp[1] = WallFriction.pressureLoss_m_flow_staticHead( 
    733         m_flow[1], 
    734         d_a, 
    735         d_b, 
    736         eta_a, 
    737         eta_b, 
    738         dlength[1], 
    739         diameter_h, 
    740         dheight_ab[1]*system.g, 
    741         roughness, 
    742         m_flow_small); 
    743     end if; 
    744     if port_b_exposesState then 
    745       port_b.p = p[n]; 
    746     else 
    747       dp[2] = WallFriction.pressureLoss_m_flow_staticHead( 
    748         m_flow[n+1], 
    749         d_a, 
    750         d_b, 
    751         eta_a, 
    752         eta_b, 
    753         dlength[2], 
    754         diameter_h, 
    755         dheight_ab[2]*system.g, 
    756         roughness, 
    757         m_flow_small); 
    758     end if; 
    759   end if; 
    760  
    761    connect(heatPorts, heatTransfer.wallHeatPort)  
    762      annotation (Line(points={{0,54},{0,29}}, color={191,0,0})); 
    763    annotation (defaultComponentName="pipe", 
    764      Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100, 
    765               100}}, 
    766           grid={1,1}), graphics={ 
    767           Ellipse( 
    768             extent={{-72,10},{-52,-10}}, 
    769             lineColor={0,0,0}, 
    770             fillColor={0,0,0}, 
    771