|
52 | 52 | { |
53 | 53 | "cell_type": "markdown", |
54 | 54 | "metadata": {}, |
55 | | - "source": "Feed hot water at 370 K and cold water at 290 K. Record the outlet temperatures over time and the per-cell temperature profiles for spatial analysis." |
| 55 | + "source": [ |
| 56 | + "Feed hot water at 370 K and cold water at 290 K. Record the outlet temperatures over time." |
| 57 | + ] |
56 | 58 | }, |
57 | 59 | { |
58 | 60 | "cell_type": "code", |
59 | 61 | "execution_count": null, |
60 | 62 | "metadata": {}, |
61 | 63 | "outputs": [], |
62 | | - "source": "N = 10 # must match N_cells\n\nT_h_in = Source(func=lambda t: 370.0) # hot inlet [K]\nT_c_in = Source(func=lambda t: 290.0) # cold inlet [K]\n\nscp_out = Scope(labels=[\"T_h_out [K]\", \"T_c_out [K]\"])\nscp_hot = Scope(labels=[f\"T_h_{i+1}\" for i in range(N)])\nscp_cold = Scope(labels=[f\"T_c_{i+1}\" for i in range(N)])\n\nconnections = [\n Connection(T_h_in, hx), # T_h_in -> port 0\n Connection(T_c_in, hx[1]), # T_c_in -> port 1\n Connection(hx, scp_out), # T_h_out -> outlet scope\n Connection(hx[1], scp_out[1]), # T_c_out -> outlet scope\n]\n\n# Connect per-cell temperatures to profile scopes\nfor i in range(N):\n connections.append(Connection(hx[2 + i], scp_hot[i])) # T_h_i\n connections.append(Connection(hx[2 + N + i], scp_cold[i])) # T_c_i\n\nsim = Simulation(\n blocks=[T_h_in, T_c_in, hx, scp_out, scp_hot, scp_cold],\n connections=connections,\n dt=0.02,\n)\n\nsim.run(200)" |
| 64 | + "source": "T_h_in = Source(func=lambda t: 370.0) # hot inlet [K]\nT_c_in = Source(func=lambda t: 290.0) # cold inlet [K]\n\nscp = Scope(labels=[\"T_h_out [K]\", \"T_c_out [K]\"])\n\nsim = Simulation(\n blocks=[T_h_in, T_c_in, hx, scp],\n connections=[\n Connection(T_h_in, hx), # T_h_in -> port 0\n Connection(T_c_in, hx[1]), # T_c_in -> port 1\n Connection(hx, scp), # T_h_out -> scope port 0\n Connection(hx[1], scp[1]), # T_c_out -> scope port 1\n ],\n dt=0.02,\n)\n\nsim.run(200)" |
63 | 65 | }, |
64 | 66 | { |
65 | 67 | "cell_type": "code", |
66 | 68 | "execution_count": null, |
67 | 69 | "metadata": {}, |
68 | 70 | "outputs": [], |
69 | | - "source": "time, out = scp_out.read()\n_, hot_profile = scp_hot.read()\n_, cold_profile = scp_cold.read()\n\nfig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 5))\n\n# Outlet temperatures over time\nax1.plot(time, out[0], label=\"Hot outlet\")\nax1.plot(time, out[1], label=\"Cold outlet\")\nax1.axhline(370, color=\"gray\", ls=\"--\", alpha=0.4, label=\"Hot inlet\")\nax1.axhline(290, color=\"gray\", ls=\"-.\", alpha=0.4, label=\"Cold inlet\")\nax1.set_xlabel(\"Time [s]\")\nax1.set_ylabel(\"Temperature [K]\")\nax1.set_title(\"Outlet Temperatures\")\nax1.legend()\nax1.grid(True, alpha=0.3)\n\n# Spatial temperature profile at steady state\ncells = np.arange(1, N + 1)\nT_h_ss = [hot_profile[i][-1] for i in range(N)]\nT_c_ss = [cold_profile[i][-1] for i in range(N)]\n\nax2.plot(cells, T_h_ss, \"o-\", color=\"tab:red\", label=\"Hot stream\")\nax2.plot(cells, T_c_ss, \"s-\", color=\"tab:blue\", label=\"Cold stream\")\nax2.set_xlabel(\"Cell number (hot flow direction →)\")\nax2.set_ylabel(\"Temperature [K]\")\nax2.set_title(\"Spatial Profile (Steady State)\")\nax2.legend()\nax2.grid(True, alpha=0.3)\n\nplt.tight_layout()\nplt.show()" |
| 71 | + "source": "time, signals = scp.read()\n\nfig, ax = plt.subplots(figsize=(8, 5))\n\nax.plot(time, signals[0], label=\"Hot outlet\")\nax.plot(time, signals[1], label=\"Cold outlet\")\nax.axhline(370, color=\"gray\", ls=\"--\", alpha=0.4, label=\"Hot inlet\")\nax.axhline(290, color=\"gray\", ls=\"-.\", alpha=0.4, label=\"Cold inlet\")\nax.set_xlabel(\"Time [s]\")\nax.set_ylabel(\"Temperature [K]\")\nax.set_title(\"Heat Exchanger Outlet Temperatures\")\nax.legend()\nax.grid(True, alpha=0.3)\n\nplt.tight_layout()\nplt.show()" |
70 | 72 | }, |
71 | 73 | { |
72 | 74 | "cell_type": "markdown", |
73 | 75 | "metadata": {}, |
74 | | - "source": "At startup, both sides are cold. The hot fluid quickly warms the exchanger from the inlet side while the cold fluid absorbs heat. At steady state, the counter-current arrangement creates the characteristic temperature cross — the cold outlet approaches the hot inlet and vice versa. The spatial profile shows the classic counter-current pattern where both streams decrease along the hot flow direction." |
| 76 | + "source": [ |
| 77 | + "At startup, both sides are cold. The hot fluid quickly warms the exchanger from the inlet side while the cold fluid absorbs heat. At steady state, the counter-current arrangement creates the characteristic temperature cross — the cold outlet approaches the hot inlet and vice versa, achieving high thermal efficiency." |
| 78 | + ] |
75 | 79 | } |
76 | 80 | ], |
77 | 81 | "metadata": { |
|
0 commit comments