Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VLE Flash Drum: From First Principles to Process Simulation

What is this project?

This project simulates a flash drum — a vessel that separates a hydrocarbon mixture into vapor and liquid streams based on thermodynamics. The feed is a 50/50 mixture of methane and propane at 298.15 K and 70 bar.

The same calculation is done two ways:

  1. Python — built from scratch using fundamental equations
  2. DWSIM — replicated in a free, open-source process simulator

The goal is to understand what process simulators are actually doing under the hood — not just click buttons.


What is a Flash Drum?

A flash drum physically separates a mixed feed into two streams:

  • Vapor outlet (top) — lighter components that prefer the gas phase
  • Liquid outlet (bottom) — heavier components that prefer the liquid phase

No reaction happens. It is purely a thermodynamic separation based on the volatility of each component.


Phase 1: Theory

Before writing any code, three core concepts were understood:

Antoine Equation

Used to calculate the saturation vapor pressure of a component at a given temperature. Saturation vapor pressure is the pressure at which a substance is in equilibrium between liquid and vapor phases.

log₁₀(Psat) = A - B / (T + C)

Where A, B, C are component-specific constants and T is temperature in Kelvin.

Raoult's Law

Relates the partial pressure of a component in the vapor phase to its liquid mole fraction:

P_i = x_i × Psat_i

This assumes the mixture is ideal — meaning no molecular interactions between different components.

K-Values

The K-value (equilibrium ratio) of a component tells us how much it prefers vapor over liquid:

K_i = Psat_i / P

  • K > 1 → component prefers vapor phase
  • K < 1 → component prefers liquid phase

At 298.15 K and 70 bar:

  • K_methane = 4.53 (strongly vapor)
  • K_propane = 0.136 (strongly liquid)

Rachford-Rice Equation

This equation solves for V (vapor fraction) given feed compositions and K-values:

Σ z_i(K_i - 1) / (1 + V(K_i - 1)) = 0

It is solved numerically because it cannot be rearranged analytically for complex mixtures.


Phase 2: Python Implementation

Built entirely from scratch — no process simulation libraries used.

Functions:

  • get_psat(component, T) — Antoine equation for Psat
  • get_K(component, T, P) — K-value from Raoult's Law
  • rachford_rice(V, z, K) — Rachford-Rice equation
  • flash_drum(T, P, z, components) — complete flash calculation

Feed Conditions:

  • Components: Methane, Propane
  • Feed composition: z = [0.5, 0.5]
  • Temperature: 298.15 K
  • Pressure: 70 bar

Results:

Stream Methane Propane
Feed 0.500 0.500
Vapor 0.8907 0.1093
Liquid 0.1966 0.8034

Vapor fraction V = 0.4371


Phase 3: DWSIM Simulation

The same flash drum was built in DWSIM using the Peng-Robinson (PR) equation of state.

Why Peng-Robinson? Peng-Robinson is a real equation of state that accounts for molecular interactions between components. At 70 bar, molecules are tightly packed and interact significantly — Raoult's Law ignores this, PR does not. PR was specifically developed for hydrocarbon systems and is the industry standard for oil and gas applications.

DWSIM Results:

Stream Methane Propane
Feed 0.500 0.500
Vapor 0.7222 0.2778
Liquid 0.3749 0.6251

Vapor fraction V = 0.3602


Comparison: Python vs DWSIM

Parameter Python (Raoult's Law) DWSIM (Peng-Robinson) Difference
Vapor fraction 0.4371 0.3602 18%
y_methane 0.8907 0.7222 19%
y_propane 0.1093 0.2778 154%
x_methane 0.1966 0.3749 91%
x_propane 0.8034 0.6251 22%

Why the difference? Raoult's Law assumes ideal behavior — no molecular interactions. At 70 bar, this assumption breaks down significantly. Methane and propane molecules interact with each other, making it harder for methane to escape into the vapor phase. Raoult's Law overestimates vaporization; Peng-Robinson gives a more physically accurate result. This is why industrial process simulators never use Raoult's Law for high-pressure hydrocarbon systems.


Tools Used

  • Python 3.x
  • scipy (brentq for numerical solving)
  • DWSIM (open-source process simulator)

Skills Demonstrated

  • Vapor-liquid equilibrium fundamentals
  • Antoine equation and Raoult's Law
  • Rachford-Rice flash calculation
  • Equation of state selection (ideal vs Peng-Robinson)
  • Process simulation in DWSIM
  • Python numerical methods

About

VLE flash drum calculator built from first principles in Python, validated against DWSIM using Peng-Robinson EOS. Covers Antoine equation, Raoult's Law, K-values, and Rachford-Rice flash calculation.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages