|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "86fb738a-7e02-4130-a660-1bfa90110cb3", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "## Reversible Reactions \n", |
| 9 | + "\n", |
| 10 | + "MobsPy has two available syntaxes for reversible reactions. Firstly, if a meta-reaction is defined with two rates instead of one, two meta-reactions will be defined. The direct sense with the first rate and the backwards sense with the second rate. \n", |
| 11 | + "\n", |
| 12 | + "Here is an example:" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "code", |
| 17 | + "execution_count": 1, |
| 18 | + "id": "408db175-d6e8-4fe1-9b47-32b2634fe85b", |
| 19 | + "metadata": {}, |
| 20 | + "outputs": [ |
| 21 | + { |
| 22 | + "name": "stdout", |
| 23 | + "output_type": "stream", |
| 24 | + "text": [ |
| 25 | + "\n", |
| 26 | + "Species\n", |
| 27 | + "A,0\n", |
| 28 | + "\n", |
| 29 | + "Mappings\n", |
| 30 | + "A :\n", |
| 31 | + "A\n", |
| 32 | + "\n", |
| 33 | + "Parameters\n", |
| 34 | + "volume,1\n", |
| 35 | + "\n", |
| 36 | + "Reactions\n", |
| 37 | + "reaction_0,{'re': [(1, 'A')], 'pr': [], 'kin': '((2*(100-A))*A)'}\n", |
| 38 | + "reaction_1,{'re': [], 'pr': [(1, 'A')], 'kin': '1 * volume'}\n", |
| 39 | + "\n" |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + "name": "stderr", |
| 44 | + "output_type": "stream", |
| 45 | + "text": [ |
| 46 | + "Compiling model\n" |
| 47 | + ] |
| 48 | + } |
| 49 | + ], |
| 50 | + "source": [ |
| 51 | + "from mobspy import *\n", |
| 52 | + "\n", |
| 53 | + "A = BaseSpecies()\n", |
| 54 | + "\n", |
| 55 | + "A >> Zero [lambda r: 2*(100 - r)*r, 1]\n", |
| 56 | + "\n", |
| 57 | + "S = Simulation(A)\n", |
| 58 | + "print(S.compile())" |
| 59 | + ] |
| 60 | + }, |
| 61 | + { |
| 62 | + "cell_type": "markdown", |
| 63 | + "id": "55c92ce6-985a-463c-a4e7-18b62c8b5de6", |
| 64 | + "metadata": {}, |
| 65 | + "source": [ |
| 66 | + "The other reversible reaction notation uses the Rev operator and an example follows bellow " |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "execution_count": 2, |
| 72 | + "id": "a2f2bf5d-64c9-49e2-af7b-47849e25fd6e", |
| 73 | + "metadata": {}, |
| 74 | + "outputs": [ |
| 75 | + { |
| 76 | + "name": "stdout", |
| 77 | + "output_type": "stream", |
| 78 | + "text": [ |
| 79 | + "\n", |
| 80 | + "Species\n", |
| 81 | + "A,0\n", |
| 82 | + "\n", |
| 83 | + "Mappings\n", |
| 84 | + "A :\n", |
| 85 | + "A\n", |
| 86 | + "\n", |
| 87 | + "Parameters\n", |
| 88 | + "volume,1\n", |
| 89 | + "\n", |
| 90 | + "Reactions\n", |
| 91 | + "reaction_0,{'re': [(1, 'A')], 'pr': [], 'kin': '((2*(100-A))*A)'}\n", |
| 92 | + "reaction_1,{'re': [], 'pr': [(1, 'A')], 'kin': '1 * volume'}\n", |
| 93 | + "\n" |
| 94 | + ] |
| 95 | + }, |
| 96 | + { |
| 97 | + "name": "stderr", |
| 98 | + "output_type": "stream", |
| 99 | + "text": [ |
| 100 | + "Compiling model\n" |
| 101 | + ] |
| 102 | + } |
| 103 | + ], |
| 104 | + "source": [ |
| 105 | + "from mobspy import *\n", |
| 106 | + "\n", |
| 107 | + "A = BaseSpecies()\n", |
| 108 | + "\n", |
| 109 | + "Rev[A >> Zero][lambda r: 2*(100 - r)*r, 1]\n", |
| 110 | + "\n", |
| 111 | + "S = Simulation(A)\n", |
| 112 | + "print(S.compile())" |
| 113 | + ] |
| 114 | + }, |
| 115 | + { |
| 116 | + "cell_type": "code", |
| 117 | + "execution_count": null, |
| 118 | + "id": "4d097916-bf4c-4d26-8d2c-464ca7bb12ce", |
| 119 | + "metadata": {}, |
| 120 | + "outputs": [], |
| 121 | + "source": [] |
| 122 | + } |
| 123 | + ], |
| 124 | + "metadata": { |
| 125 | + "kernelspec": { |
| 126 | + "display_name": "Python 3 (ipykernel)", |
| 127 | + "language": "python", |
| 128 | + "name": "python3" |
| 129 | + }, |
| 130 | + "language_info": { |
| 131 | + "codemirror_mode": { |
| 132 | + "name": "ipython", |
| 133 | + "version": 3 |
| 134 | + }, |
| 135 | + "file_extension": ".py", |
| 136 | + "mimetype": "text/x-python", |
| 137 | + "name": "python", |
| 138 | + "nbconvert_exporter": "python", |
| 139 | + "pygments_lexer": "ipython3", |
| 140 | + "version": "3.13.1" |
| 141 | + } |
| 142 | + }, |
| 143 | + "nbformat": 4, |
| 144 | + "nbformat_minor": 5 |
| 145 | +} |
0 commit comments