Summary We present a new algorithm based on automatic differentiation that enables precise computation of the derivatives of the Z-factor, facilitating the utilization of Newton’s method or coupling with a robust flow solver. Leveraging a free open-source code [MATLAB Reservoir Simulation Toolbox (MRST)], we develop an electrolyte cubic plus association (e-CPA) equation of state (EoS) model to accurately represent the injection of carbon dioxide (CO2) in brine. By integrating flow and thermodynamics, we construct an advanced compositional simulator using MRST’s object-oriented, automatic differentiation framework and the newly developed e-CPA EoS model. This simulator offers flexibility through both overall-composition and natural-variable formulations, achieved by selecting different primary variables. The Péneloux volume translation technique is employed to modify the EoS model’s volume, ensuring accurate density calculation for the mixture. Additionally, we introduce a viscosity model, e-CPA-FV, which accurately predicts the viscosity of carbon capture and storage (CCS) fluids, surpassing the accuracy of the traditional Lohrenz-Bray-Clark (LBC) model. Our simulator demonstrates superior performance in predicting CO2-brine systems compared with the standard formulation based on the Peng-Robinson (PR) EoS and can handle brine with various salts. The self-contained source code necessary to reproduce all examples is available on the open-access Zenodo digital repository (doi: 10.5281/zenodo.10691505).