{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Work in progress, it is far from trivial to make ``quantities`` and ``sympy`` play nice together" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import math\n", "from chempy import Equilibrium, ReactionSystem\n", "from chempy.units import SI_base_registry, Backend, default_units as u, default_constants as c\n", "from chempy.thermodynamics import GibbsEqConst\n", "from chempy.kinetics.rates import MassAction, Arrhenius\n", "from chempy.kinetics.ode import get_odesys" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "DH, DS, R = -20e3 * u.J/u.mol, -30 * u.J/u.mol/u.K, c.molar_gas_constant.definition\n", "ref = 'reinterpreted from: M. W. Lister & D. E. Rivington: Can. J. Chem., 1955, 33(10): 1572-1590'\n", "eq = Equilibrium({'Fe+3', 'SCN-'}, {'FeSCN+2'}, GibbsEqConst([DH/R, DS/R]))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "be = Backend()\n", "eq.equilibrium_constant({'temperature': 298.15*u.K}, backend=be)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A, Ea = math.exp(35.5)/u.molar/u.s, 72.2e3 * u.J/u.mol\n", "fw, bw = eq.as_reactions(kf=MassAction(Arrhenius([A, Ea/R])))\n", "fw.param.dedimensionalisation(SI_base_registry)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "params = {'temperature': 298.15*u.K, 'Fe+3': 1e-2*u.molar, 'SCN-': 1e-3*u.molar, 'FeSCN+2': 1e-6*u.molar}\n", "fw.rate(params, backend=be)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bw.param.dedimensionalisation(SI_base_registry)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bw.rate(params, backend=be) # note incorrect formula in bw case (need to divide by c0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rsys = ReactionSystem([fw, bw])\n", "rsys" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Still failing\n", "#odesys = get_odesys(rsys, units=SI_base_registry)[0]" ] } ], "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.6.3" } }, "nbformat": 4, "nbformat_minor": 1 }