// Reverse-osmosis model: solution-diffusion transport with film-theory // concentration polarization. Simplified for illustration, not for design. // Units: pressure bar, salinity mg/L as NaCl, flux L/m²/h (LMH), energy kWh/m³. export const MEMBRANES = { brackish: { name: 'Brackish-water membrane', A: 3.5, B: 0.25, fluxLimit: 30 }, seawater: { name: 'Seawater membrane', A: 1.0, B: 0.08, fluxLimit: 20 } }; export const PRESETS = { brackish: { label: 'Brackish groundwater', salinity: 3000, pressure: 12, recovery: 80, membrane: 'brackish', erd: false }, seawater: { label: 'Seawater', salinity: 35000, pressure: 60, recovery: 45, membrane: 'seawater', erd: true }, reuse: { label: 'Water reuse', salinity: 1000, pressure: 9, recovery: 85, membrane: 'brackish', erd: false } }; // Osmotic pressure of NaCl at 25 °C: van 't Hoff with an osmotic coefficient of 0.93. export const osmotic = mgL => 0.789 * mgL / 1000; const K_MASS_TRANSFER = 100; // LMH, feed-channel mass-transfer coefficient const CHANNEL_LOSS = 1; // bar, feed-to-concentrate pressure drop const PUMP_EFF = 0.8, ERD_EFF = 0.95; export function roModel({ pressure, salinity, recovery, membrane = 'brackish', erd = false }) { const m = MEMBRANES[membrane], R = Math.min(0.95, Math.max(0.01, recovery / 100)); // Average salinity along the feed channel as water is removed (log-mean). const bulk = salinity * Math.log(1 / (1 - R)) / R; let flux = 10, permeate = 0, beta = 1, wall = bulk; for (let i = 0; i < 40; i++) { beta = Math.exp(flux / K_MASS_TRANSFER); // salt builds up at the membrane wall wall = bulk * beta; permeate = m.B * wall / (flux + m.B); // salt flux / water flux const ndp = pressure - CHANNEL_LOSS / 2 - (osmotic(wall) - osmotic(permeate)); const next = Math.max(0, m.A * ndp); flux += (next - flux) * 0.5; if (flux < 1e-4) { flux = 0; break; } } const osmoticWall = osmotic(bulk * Math.exp(flux / K_MASS_TRANSFER)); const ndp = pressure - CHANNEL_LOSS / 2 - (osmoticWall - osmotic(flux > 0 ? permeate : 0)); const running = flux > 0.5; // below this only a salty trickle diffuses through if (!running) { flux = 0; permeate = 0; } const rejection = running ? 1 - permeate / salinity : 0; const concentrate = running ? (salinity - R * permeate) / (1 - R) : salinity; const base = pressure / (36 * PUMP_EFF); // 1 bar·m³ = 1/36 kWh const energy = running ? (erd ? base * (1 + (1 - ERD_EFF) * (1 - R) / R) : base / R) : 0; const notes = []; if (!running) notes.push('No clean water: the pressure is below the osmotic pressure at the membrane. Raise the pressure or lower the recovery.'); else { if (flux > m.fluxLimit) notes.push('Flux is high for this membrane. A real plant would foul quickly here.'); if (R >= 0.8) notes.push('High recovery concentrates scale-forming salts. Real plants dose antiscalant.'); if (permeate > 500) notes.push('Permeate is above 500 mg/L, a common drinking-water guideline for dissolved solids.'); if (!notes.length) notes.push('Running well: pressure beats osmotic pressure, salt stays on the feed side.'); } return { running, flux, permeate, rejection, concentrate, energy, ndp, osmoticWall, osmoticFeed: osmotic(salinity), beta, notes, membrane: m }; }