This example is interactive. Click the play button on any cell to execute it, or run all cells in sequence.

Counter-Current Heat Exchanger

Simulating the startup transient of a counter-current shell-and-tube heat exchanger, showing how temperature profiles develop along the exchanger length.

The exchanger is discretized into MATHINLINE2ENDMATH cells along its length. In each cell, the hot and cold streams exchange heat proportional to the local temperature difference:

MATHDISPLAY0ENDMATH

MATHDISPLAY1ENDMATH

The hot stream flows from cell 1 to MATHINLINE3ENDMATH, the cold stream flows counter-currently from cell MATHINLINE4ENDMATH to 1.

Python
Loading...

Configure a heat exchanger with 10 cells. Both sides start at 300 K (cold), then hot fluid at 370 K enters. This lets us watch the temperature profile build up from the initial uniform state. The high MATHINLINE0ENDMATH relative to the flow rate ensures significant heat transfer.

Python
Loading...

Feed hot water at 370 K and cold water at 290 K. Record the outlet temperatures over time.

Python
Loading...
18:18:16 - INFO - LOGGING (log: True)
18:18:16 - INFO - BLOCKS (total: 4, dynamic: 1, static: 3, eventful: 0)
18:18:16 - INFO - GRAPH (nodes: 4, edges: 4, alg. depth: 1, loop depth: 0, runtime: 0.174ms)
18:18:16 - INFO - STARTING -> TRANSIENT (Duration: 200.00s)
18:18:17 - INFO - --------------------   1% | 0.0s<1.2s | 8259.1 it/s
18:18:17 - INFO - ####----------------  20% | 0.3s<1.0s | 8070.1 it/s
18:18:17 - INFO - ########------------  40% | 0.6s<0.8s | 7989.9 it/s
18:18:17 - INFO - ############--------  60% | 0.8s<0.5s | 8277.9 it/s
18:18:18 - INFO - ################----  80% | 1.1s<0.3s | 7985.9 it/s
18:18:18 - INFO - #################### 100% | 1.3s<--:-- | 10878.7 it/s
18:18:18 - INFO - FINISHED -> TRANSIENT (total steps: 10000, successful: 10000, runtime: 1258.22 ms)
Python
Loading...

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.