{ "cells": [ { "cell_type": "markdown", "id": "0da81065", "metadata": {}, "source": [ "# Carbon dioxide gas solubility in the NaCl-brine\n", "\n", "This tutorial demonstrates how to simulate the solubility of CO2 gas in the NaCl-brine and its dependence on\n", "the salinity of the brine (also called a salting-out effect).\n", "\n", "First, we import all the necessary packages for further simulations:" ] }, { "cell_type": "code", "execution_count": null, "id": "616fff4c", "metadata": { "lines_to_next_cell": 1 }, "outputs": [], "source": [ "from reaktoro import *\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "id": "82474694", "metadata": {}, "source": [ "Function `solubility_co2()` returns the concentration of CO2(g) that was dissolved in the brined:" ] }, { "cell_type": "code", "execution_count": null, "id": "39044bba", "metadata": { "lines_to_next_cell": 1 }, "outputs": [], "source": [ "def solubility_co2(system, T, P, n0CO2g, mNaCl):\n", "\n", " # Define equilibrium problem as a mixture of NaCl-brine with given salinity and\n", " # CO2 of a given initial concentration at fixed T and P\n", " problem = EquilibriumProblem(system)\n", " problem.setTemperature(T, \"celsius\")\n", " problem.setPressure(P, \"bar\")\n", " problem.add(\"H2O\", 1.0, \"kg\")\n", " problem.add(\"CO2\", n0CO2g, \"mol\")\n", " problem.add(\"NaCl\", mNaCl, \"mol\")\n", "\n", " # Equilibrate chemical problem\n", " state = equilibrate(problem)\n", "\n", " # Return the difference of initial amount of the CO2(g) and remaining one after equilibration\n", " return (n0CO2g - state.speciesAmount(\"CO2(g)\"))" ] }, { "cell_type": "markdown", "id": "fb07ae2e", "metadata": {}, "source": [ "Below, we set up the chemical system for running the solubility calculations:" ] }, { "cell_type": "code", "execution_count": null, "id": "92118a6c", "metadata": {}, "outputs": [], "source": [ "# Define database\n", "database = Database(\"supcrt98.xml\")\n", "\n", "# Initialize phases with chemical editor\n", "editor = ChemicalEditor(database)\n", "editor.addAqueousPhaseWithElements(\"H O C Na Cl\")\n", "editor.addGaseousPhase([\"CO2(g)\"])\n", "editor.addMineralPhase(\"Halite\")\n", "\n", "# Create chemical system\n", "system = ChemicalSystem(editor)\n", "\n", "# Initialize temperature (in celsius)\n", "T = np.arange(20.0, 150.0, 5.0)\n", "# Initialize pressure (in bar)\n", "P = 1.0\n", "# Initial amount of CO2(g) (in mol)\n", "n0CO2g = 10.0\n", "\n", "# Generate the lists of CO2(g) mols that got dissolved in NaCl-brine of different salinity\n", "deltaCO2_nacl1 = [solubility_co2(system, t, P, n0CO2g, mNaCl=1.0) for t in T]\n", "deltaCO2_nacl2 = [solubility_co2(system, t, P, n0CO2g, mNaCl=2.0) for t in T]\n", "deltaCO2_nacl4 = [solubility_co2(system, t, P, n0CO2g, mNaCl=4.0) for t in T]\n", "deltaCO2_nacl6 = [solubility_co2(system, t, P, n0CO2g, mNaCl=6.0) for t in T]" ] }, { "cell_type": "markdown", "id": "674eb391", "metadata": {}, "source": [ "Plot solubility of CO2(g) as a function of temperature for different salinities of NaCl-brine:" ] }, { "cell_type": "code", "execution_count": null, "id": "e715b7ce", "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots()\n", "ax.plot(T, deltaCO2_nacl1, label=f\"1 NaCl molal\")\n", "ax.plot(T, deltaCO2_nacl2, label=f\"2 NaCl molal\")\n", "ax.plot(T, deltaCO2_nacl4, label=f\"4 NaCl molal\")\n", "ax.plot(T, deltaCO2_nacl6, label=f\"6 NaCl molal\")\n", "ax.legend(loc=\"best\")\n", "ax.grid(True)\n", "ax.set(xlabel='Temperature [°C]')\n", "ax.set(ylabel='Solubility [mol/kgw]')\n", "ax.set(title='Solubility of CO2 in NaCl brine, P = ' + str(P) + ' bar')\n", "plt.savefig('co2-solubility-nacl-h2o-vs-temperature-1bar.png', bbox_inches='tight')" ] }, { "cell_type": "markdown", "id": "54604634", "metadata": {}, "source": [ "We see the illustration of the so-called salting-out effect. It indicates lower solubility of the CO2(g)\n", "for more saline NaCl-brines. Moreover, we see that the solubility of carbon dioxide decreases with the growth of the\n", "temperature.\n", "\n", "Alternatively, we can study the dependence of the CO2(g) solubility on the pressure increase:" ] }, { "cell_type": "code", "execution_count": null, "id": "8488db03", "metadata": {}, "outputs": [], "source": [ "# Initialize pressure range (in bar)\n", "P = np.arange(1.0, 300.0, 1.0)\n", "# Initialize pressure (in celsius)\n", "T = 300.0\n", "# Generate the lists of CO2(g) mols that got dissolved in NaCl-brine of different salinity\n", "deltaCO2_nacl1 = [solubility_co2(system, T, p, n0CO2g, mNaCl=1.0) for p in P]\n", "deltaCO2_nacl2 = [solubility_co2(system, T, p, n0CO2g, mNaCl=2.0) for p in P]\n", "deltaCO2_nacl4 = [solubility_co2(system, T, p, n0CO2g, mNaCl=4.0) for p in P]\n", "deltaCO2_nacl6 = [solubility_co2(system, T, p, n0CO2g, mNaCl=6.0) for p in P]" ] }, { "cell_type": "markdown", "id": "33822d71", "metadata": {}, "source": [ "Below, we plot solubility of CO2(g) as a function of pressure for different salinities of NaCl-brine:" ] }, { "cell_type": "code", "execution_count": null, "id": "7c9f97be", "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots()\n", "ax.plot(P, deltaCO2_nacl1, label=f\"1 NaCl molal\")\n", "ax.plot(P, deltaCO2_nacl2, label=f\"2 NaCl molal\")\n", "ax.plot(P, deltaCO2_nacl4, label=f\"4 NaCl molal\")\n", "ax.plot(P, deltaCO2_nacl6, label=f\"6 NaCl molal\")\n", "ax.legend(loc=\"best\")\n", "ax.grid(True)\n", "ax.set(xlabel='Pressure [bar]')\n", "ax.set(ylabel='Solubility [mol/kgw]')\n", "ax.set(title='Solubility of CO2 in NaCl brine, T = ' + str(T) + ' celsius')\n", "plt.savefig('co2-solubility-nacl-h2o-vs-pressure-300celsius.png', bbox_inches='tight')" ] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 5 }