Equilibrium Concentration Solver for 2A + B ⇌ 2D Reaction

Version 1.0.0 (8.69 KB) by Abhinav
MATLAB script to compute the equilibrium extent of reaction and equilibrium concentrations for the chemical system 2A + B ⇌ 2D using a nonli
1 Download
Updated 10 Nov 2025

View License

This MATLAB script calculates the equilibrium concentrations and extent of reaction for the chemical system:2A+B2D2A + B \rightleftharpoons 2D2A+B2D
using a nonlinear algebraic solver based on the equilibrium constant expression.
The program demonstrates how to use MATLAB’s fsolve to determine the equilibrium point for reactions with mass-balance constraints.
Features
  • Formulates and solves the nonlinear equation for chemical equilibrium
  • Calculates equilibrium concentrations of all reactants and products
  • Verifies that the equilibrium constant KKK is satisfied
  • Plots the nonlinear function f(x)f(x)f(x) versus extent of reaction xxx
  • Fully commented and student-friendly code
Reaction Model
2A + B ⇌ 2D
Let x be the extent of reaction (in moles).
The equilibrium concentrations of each species are expressed as:
[A] = A0 - 2x
[B] = B0 - x
[D] = D0 + 2x
The equilibrium constant expression is:
K = ([D]^2) / ([A]^2 * [B])
Requirements
  • MATLAB R2018a or later
  • Optimization Toolbox (fsolve)
Author
Abhinav Keshewar
Department of Electrical Engineering
K.K Wagh Institute Of Engineering Education and Research, Nashik
📩 aakeshewar370623@kkwagh.edu.in

Cite As

Abhinav (2026). Equilibrium Concentration Solver for 2A + B ⇌ 2D Reaction (https://in.mathworks.com/matlabcentral/fileexchange/182565-equilibrium-concentration-solver-for-2a-b-2d-reaction), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2025b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
1.0.0