diff --git a/docs/source/tutorials/10_Process.ipynb b/docs/source/tutorials/10_Process.ipynb index 2a4817a6..945c66f0 100644 --- a/docs/source/tutorials/10_Process.ipynb +++ b/docs/source/tutorials/10_Process.ipynb @@ -82,15 +82,7 @@ "execution_count": 2, "id": "3dc1138e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This tutorial was made with qsdsan v1.2.5.\n" - ] - } - ], + "outputs": [], "source": [ "import qsdsan as qs\n", "print(f'This tutorial was made with qsdsan v{qs.__version__}.')" @@ -117,24 +109,10 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "61b1bd62", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "Image(url='https://lucid.app/publicSegments/view/2c231fa2-6065-46b9-83af-a790ce38b6c0/image.png', width=600)" ] @@ -158,21 +136,10 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "75766cf7", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "qsdsan._process.Process" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# If you check\n", "qs.Process\n", @@ -192,21 +159,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "id": "50db4564", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# If you check\n", "qs.processes" @@ -222,37 +178,10 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "id": "fc717b78", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "('DiffusedAeration',\n", - " 'create_asm1_cmps',\n", - " 'ASM1',\n", - " 'create_asm2d_cmps',\n", - " 'ASM2d',\n", - " 'create_adm1_cmps',\n", - " 'ADM1',\n", - " 'non_compet_inhibit',\n", - " 'substr_inhibit',\n", - " 'T_correction_factor',\n", - " 'pH_inhibit',\n", - " 'Hill_inhibit',\n", - " 'rhos_adm1',\n", - " 'Decay',\n", - " 'KineticReaction',\n", - " 'create_pm2_cmps',\n", - " 'PM2')" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# To see the list of objects that can be directly imported from this folder\n", "qs.processes.__all__" @@ -270,39 +199,12 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "id": "6e6931bb", "metadata": { "scrolled": true }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'__all__',\n", - " '__builtins__',\n", - " '__cached__',\n", - " '__doc__',\n", - " '__file__',\n", - " '__loader__',\n", - " '__name__',\n", - " '__package__',\n", - " '__path__',\n", - " '__spec__',\n", - " '_adm1',\n", - " '_aeration',\n", - " '_asm1',\n", - " '_asm2d',\n", - " '_decay',\n", - " '_kinetic_reaction',\n", - " '_pm2'}" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# You can see other attributes of the `qs.processes` folder with the `dir` function\n", "set(dir(qs.processes)) - set(qs.processes.__all__)" @@ -318,21 +220,10 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "id": "82751cf8", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# For example, `_asm1.py` is a script in the `processes` folder.\n", "qs.processes._asm1" @@ -363,18 +254,10 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "id": "7e4b98a4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CompiledComponents([S_I, S_S, X_I, X_S, X_BH, X_BA, X_P, S_O, S_NO, S_NH, S_ND, X_ND, S_ALK, S_N2, H2O])\n" - ] - } - ], + "outputs": [], "source": [ "# Before we get to the subsections, let's get ready by loading ASM1-related objects in qsdsan\n", "from qsdsan.processes import create_asm1_cmps, ASM1\n", @@ -394,27 +277,10 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "id": "2b7ccd5b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Thermo(\n", - " chemicals=CompiledComponents([S_I, S_S, X_I, X_S, X_BH, X_BA, X_P, S_O, S_NO, S_NH, S_ND, X_ND, S_ALK, S_N2, H2O]),\n", - " mixture=Mixture(\n", - " rule='ideal', ...\n", - " include_excess_energies=False\n", - " ),\n", - " Gamma=DortmundActivityCoefficients,\n", - " Phi=IdealFugacityCoefficients,\n", - " PCF=MockPoyintingCorrectionFactors\n", - ")\n" - ] - } - ], + "outputs": [], "source": [ "# By default, the thermo is set with this `CompiledComponents` object upon its creation.\n", "# We can verify that by calling the `get_thermo` function\n", @@ -423,21 +289,10 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "id": "948340c9", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(qsdsan._process.CompiledProcesses,)" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Next we need to create an instance of the ASM1 model\n", "# We can see that `ASM1` is a subclass of `CompiledProcesses`, so it can be used for demonstration\n", @@ -447,7 +302,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "id": "7357bed8", "metadata": { "scrolled": true @@ -460,20 +315,12 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "id": "bdf27943", "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ASM1([aero_growth_hetero, anox_growth_hetero, aero_growth_auto, decay_hetero, decay_auto, ammonification, hydrolysis, hydrolysis_N])\n" - ] - } - ], + "outputs": [], "source": [ "# Without getting into the details of ASM1, we will leave all parameters at their default values \n", "asm1 = ASM1()\n", @@ -503,43 +350,10 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "id": "25a826a8", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Process: aero_growth_hetero\n", - "[stoichiometry] S_S: -1.0/Y_H\n", - " X_BH: 1.00\n", - " S_O: 1.0*(Y_H - 1.0)/Y_H\n", - " S_NH: -0.0800\n", - " S_ALK: -0.0686\n", - "[reference] X_BH\n", - "[rate equation] S_NH*S_O*S_S*X_BH*mu_H/((K_N...\n", - "[parameters] Y_H: 0.67\n", - " Y_A: 0.24\n", - " f_P: 0.08\n", - " mu_H: 4\n", - " K_S: 10\n", - " K_O_H: 0.2\n", - " K_NO: 0.5\n", - " b_H: 0.3\n", - " mu_A: 0.5\n", - " K_NH: 1\n", - " K_O_A: 0.4\n", - " b_A: 0.05\n", - " eta_g: 0.8\n", - " k_a: 0.05\n", - " k_h: 3\n", - " K_X: 0.1\n", - " eta_h: 0.8\n", - "[dynamic parameters] \n" - ] - } - ], + "outputs": [], "source": [ "# Let's take the 0th process in `asm1` as an example to learn about `Process`:\n", "# p1 = asm1.tuple[0]\n", @@ -573,25 +387,10 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "id": "baea578a", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'S_S': -1.49253731343284,\n", - " 'X_BH': 1.00000000000000,\n", - " 'S_O': -0.492537313432836,\n", - " 'S_NH': -0.0800000000000000,\n", - " 'S_ALK': -0.0685997415522571}" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# For example, we can retrieve information on the stoichiometry of this process\n", "p1.stoichiometry" @@ -611,21 +410,10 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 16, "id": "acb5b8e0", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'X_BH'" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# This information can also be accessed by calling the `ref_component` property.\n", "p1.ref_component" @@ -633,26 +421,12 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "id": "d0612896", "metadata": { "scrolled": true }, - "outputs": [ - { - "data": { - "text/latex": [ - "$\\displaystyle \\frac{4.0 S_{NH} S_{O} S_{S} X_{BH}}{\\left(S_{NH} + 1.0\\right) \\left(S_{O} + 0.2\\right) \\left(S_{S} + 10.0\\right)}$" - ], - "text/plain": [ - "4.0*S_NH*S_O*S_S*X_BH/((S_NH + 1.0)*(S_O + 0.2)*(S_S + 10.0))" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Another defining characteristics of a process is its rate equation, which is stored as a\n", "# property of the `Process` object\n", @@ -671,24 +445,10 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "id": "0ce7b4df", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$\\displaystyle \\frac{S_{NH} S_{O} S_{S} X_{BH} \\mu_{H}}{\\left(K_{NH} + S_{NH}\\right) \\left(K_{O H} + S_{O}\\right) \\left(K_{S} + S_{S}\\right)}$" - ], - "text/plain": [ - "S_NH*S_O*S_S*X_BH*mu_H/((K_NH + S_NH)*(K_O_H + S_O)*(K_S + S_S))" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# If we access the private attribute\n", "p1._rate_equation" @@ -704,7 +464,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 19, "id": "50b77ac8", "metadata": {}, "outputs": [], @@ -722,21 +482,10 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 20, "id": "0142f901", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Now that we've understood the required input to the rate equation, we can try evaluating the\n", "# process rate. Let's try with all component concentrations equal to 1.\n", @@ -755,21 +504,10 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 21, "id": "aceafb27", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "0.15151515151515152" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Note that the `rate_equation` attribute only stores the formula.\n", "# The evaluation of process rate is done through the `rate_function` attribute, which is rendered\n", @@ -791,37 +529,10 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 22, "id": "62dc9537", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Y_H': 0.67,\n", - " 'Y_A': 0.24,\n", - " 'f_P': 0.08,\n", - " 'mu_H': 4.0,\n", - " 'K_S': 10.0,\n", - " 'K_O_H': 0.2,\n", - " 'K_NO': 0.5,\n", - " 'b_H': 0.3,\n", - " 'mu_A': 0.5,\n", - " 'K_NH': 1.0,\n", - " 'K_O_A': 0.4,\n", - " 'b_A': 0.05,\n", - " 'eta_g': 0.8,\n", - " 'k_a': 0.05,\n", - " 'k_h': 3.0,\n", - " 'K_X': 0.1,\n", - " 'eta_h': 0.8}" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# For `asm1` and the individual processes within `asm1`, parameters are stored as a dictionary\n", "p1.parameters\n", @@ -839,37 +550,10 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 23, "id": "0ab063bf", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Y_H': 0.8,\n", - " 'Y_A': 0.24,\n", - " 'f_P': 0.08,\n", - " 'mu_H': 6.0,\n", - " 'K_S': 8.0,\n", - " 'K_O_H': 0.2,\n", - " 'K_NO': 0.5,\n", - " 'b_H': 0.3,\n", - " 'mu_A': 0.5,\n", - " 'K_NH': 1.0,\n", - " 'K_O_A': 0.4,\n", - " 'b_A': 0.05,\n", - " 'eta_g': 0.8,\n", - " 'k_a': 0.05,\n", - " 'k_h': 3.0,\n", - " 'K_X': 0.1,\n", - " 'eta_h': 0.8}" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# If you update parameter values for `p1`, the same parameters will be updated accordingly for\n", "# `asm1` and any other processes in `asm1`.\n", @@ -879,21 +563,10 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 24, "id": "c69a557c", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "0.2777777777777778" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# If you evaluate process rate or stoichiometry again with the same input, \n", "# you should now expect different output.\n", @@ -911,21 +584,10 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 25, "id": "b7115278", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "('COD', 'charge', 'N')" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "p1.conserved_for" ] @@ -940,20 +602,10 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 26, "id": "772e7e78", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "C:\\Users\\joy_c\\anaconda3\\envs\\tut\\lib\\site-packages\\qsdsan\\_process.py:499: UserWarning: The following materials aren't strictly conserved by the stoichiometric coefficients. A positive value means the material is created, a negative value means the material is destroyed:\n", - " charge: -5.20417042793042E-18\n", - " warn(\"The following materials aren't strictly conserved by the \"\n" - ] - } - ], + "outputs": [], "source": [ "# No return indicates that all materials in `conserved_for` are conserved.\n", "# Otherwise, a warning or a `RuntimeError` will be raised.\n", @@ -983,21 +635,10 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 27, "id": "b5bde6b2", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(qsdsan._process.Processes,)" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "qs.CompiledProcesses.__bases__" ] @@ -1012,21 +653,10 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 28, "id": "3ee5e0dd", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Let's verify that\n", "isinstance(asm1, qs.CompiledProcesses)" @@ -1042,18 +672,10 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 29, "id": "9f6ae9b6", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Processes([aero_growth_hetero, anox_growth_hetero, aero_growth_auto, decay_hetero, decay_auto, ammonification, hydrolysis, hydrolysis_N])\n" - ] - } - ], + "outputs": [], "source": [ "asm1 = qs.Processes(asm1.tuple)\n", "asm1.show()" @@ -1061,30 +683,12 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 30, "id": "3b1e8036", "metadata": { "scrolled": true }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'aero_growth_hetero': ,\n", - " 'anox_growth_hetero': ,\n", - " 'aero_growth_auto': ,\n", - " 'decay_hetero': ,\n", - " 'decay_auto': ,\n", - " 'ammonification': ,\n", - " 'hydrolysis': ,\n", - " 'hydrolysis_N': }" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Let's see what difference \"decompiling\" made\n", "asm1.__dict__" @@ -1100,191 +704,12 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 31, "id": "48443f1d", "metadata": { "scrolled": true }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'aero_growth_hetero': ,\n", - " 'anox_growth_hetero': ,\n", - " 'aero_growth_auto': ,\n", - " 'decay_hetero': ,\n", - " 'decay_auto': ,\n", - " 'ammonification': ,\n", - " 'hydrolysis': ,\n", - " 'hydrolysis_N': ,\n", - " 'tuple': (,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ),\n", - " 'size': 8,\n", - " 'IDs': ('aero_growth_hetero',\n", - " 'anox_growth_hetero',\n", - " 'aero_growth_auto',\n", - " 'decay_hetero',\n", - " 'decay_auto',\n", - " 'ammonification',\n", - " 'hydrolysis',\n", - " 'hydrolysis_N'),\n", - " '_index': {'aero_growth_hetero': 0,\n", - " 'anox_growth_hetero': 1,\n", - " 'aero_growth_auto': 2,\n", - " 'decay_hetero': 3,\n", - " 'decay_auto': 4,\n", - " 'ammonification': 5,\n", - " 'hydrolysis': 6,\n", - " 'hydrolysis_N': 7},\n", - " '_components': CompiledComponents([S_I, S_S, X_I, X_S, X_BH, X_BA, X_P, S_O, S_NO, S_NH, S_ND, X_ND, S_ALK, S_N2, H2O]),\n", - " '_parameters': {'Y_H': 0.8,\n", - " 'Y_A': 0.24,\n", - " 'f_P': 0.08,\n", - " 'mu_H': 6.0,\n", - " 'K_S': 8.0,\n", - " 'K_O_H': 0.2,\n", - " 'K_NO': 0.5,\n", - " 'b_H': 0.3,\n", - " 'mu_A': 0.5,\n", - " 'K_NH': 1.0,\n", - " 'K_O_A': 0.4,\n", - " 'b_A': 0.05,\n", - " 'eta_g': 0.8,\n", - " 'k_a': 0.05,\n", - " 'k_h': 3.0,\n", - " 'K_X': 0.1,\n", - " 'eta_h': 0.8},\n", - " '_dyn_params': {},\n", - " '_stoichiometry': [[0,\n", - " -1.25000000000000,\n", - " 0,\n", - " 0,\n", - " 1.00000000000000,\n", - " 0,\n", - " 0,\n", - " -0.250000000000000,\n", - " 0,\n", - " -0.0800000000000000,\n", - " 0,\n", - " 0,\n", - " -0.0685997415522571,\n", - " 0,\n", - " 0],\n", - " [0,\n", - " -1.25000000000000,\n", - " 0,\n", - " 0,\n", - " 1.00000000000000,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " -0.0875000000000000,\n", - " -0.0800000000000001,\n", - " 0,\n", - " 0,\n", - " 0.00643122577052393,\n", - " 0.0875000000000000,\n", - " 0],\n", - " [0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1.00000000000000,\n", - " 0,\n", - " -18.0476190476190,\n", - " 4.16666666666667,\n", - " -4.24666666666667,\n", - " 0,\n", - " 0,\n", - " -7.21440615324570,\n", - " 0,\n", - " 0],\n", - " [0,\n", - " 0,\n", - " 0,\n", - " 0.920000000000000,\n", - " -1.00000000000000,\n", - " 0,\n", - " 0.0800000000000000,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0.0752000000000000,\n", - " 0,\n", - " 0,\n", - " 0],\n", - " [0,\n", - " 0,\n", - " 0,\n", - " 0.920000000000000,\n", - " 0,\n", - " -1.00000000000000,\n", - " 0.0800000000000000,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0.0752000000000000,\n", - " 0,\n", - " 0,\n", - " 0],\n", - " [0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1.00000000000000,\n", - " -1.00000000000000,\n", - " 0,\n", - " 0.857496769403214,\n", - " 0,\n", - " 0],\n", - " [0, 1.0, 0, -1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", - " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, -1.0, 0, 0, 0]],\n", - " '_stoichio_lambdified': None,\n", - " '_rate_equations': (S_NH*S_O*S_S*X_BH*mu_H/((K_NH + S_NH)*(K_O_H + S_O)*(K_S + S_S)),\n", - " K_O_H*S_NH*S_NO*S_S*X_BH*eta_g*mu_H/((K_NH + S_NH)*(K_NO + S_NO)*(K_O_H + S_O)*(K_S + S_S)),\n", - " S_NH*S_O*X_BA*mu_A/((K_NH + S_NH)*(K_O_A + S_O)),\n", - " X_BH*b_H,\n", - " X_BA*b_A,\n", - " S_ND*X_BH*k_a,\n", - " X_BH*X_S*k_h*(K_O_H*S_NO*eta_h/((K_NO + S_NO)*(K_O_H + S_O)) + S_O/(K_O_H + S_O))/(K_X*X_BH + X_S),\n", - " X_BH*X_ND*k_h*(K_O_H*S_NO*eta_h/((K_NO + S_NO)*(K_O_H + S_O)) + S_O/(K_O_H + S_O))/(K_X*X_BH + X_S)),\n", - " '_production_rates': [0,\n", - " -1.25*K_O_H*S_NH*S_NO*S_S*X_BH*eta_g*mu_H/((K_NH + S_NH)*(K_NO + S_NO)*(K_O_H + S_O)*(K_S + S_S)) - 1.25*S_NH*S_O*S_S*X_BH*mu_H/((K_NH + S_NH)*(K_O_H + S_O)*(K_S + S_S)) + 1.0*X_BH*X_S*k_h*(K_O_H*S_NO*eta_h/((K_NO + S_NO)*(K_O_H + S_O)) + S_O/(K_O_H + S_O))/(K_X*X_BH + X_S),\n", - " 0,\n", - " 0.92*X_BA*b_A - 1.0*X_BH*X_S*k_h*(K_O_H*S_NO*eta_h/((K_NO + S_NO)*(K_O_H + S_O)) + S_O/(K_O_H + S_O))/(K_X*X_BH + X_S) + 0.92*X_BH*b_H,\n", - " 1.0*K_O_H*S_NH*S_NO*S_S*X_BH*eta_g*mu_H/((K_NH + S_NH)*(K_NO + S_NO)*(K_O_H + S_O)*(K_S + S_S)) + 1.0*S_NH*S_O*S_S*X_BH*mu_H/((K_NH + S_NH)*(K_O_H + S_O)*(K_S + S_S)) - 1.0*X_BH*b_H,\n", - " 1.0*S_NH*S_O*X_BA*mu_A/((K_NH + S_NH)*(K_O_A + S_O)) - 1.0*X_BA*b_A,\n", - " 0.08*X_BA*b_A + 0.08*X_BH*b_H,\n", - " -0.25*S_NH*S_O*S_S*X_BH*mu_H/((K_NH + S_NH)*(K_O_H + S_O)*(K_S + S_S)) - 18.047619047619*S_NH*S_O*X_BA*mu_A/((K_NH + S_NH)*(K_O_A + S_O)),\n", - " -0.0875*K_O_H*S_NH*S_NO*S_S*X_BH*eta_g*mu_H/((K_NH + S_NH)*(K_NO + S_NO)*(K_O_H + S_O)*(K_S + S_S)) + 4.16666666666667*S_NH*S_O*X_BA*mu_A/((K_NH + S_NH)*(K_O_A + S_O)),\n", - " -0.0800000000000001*K_O_H*S_NH*S_NO*S_S*X_BH*eta_g*mu_H/((K_NH + S_NH)*(K_NO + S_NO)*(K_O_H + S_O)*(K_S + S_S)) + 1.0*S_ND*X_BH*k_a - 0.08*S_NH*S_O*S_S*X_BH*mu_H/((K_NH + S_NH)*(K_O_H + S_O)*(K_S + S_S)) - 4.24666666666667*S_NH*S_O*X_BA*mu_A/((K_NH + S_NH)*(K_O_A + S_O)),\n", - " -1.0*S_ND*X_BH*k_a + 1.0*X_BH*X_ND*k_h*(K_O_H*S_NO*eta_h/((K_NO + S_NO)*(K_O_H + S_O)) + S_O/(K_O_H + S_O))/(K_X*X_BH + X_S),\n", - " 0.0752*X_BA*b_A - 1.0*X_BH*X_ND*k_h*(K_O_H*S_NO*eta_h/((K_NO + S_NO)*(K_O_H + S_O)) + S_O/(K_O_H + S_O))/(K_X*X_BH + X_S) + 0.0752*X_BH*b_H,\n", - " 0.00643122577052393*K_O_H*S_NH*S_NO*S_S*X_BH*eta_g*mu_H/((K_NH + S_NH)*(K_NO + S_NO)*(K_O_H + S_O)*(K_S + S_S)) + 0.857496769403214*S_ND*X_BH*k_a - 0.0685997415522571*S_NH*S_O*S_S*X_BH*mu_H/((K_NH + S_NH)*(K_O_H + S_O)*(K_S + S_S)) - 7.2144061532457*S_NH*S_O*X_BA*mu_A/((K_NH + S_NH)*(K_O_A + S_O)),\n", - " 0.0875*K_O_H*S_NH*S_NO*S_S*X_BH*eta_g*mu_H/((K_NH + S_NH)*(K_NO + S_NO)*(K_O_H + S_O)*(K_S + S_S)),\n", - " 0],\n", - " '_rate_function': None}" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "asm1.compile()\n", "asm1.__dict__" @@ -1300,181 +725,10 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 32, "id": "027cbd6b", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
S_IS_SX_IX_SX_BH...S_NDX_NDS_ALKS_N2H2O
aero_growth_hetero0-1.25001...00-0.068600
anox_growth_hetero0-1.25001...000.006430.08750
aero_growth_auto00000...00-7.2100
decay_hetero0000.92-1...00.0752000
decay_auto0000.920...00.0752000
ammonification00000...-100.85700
hydrolysis010-10...00000
hydrolysis_N00000...1-1000
\n", - "

