Changeset 1949
- Timestamp:
- 12/05/2008 06:48:56 AM (5 weeks ago)
- Location:
- Modelica_Fluid/branches/StreamConnector/Modelica_Fluid
- Files:
-
- 2 added
- 7 modified
-
Examples/AST_BatchPlant.mo (modified) (3 diffs)
-
HeatExchangers.mo (modified) (3 diffs)
-
Pipes.mo (modified) (16 diffs)
-
Test/TestComponents/HeatExchangers/TestHeatExchanger.mo (modified) (2 diffs)
-
Test/TestComponents/Pipes/StaticPipe.mo (added)
-
Test/TestCriticalCases.mo (modified) (1 diff)
-
Test/TestOverdeterminedSteadyStateInit.mo (modified) (3 diffs)
-
Volumes.mo (modified) (1 diff)
-
clean.bat (added)
Legend:
- Unmodified
- Added
- Removed
-
Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/Examples/AST_BatchPlant.mo
r1946 r1949 382 382 annotation (Placement(transformation(extent={{-100, 383 383 -140},{-60,-100}}, rotation=0))); 384 Modelica_Fluid.Pipes. LumpedPipe_Old pipeB1B2(384 Modelica_Fluid.Pipes.ToBeRemoved.LumpedPipe_Old pipeB1B2( 385 385 redeclare package Medium = BatchMedium, 386 386 length=1, … … 447 447 extent={{-10,10},{10,-10}}, 448 448 rotation=90))); 449 Modelica_Fluid.Pipes. LumpedPipe_Old pipePump1B1(449 Modelica_Fluid.Pipes.ToBeRemoved.LumpedPipe_Old pipePump1B1( 450 450 redeclare package Medium = BatchMedium, 451 451 length=1, … … 458 458 extent={{-10,10},{10,-10}}, 459 459 rotation=90))); 460 Modelica_Fluid.Pipes. LumpedPipe_Old pipePump2B2(460 Modelica_Fluid.Pipes.ToBeRemoved.LumpedPipe_Old pipePump2B2( 461 461 redeclare package Medium = BatchMedium, 462 462 length=1, -
Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/HeatExchangers.mo
r1945 r1949 323 323 324 324 //Pressure drop and heat transfer 325 replaceable package WallFriction_1 =326 Modelica_Fluid.P ressureLosses.BaseClasses.WallFriction.QuadraticTurbulent325 replaceable model PressureDrop_1 = 326 Modelica_Fluid.Pipes.BaseClasses.PressureDrop.QuadraticTurbulentFlow 327 327 constrainedby 328 Modelica_Fluid.P ressureLosses.BaseClasses.WallFriction.PartialWallFriction329 "Characteristic of wall friction" annotation(choicesAllMatching, Dialog(tab="General", group="Fluid 1"));330 replaceable package WallFriction_2 =331 Modelica_Fluid.P ressureLosses.BaseClasses.WallFriction.QuadraticTurbulent328 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 332 332 constrainedby 333 Modelica_Fluid.P ressureLosses.BaseClasses.WallFriction.PartialWallFriction334 "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")); 335 335 parameter SI.Length roughness_1=2.5e-5 336 336 "Absolute roughness of pipe (default = smooth steel pipe)" annotation(Dialog(tab="General", group="Fluid 1")); 337 337 parameter SI.Length roughness_2=2.5e-5 338 338 "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 */ 353 355 //Display variables 354 356 SI.HeatFlowRate Q_flow_1 "Total heat flow rate of pipe 1"; 355 357 SI.HeatFlowRate Q_flow_2 "Total heat flow rate of pipe 2"; 356 358 357 Modelica_Fluid.Pipes.DistributedPipe _Oldpipe_1(359 Modelica_Fluid.Pipes.DistributedPipe pipe_1( 358 360 redeclare package Medium = Medium_1, 359 361 isCircular=false, … … 372 374 perimeter=perimeter_1, 373 375 crossArea=crossArea_1, 374 redeclare package WallFriction = WallFriction_1,375 376 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, 377 381 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 _Oldpipe_2(382 d_nominal=d_nominal_1) 383 */ 384 385 Modelica_Fluid.Pipes.DistributedPipe pipe_2( 382 386 redeclare package Medium = Medium_2, 383 387 nNodes=nNodes, … … 398 402 p_a_start=p_a_start1, 399 403 p_b_start=p_b_start2, 400 redeclare package WallFriction = WallFriction_2,401 404 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) 406 406 annotation (Placement(transformation(extent={{20,88},{-40,28}}, 407 407 rotation=0))); 408 /* 409 (use_nominal=use_nominal, 410 eta_nominal=eta_nominal_2, 411 d_nominal=d_nominal_2) 412 */ 408 413 annotation (Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100, 409 414 -100},{100,100}}, -
Modelica_Fluid/branches/StreamConnector/Modelica_Fluid/Pipes.mo
r1946 r1949 13 13 Medium.setState_phX(port_b.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow))}, 14 14 final allowFlowReversal=allowFlowReversal, 15 final dynamicsType=Modelica_Fluid.Types.Dynamics.SteadyState, 16 final initType=Modelica_Fluid.Types.Init.SteadyState, 15 17 final p_a_start=p_a_start, 16 18 final p_b_start=p_b_start, … … 188 190 189 191 // 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); 191 194 192 195 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); 194 198 195 199 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; 198 206 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); 203 209 204 210 // Advanced model options 205 211 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); 208 214 Medium.ThermodynamicState state_a "state defined by volume outside port_a"; 209 215 Medium.ThermodynamicState state_b "state defined by volume outside port_b"; … … 211 217 "state vector for pressureDrop model"; 212 218 219 // Pressure drop model 213 220 replaceable PressureDrop pressureDrop( 214 221 redeclare final package Medium = Medium, … … 216 223 state=flowState, 217 224 final allowFlowReversal=allowFlowReversal, 225 final dynamicsType=dynamicsType, 226 final initType=initType, 218 227 final p_a_start=p_a_start, 219 228 final p_b_start=p_b_start, … … 229 238 230 239 // 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) 233 243 "Mass flow rates of fluid across segment boundaries"; 234 244 Medium.MassFlowRate[n+1, Medium.nXi] mXi_flow … … 268 278 269 279 // Source/sink terms for mass and energy balances 270 fluidVolume=fill(V/n Nodes, n);280 fluidVolume=fill(V/n, n); 271 281 Ws_flow=zeros(n); 272 282 for i in 1:n loop 273 283 ms_flow[i] = m_flow[i] - m_flow[i + 1]; 274 284 msXi_flow[i, :] = mXi_flow[i, :] - mXi_flow[i + 1, :]; 275 end for;276 for i in 1:n loop277 285 Hs_flow[i] = H_flow[i] - H_flow[i + 1]; 278 286 end for; … … 289 297 290 298 // Boundary conditions 291 port_a.h_outflow = medium[1].h;292 port_b.h_outflow = medium[nNodes].h;293 299 port_a.m_flow = m_flow[1]; 294 300 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; 295 305 port_a.C_outflow = inStream(port_b.C_outflow); 296 306 port_b.C_outflow = inStream(port_a.C_outflow); … … 301 311 else 302 312 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)); 304 314 end if; 305 315 … … 307 317 fill(medium[1].p, n-1) = medium[2:n].p; 308 318 if modelStructure == ModelStructure.a_v_b then 319 m_flow[1] = pressureDrop.m_flow[1]; 309 320 flowState[1] = state_a; 310 321 flowState[2] = medium[iLumped].state; 311 322 flowState[3] = state_b; 323 m_flow[n+1] = pressureDrop.m_flow[2]; 312 324 elseif modelStructure == ModelStructure.av_b then 325 port_a.p = medium[1].p; 313 326 flowState[1] = medium[iLumped].state; 314 327 flowState[2] = state_b; 328 m_flow[n+1] = pressureDrop.m_flow[1]; 315 329 elseif modelStructure == ModelStructure.a_vb then 330 m_flow[1] = pressureDrop.m_flow[1]; 316 331 flowState[1] = state_a; 317 332 flowState[2] = medium[iLumped].state; 333 port_b.p = medium[n].p; 318 334 else // avb 335 port_a.p = medium[1].p; 319 336 flowState[1] = medium[iLumped].state; 337 port_b.p = medium[n].p; 320 338 end if; 321 m_flow[1] = pressureDrop.m_flow[1];322 m_flow[n+1] = pressureDrop.m_flow[nFlows];323 339 else 324 340 if modelStructure == ModelStructure.a_v_b then … … 428 444 end DistributedPipe; 429 445 430 model StaticPipe_Old431 "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 equation456 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_Old469 // Assumptions470 parameter Modelica_Fluid.Types.Dynamics dynamicsType=system.dynamicsType471 "Dynamics option"472 annotation(Evaluate=true, Dialog(tab = "Assumptions"));473 474 // Initialization475 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 box479 extends Modelica_Fluid.Pipes.BaseClasses.PartialPipe_Old;480 481 //Initialization482 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 else485 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 then491 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_default497 "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 heatPort570 annotation (Placement(transformation(extent={{-10,44},{10,64}}, rotation=571 0)));572 equation573 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 how599 to build up more detailed models from the basic components.600 Note, if the \"heatPort\" is not connected, then the pipe601 is totally insulated (= no thermal flow from the fluid to the602 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_Old620 "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_b628 "Determines whether flow or volume models are present at the ports" annotation(Evaluate=true);629 630 final parameter Integer nl=integer(n/2)+1631 "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_Re641 "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 protected657 SI.DynamicViscosity eta_a=if not WallFriction.use_eta then 1.e-10 else (if658 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 equation662 // Only one connection allowed to a port to avoid unwanted ideal mixing663 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 takes666 place with these connections which is usually not the intention667 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 takes672 place with these connections which is usually not the intention673 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 effects680 //two momentum balances, one on each side of pressure state681 dp = {port_a.p - p[nl], p[nl] - port_b.p};682 //lumped pressure683 p[1]*ones(n-1) = p[2:n];684 685 if modelStructure == ModelStructure.a_v_b then686 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 then689 dlength = {0, length};690 elseif modelStructure == ModelStructure.a_vb then691 dlength = {length, 0};692 else // avb693 dlength = {0, 0};694 end if;695 dheight_ab = dlength/length*height_ab;696 697 if from_dp and not WallFriction.dp_is_zero then698 if port_a_exposesState then699 port_a.p = p[1];700 else701 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 then714 port_b.p = p[n];715 else716 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 else729 if port_a_exposesState then730 port_a.p = p[1];731 else732 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 then745 port_b.p = p[n];746 else747 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 <
