Tuesday, 28 April 2026

The Chemistry and Code of Sulfur Recovery

In industrial chemistry, removing sulfur from "sour gas" (natural gas containing H_2S) is a critical safety and environmental task. One of the most elegant ways to do this is the Claus Process. Today, we’ll use Python to model this reaction, balancing the stoichiometry and calculating the physical volumes of our products.

The Reaction

​We are looking at the reaction where sulfur dioxide (SO2)—often from coal burning—is neutralized by hydrogen sulfide (H2S):

SO2 +H2S -> 3S + 2H2O

The Python Script



"""
Project: The 70-Year-Old Coder
Topic: Stoichiometry & Physics of the Claus Process
"""

# 1. Chemical Constants
atwts = {"S": 32.06, "O": 15.999, "H": 1.008}
stoichiometry = {"SO2": 1, "H2S": 2, "S": 3, "H2O": 2}

def mol_weight(chem):
    return sum([v * atwts.get(c.upper()) for c, v in chem.items()])

species_data = {
    "SO2": {"s": 1, "o": 2},
    "H2S": {"h": 2, "s": 1},
    "S":   {"s": 1},
    "H2O": {"h": 2, "o": 1}
}

molecular_wts = {name: mol_weight(comp) for name, comp in species_data.items()}

# 2. Input Parameters
wt_coal_tons = 2
pct_sulfur = 3.5
temp_c = 27
pressure_atm = 1

# 3. Mass & Gas Calculations
sulfur_in_coal_gm = wt_coal_tons * 1_000_000 * (pct_sulfur / 100)
so2_formed = (molecular_wts['SO2'] / atwts['S']) * sulfur_in_coal_gm

# Molar ratio calculation for H2S required
h2s_req = (stoichiometry['H2S'] * molecular_wts['H2S']) / \
          (stoichiometry['SO2'] * molecular_wts['SO2']) * so2_formed

# Volume using Charles's Law (v1/t1 = v2/t2) at 1 atm
R = 0.08206  
temp_k = temp_c + 273.15
moles_h2s = h2s_req / molecular_wts['H2S']
vol_h2s_liters = (moles_h2s * R * temp_k) / pressure_atm

# 4. Physical Recovery (Density Logic)
s_recovered_gm = (stoichiometry['S'] * molecular_wts['S']) / \
                 (stoichiometry['SO2'] * molecular_wts['SO2']) * so2_formed
                 
density_s = 2.07  # g/cm3
vol_s_liters = (s_recovered_gm / density_s) / 1000

# --- OUTPUT ---
print(f"--- Results for {wt_coal_tons} Tons of Coal ({pct_sulfur}% S) ---")
print(f"SO2 Produced:      {so2_formed/1000:.2f} kg")
print(f"H2S Required:      {h2s_req/1000:.2f} kg")
print(f"Volume of H2S:     {vol_h2s_liters:.0f} Liters at {temp_c}°C")
print(f"\n--- Physical Recovery ---")
print(f"Sulfur Recovered:  {s_recovered_gm/1000:.2f} kg")
print(f"Sulfur Volume:     {vol_s_liters:.1f} Liters")

No comments:

Post a Comment

Visualizing Particle Kinematics with Python

Understanding the relationship between position, velocity, and acceleration is fundamental to physics. However, seeing how these variables e...