Changeset 902 for branches/gui/eml
- Timestamp:
- Feb 15, 2010, 1:28:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/eml/streams.mso
r757 r902 129 129 Pallete = false; 130 130 131 PARAMETERS132 outer PP as Plugin(Brief = "External Physical Properties", Type="PP");133 134 131 VARIABLES 135 132 s as entr_mol (Brief = "Stream Entropy"); … … 140 137 s = (1-v)*PP.LiquidEntropy(T, P, x) + v*PP.VapourEntropy(T, P, y); 141 138 139 end 140 141 Model source 142 143 ATTRIBUTES 144 Pallete = true; 145 Icon = "icon/Source"; 146 Brief = "Material stream source"; 147 Info = " 148 This model should be used for boundary streams. 149 Usually these streams are known and come from another process 150 units. 151 152 The user should specify: 153 * Total molar (mass or volumetric) flow 154 * Temperature 155 * Pressure 156 * Molar or mass composition 157 158 No matter the specification set, the model will calculate some 159 additional properties: 160 * Mass density 161 * Mass flow 162 * Mass compostions 163 * Specific volume 164 * Vapour fraction 165 * Volumetric flow 166 * Liquid and Vapour compositions 167 "; 168 169 PARAMETERS 170 outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); 171 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 172 M(NComp) as molweight (Brief = "Component Mol Weight", Protected=true); 173 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid"); 174 CompositionBasis as Switcher (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar"); 175 176 SET 177 178 M = PP.MolecularWeight(); 179 180 VARIABLES 181 182 out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true); 183 184 Composition(NComp) as fraction (Brief = "Stream Composition"); 185 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true); 186 F as flow_mol (Brief = "Stream Molar Flow Rate"); 187 Fw as flow_mass (Brief = "Stream Mass Flow"); 188 Fvol as flow_vol (Brief = "Volumetric Flow"); 189 T as temperature (Brief = "Stream Temperature"); 190 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); 191 P as pressure (Brief = "Stream Pressure"); 192 193 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); 194 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); 195 196 Mw as molweight (Brief = "Average Mol Weight",Protected=true); 197 vm as volume_mol (Brief = "Molar Volume",Protected=true); 198 rho as dens_mass (Brief = "Stream Mass Density",Protected=true); 199 rhom as dens_mol (Brief = "Stream Molar Density",Protected=true); 200 201 zmass(NComp) as fraction (Brief = "Mass Fraction",Protected=true); 202 203 EQUATIONS 204 205 switch CompositionBasis 206 207 case "Molar": 208 "Stream Molar Composition" 209 Outlet.z = Composition/sum(Composition); 210 211 "Stream Mass Composition" 212 zmass = M*Outlet.z / Mw; 213 214 case "Mass": 215 "Stream Mass Composition" 216 zmass = Composition/sum(Composition); 217 218 "Stream Molar Composition" 219 Outlet.z*sum(zmass/M) = zmass/M; 220 221 end 222 223 switch ValidPhases 224 225 case "Liquid-Only": 226 227 "Vapour Fraction" 228 Outlet.v = 0; 229 230 "Liquid Composition" 231 x = Outlet.z; 232 233 "Vapour Composition" 234 y = Outlet.z; 235 236 "Overall Enthalpy" 237 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); 238 239 "Molar Volume" 240 vm = PP.LiquidVolume(Outlet.T, Outlet.P, x); 241 242 case "Vapour-Only": 243 244 "Vapor Fraction" 245 Outlet.v = 1; 246 247 "Liquid Composition" 248 x = Outlet.z; 249 250 "Vapour Composition" 251 y = Outlet.z; 252 253 "Overall Enthalpy" 254 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 255 256 "Molar Volume" 257 vm = PP.VapourVolume(Outlet.T, Outlet.P, y); 258 259 260 case "Vapour-Liquid": 261 262 "Flash Calculation" 263 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); 264 265 "Overall Enthalpy" 266 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 267 268 "Molar Volume" 269 vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y); 270 271 end 272 273 "Sum of Composition" 274 SumOfComposition = sum(Composition); 275 276 "Molar Density" 277 rhom * vm = 1; 278 279 "Average Molecular Weight" 280 Mw = sum(M*Outlet.z); 281 282 "Mass or Molar Density" 283 rhom * Mw = rho; 284 285 "Flow Mass" 286 Fw = Mw*Outlet.F; 287 288 "Volumetric Flow" 289 Fvol = Outlet.F*vm ; 290 291 "Temperature in °C" 292 T_Cdeg = Outlet.T - 273.15 * 'K'; 293 294 "Equate Flow" 295 Outlet.F = F; 296 297 "Equate Pressures" 298 Outlet.P = P; 299 300 "Equate Temperatures" 301 Outlet.T = T; 302 303 end 304 305 Model source2 306 307 ATTRIBUTES 308 Pallete = true; 309 Icon = "icon/Source2"; 310 Brief = "Material stream source"; 311 Info = " 312 This model should be used for boundary streams. 313 Usually these streams are known and come from another process 314 units. 315 316 The user should specify: 317 * Total molar (mass or volumetric) flow 318 * Temperature 319 * Pressure 320 * Molar or mass composition 321 322 No matter the specification set, the model will calculate some 323 additional properties: 324 * Mass density 325 * Mass flow 326 * Mass compostions 327 * Specific volume 328 * Vapour fraction 329 * Volumetric flow 330 * Liquid and Vapour compositions 331 "; 332 333 PARAMETERS 334 outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); 335 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 336 M(NComp) as molweight (Brief = "Component Mol Weight", Protected=true); 337 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid"); 338 CompositionBasis as Switcher (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar"); 339 340 341 SET 342 343 M = PP.MolecularWeight(); 344 345 VARIABLES 346 347 out Outlet as stream (Brief = "Outlet stream", PosX=0, PosY=0.5256, Symbol="_{out}",Protected=true); 348 349 Composition(NComp) as fraction (Brief = "Stream Composition"); 350 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true); 351 F as flow_mol (Brief = "Stream Molar Flow Rate"); 352 Fw as flow_mass (Brief = "Stream Mass Flow"); 353 Fvol as flow_vol (Brief = "Volumetric Flow"); 354 T as temperature (Brief = "Stream Temperature"); 355 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); 356 P as pressure (Brief = "Stream Pressure"); 357 358 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); 359 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); 360 361 Mw as molweight (Brief = "Average Mol Weight",Protected=true); 362 vm as volume_mol (Brief = "Molar Volume",Protected=true); 363 rho as dens_mass (Brief = "Stream Mass Density",Protected=true); 364 rhom as dens_mol (Brief = "Stream Molar Density",Protected=true); 365 366 zmass(NComp) as fraction (Brief = "Mass Fraction",Protected=true); 367 368 EQUATIONS 369 370 switch CompositionBasis 371 372 case "Molar": 373 "Stream Molar Composition" 374 Outlet.z = Composition/sum(Composition); 375 376 "Stream Mass Composition" 377 zmass = M*Outlet.z / Mw; 378 379 case "Mass": 380 "Stream Mass Composition" 381 zmass = Composition/sum(Composition); 382 383 "Stream Molar Composition" 384 Outlet.z*sum(zmass/M) = zmass/M; 385 386 end 387 388 switch ValidPhases 389 390 case "Liquid-Only": 391 392 "Vapour Fraction" 393 Outlet.v = 0; 394 395 "Liquid Composition" 396 x = Outlet.z; 397 398 "Vapour Composition" 399 y = Outlet.z; 400 401 "Overall Enthalpy" 402 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); 403 404 "Molar Volume" 405 vm = PP.LiquidVolume(Outlet.T, Outlet.P, x); 406 407 case "Vapour-Only": 408 409 "Vapor Fraction" 410 Outlet.v = 1; 411 412 "Liquid Composition" 413 x = Outlet.z; 414 415 "Vapour Composition" 416 y = Outlet.z; 417 418 "Overall Enthalpy" 419 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 420 421 "Molar Volume" 422 vm = PP.VapourVolume(Outlet.T, Outlet.P, y); 423 424 425 case "Vapour-Liquid": 426 427 "Flash Calculation" 428 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); 429 430 "Overall Enthalpy" 431 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 432 433 "Molar Volume" 434 vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y); 435 436 end 437 438 "Sum of Composition" 439 SumOfComposition = sum(Composition); 440 441 "Molar Density" 442 rhom * vm = 1; 443 444 "Average Molecular Weight" 445 Mw = sum(M*Outlet.z); 446 447 "Mass or Molar Density" 448 rhom * Mw = rho; 449 450 "Flow Mass" 451 Fw = Mw*Outlet.F; 452 453 "Volumetric Flow" 454 Fvol = Outlet.F*vm ; 455 456 "Temperature in °C" 457 T_Cdeg = Outlet.T - 273.15 * 'K'; 458 459 "Equate Flow" 460 Outlet.F = F; 461 462 "Equate Pressures" 463 Outlet.P = P; 464 465 "Equate Temperatures" 466 Outlet.T = T; 467 468 end 469 470 Model simple_source 471 472 ATTRIBUTES 473 Pallete = true; 474 Icon = "icon/Source"; 475 Brief = "Simple Material stream source"; 476 Info = " 477 This model should be used for boundary streams. 478 Usually these streams are known and come from another process 479 units. 480 481 The user should specify: 482 * Total molar flow 483 * Temperature 484 * Pressure 485 * Molar composition 486 "; 487 488 PARAMETERS 489 outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); 490 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 491 M(NComp) as molweight (Brief = "Component Mol Weight", Protected=true); 492 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid"); 493 494 495 SET 496 497 M = PP.MolecularWeight(); 498 499 VARIABLES 500 501 out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true); 502 503 MolarComposition(NComp) as fraction (Brief = "Stream Molar Composition"); 504 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true); 505 F as flow_mol (Brief = "Stream Molar Flow Rate"); 506 T as temperature (Brief = "Stream Temperature"); 507 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); 508 P as pressure (Brief = "Stream Pressure"); 509 510 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); 511 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); 512 513 514 EQUATIONS 515 516 "Sum of Composition" 517 SumOfComposition = sum(MolarComposition); 518 519 "Stream Molar Composition" 520 Outlet.z = MolarComposition/sum(MolarComposition); 521 522 523 switch ValidPhases 524 525 case "Liquid-Only": 526 527 "Vapour Fraction" 528 Outlet.v = 0; 529 530 "Liquid Composition" 531 x = Outlet.z; 532 533 "Vapour Composition" 534 y = Outlet.z; 535 536 "Overall Enthalpy" 537 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); 538 539 540 case "Vapour-Only": 541 542 "Vapor Fraction" 543 Outlet.v = 1; 544 545 "Liquid Composition" 546 x = Outlet.z; 547 548 "Vapour Composition" 549 y = Outlet.z; 550 551 "Overall Enthalpy" 552 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 553 554 555 case "Vapour-Liquid": 556 557 "Flash Calculation" 558 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); 559 560 "Overall Enthalpy" 561 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 562 563 564 end 565 566 "Temperature in °C" 567 T_Cdeg = Outlet.T - 273.15 * 'K'; 568 569 "Equate Flow" 570 Outlet.F = F; 571 572 "Equate Pressures" 573 Outlet.P = P; 574 575 "Equate Temperatures" 576 Outlet.T = T; 577 578 end 579 580 Model simple_source2 581 582 ATTRIBUTES 583 Pallete = true; 584 Icon = "icon/Source2"; 585 Brief = "Simple Material stream source"; 586 Info = " 587 This model should be used for boundary streams. 588 Usually these streams are known and come from another process 589 units. 590 591 The user should specify: 592 * Total molar flow 593 * Temperature 594 * Pressure 595 * Molar composition 596 "; 597 598 PARAMETERS 599 outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); 600 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 601 M(NComp) as molweight (Brief = "Component Mol Weight", Protected=true); 602 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid"); 603 604 605 SET 606 607 M = PP.MolecularWeight(); 608 609 VARIABLES 610 611 out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true); 612 613 MolarComposition(NComp) as fraction (Brief = "Stream Molar Composition"); 614 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true); 615 F as flow_mol (Brief = "Stream Molar Flow Rate"); 616 T as temperature (Brief = "Stream Temperature"); 617 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); 618 P as pressure (Brief = "Stream Pressure"); 619 620 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); 621 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); 622 623 624 EQUATIONS 625 626 "Sum of Composition" 627 SumOfComposition = sum(MolarComposition); 628 629 "Stream Molar Composition" 630 Outlet.z = MolarComposition/sum(MolarComposition); 631 632 633 switch ValidPhases 634 635 case "Liquid-Only": 636 637 "Vapour Fraction" 638 Outlet.v = 0; 639 640 "Liquid Composition" 641 x = Outlet.z; 642 643 "Vapour Composition" 644 y = Outlet.z; 645 646 "Overall Enthalpy" 647 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); 648 649 650 case "Vapour-Only": 651 652 "Vapor Fraction" 653 Outlet.v = 1; 654 655 "Liquid Composition" 656 x = Outlet.z; 657 658 "Vapour Composition" 659 y = Outlet.z; 660 661 "Overall Enthalpy" 662 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 663 664 665 case "Vapour-Liquid": 666 667 "Flash Calculation" 668 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); 669 670 "Overall Enthalpy" 671 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y); 672 673 674 end 675 676 "Temperature in °C" 677 T_Cdeg = Outlet.T - 273.15 * 'K'; 678 679 "Equate Flow" 680 Outlet.F = F; 681 682 "Equate Pressures" 683 Outlet.P = P; 684 685 "Equate Temperatures" 686 Outlet.T = T; 687 142 688 end 143 689 … … 164 710 outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); 165 711 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 166 M(NComp) as molweight (Brief = "Component Mol Weight");712 M(NComp) as molweight (Brief = "Component Mol Weight", Protected=true); 167 713 168 714 SET … … 236 782 outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); 237 783 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 238 M(NComp) as molweight (Brief = "Component Mol Weight");784 M(NComp) as molweight (Brief = "Component Mol Weight", Protected=true); 239 785 240 786 SET … … 374 920 outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); 375 921 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 376 M(NComp) as molweight (Brief = "Component Mol Weight");922 M(NComp) as molweight (Brief = "Component Mol Weight", Protected=true); 377 923 378 924 SET … … 472 1018 end 473 1019 474 Model source475 476 ATTRIBUTES477 Pallete = true;478 Icon = "icon/Source";479 Brief = "Material stream source";480 Info = "481 This model should be used for boundary streams.482 Usually these streams are known and come from another process483 units.484 485 The user should specify:486 * Total molar (mass or volumetric) flow487 * Temperature488 * Pressure489 * Molar or mass composition490 491 No matter the specification set, the model will calculate some492 additional properties:493 * Mass density494 * Mass flow495 * Mass compostions496 * Specific volume497 * Vapour fraction498 * Volumetric flow499 * Liquid and Vapour compositions500 ";501 502 PARAMETERS503 outer PP as Plugin (Brief = "External Physical Properties", Type="PP");504 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);505 M(NComp) as molweight (Brief = "Component Mol Weight");506 CompositionBasis as Switcher (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");507 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");508 509 510 SET511 512 M = PP.MolecularWeight();513 514 VARIABLES515 516 out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);517 518 Composition(NComp) as fraction (Brief = "Stream Composition");519 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true);520 F as flow_mol (Brief = "Stream Molar Flow Rate");521 Fw as flow_mass (Brief = "Stream Mass Flow");522 Fvol as flow_vol (Brief = "Volumetric Flow");523 T as temperature (Brief = "Stream Temperature");524 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200);525 P as pressure (Brief = "Stream Pressure");526 527 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true);528 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true);529 530 Mw as molweight (Brief = "Average Mol Weight",Protected=true);531 vm as volume_mol (Brief = "Molar Volume",Protected=true);532 rho as dens_mass (Brief = "Stream Mass Density",Protected=true);533 rhom as dens_mol (Brief = "Stream Molar Density",Protected=true);534 535 zmass(NComp) as fraction (Brief = "Mass Fraction",Protected=true);536 537 EQUATIONS538 539 switch CompositionBasis540 541 case "Molar":542 "Stream Molar Composition"543 Outlet.z = Composition/sum(Composition);544 545 "Stream Mass Composition"546 zmass = M*Outlet.z / Mw;547 548 case "Mass":549 "Stream Mass Composition"550 zmass = Composition/sum(Composition);551 552 "Stream Molar Composition"553 Outlet.z*sum(zmass/M) = zmass/M;554 555 end556 557 switch ValidPhases558 559 case "Liquid-Only":560 561 "Vapour Fraction"562 Outlet.v = 0;563 564 "Liquid Composition"565 x = Outlet.z;566 567 "Vapour Composition"568 y = Outlet.z;569 570 "Overall Enthalpy"571 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);572 573 "Molar Volume"574 vm = PP.LiquidVolume(Outlet.T, Outlet.P, x);575 576 case "Vapour-Only":577 578 "Vapor Fraction"579 Outlet.v = 1;580 581 "Liquid Composition"582 x = Outlet.z;583 584 "Vapour Composition"585 y = Outlet.z;586 587 "Overall Enthalpy"588 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);589 590 "Molar Volume"591 vm = PP.VapourVolume(Outlet.T, Outlet.P, y);592 593 594 case "Vapour-Liquid":595 596 "Flash Calculation"597 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);598 599 "Overall Enthalpy"600 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);601 602 "Molar Volume"603 vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);604 605 end606 607 "Sum of Composition"608 SumOfComposition = sum(Composition);609 610 "Molar Density"611 rhom * vm = 1;612 613 "Average Molecular Weight"614 Mw = sum(M*Outlet.z);615 616 "Mass or Molar Density"617 rhom * Mw = rho;618 619 "Flow Mass"620 Fw = Mw*Outlet.F;621 622 "Volumetric Flow"623 Fvol = Outlet.F*vm ;624 625 "Temperature in °C"626 T_Cdeg = Outlet.T - 273.15 * 'K';627 628 "Equate Flow"629 Outlet.F = F;630 631 "Equate Pressures"632 Outlet.P = P;633 634 "Equate Temperatures"635 Outlet.T = T;636 637 end638 639 Model source2640 641 ATTRIBUTES642 Pallete = true;643 Icon = "icon/Source2";644 Brief = "Material stream source";645 Info = "646 This model should be used for boundary streams.647 Usually these streams are known and come from another process648 units.649 650 The user should specify:651 * Total molar (mass or volumetric) flow652 * Temperature653 * Pressure654 * Molar or mass composition655 656 No matter the specification set, the model will calculate some657 additional properties:658 * Mass density659 * Mass flow660 * Mass compostions661 * Specific volume662 * Vapour fraction663 * Volumetric flow664 * Liquid and Vapour compositions665 ";666 667 PARAMETERS668 outer PP as Plugin (Brief = "External Physical Properties", Type="PP");669 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);670 M(NComp) as molweight (Brief = "Component Mol Weight");671 CompositionBasis as Switcher (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");672 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");673 674 675 SET676 677 M = PP.MolecularWeight();678 679 VARIABLES680 681 out Outlet as stream (Brief = "Outlet stream", PosX=0, PosY=0.5256, Symbol="_{out}",Protected=true);682 683 Composition(NComp) as fraction (Brief = "Stream Composition");684 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true);685 F as flow_mol (Brief = "Stream Molar Flow Rate");686 Fw as flow_mass (Brief = "Stream Mass Flow");687 Fvol as flow_vol (Brief = "Volumetric Flow");688 T as temperature (Brief = "Stream Temperature");689 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200);690 P as pressure (Brief = "Stream Pressure");691 692 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true);693 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true);694 695 Mw as molweight (Brief = "Average Mol Weight",Protected=true);696 vm as volume_mol (Brief = "Molar Volume",Protected=true);697 rho as dens_mass (Brief = "Stream Mass Density",Protected=true);698 rhom as dens_mol (Brief = "Stream Molar Density",Protected=true);699 700 zmass(NComp) as fraction (Brief = "Mass Fraction",Protected=true);701 702 EQUATIONS703 704 switch CompositionBasis705 706 case "Molar":707 "Stream Molar Composition"708 Outlet.z = Composition/sum(Composition);709 710 "Stream Mass Composition"711 zmass = M*Outlet.z / Mw;712 713 case "Mass":714 "Stream Mass Composition"715 zmass = Composition/sum(Composition);716 717 "Stream Molar Composition"718 Outlet.z*sum(zmass/M) = zmass/M;719 720 end721 722 switch ValidPhases723 724 case "Liquid-Only":725 726 "Vapour Fraction"727 Outlet.v = 0;728 729 "Liquid Composition"730 x = Outlet.z;731 732 "Vapour Composition"733 y = Outlet.z;734 735 "Overall Enthalpy"736 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);737 738 "Molar Volume"739 vm = PP.LiquidVolume(Outlet.T, Outlet.P, x);740 741 case "Vapour-Only":742 743 "Vapor Fraction"744 Outlet.v = 1;745 746 "Liquid Composition"747 x = Outlet.z;748 749 "Vapour Composition"750 y = Outlet.z;751 752 "Overall Enthalpy"753 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);754 755 "Molar Volume"756 vm = PP.VapourVolume(Outlet.T, Outlet.P, y);757 758 759 case "Vapour-Liquid":760 761 "Flash Calculation"762 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);763 764 "Overall Enthalpy"765 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);766 767 "Molar Volume"768 vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);769 770 end771 772 "Sum of Composition"773 SumOfComposition = sum(Composition);774 775 "Molar Density"776 rhom * vm = 1;777 778 "Average Molecular Weight"779 Mw = sum(M*Outlet.z);780 781 "Mass or Molar Density"782 rhom * Mw = rho;783 784 "Flow Mass"785 Fw = Mw*Outlet.F;786 787 "Volumetric Flow"788 Fvol = Outlet.F*vm ;789 790 "Temperature in °C"791 T_Cdeg = Outlet.T - 273.15 * 'K';792 793 "Equate Flow"794 Outlet.F = F;795 796 "Equate Pressures"797 Outlet.P = P;798 799 "Equate Temperatures"800 Outlet.T = T;801 802 end803 804 Model simple_source805 806 ATTRIBUTES807 Pallete = true;808 Icon = "icon/Source";809 Brief = "Simple Material stream source";810 Info = "811 This model should be used for boundary streams.812 Usually these streams are known and come from another process813 units.814 815 The user should specify:816 * Total molar flow817 * Temperature818 * Pressure819 * Molar composition820 ";821 822 PARAMETERS823 outer PP as Plugin (Brief = "External Physical Properties", Type="PP");824 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);825 M(NComp) as molweight (Brief = "Component Mol Weight");826 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");827 828 829 SET830 831 M = PP.MolecularWeight();832 833 VARIABLES834 835 out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);836 837 MolarComposition(NComp) as fraction (Brief = "Stream Molar Composition");838 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true);839 F as flow_mol (Brief = "Stream Molar Flow Rate");840 T as temperature (Brief = "Stream Temperature");841 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200);842 P as pressure (Brief = "Stream Pressure");843 844 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true);845 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true);846 847 848 EQUATIONS849 850 "Sum of Composition"851 SumOfComposition = sum(MolarComposition);852 853 "Stream Molar Composition"854 Outlet.z = MolarComposition/sum(MolarComposition);855 856 857 switch ValidPhases858 859 case "Liquid-Only":860 861 "Vapour Fraction"862 Outlet.v = 0;863 864 "Liquid Composition"865 x = Outlet.z;866 867 "Vapour Composition"868 y = Outlet.z;869 870 "Overall Enthalpy"871 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);872 873 874 case "Vapour-Only":875 876 "Vapor Fraction"877 Outlet.v = 1;878 879 "Liquid Composition"880 x = Outlet.z;881 882 "Vapour Composition"883 y = Outlet.z;884 885 "Overall Enthalpy"886 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);887 888 889 case "Vapour-Liquid":890 891 "Flash Calculation"892 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);893 894 "Overall Enthalpy"895 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);896 897 898 end899 900 "Temperature in °C"901 T_Cdeg = Outlet.T - 273.15 * 'K';902 903 "Equate Flow"904 Outlet.F = F;905 906 "Equate Pressures"907 Outlet.P = P;908 909 "Equate Temperatures"910 Outlet.T = T;911 912 end913 914 Model simple_source2915 916 ATTRIBUTES917 Pallete = true;918 Icon = "icon/Source2";919 Brief = "Simple Material stream source";920 Info = "921 This model should be used for boundary streams.922 Usually these streams are known and come from another process923 units.924 925 The user should specify:926 * Total molar flow927 * Temperature928 * Pressure929 * Molar composition930 ";931 932 PARAMETERS933 outer PP as Plugin (Brief = "External Physical Properties", Type="PP");934 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);935 M(NComp) as molweight (Brief = "Component Mol Weight");936 ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");937 938 939 SET940 941 M = PP.MolecularWeight();942 943 VARIABLES944 945 out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);946 947 MolarComposition(NComp) as fraction (Brief = "Stream Molar Composition");948 SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true);949 F as flow_mol (Brief = "Stream Molar Flow Rate");950 T as temperature (Brief = "Stream Temperature");951 T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200);952 P as pressure (Brief = "Stream Pressure");953 954 x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true);955 y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true);956 957 958 EQUATIONS959 960 "Sum of Composition"961 SumOfComposition = sum(MolarComposition);962 963 "Stream Molar Composition"964 Outlet.z = MolarComposition/sum(MolarComposition);965 966 967 switch ValidPhases968 969 case "Liquid-Only":970 971 "Vapour Fraction"972 Outlet.v = 0;973 974 "Liquid Composition"975 x = Outlet.z;976 977 "Vapour Composition"978 y = Outlet.z;979 980 "Overall Enthalpy"981 Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);982 983 984 case "Vapour-Only":985 986 "Vapor Fraction"987 Outlet.v = 1;988 989 "Liquid Composition"990 x = Outlet.z;991 992 "Vapour Composition"993 y = Outlet.z;994 995 "Overall Enthalpy"996 Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);997 998 999 case "Vapour-Liquid":1000 1001 "Flash Calculation"1002 [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);1003 1004 "Overall Enthalpy"1005 Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);1006 1007 1008 end1009 1010 "Temperature in °C"1011 T_Cdeg = Outlet.T - 273.15 * 'K';1012 1013 "Equate Flow"1014 Outlet.F = F;1015 1016 "Equate Pressures"1017 Outlet.P = P;1018 1019 "Equate Temperatures"1020 Outlet.T = T;1021 1022 end1023 1024 1020 Model sourceNoFlow 1025 1021
Note: See TracChangeset
for help on using the changeset viewer.