8 rows × 15 columns

\n", - "
" - ], - "text/plain": [ - " S_I S_S X_I X_S X_BH ... S_ND X_ND S_ALK S_N2 H2O\n", - "aero_growth_hetero 0 -1.25 0 0 1 ... 0 0 -0.0686 0 0\n", - "anox_growth_hetero 0 -1.25 0 0 1 ... 0 0 0.00643 0.0875 0\n", - "aero_growth_auto 0 0 0 0 0 ... 0 0 -7.21 0 0\n", - "decay_hetero 0 0 0 0.92 -1 ... 0 0.0752 0 0 0\n", - "decay_auto 0 0 0 0.92 0 ... 0 0.0752 0 0 0\n", - "ammonification 0 0 0 0 0 ... -1 0 0.857 0 0\n", - "hydrolysis 0 1 0 -1 0 ... 0 0 0 0 0\n", - "hydrolysis_N 0 0 0 0 0 ... 1 -1 0 0 0\n", - "\n", - "[8 rows x 15 columns]" - ] - }, - "execution_count": 33, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# For example, the stoichiometric coefficients of all processes are compiled into a table that\n", "# is in consistent format as a Petersen matrix\n", @@ -1483,88 +737,10 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 33, "id": "18541f64", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
rate_equation
aero_growth_hetero6.0*S_NH*S_O*S_S*X_BH/((S_NH + ...
anox_growth_hetero0.96*S_NH*S_NO*S_S*X_BH/((S_NH ...
aero_growth_auto0.5*S_NH*S_O*X_BA/((S_NH + 1.0)...
decay_hetero0.3*X_BH
decay_auto0.05*X_BA
ammonification0.05*S_ND*X_BH
hydrolysis3.0*X_BH*X_S*(0.16*S_NO/((S_NO ...
hydrolysis_N3.0*X_BH*X_ND*(0.16*S_NO/((S_NO...
\n", - "
" - ], - "text/plain": [ - " rate_equation\n", - "aero_growth_hetero 6.0*S_NH*S_O*S_S*X_BH/((S_NH + ...\n", - "anox_growth_hetero 0.96*S_NH*S_NO*S_S*X_BH/((S_NH ...\n", - "aero_growth_auto 0.5*S_NH*S_O*X_BA/((S_NH + 1.0)...\n", - "decay_hetero 0.3*X_BH\n", - "decay_auto 0.05*X_BA\n", - "ammonification 0.05*S_ND*X_BH\n", - "hydrolysis 3.0*X_BH*X_S*(0.16*S_NO/((S_NO ...\n", - "hydrolysis_N 3.0*X_BH*X_ND*(0.16*S_NO/((S_NO..." - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Similarly for the rate equations\n", "asm1.rate_equations" @@ -1572,21 +748,10 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 34, "id": "a872533e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([0.278, 0.03 , 0.179, 0.3 , 0.05 , 0.05 , 2.515, 2.515])" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# More importantly, the `rate_function` attribute of a `CompiledProcesses` now outputs an array\n", "# with each element corresponding orderly to the individual processes\n", @@ -1613,123 +778,10 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 35, "id": "81541f71", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
rate_of_production
S_I0
S_S-1.2*S_NH*S_NO*S_S*X_BH/((S_NH ...
X_I0
X_S0.046*X_BA - 3.0*X_BH*X_S*(0.16...
X_BH0.96*S_NH*S_NO*S_S*X_BH/((S_NH ...
X_BA0.5*S_NH*S_O*X_BA/((S_NH + 1.0)...
X_P0.004*X_BA + 0.024*X_BH
S_O-1.5*S_NH*S_O*S_S*X_BH/((S_NH +...
S_NO-0.084*S_NH*S_NO*S_S*X_BH/((S_N...
S_NH0.05*S_ND*X_BH - 0.076800000000...
S_ND-0.05*S_ND*X_BH + 3.0*X_BH*X_ND...
X_ND0.00376*X_BA - 3.0*X_BH*X_ND*(0...
S_ALK0.0428748384701607*S_ND*X_BH + ...
S_N20.084*S_NH*S_NO*S_S*X_BH/((S_NH...
H2O0
\n", - "
" - ], - "text/plain": [ - " rate_of_production\n", - "S_I 0\n", - "S_S -1.2*S_NH*S_NO*S_S*X_BH/((S_NH ...\n", - "X_I 0\n", - "X_S 0.046*X_BA - 3.0*X_BH*X_S*(0.16...\n", - "X_BH 0.96*S_NH*S_NO*S_S*X_BH/((S_NH ...\n", - "X_BA 0.5*S_NH*S_O*X_BA/((S_NH + 1.0)...\n", - "X_P 0.004*X_BA + 0.024*X_BH\n", - "S_O -1.5*S_NH*S_O*S_S*X_BH/((S_NH +...\n", - "S_NO -0.084*S_NH*S_NO*S_S*X_BH/((S_N...\n", - "S_NH 0.05*S_ND*X_BH - 0.076800000000...\n", - "S_ND -0.05*S_ND*X_BH + 3.0*X_BH*X_ND...\n", - "X_ND 0.00376*X_BA - 3.0*X_BH*X_ND*(0...\n", - "S_ALK 0.0428748384701607*S_ND*X_BH + ...\n", - "S_N2 0.084*S_NH*S_NO*S_S*X_BH/((S_NH...\n", - "H2O 0" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# This matrix operation is already streamlined for `CompiledProcesses` objects, you can see the \n", "# mathematical form of the rates of production as a function of component concentrations.\n", @@ -1738,23 +790,10 @@ }, { "cell_type": "code", - "execution_count": 37, - "id": "b508e20f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([ 0.000e+00, 2.131e+00, 0.000e+00, -2.193e+00, 7.407e-03,\n", - " 1.286e-01, 2.800e-02, -3.292e+00, 7.415e-01, -7.329e-01,\n", - " 2.465e+00, -2.489e+00, -1.264e+00, 2.593e-03, 0.000e+00])" - ] - }, - "execution_count": 37, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": 36, + "id": "b508e20f", + "metadata": {}, + "outputs": [], "source": [ "# To evaluate the rates of production for all components, all you need to\n", "# do is to call the `production_rates_eval` method.\n", @@ -1829,18 +868,10 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 37, "id": "cad5a69b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CompiledComponents([X_S, S_S, O2, CO2, X_B, H2O])\n" - ] - } - ], + "outputs": [], "source": [ "# Load the default set of components\n", "cmps_all = qs.Components.load_default()\n", @@ -1868,21 +899,10 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 38, "id": "494eb3e8", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 39, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Now we can check if their `measured_as` attributes are correctly set\n", "# X_S.measured_as == 'COD'\n", @@ -1892,21 +912,10 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 39, "id": "2de7d166", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "-1.0" - ] - }, - "execution_count": 40, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Then you can check relevant `i_` properties of the components\n", "# For example, O2 should have a negative COD content, or more specifically -1 gCOD/gO2\n", @@ -1927,7 +936,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 40, "id": "7b264f76", "metadata": {}, "outputs": [], @@ -1957,7 +966,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 41, "id": "1906bcd6", "metadata": {}, "outputs": [], @@ -1976,7 +985,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 42, "id": "7b7437a4", "metadata": {}, "outputs": [], @@ -2005,7 +1014,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 43, "id": "4f98d569", "metadata": {}, "outputs": [], @@ -2028,7 +1037,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 44, "id": "c7ce74d2", "metadata": {}, "outputs": [], @@ -2049,24 +1058,10 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 45, "id": "e7facea8", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Process: hydrolysis\n", - "[stoichiometry] X_S: -1\n", - " S_S: 1\n", - "[reference] X_S\n", - "[rate equation] X_S*k_hyd\n", - "[parameters] k_hyd: k_hyd\n", - "[dynamic parameters] \n" - ] - } - ], + "outputs": [], "source": [ "# Upon initiation, the parameters are stored as symbols. We still need to set values to them\n", "# before we can evalute process rate.\n", @@ -2075,28 +1070,10 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 46, "id": "9d199cf0", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Process: growth\n", - "[stoichiometry] S_S: -1/y_B\n", - " O2: (y_B - 1.0)/y_B\n", - " CO2: 0.002*(160.0 - 183.0*y_B)/y_B\n", - " X_B: 1.00\n", - "[reference] X_B\n", - "[rate equation] S_S*X_B*mu_B/(K_S + S_S)\n", - "[parameters] y_B: y_B\n", - " mu_B: mu_B\n", - " K_S: K_S\n", - "[dynamic parameters] \n" - ] - } - ], + "outputs": [], "source": [ "# At this point, the initiation of process 3 should be quite straightforward.\n", "# Here shows an alternative way to input stoichiometry\n", @@ -2137,20 +1114,12 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 47, "id": "18d7995b", "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CompiledProcesses([hydrolysis, growth, decay])\n" - ] - } - ], + "outputs": [], "source": [ "# Now the final step is to compile the individual processes into a biokinetic model\n", "bkm = qs.Processes([pc1, pc2, pc3])\n", @@ -2160,21 +1129,10 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 48, "id": "0a4159a3", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'k_hyd': k_hyd, 'y_B': y_B, 'mu_B': mu_B, 'K_S': K_S, 'b': b}" - ] - }, - "execution_count": 55, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Parameters in the stoichiometry and rate equations across all processes are compiled into\n", "# a shared dictionary.\n", @@ -2185,83 +1143,10 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 49, "id": "6bec6d90", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
X_SS_SO2CO2X_BH2O
hydrolysis-110000
growth0-1.25-0.250.03410
decay1000-10
\n", - "
" - ], - "text/plain": [ - " X_S S_S O2 CO2 X_B H2O\n", - "hydrolysis -1 1 0 0 0 0\n", - "growth 0 -1.25 -0.25 0.034 1 0\n", - "decay 1 0 0 0 -1 0" - ] - }, - "execution_count": 56, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# After setting parameter values, the model will be ready\n", "bkm.set_parameters(k_hyd=3.0, y_B=0.8, mu_B=4.0, K_S=9.0, b=0.4)\n", @@ -2270,78 +1155,10 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 50, "id": "f13307e3", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
rate_of_production
X_S0.4*X_B - 3.0*X_S
S_S-5.0*S_S*X_B/(S_S + 9.0) + 3.0*X_S
O2-1.0*S_S*X_B/(S_S + 9.0)
CO20.136*S_S*X_B/(S_S + 9.0)
X_B4.0*S_S*X_B/(S_S + 9.0) - 0.4*X_B
H2O0
\n", - "
" - ], - "text/plain": [ - " rate_of_production\n", - "X_S 0.4*X_B - 3.0*X_S\n", - "S_S -5.0*S_S*X_B/(S_S + 9.0) + 3.0*X_S\n", - "O2 -1.0*S_S*X_B/(S_S + 9.0)\n", - "CO2 0.136*S_S*X_B/(S_S + 9.0)\n", - "X_B 4.0*S_S*X_B/(S_S + 9.0) - 0.4*X_B\n", - "H2O 0" - ] - }, - "execution_count": 57, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "bkm.production_rates" ] @@ -2365,91 +1182,14 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 51, "id": "1b8ebfca", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
X_SS_SO2CO2X_BH2OUnnamed: 7
hydrolysis-110000k_hyd*X_S
growth0(-1)/y_B??10mu_B*S_S/(K_S + S_S)*X_B
decay1000-10b*X_B
\n", - "
" - ], - "text/plain": [ - " X_S S_S O2 CO2 X_B H2O Unnamed: 7\n", - "hydrolysis -1 1 0 0 0 0 k_hyd*X_S\n", - "growth 0 (-1)/y_B ? ? 1 0 mu_B*S_S/(K_S + S_S)*X_B\n", - "decay 1 0 0 0 -1 0 b*X_B" - ] - }, - "execution_count": 58, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Stoichiometry and rate equations are usually described in a table format\n", "from qsdsan.utils import load_data\n", - "df_bkm = load_data('_bkm.tsv', index_col=0)\n", + "df_bkm = load_data('assets/_bkm.tsv', index_col=0)\n", "df_bkm" ] }, @@ -2463,22 +1203,14 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 52, "id": "8703f7bf", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CompiledProcesses([hydrolysis, growth, decay])\n" - ] - } - ], + "outputs": [], "source": [ "# The same amount of information is still required to create the model.\n", "bkm_batch = qs.Processes.load_from_file(\n", - " path='_bkm.tsv', \n", + " path='assets/_bkm.tsv', \n", " conserved_for=('COD', 'C'),\n", " parameters=('k_hyd', 'y_B', 'mu_B', 'K_S', 'b'),\n", " compile=True\n", @@ -2488,83 +1220,10 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 53, "id": "4105ea73", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
X_SS_SO2CO2X_BH2O
hydrolysis-110000
growth0-1.0/y_B1.0*(y_B - 1.0)/y_B0.002*(160.0 - 183.0*y_B)/y_B1.000000000000000
decay1000-10
\n", - "
" - ], - "text/plain": [ - " X_S S_S O2 CO2 X_B H2O\n", - "hydrolysis -1 1 0 0 0 0\n", - "growth 0 -1.0/y_B 1.0*(y_B - 1.0)/y_B 0.002*(160.0 - 183.0*y_B)/y_B 1.00000000000000 0\n", - "decay 1 0 0 0 -1 0" - ] - }, - "execution_count": 60, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# You can see `bkm_batch` is equivalent to the `bkm` we created above\n", "bkm_batch.stoichiometry\n", @@ -2574,21 +1233,10 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 54, "id": "ba36c5ed", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'X_S'" - ] - }, - "execution_count": 61, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# The reference component of each process is inferred from its stoichiometry\n", "bkm_batch.decay.ref_component" @@ -2596,26 +1244,14 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 55, "id": "57c80cc6", "metadata": {}, - "outputs": [ - { - "ename": "RuntimeError", - "evalue": "The following materials are unconserved by the stoichiometric coefficients. A positive value means the material is created, a negative value means the material is destroyed:\n C: -0.05", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mRuntimeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_8464\\355048950.py\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# `conserved_for` now applies to all processes\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mbkm_batch\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecay\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcheck_conservation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;32m~\\anaconda3\\envs\\tut\\lib\\site-packages\\qsdsan\\_process.py\u001b[0m in \u001b[0;36mcheck_conservation\u001b[1;34m(self, rtol, atol)\u001b[0m\n\u001b[0;32m 484\u001b[0m \u001b[0mmaterials\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_conserved_for\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 485\u001b[0m \u001b[0munconserved\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmaterials\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mic_dot_v\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconserved\u001b[0m \u001b[1;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mconserved_arr\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mconserved\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 486\u001b[1;33m raise RuntimeError(\"The following materials are unconserved by the \"\n\u001b[0m\u001b[0;32m 487\u001b[0m \u001b[1;34m\"stoichiometric coefficients. A positive value \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 488\u001b[0m \u001b[1;34m\"means the material is created, a negative value \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mRuntimeError\u001b[0m: The following materials are unconserved by the stoichiometric coefficients. A positive value means the material is created, a negative value means the material is destroyed:\n C: -0.05" - ] - } - ], + "outputs": [], "source": [ - "# `conserved_for` now applies to all processes\n", - "bkm_batch.decay.check_conservation()" + "# `conserved_for` now applies to all processes,\n", + "# the following will trigger an error\n", + "# bkm_batch.decay.check_conservation()" ] }, { @@ -2628,21 +1264,10 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 56, "id": "cf5c08b4", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'X_S': 0.32, 'S_S': 0.32, 'O2': 0.0, 'CO2': 1.0, 'X_B': 0.366, 'H2O': 0.0}" - ] - }, - "execution_count": 63, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# `i_C` values for each component\n", "dict(zip(cmps_bkm.IDs, cmps_bkm.i_C))" @@ -2675,7 +1300,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 57, "id": "29c15cb9", "metadata": {}, "outputs": [], @@ -2700,21 +1325,10 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 58, "id": "7fe90104", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'k_hyd': 3.0, 'y_B': 0.8, 'mu_B': 4.0, 'K_S': 9.0, 'b': 0.4}" - ] - }, - "execution_count": 65, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# At this point, the value for `y_B` is not updated yet, since we haven't evalutated it\n", "# with input of component concentrations\n", @@ -2723,30 +1337,10 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 59, "id": "9121e9cc", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Process: growth\n", - "[stoichiometry] S_S: -1/y_B\n", - " O2: (y_B - 1.0)/y_B\n", - " CO2: 0.002*(160.0 - 183.0*y_B)/y_B\n", - " X_B: 1.00\n", - "[reference] X_B\n", - "[rate equation] S_S*X_B*mu_B/(K_S + S_S)\n", - "[parameters] k_hyd: 3\n", - " y_B: 0.8\n", - " mu_B: 4\n", - " K_S: 9\n", - " b: 0.4\n", - "[dynamic parameters] \n" - ] - } - ], + "outputs": [], "source": [ "# But the list of dynamic parameters have been updated\n", "pc2.show()" @@ -2754,21 +1348,10 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 60, "id": "248e0922", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "qsdsan._process.DynamicParameter" - ] - }, - "execution_count": 67, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# `y_B` is now a `DynamicParameter` object stored in the `_dyn_params` attribute of the process\n", "type(pc2._dyn_params['y_B'])" @@ -2776,23 +1359,12 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 61, "id": "9dc27821", "metadata": { "scrolled": false }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'k_hyd': 3.0, 'y_B': 0.5656854249492381, 'mu_B': 4.0, 'K_S': 9.0, 'b': 0.4}" - ] - }, - "execution_count": 68, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Assuming component concentrations are all 1.\n", "state_bkm = np.ones(6)\n", @@ -2804,83 +1376,10 @@ }, { "cell_type": "code", - "execution_count": 69, + "execution_count": 62, "id": "d765098e", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
X_SS_SO2CO2X_BH2O
hydrolysis-110000
growth0-1.77-0.7680.210
decay1000-10
\n", - "
" - ], - "text/plain": [ - " X_S S_S O2 CO2 X_B H2O\n", - "hydrolysis -1 1 0 0 0 0\n", - "growth 0 -1.77 -0.768 0.2 1 0\n", - "decay 1 0 0 0 -1 0" - ] - }, - "execution_count": 69, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Then the stoichiometry is updated accordingly\n", "bkm.stoichiometry" @@ -2909,21 +1408,10 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 63, "id": "cb7c404e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 70, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# The use of `Kinetics` to define process rate is also similar\n", "# For example, for the decay process\n", @@ -2955,21 +1443,10 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 64, "id": "5fdddd88", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([1.732, 2.309, 0.369])" - ] - }, - "execution_count": 71, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Define the function\n", "def rhos_eval(state_arr, params):\n", diff --git a/docs/source/tutorials/12_Anaerobic_Digestion_Model_No_1.ipynb b/docs/source/tutorials/12_Anaerobic_Digestion_Model_No_1.ipynb index ca9f713e..34e0cc52 100644 --- a/docs/source/tutorials/12_Anaerobic_Digestion_Model_No_1.ipynb +++ b/docs/source/tutorials/12_Anaerobic_Digestion_Model_No_1.ipynb @@ -73,7 +73,7 @@ "id": "180af880", "metadata": {}, "source": [ - "![ADM1.JPG](attachment:ADM1.JPG)" + "![assets/ADM1.JPG](attachment:ADM1.JPG)" ] }, { @@ -808,10 +808,10 @@ "\n", "\n", "\n", + "Anaerobic CSTR->179376415616 -->\n", "\n", "AD\n", - "Anaerobic CSTR:c->129151411681:w\n", + "Anaerobic CSTR:c->179376415616:w\n", "\n", "\n", " Biogas\n", @@ -819,20 +819,20 @@ "\n", "\n", "\n", + "Anaerobic CSTR->179376414536 -->\n", "\n", "AD\n", - "Anaerobic CSTR:c->129151412281:w\n", + "Anaerobic CSTR:c->179376414536:w\n", "\n", "\n", " Effluent\n", "\n", "\n", "\n", - "\n", "\n", - "129151411601:e->AD\n", + "179376414696:e->AD\n", "Anaerobic CSTR:c\n", "\n", "\n", "\n", "\n", - "\n", + "\n", "\n", - "129151411601\n", + "179376414696\n", "\n", "\n", - "\n", + "\n", "\n", - "129151411681\n", + "179376415616\n", "\n", "\n", - "\n", + "\n", "\n", - "129151412281\n", + "179376414536\n", "\n", "\n", "\n", @@ -1136,7 +1136,9 @@ "cell_type": "code", "execution_count": 15, "id": "55247c4c", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [ { "data": { diff --git a/docs/source/tutorials/_bkm.tsv b/docs/source/tutorials/assets/_bkm.tsv similarity index 100% rename from docs/source/tutorials/_bkm.tsv rename to docs/source/tutorials/assets/_bkm.tsv diff --git a/docs/source/tutorials/adm1.jpg b/docs/source/tutorials/assets/adm1.jpg similarity index 100% rename from docs/source/tutorials/adm1.jpg rename to docs/source/tutorials/assets/adm1.jpg