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

Activity Coefficients

Simulating how NRTL activity coefficients for the ethanol-water system evolve with temperature using PathSim blocks and connections.

The NRTL (Non-Random Two-Liquid) model computes liquid-phase activity coefficients MATHINLINE1ENDMATH that quantify deviations from ideal mixing:

MATHDISPLAY0ENDMATH

Here we wire an NRTL block and two Antoine blocks into a simulation to see how activity coefficients and the resulting bubble pressures change with temperature.

Python
Loading...

System Definition

Set up the blocks: a temperature source, Antoine correlations for both components, and an NRTL activity coefficient model for a 40/60 ethanol-water mixture.

Python
Loading...

A custom Function block computes the bubble pressure from the activity coefficients and pure-component vapor pressures:

MATHDISPLAY0ENDMATH

Python
Loading...

Wiring and Simulation

Connect the temperature source to NRTL and both Antoine blocks. The NRTL outputs and Antoine outputs feed into the bubble pressure calculation. Scopes record everything.

Python
Loading...
18:18:27 - INFO - LOGGING (log: True)
18:18:27 - INFO - BLOCKS (total: 7, dynamic: 0, static: 7, eventful: 0)
18:18:27 - INFO - GRAPH (nodes: 7, edges: 10, alg. depth: 3, loop depth: 0, runtime: 0.060ms)
18:18:27 - INFO - STARTING -> TRANSIENT (Duration: 100.00s)
18:18:27 - INFO - --------------------   1% | 0.0s<0.1s | 3798.4 it/s
18:18:27 - INFO - ####----------------  20% | 0.0s<0.0s | 18536.8 it/s
18:18:27 - INFO - ########------------  40% | 0.0s<0.0s | 18993.9 it/s
18:18:27 - INFO - ############--------  60% | 0.0s<0.0s | 18524.7 it/s
18:18:27 - INFO - ################----  80% | 0.0s<0.0s | 18866.5 it/s
18:18:27 - INFO - #################### 100% | 0.0s<--:-- | 18440.7 it/s
18:18:27 - INFO - FINISHED -> TRANSIENT (total steps: 200, successful: 200, runtime: 16.90 ms)
Python
Loading...

Both activity coefficients exceed 1, confirming positive deviation from Raoult's law — a characteristic of the ethanol-water system. The bubble pressure rises steeply with temperature, crossing 1 atm near the expected boiling point of the mixture.