File size: 30,015 Bytes
eb1a751 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | <!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hensmith Quickstart</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,500;0,600;0,700;1,500&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
<style>
:root{
/* light palette (also the default un-stamped state) */
--ground:#eef2f7;
--ground-2:#e4eaf2;
--surface:#FFFFFF;
--surface-2:#F4F8F9;
--ink:#132029;
--ink-soft:#33434f;
--muted:#5c6b78;
--line:#d8e0ea;
--line-soft:#e7edf3;
--accent:#2e6db4;
--accent-ink:#1f4f85;
--accent-fill:#2e6db4;
--callout-bg:rgba(46,109,180,.12);
--callout-ink:#1f4f85;
--callout-line:rgba(46,109,180,.30);
--shadow:0 24px 60px -28px rgba(19,34,41,.45), 0 6px 18px -12px rgba(19,34,41,.30);
--canvas:#FFFFFF;
--canvas-line:#E1E9EB;
/* the code/terminal editor — a committed dark look in every theme */
--code-bg:#0B1519;
--code-surface:#0E1C22;
--code-line:#182b32;
--code-ink:#CBD8DB;
--code-dim:#7f9299;
--code-gutter:#455a61;
--c-fn:#5FC1E4;
--c-kw:#E6B673;
--c-str:#87D0A9;
--c-num:#E6B673;
--c-com:#5a7178;
--c-attr:#B9C7CB;
--thl:#f0665f;
}
@media (prefers-color-scheme: dark){
:root:not([data-theme="light"]){
--ground:#0e141b;
--ground-2:#0a1016;
--surface:#141c25;
--surface-2:#19232e;
--ink:#e6ecf2;
--ink-soft:#c2ccd6;
--muted:#93a1ae;
--line:#233040;
--line-soft:#1b2633;
--accent:#5b9be0;
--accent-ink:#8fbdf0;
--accent-fill:#4a8ad3;
--callout-bg:rgba(91,155,224,.14);
--callout-ink:#a9cdf4;
--callout-line:rgba(91,155,224,.30);
--shadow:0 30px 70px -30px rgba(0,0,0,.7), 0 8px 24px -16px rgba(0,0,0,.6);
--canvas:#F3F6F7;
--canvas-line:#0a1114;
--thl:#f0665f;
}
}
:root[data-theme="dark"]{
--ground:#0e141b;
--ground-2:#0a1016;
--surface:#141c25;
--surface-2:#19232e;
--ink:#e6ecf2;
--ink-soft:#c2ccd6;
--muted:#93a1ae;
--line:#233040;
--line-soft:#1b2633;
--accent:#5b9be0;
--accent-ink:#8fbdf0;
--accent-fill:#4a8ad3;
--callout-bg:rgba(91,155,224,.14);
--callout-ink:#a9cdf4;
--callout-line:rgba(91,155,224,.30);
--shadow:0 30px 70px -30px rgba(0,0,0,.7), 0 8px 24px -16px rgba(0,0,0,.6);
--canvas:#F3F6F7;
--canvas-line:#0a1114;
--thl:#f0665f;
}
*{box-sizing:border-box}
html,body{margin:0}
body{
background:
radial-gradient(1100px 520px at 82% -8%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
var(--ground);
color:var(--ink);
font-family:"IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
-webkit-font-smoothing:antialiased;
line-height:1.5;
min-height:100vh;
display:flex;
align-items:center;
justify-content:center;
padding:clamp(14px,3vw,44px);
}
.wrap{width:100%;max-width:1120px}
.tagline{
display:flex;align-items:baseline;gap:.6rem;flex-wrap:wrap;
margin:0 4px 14px;
}
.tagline .kicker{
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.72rem;letter-spacing:.22em;text-transform:uppercase;
color:var(--accent-ink);font-weight:500;
}
.tagline .sep{color:var(--line);}
.tagline .lead{color:var(--muted);font-size:.86rem;}
/* ---- player shell ---- */
.player{
background:var(--surface);
border:1px solid var(--line);
border-radius:18px;
box-shadow:var(--shadow);
overflow:hidden;
}
.chrome{
display:flex;align-items:center;gap:14px;
padding:13px 18px;
border-bottom:1px solid var(--line-soft);
background:linear-gradient(var(--surface), var(--surface-2));
}
.brand{display:flex;align-items:center;gap:10px;min-width:0}
.brand img{height:26px;width:auto;display:block}
.brand .name{
font-weight:600;letter-spacing:-.01em;font-size:1.02rem;
}
.dots{display:flex;gap:6px;margin-left:2px}
.dots i{width:9px;height:9px;border-radius:50%;background:var(--line);display:block}
.now{
margin-left:auto;display:flex;align-items:center;gap:10px;
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.78rem;color:var(--muted);min-width:0;
}
.now .num{color:var(--accent-ink);font-weight:500}
.now .lbl{color:var(--ink-soft);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* ---- stage ---- */
.stage{
display:grid;
grid-template-columns:minmax(0,0.92fr) minmax(0,1.08fr);
min-height:452px;
position:relative;
}
.pane{padding:22px 24px;min-width:0}
.code-pane{
background:var(--code-bg);
border-right:1px solid var(--line-soft);
display:flex;flex-direction:column;
}
.file-tab{
display:flex;align-items:center;gap:8px;
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.72rem;color:var(--code-dim);
padding-bottom:12px;margin-bottom:4px;
border-bottom:1px solid var(--code-line);
letter-spacing:.02em;
}
.file-tab b{color:var(--code-ink);font-weight:500}
.file-tab .py{color:var(--c-fn)}
.code{
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.82rem;line-height:1.72;
color:var(--code-ink);
margin-top:14px;
white-space:pre;
overflow-x:auto;
scrollbar-width:thin;scrollbar-color:var(--code-line) transparent;
flex:1;
counter-reset:l;
}
.code .ln{
display:block;position:relative;
padding-left:34px;
opacity:0;transform:translateY(5px);
transition:opacity .38s ease, transform .38s ease;
}
.code .ln::before{
counter-increment:l;content:counter(l);
position:absolute;left:0;top:0;width:22px;text-align:right;
color:var(--code-gutter);font-size:.72rem;
}
.code .ln.on{opacity:1;transform:none}
.code .ln.blank{min-height:.6em}
.c-fn{color:var(--c-fn)}
.c-kw{color:var(--c-kw)}
.c-str{color:var(--c-str)}
.c-num{color:var(--c-num)}
.c-com{color:var(--c-com);font-style:italic}
.caret{
display:inline-block;width:7px;height:1.05em;
background:var(--c-fn);vertical-align:-2px;margin-left:2px;border-radius:1px;
animation:blink 1s steps(2,start) infinite;opacity:.85;
}
@keyframes blink{50%{opacity:0}}
/* output pane */
.out-pane{
background:var(--surface);
display:flex;flex-direction:column;
}
.caption{
font-family:"Spectral", Georgia, serif;
font-size:1.16rem;line-height:1.34;font-weight:600;
color:var(--ink);letter-spacing:-.005em;
text-wrap:balance;margin:0 0 4px;
opacity:0;transform:translateY(6px);
transition:opacity .5s ease, transform .5s ease;
}
.caption.on{opacity:1;transform:none}
.caption em{color:var(--accent-ink);font-style:italic}
.sub{
font-size:.85rem;color:var(--muted);margin:0 0 14px;max-width:46ch;
opacity:0;transition:opacity .5s ease .06s;
}
.sub.on{opacity:1}
.output{
flex:1;display:flex;flex-direction:column;justify-content:center;
min-height:0;
}
.canvas{
background:var(--canvas);
border:1px solid var(--canvas-line);
border-radius:12px;
padding:12px;
display:flex;align-items:center;justify-content:center;
box-shadow:0 10px 26px -20px rgba(0,0,0,.55);
opacity:0;transform:scale(.985);
transition:opacity .55s ease, transform .55s ease;
}
.canvas.on{opacity:1;transform:none}
.canvas img{max-width:100%;max-height:322px;height:auto;display:block;border-radius:4px}
/* figure outputs that ship a dark variant: show only the theme-appropriate
one (mirrors the .brand rules) */
.canvas img.fig-dark{display:none}
:root[data-theme="dark"] .canvas img.fig-light{display:none}
:root[data-theme="dark"] .canvas img.fig-dark{display:block}
@media (prefers-color-scheme: dark){
:root:not([data-theme="light"]) .canvas img.fig-light{display:none}
:root:not([data-theme="light"]) .canvas img.fig-dark{display:block}
}
/* terminal output */
.term{
background:var(--code-surface);
border:1px solid var(--code-line);
border-radius:12px;
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.72rem;line-height:1.62;
color:var(--code-ink);
padding:14px 16px;
overflow:auto;max-height:328px;white-space:pre;
scrollbar-width:thin;scrollbar-color:var(--code-line) transparent;
opacity:0;transform:translateY(6px);
transition:opacity .5s ease, transform .5s ease;
}
.term.on{opacity:1;transform:none}
.term .dim{color:var(--code-dim)}
.term .thl{color:var(--thl);font-weight:500}
.term .cmd{color:var(--c-fn)}
.callouts{
display:flex;flex-wrap:wrap;gap:8px;margin-top:14px;
}
.chip-c{
display:inline-flex;align-items:baseline;gap:7px;
background:var(--callout-bg);
border:1px solid var(--callout-line);
color:var(--callout-ink);
border-radius:999px;
padding:5px 12px;
font-size:.78rem;
opacity:0;transform:translateY(6px) scale(.96);
transition:opacity .34s ease, transform .34s ease;
}
.chip-c.on{opacity:1;transform:none}
.chip-c b{
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-weight:500;color:var(--accent-ink);font-size:.82rem;
}
/* intro scene overlay */
.intro{
position:absolute;inset:0;z-index:5;
background:
radial-gradient(680px 380px at 50% 30%, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface) 72%);
display:flex;flex-direction:column;align-items:center;justify-content:center;
text-align:center;padding:34px;gap:16px;
transition:opacity .6s ease;
}
.intro .mark{height:52px;width:auto;opacity:0;transform:translateY(8px);transition:.7s ease}
.intro.on .mark{opacity:1;transform:none}
.intro h1{
font-family:"Spectral", Georgia, serif;
font-weight:700;font-size:clamp(1.6rem,3.4vw,2.5rem);
line-height:1.1;letter-spacing:-.02em;margin:0;max-width:16ch;
text-wrap:balance;color:var(--ink);
opacity:0;transform:translateY(10px);transition:.7s ease .12s;
}
.intro.on h1{opacity:1;transform:none}
.intro h1 em{color:var(--accent-ink);font-style:italic}
.intro .flow{
display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:center;
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.78rem;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);
opacity:0;transition:.7s ease .26s;
}
.intro.on .flow{opacity:1}
.intro .flow span{color:var(--ink-soft)}
.intro .flow i{color:var(--accent);font-style:normal}
/* end card */
.endcard{
position:absolute;inset:0;z-index:6;
background:color-mix(in srgb, var(--surface) 90%, transparent);
backdrop-filter:blur(3px);
display:flex;flex-direction:column;align-items:center;justify-content:center;
gap:16px;text-align:center;padding:30px;
opacity:0;pointer-events:none;transition:opacity .45s ease;
}
.endcard.show{opacity:1;pointer-events:auto}
.endcard p{
font-family:"Spectral", Georgia, serif;font-size:1.3rem;font-weight:600;margin:0;
color:var(--ink);
}
.endcard .row{display:flex;gap:12px;flex-wrap:wrap;justify-content:center}
.btn{
font-family:"IBM Plex Sans",sans-serif;font-size:.9rem;font-weight:500;
border-radius:10px;padding:10px 18px;cursor:pointer;text-decoration:none;
border:1px solid var(--line);background:var(--surface-2);color:var(--ink);
display:inline-flex;align-items:center;gap:8px;transition:.18s ease;
}
.btn:hover{border-color:var(--accent);color:var(--accent-ink)}
.btn.primary{background:var(--accent-fill);border-color:var(--accent-fill);color:#fff}
.btn.primary:hover{filter:brightness(1.06);color:#fff}
/* ---- transport ---- */
.transport{
display:flex;align-items:center;gap:14px;
padding:13px 18px;
border-top:1px solid var(--line-soft);
background:var(--surface-2);
}
.pp{
width:38px;height:38px;flex:none;border-radius:50%;
border:1px solid var(--accent-fill);
background:var(--accent-fill);color:#fff;cursor:pointer;
display:grid;place-items:center;transition:.18s ease;
}
.pp:hover{filter:brightness(1.07)}
.pp svg{width:16px;height:16px;display:block}
.track{
flex:1;display:flex;gap:5px;align-items:center;
}
.seg{
flex:1;height:6px;border-radius:4px;background:var(--ground-2);
overflow:hidden;cursor:pointer;position:relative;
}
.seg::after{
content:"";position:absolute;inset:0;background:var(--line-soft);opacity:0;
}
.seg span{display:block;height:100%;width:0;background:var(--accent-fill);border-radius:4px}
.time{
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.76rem;color:var(--muted);flex:none;font-variant-numeric:tabular-nums;
}
/* ---- step chips ---- */
.chips{
display:flex;gap:8px;flex-wrap:wrap;
padding:12px 18px 16px;
border-top:1px solid var(--line-soft);
background:var(--surface);
}
.chip{
display:flex;align-items:center;gap:9px;
border:1px solid var(--line);border-radius:10px;
background:var(--surface);color:var(--muted);
padding:7px 12px;cursor:pointer;font-size:.82rem;
transition:.18s ease;flex:1 1 auto;min-width:0;
}
.chip:hover{border-color:var(--accent);color:var(--ink)}
.chip .n{
font-family:"IBM Plex Mono", ui-monospace, monospace;
font-size:.72rem;color:var(--muted);font-weight:500;
}
.chip .t{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500}
.chip.active{
border-color:var(--accent);
background:var(--callout-bg);color:var(--ink);
}
.chip.active .n{color:var(--accent-ink)}
.chip.done .n{color:var(--accent)}
.foot{
margin:14px 6px 0;text-align:center;color:var(--muted);font-size:.78rem;
}
.foot code{
font-family:"IBM Plex Mono", ui-monospace, monospace;
background:var(--surface-2);border:1px solid var(--line-soft);
padding:1px 6px;border-radius:5px;color:var(--accent-ink);font-size:.74rem;
}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
@media (max-width:840px){
/* single column: the stage is as tall as its two stacked panes, which are
empty during the intro and end scenes, so keep room for those overlays
(they are absolutely positioned and add no height of their own) */
.stage{grid-template-columns:1fr;min-height:360px}
.code-pane{border-right:none;border-bottom:1px solid var(--line-soft)}
.code{font-size:.78rem}
.now .lbl{display:none}
.chip{flex:1 1 40%}
}
@media (max-width:480px){
.pane{padding:18px 16px}
.intro{padding:24px 18px}
.chip{flex:1 1 100%}
}
@media (prefers-reduced-motion: reduce){
.code .ln,.caption,.sub,.canvas,.term,.chip-c,.intro .mark,.intro h1,.intro .flow{
transition:none !important;
}
.caret{animation:none}
}
</style>
<div class="wrap">
<div class="tagline">
<span class="kicker">hensmith</span>
<span class="sep">/</span>
<span class="lead">Heat exchanger network synthesis for any BioSTEAM system — build, simulate, read the savings, draw the pinch diagram.</span>
</div>
<div class="player" id="player">
<div class="chrome">
<div class="brand">
<img src="images/logo/logo_hensmith.png" alt="hensmith logo">
<span class="dots"><i></i><i></i><i></i></span>
</div>
<div class="now"><span class="num" id="nowNum">00</span><span class="lbl" id="nowLbl">Intro</span></div>
</div>
<div class="stage" id="stage">
<div class="pane code-pane">
<div class="file-tab">
<span class="py">●</span> <b>quickstart</b><span>.py</span>
</div>
<div class="code" id="code"></div>
</div>
<div class="pane out-pane">
<p class="caption" id="caption"></p>
<p class="sub" id="sub"></p>
<div class="output" id="output"></div>
<div class="callouts" id="callouts"></div>
</div>
<div class="intro" id="intro">
<img class="mark" src="images/logo/mark_hensmith.png" alt="">
<h1>Synthesize the heat exchanger network of <em>any BioSTEAM system.</em></h1>
<div class="flow">
<span>Build</span><i>→</i><span>Simulate</span><i>→</i><span>Savings</span><i>→</i><span>Pinch diagram</span>
</div>
</div>
<div class="endcard" id="endcard">
<p>That's the quickstart — in about a minute.</p>
<div class="row">
<button class="btn primary" id="replay">↻ Replay</button>
<a class="btn" href="../tutorial/index.html" target="_blank" rel="noopener">Read the full tutorial →</a>
</div>
</div>
</div>
<div class="transport">
<button class="pp" id="pp" aria-label="Pause"></button>
<div class="track" id="track"></div>
<div class="time"><span id="tCur">0:00</span> / <span id="tTot">0:00</span></div>
</div>
<div class="chips" id="chips"></div>
</div>
<p class="foot">Every figure and number is real output of the code shown — the HeatExchangerNetwork doctest system. Press <code>space</code> to play/pause, <code>←/→</code> to step.</p>
</div>
<script>
const FIG = {
flowsheet_light: "images/examples/tutorial_01_quickstart_flowsheet_light.png",
flowsheet_dark: "images/examples/tutorial_01_quickstart_flowsheet_dark.png",
pinch: "images/examples/tutorial_01_quickstart_pinch_diagram.png",
};
const scenes = [
{ num:"", label:"Intro", intro:true, dur:3400 },
{ num:"01", label:"Build the flowsheet", dur:12000, lineMs:430,
code:[
"import biosteam as bst",
"from hensmith import HeatExchangerNetwork",
"",
"bst.settings.set_thermo(['Water', 'Methanol', 'Glycerol'])",
"feed1 = bst.Stream('feed1', flow=(8000, 100, 25))",
"feed2 = bst.Stream('feed2', flow=(10000, 1000, 10))",
"D1 = bst.ShortcutColumn('D1', ins=feed1, outs=('distillate', 'bottoms_product'),",
" LHK=('Methanol', 'Water'), y_top=0.99, x_bot=0.01, k=2,",
" is_divided=True)",
"D1_H1 = bst.HXutility('D1_H1', ins=D1.outs[1], T=300)",
"D1_H2 = bst.HXutility('D1_H2', ins=D1.outs[0], T=300)",
"F1 = bst.Flash('F1', ins=feed2, outs=('vapor', 'liquid'), V=0.9, P=101325)",
"HXN = HeatExchangerNetwork('HXN', T_min_app=5.)",
"sys = bst.System.from_units('sys', units=[D1, D1_H1, D1_H2, F1, HXN])",
"sys.diagram()",
],
caption:"A methanol/water column, two product coolers and a flash — plus the <em>network facility</em>.",
sub:"The column's condenser and reboiler and the flash's feed heater are auxiliary exchangers; the network integrates every heating and cooling utility it finds.",
output:{type:"figure", src:"flowsheet_light", srcDark:"flowsheet_dark", alt:"Flowsheet: D1 column with D1_H1/D1_H2 coolers, F1 flash, and the HXN facility."},
callouts:[{"v": "5", "l": "streams to integrate"}, {"v": "3", "l": "auxiliary exchangers"}] },
{ num:"02", label:"Simulate and read the savings", dur:13000, lineMs:520,
code:["sys.simulate()", "HXN.results()"],
caption:"One simulation synthesizes the network and reports the <em>utility savings</em>.",
sub:"The facility's utilities are the difference new minus original, so negative duties and costs are savings; its cost is the added exchanger cost.",
output:{type:"terminal", html:`<span class="cmd">>>> HXN.results()</span>\nHeat exchanger network Units HXN
Low pressure steam Duty kJ/hr -6.32e+07
Flow kmol/hr -1.63e+03
Cost USD/hr -389
Chilled water Duty kJ/hr 4.21e+07
Flow kmol/hr -2.78e+04
Cost USD/hr -211
Cooling water Duty kJ/hr 1.79e+07
Flow kmol/hr -1.22e+04
Cost USD/hr -5.98
Purchase cost Heat exchangers USD 3.46e+05
Total purchase cost USD 3.46e+05
Installed equipment cost USD 1.11e+06
Utility cost USD/hr -605`},
callouts:[{"v": "−17.5 %", "l": "heating utility"}, {"v": "−96.9 %", "l": "cooling utility"}, {"v": "−605 USD/hr", "l": "utility cost (savings)"}] },
{ num:"03", label:"Draw the pinch diagram", dur:13000, lineMs:520,
code:["fig, ax = HXN.plot_pinch_diagram()"],
caption:"Cold streams above, hot streams below, one connector per <em>process exchanger</em>.",
sub:"The dashed line is the pinch: cold-side exchangers to its left, hot-side to its right; circles mark the utility exchangers that finish each stream.",
output:{type:"figure", src:"pinch", alt:"Pinch diagram of the quickstart network: five streams, four process exchangers, dashed pinch line, utility circles."},
callouts:[{"v": "4", "l": "process exchangers"}, {"v": "pinch", "l": "cold side | hot side"}, {"v": "1.11e+06 USD", "l": "added installed cost"}] },
{ num:"04", label:"Inspect the network", dur:15000, lineMs:520,
code:["HXN.stream_life_cycles"],
caption:"Every stream's <em>life cycle</em> through the network, in flow order.",
sub:"Each stage is an HXprocess or HXutility of the network's own system, HXN.HXN_sys, with the stream's enthalpy in and out.",
output:{type:"terminal", html:`<span class="cmd">>>> HXN.stream_life_cycles</span>\n[<StreamLifeCycle: Stream_0, cold
life_cycle = [
<LifeStage: <HXprocess: HX_0_2_hs>, H_in = 5.38e+06 kJ/hr, H_out = 4.24e+07 kJ/hr>
<LifeStage: <HXutility: Util_0_hs>, H_in = 4.24e+07 kJ/hr, H_out = 6.92e+07 kJ/hr>
]>, <StreamLifeCycle: Stream_1, cold
life_cycle = [
<LifeStage: <HXprocess: HX_1_2_hs>, H_in = 0 kJ/hr, H_out = 5.05e+06 kJ/hr>
<LifeStage: <HXprocess: HX_1_4_hs>, H_in = 5.05e+06 kJ/hr, H_out = 5.08e+06 kJ/hr>
<LifeStage: <HXprocess: HX_1_3_hs>, H_in = 5.08e+06 kJ/hr, H_out = 2.3e+07 kJ/hr>
<LifeStage: <HXutility: Util_1_hs>, H_in = 2.3e+07 kJ/hr, H_out = 2.79e+08 kJ/hr>
]>, <StreamLifeCycle: Stream_2, hot
life_cycle = [
<LifeStage: <HXprocess: HX_0_2_hs>, H_in = 4.52e+07 kJ/hr, H_out = 8.12e+06 kJ/hr>
<LifeStage: <HXprocess: HX_1_2_hs>, H_in = 8.12e+06 kJ/hr, H_out = 3.07e+06 kJ/hr>
<LifeStage: <HXutility: Util_2_cs>, H_in = 3.07e+06 kJ/hr, H_out = 1.14e+06 kJ/hr>
]>, <StreamLifeCycle: Stream_3, hot
life_cycle = [
<LifeStage: <HXprocess: HX_1_3_hs>, H_in = 2.04e+07 kJ/hr, H_out = 2.47e+06 kJ/hr>
<LifeStage: <HXutility: Util_3_cs>, H_in = 2.47e+06 kJ/hr, H_out = 2.47e+06 kJ/hr>
]>, <StreamLifeCycle: Stream_4, hot
life_cycle = [
<LifeStage: <HXprocess: HX_1_4_hs>, H_in = 7.51e+05 kJ/hr, H_out = 7.18e+05 kJ/hr>
<LifeStage: <HXutility: Util_4_cs>, H_in = 7.18e+05 kJ/hr, H_out = 7.18e+05 kJ/hr>
]>]`},
callouts:[{"v": "3", "l": "exchangers on Stream_1 before its utility"}, {"v": "2e-11 %", "l": "energy balance error"}] },
];
/* preload figures */
Object.values(FIG).forEach(src=>{const i=new Image(); i.src=src;});
const RM = matchMedia("(prefers-reduced-motion: reduce)").matches;
const KW = new Set(["import","as","True","False","None","and","or","not","in","for","if"]);
function esc(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");}
function hl(line){
let s = esc(line);
s = s.replace(/(#.*)$/,'<span class="c-com">$1</span>');
s = s.replace(/('[^&]*?'|'[^']*')/g,'<span class="c-str">$1</span>');
s = s.replace(/\b(\d+\.?\d*(?:e[+-]?\d+)?)\b/gi,'<span class="c-num">$1</span>');
s = s.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\b/g,(m)=>KW.has(m)?`<span class="c-kw">${m}</span>`:m);
s = s.replace(/\b([A-Za-z_][A-Za-z0-9_]*)(\()/g,'<span class="c-fn">$1</span>$2');
return s;
}
const $ = s=>document.querySelector(s);
const codeEl=$("#code"), capEl=$("#caption"), subEl=$("#sub"),
outEl=$("#output"), calEl=$("#callouts"), introEl=$("#intro"),
endEl=$("#endcard"), nowNum=$("#nowNum"), nowLbl=$("#nowLbl"),
trackEl=$("#track"), chipsEl=$("#chips"), ppEl=$("#pp"),
tCur=$("#tCur"), tTot=$("#tTot");
const total = scenes.reduce((a,s)=>a+s.dur,0);
const starts = []; let acc=0; scenes.forEach(s=>{starts.push(acc); acc+=s.dur;});
/* build track segments + chips */
scenes.forEach((s,i)=>{
const seg=document.createElement("div");
seg.className="seg"; seg.innerHTML="<span></span>";
seg.style.flex = Math.max(s.dur,3000);
seg.addEventListener("click",()=>jump(i));
trackEl.appendChild(seg);
if(!s.intro){
const c=document.createElement("button");
c.className="chip";
c.innerHTML=`<span class="n">${s.num}</span><span class="t">${s.label}</span>`;
c.addEventListener("click",()=>jump(i));
chipsEl.appendChild(c);
}
});
const segEls=[...trackEl.children];
const chipEls=[...chipsEl.children];
const PLAY='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>';
const PAUSE='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M6 5h4v14H6zM14 5h4v14h-4z"/></svg>';
/* Starts paused on the intro poster; autoStart() (below) flips this to true
the first time the player scrolls into view. */
let current=0, t=0, playing=false, built=-1, ended=false;
function fmt(ms){const s=Math.round(ms/1000);return `${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`;}
tTot.textContent=fmt(total);
function buildScene(i){
const s=scenes[i];
codeEl.innerHTML="";
if(s.code){
s.code.forEach(l=>{
const d=document.createElement("span");
d.className="ln"+(l.trim()===""?" blank":"");
d.innerHTML = l.trim()===""? " " : hl(l);
codeEl.appendChild(d);
});
}
capEl.innerHTML = s.caption||"";
subEl.innerHTML = s.sub||"";
outEl.innerHTML="";
if(s.output){
if(s.output.type==="figure"){
const w=document.createElement("div"); w.className="canvas";
const alt=s.output.alt||"";
/* a figure with a dark variant gets both images; CSS shows the one
matching the theme */
w.innerHTML = s.output.srcDark
? `<img class="fig-light" src="${FIG[s.output.src]}" alt="${alt}"><img class="fig-dark" src="${FIG[s.output.srcDark]}" alt="${alt}">`
: `<img src="${FIG[s.output.src]}" alt="${alt}">`;
outEl.appendChild(w);
} else {
const w=document.createElement("div"); w.className="term";
w.innerHTML=s.output.html;
outEl.appendChild(w);
}
}
calEl.innerHTML="";
(s.callouts||[]).forEach(c=>{
const el=document.createElement("span");
el.className="chip-c";
el.innerHTML=`<b>${c.v}</b><span>${c.l}</span>`;
calEl.appendChild(el);
});
introEl.style.display = s.intro? "flex":"none";
introEl.classList.toggle("on", !!s.intro);
nowNum.textContent = s.num||"00";
nowLbl.textContent = s.label;
chipEls.forEach((c,ci)=>{
c.classList.toggle("active", ci===i-1);
c.classList.toggle("done", ci<i-1);
});
built=i;
}
function render(){
const s=scenes[current];
if(built!==current) buildScene(current);
if(!s.intro){
const lineMs=RM?0:(s.lineMs||500);
const lines=[...codeEl.children];
const shown = RM? lines.length : Math.min(lines.length, Math.floor(t/Math.max(lineMs,1))+1);
lines.forEach((ln,idx)=>ln.classList.toggle("on", idx<shown));
const codeDone = RM?0:lines.length*lineMs;
const outT = codeDone + 350;
const on = t>=outT;
capEl.classList.toggle("on", t>=Math.max(0,codeDone-400));
subEl.classList.toggle("on", t>=Math.max(0,codeDone-200));
const canv=outEl.firstElementChild;
if(canv) canv.classList.toggle("on", on);
if(canv && canv.classList.contains("term") && !RM){
const sc=canv.scrollHeight-canv.clientHeight;
if(sc>4){
const s0=outT+1500, s1=s.dur-2800;
const p=Math.min(1,Math.max(0,(t-s0)/(s1-s0)));
canv.scrollTop=p*sc;
}
}
const cs=[...calEl.children];
cs.forEach((c,ci)=>c.classList.toggle("on", t>=outT+500+ci*430));
}
/* progress */
segEls.forEach((seg,si)=>{
const bar=seg.firstElementChild;
let f = si<current?1 : si>current?0 : Math.min(1,t/s.dur);
bar.style.width=(f*100)+"%";
});
tCur.textContent=fmt(Math.min(total, starts[current]+Math.min(t,s.dur)));
ppEl.innerHTML = playing?PAUSE:PLAY;
ppEl.setAttribute("aria-label", playing?"Pause":"Play");
}
function jump(i){
ended=false; endEl.classList.remove("show");
current=Math.max(0,Math.min(scenes.length-1,i));
t=0; built=-1; playing=true; render();
}
let last=performance.now();
function frame(now){
const dt=Math.min(now-last,60); last=now;
if(playing && !ended){
t+=dt;
if(t>=scenes[current].dur){
if(current<scenes.length-1){ current++; t=0; }
else { t=scenes[current].dur; playing=false; ended=true; endEl.classList.add("show"); }
}
}
render();
requestAnimationFrame(frame);
}
ppEl.addEventListener("click",()=>{
if(ended){ jump(0); return; }
playing=!playing;
});
$("#replay").addEventListener("click",()=>jump(0));
document.addEventListener("keydown",e=>{
if(e.code==="Space"){ e.preventDefault(); if(ended){jump(0);} else {playing=!playing;} }
else if(e.code==="ArrowRight"){ e.preventDefault(); jump(current+1); }
else if(e.code==="ArrowLeft"){ e.preventDefault(); jump(current-1); }
});
/* Don't play until the demo is scrolled into view. Embedded in the docs page
the player sits below the fold, so an IntersectionObserver created here (and
clipped by the parent-page viewport, even across the iframe) holds it on the
intro poster until the reader reaches it. Opened standalone it's in view at
load, so this fires immediately. Auto-start happens once; manual play/pause
afterwards is untouched. */
let autoStarted=false;
function autoStart(){
if(autoStarted) return;
autoStarted=true;
if(!ended) playing=true;
}
if("IntersectionObserver" in window){
const io=new IntersectionObserver((entries,obs)=>{
if(entries.some(e=>e.isIntersecting)){ autoStart(); obs.disconnect(); }
}, {threshold:0.25});
io.observe($("#player"));
} else {
autoStart(); // no IO support -> preserve the original auto-play behavior
}
render();
requestAnimationFrame(frame);
</script>
|