{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This is a case-study for the API and not yet a ready demo." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from __future__ import print_function, division\n", "from collections import defaultdict\n", "from chempy import Species, Equilibrium, Henry\n", "from chempy.equilibria import EqSystem\n", "from chempy.units import default_units as u" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "species_keys = 'CO2(g) CO2(aq) H2O H2CO3 H+ HCO3- CO3-2 Ca+2 CaCO3(s)'.split()\n", "eq_str = \"\"\"\n", "CO2(aq) = CO2(g); chempy.henry.HenryWithUnits(3.3e-4 * molar / Pa, 2400 * K)\n", "CO2(aq) + H2O = H2CO3; 1.7e-3/55.4\n", "H2CO3 = H+ + HCO3-; 10**-3.6\n", "HCO3- = H+ + CO3-2; 10**-10.329\n", "CaCO3(s) = Ca+2 + CO3-2; 3.3e-9\n", "\"\"\" # eventually: 55.4 <- [H2O]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "species = [Species.from_formula(s) for s in species_keys]\n", "reactions = [Equilibrium.from_string(s, species_keys) for s in eq_str.split('\\n')[1:-1]]\n", "print('\\n'.join(map(str , reactions)))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#init_conc = defaultdict(lambda: 0*u.molar, {'H2O': 55.5*u.molar, 'CO2(g)': 1*u.atm})\n", "#eqsys = EqSystem(reactions, species)\n", "#eqsys\n", "\n", "# Before this works, mass conservation equations must be adjusted to deal with an \"inifinte\" amount of gas:\n", "#eqsys.root(init_conc, state=298.15*u.K)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.0" } }, "nbformat": 4, "nbformat_minor": 1 }