{ "cells": [ { "cell_type": "markdown", "id": "49bcb5b0-f19d-4b96-a5f1-e0ae30f66d8f", "metadata": {}, "source": [ "## `U` (\"Up-regulator\") up-regulates `X` , by sharing an upstream reagent `S` (\"Source\") across 2 separate reactions: \n", "### `2 S <-> U` and `S <-> X` (both mostly forward)\n", "\n", "1st-order kinetics throughout. \n", "\n", "Invoking [Le Chatelier's principle](https://www.chemguide.co.uk/physical/equilibria/lechatelier.html), it can be seen that, starting from equilibrium, when [U] goes up, so does [S]; and when [S] goes up, so does [X]. \n", "Conversely, when [U] goes down, so does [S]; and when [S] goes down, so does [X]. \n", "\n", "This experiment is a counterpart of experiment `up_regulate_2`, with \"upstream\" rather than \"downstream\" reactions.\n", "\n", "Note: numerical errors in the same reactions (with the same initial conditions) is explored in the experiment \"large_time_steps_2\"\n", "\n", "LAST REVISED: Nov. 4, 2023" ] }, { "cell_type": "code", "execution_count": 1, "id": "437be530-28df-4819-a681-0d63a66e9f83", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Added 'D:\\Docs\\- MY CODE\\BioSimulations\\life123-Win7' to sys.path\n" ] } ], "source": [ "import set_path # Importing this module will add the project's home directory to sys.path" ] }, { "cell_type": "code", "execution_count": 2, "id": "da078672", "metadata": { "tags": [] }, "outputs": [], "source": [ "from experiments.get_notebook_info import get_notebook_basename\n", "\n", "from src.modules.chemicals.chem_data import ChemData as chem\n", "from src.modules.reactions.reaction_dynamics import ReactionDynamics\n", "\n", "from src.modules.visualization.graphic_log import GraphicLog" ] }, { "cell_type": "code", "execution_count": 3, "id": "cc53849f-351d-49e0-bfa8-22f8d8e22f8e", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-> Output will be LOGGED into the file 'up_regulate_3.log.htm'\n" ] } ], "source": [ "# Initialize the HTML logging\n", "log_file = get_notebook_basename() + \".log.htm\" # Use the notebook base filename for the log file\n", "\n", "# Set up the use of some specified graphic (Vue) components\n", "GraphicLog.config(filename=log_file,\n", " components=[\"vue_cytoscape_1\"],\n", " extra_js=\"https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.21.2/cytoscape.umd.js\")" ] }, { "cell_type": "markdown", "id": "d6d3ca49-589d-49b7-8424-37c7b01bcacf", "metadata": {}, "source": [ "### Initialize the system" ] }, { "cell_type": "code", "execution_count": 4, "id": "23c15e66-52e4-495b-aa3d-ecddd8d16942", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of reactions: 2 (at temp. 25 C)\n", "0: 2 S <-> U (kF = 8 / kR = 2 / delta_G = -3,436.6 / K = 4) | 1st order in all reactants & products\n", "1: S <-> X (kF = 6 / kR = 3 / delta_G = -1,718.3 / K = 2) | 1st order in all reactants & products\n", "Set of chemicals involved in the above reactions: {'S', 'X', 'U'}\n", "[GRAPHIC ELEMENT SENT TO LOG FILE `up_regulate_3.log.htm`]\n" ] } ], "source": [ "# Initialize the system\n", "chem_data = chem(names=[\"U\", \"X\", \"S\"])\n", "\n", "# Reaction 2 S <-> U , with 1st-order kinetics for all species (mostly forward)\n", "chem_data.add_reaction(reactants=[(2, \"S\")], products=\"U\",\n", " forward_rate=8., reverse_rate=2.)\n", "\n", "# Reaction S <-> X , with 1st-order kinetics for all species (mostly forward)\n", "chem_data.add_reaction(reactants=\"S\", products=\"X\",\n", " forward_rate=6., reverse_rate=3.)\n", "\n", "chem_data.describe_reactions()\n", "\n", "# Send the plot of the reaction network to the HTML log file\n", "graph_data = chem_data.prepare_graph_network()\n", "GraphicLog.export_plot(graph_data, \"vue_cytoscape_1\")" ] }, { "cell_type": "markdown", "id": "d1d0eabb-b5b1-4e15-846d-5e483a5a24a7", "metadata": {}, "source": [ "### Set the initial concentrations of all the chemicals" ] }, { "cell_type": "code", "execution_count": 5, "id": "e80645d6-eb5b-4c78-8b46-ae126d2cb2cf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0:\n", "3 species:\n", " Species 0 (U). Conc: 50.0\n", " Species 1 (X). Conc: 100.0\n", " Species 2 (S). Conc: 0.0\n", "Set of chemicals involved in reactions: {'S', 'X', 'U'}\n" ] } ], "source": [ "dynamics = ReactionDynamics(chem_data=chem_data)\n", "dynamics.set_conc(conc={\"U\": 50., \"X\": 100., \"S\": 0.})\n", "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": null, "id": "f5030a8a-2609-4887-91c6-1531d66321fb", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "0b46b395-3f68-4dbd-b0c5-d67a0e623726", "metadata": { "tags": [] }, "source": [ "# 1. Take the initial system to equilibrium" ] }, { "cell_type": "code", "execution_count": 6, "id": "853a1827-5628-435b-91dc-cc51316ebcc2", "metadata": {}, "outputs": [], "source": [ "dynamics = ReactionDynamics(chem_data=chem_data)\n", "dynamics.set_conc(conc={\"U\": 50., \"X\": 100., \"S\": 0.})\n", "#dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 7, "id": "909a9301-8eda-44af-ba36-9d7167aedd33", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "* INFO: the tentative time step (0.01) leads to a least one norm value > its ABORT threshold:\n", " -> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 0.005) [Step started at t=0, and will rewind there]\n", "43 total step(s) taken\n" ] } ], "source": [ "dynamics.set_diagnostics() # To save diagnostic information about the call to single_compartment_react()\n", "\n", "# All of these settings are currently close to the default values... but subject to change; set for repeatability\n", "dynamics.set_thresholds(norm=\"norm_A\", low=0.5, high=0.8, abort=1.44)\n", "dynamics.set_thresholds(norm=\"norm_B\", low=0.08, high=0.5, abort=1.5)\n", "dynamics.set_step_factors(upshift=1.5, downshift=0.5, abort=0.5)\n", "dynamics.set_error_step_factor(0.5)\n", "\n", "dynamics.single_compartment_react(initial_step=0.01, target_end_time=1.5,\n", " variable_steps=True, explain_variable_steps=False)\n", "\n", "#df = dynamics.get_history()\n", "#dynamics.explain_time_advance()" ] }, { "cell_type": "markdown", "id": "cbf6c9c7-8cec-400f-9e70-49ff1a9f485c", "metadata": { "tags": [] }, "source": [ "## Plots of changes of concentration with time" ] }, { "cell_type": "code", "execution_count": 8, "id": "db4e74d0-3f9d-49dc-9553-bf3cdfe785f2", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Chemical=U
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "U", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "U", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486 ], "xaxis": "x", "y": [ 50, 49.5, 49.3025, 49.1279125, 48.974772375, 48.841703944531254, 48.72741553951446, 48.63069439895918, 48.55040187648133, 48.485468937831165, 48.40960342873317, 48.363918726573424, 48.34542943732506, 48.35442192115496, 48.412964817686024, 48.563788409887835, 48.794496507448386, 49.232024381492934, 49.77305626452036, 50.679867944645785, 51.17387187582093, 51.92163025559485, 53.04465236366425, 54.14644146544591, 55.20543277156762, 56.213136060878696, 57.16724543798181, 58.51887038983838, 59.137114110549426, 60.024316815170444, 61.268502405471146, 61.82974583644012, 62.63038456117153, 63.74311816997822, 64.73322726805728, 65.61422032967758, 66.79007362899101, 67.77154751087184, 69.00038827864219, 69.92452094285747, 70.96699268135814, 71.6217214411839, 72.23852916776461, 72.64754791961869 ], "yaxis": "y" }, { "hovertemplate": "Chemical=X
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "X", "line": { "color": "orange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "X", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486 ], "xaxis": "x", "y": [ 100, 98.5, 97.79875, 97.119203125, 96.4601836796875, 95.82058637564454, 95.1993720638566, 94.59556372623439, 94.00824271042534, 93.43654519314633, 92.60121569067523, 91.79749250682195, 91.02295079202091, 89.9015974211554, 88.83640557203145, 87.3135783361146, 85.89111990471476, 83.88442037099962, 82.03984691017621, 79.46489556174677, 78.2941056586168, 76.60354592432253, 74.20101800580426, 71.97247802494245, 69.88992436494142, 67.93626460974453, 66.09986774357947, 63.50796023276986, 62.32585757818592, 60.63007083885702, 58.25274168840475, 57.18059176222204, 55.65114528572433, 53.52553850967771, 51.63419108531924, 49.951281868101084, 47.705118490711584, 45.830266678427996, 43.48288445758348, 41.71756819977594, 39.72619577063346, 38.4755059413471, 37.297254430062154, 36.515929976181866 ], "yaxis": "y" }, { "hovertemplate": "Chemical=S
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "S", "line": { "color": "blue", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "S", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486 ], "xaxis": "x", "y": [ 0, 2.5, 3.59625, 4.624971875, 5.5902715703125, 6.496005735292969, 7.345796857114502, 8.143047475847274, 8.890953536612024, 9.592516931191366, 10.579577451858441, 11.474670040031214, 12.286190333328987, 13.389558736534692, 14.337664792596508, 15.55884484410973, 16.51988708038848, 17.651530866014525, 18.41404056078308, 19.175368548961664, 19.358150589741353, 19.553193564487778, 19.70967726686726, 19.73463904416575, 19.69921009192334, 19.63746326849809, 19.565641380456917, 19.454298987553386, 19.399914200715244, 19.321295530802107, 19.210253500652975, 19.159916564897735, 19.088085591932618, 18.98822515036587, 18.899354378566212, 18.820277472543765, 18.714734251306396, 18.626638299828322, 18.516338985132133, 18.43338991450913, 18.339818866650276, 18.281051176285132, 18.22568723440864, 18.188974184580783 ], "yaxis": "y" } ], "layout": { "autosize": true, "legend": { "title": { "text": "Chemical" }, "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Changes in concentration for `2 S <-> U` and `S <-> X`" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 1.604932968616486 ], "title": { "text": "SYSTEM TIME" }, "type": "linear" }, "yaxis": { "anchor": "x", "autorange": true, "domain": [ 0, 1 ], "range": [ -5.555555555555555, 105.55555555555556 ], "title": { "text": "concentration" }, "type": "linear" } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "dynamics.plot_curves(colors=['green', 'orange', 'blue'])" ] }, { "cell_type": "markdown", "id": "53406956-8084-43fe-9540-1212e9cc2258", "metadata": {}, "source": [ "### Note that [S] is initially 0, and that it builds up thru _reverse_ reactions" ] }, { "cell_type": "markdown", "id": "962acf15-3b50-40e4-9daa-3dcca7d3291a", "metadata": {}, "source": [ "### Equilibrium" ] }, { "cell_type": "code", "execution_count": 9, "id": "2783a665-fca0-44e5-8d42-af2a96eae392", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: 2 S <-> U\n", "Final concentrations: [U] = 72.65 ; [S] = 18.19\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 3.99404\n", " Formula used: [U] / [S]\n", "2. Ratio of forward/reverse reaction rates: 4.0\n", "Discrepancy between the two values: 0.1489 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n", "1: S <-> X\n", "Final concentrations: [X] = 36.52 ; [S] = 18.19\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 2.00759\n", " Formula used: [X] / [S]\n", "2. Ratio of forward/reverse reaction rates: 2.0\n", "Discrepancy between the two values: 0.3793 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Verify that the reaction has reached equilibrium\n", "dynamics.is_in_equilibrium()" ] }, { "cell_type": "code", "execution_count": null, "id": "27a1b761-19bb-4ec4-83e7-6b7c85e0f165", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "448ec7fa-6529-438b-84ba-47888c2cd080", "metadata": { "tags": [] }, "source": [ "# 2. Now, let's suddenly increase [U]" ] }, { "cell_type": "code", "execution_count": 10, "id": "e82c46d1-482a-41fb-873e-11a42561603d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 1.604933:\n", "3 species:\n", " Species 0 (U). Conc: 72.64754791961869\n", " Species 1 (X). Conc: 36.515929976181866\n", " Species 2 (S). Conc: 18.188974184580783\n", "Set of chemicals involved in reactions: {'S', 'X', 'U'}\n" ] } ], "source": [ "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 11, "id": "7245be7a-c9db-45f5-b033-d6c521237a9c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 1.604933:\n", "3 species:\n", " Species 0 (U). Conc: 100.0\n", " Species 1 (X). Conc: 36.515929976181866\n", " Species 2 (S). Conc: 18.188974184580783\n", "Set of chemicals involved in reactions: {'S', 'X', 'U'}\n" ] } ], "source": [ "dynamics.set_single_conc(species_name=\"U\", conc=100.)\n", "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 12, "id": "61eead55-fcef-41cd-b29e-f2d5ad5c6078", "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", "
SYSTEM TIMEUXScaption
421.29703972.23852937.29725418.225687
431.60493372.64754836.51593018.188974
441.604933100.00000036.51593018.188974Set concentration of `U`
\n", "
" ], "text/plain": [ " SYSTEM TIME U X S caption\n", "42 1.297039 72.238529 37.297254 18.225687 \n", "43 1.604933 72.647548 36.515930 18.188974 \n", "44 1.604933 100.000000 36.515930 18.188974 Set concentration of `U`" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.get_history(tail=3)" ] }, { "cell_type": "markdown", "id": "24455d58-a0ea-43fa-b6ad-95c42a8b34b2", "metadata": {}, "source": [ "### Again, take the system to equilibrium" ] }, { "cell_type": "code", "execution_count": 13, "id": "c06fd8d8-d550-4e35-a239-7b91bee32be9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "19 total step(s) taken\n" ] } ], "source": [ "dynamics.set_step_factors(upshift=1.2, downshift=0.5, abort=0.4) # Needs to tighten to time advance, to prevent mild instability\n", "\n", "\n", "dynamics.single_compartment_react(initial_step=0.01, target_end_time=3.0,\n", " variable_steps=True, explain_variable_steps=False)\n", "\n", "#df = dynamics.get_history()\n", "#dynamics.explain_time_advance()" ] }, { "cell_type": "code", "execution_count": 14, "id": "5af5d869-16ff-4f1d-ab83-4865b42e6376", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Chemical=U
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "U", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "U", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006 ], "xaxis": "x", "y": [ 50, 49.5, 49.3025, 49.1279125, 48.974772375, 48.841703944531254, 48.72741553951446, 48.63069439895918, 48.55040187648133, 48.485468937831165, 48.40960342873317, 48.363918726573424, 48.34542943732506, 48.35442192115496, 48.412964817686024, 48.563788409887835, 48.794496507448386, 49.232024381492934, 49.77305626452036, 50.679867944645785, 51.17387187582093, 51.92163025559485, 53.04465236366425, 54.14644146544591, 55.20543277156762, 56.213136060878696, 57.16724543798181, 58.51887038983838, 59.137114110549426, 60.024316815170444, 61.268502405471146, 61.82974583644012, 62.63038456117153, 63.74311816997822, 64.73322726805728, 65.61422032967758, 66.79007362899101, 67.77154751087184, 69.00038827864219, 69.92452094285747, 70.96699268135814, 71.6217214411839, 72.23852916776461, 72.64754791961869, 100, 99.45511793476646, 98.91935136960488, 98.4067839814589, 97.92739229074814, 97.48366780688417, 97.06857107865042, 96.66660355784194, 96.2589889534477, 95.83158398049471, 95.38127708449245, 94.91652617556622, 94.45274477491586, 94.00855842831685, 93.60476208097151, 93.26103670085975, 92.99270695838744, 92.80495219992822, 92.69524685154005, 92.63103996217262 ], "yaxis": "y" }, { "hovertemplate": "Chemical=X
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "X", "line": { "color": "orange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "X", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006 ], "xaxis": "x", "y": [ 100, 98.5, 97.79875, 97.119203125, 96.4601836796875, 95.82058637564454, 95.1993720638566, 94.59556372623439, 94.00824271042534, 93.43654519314633, 92.60121569067523, 91.79749250682195, 91.02295079202091, 89.9015974211554, 88.83640557203145, 87.3135783361146, 85.89111990471476, 83.88442037099962, 82.03984691017621, 79.46489556174677, 78.2941056586168, 76.60354592432253, 74.20101800580426, 71.97247802494245, 69.88992436494142, 67.93626460974453, 66.09986774357947, 63.50796023276986, 62.32585757818592, 60.63007083885702, 58.25274168840475, 57.18059176222204, 55.65114528572433, 53.52553850967771, 51.63419108531924, 49.951281868101084, 47.705118490711584, 45.830266678427996, 43.48288445758348, 41.71756819977594, 39.72619577063346, 38.4755059413471, 37.297254430062154, 36.515929976181866, 36.515929976181866, 36.51179052797126, 36.585733267918904, 36.75746203921879, 37.04311527987203, 37.4518774114552, 37.98334560142412, 38.62701809600376, 39.36468822266755, 40.17474637042198, 41.0352790512136, 41.92296282246269, 42.80895910139629, 43.65740235884662, 44.42883434661413, 45.08527243954951, 45.59825424530453, 45.955571410275525, 46.17074471144363, 46.26386257327225 ], "yaxis": "y" }, { "hovertemplate": "Chemical=S
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "S", "line": { "color": "blue", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "S", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006 ], "xaxis": "x", "y": [ 0, 2.5, 3.59625, 4.624971875, 5.5902715703125, 6.496005735292969, 7.345796857114502, 8.143047475847274, 8.890953536612024, 9.592516931191366, 10.579577451858441, 11.474670040031214, 12.286190333328987, 13.389558736534692, 14.337664792596508, 15.55884484410973, 16.51988708038848, 17.651530866014525, 18.41404056078308, 19.175368548961664, 19.358150589741353, 19.553193564487778, 19.70967726686726, 19.73463904416575, 19.69921009192334, 19.63746326849809, 19.565641380456917, 19.454298987553386, 19.399914200715244, 19.321295530802107, 19.210253500652975, 19.159916564897735, 19.088085591932618, 18.98822515036587, 18.899354378566212, 18.820277472543765, 18.714734251306396, 18.626638299828322, 18.516338985132133, 18.43338991450913, 18.339818866650276, 18.281051176285132, 18.22568723440864, 18.188974184580783, 18.188974184580783, 19.282877763258465, 20.280468153633986, 21.133874158626078, 21.80700429939433, 22.285691135539125, 22.584416402037693, 22.744678949075027, 22.822238031199703, 22.866989829351244, 22.90707094056414, 22.948888987167532, 22.99045550953466, 23.030384945282346, 23.066545652205498, 23.09755831949365, 23.121235998683233, 23.13942835063069, 23.14366574623894, 23.178961663145174 ], "yaxis": "y" } ], "layout": { "autosize": true, "legend": { "title": { "text": "Chemical" }, "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Changes in concentration for `2 S <-> U` and `S <-> X`" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 3.1523329654696006 ], "title": { "text": "SYSTEM TIME" }, "type": "linear" }, "yaxis": { "anchor": "x", "autorange": true, "domain": [ 0, 1 ], "range": [ -5.555555555555555, 105.55555555555556 ], "title": { "text": "concentration" }, "type": "linear" } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "dynamics.plot_curves(colors=['green', 'orange', 'blue'])" ] }, { "cell_type": "markdown", "id": "158e3787-f2d5-4a01-aaa9-6066e93e584c", "metadata": {}, "source": [ "### The (transiently) high value of [U] led to an increase in [X]" ] }, { "cell_type": "code", "execution_count": 15, "id": "c3afbcc8-bdae-4938-a3f1-ce00d62816f2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: 2 S <-> U\n", "Final concentrations: [U] = 92.63 ; [S] = 23.18\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 3.99634\n", " Formula used: [U] / [S]\n", "2. Ratio of forward/reverse reaction rates: 4.0\n", "Discrepancy between the two values: 0.09147 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n", "1: S <-> X\n", "Final concentrations: [X] = 46.26 ; [S] = 23.18\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 1.99594\n", " Formula used: [X] / [S]\n", "2. Ratio of forward/reverse reaction rates: 2.0\n", "Discrepancy between the two values: 0.2029 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Verify that the reaction has reached equilibrium\n", "dynamics.is_in_equilibrium()" ] }, { "cell_type": "code", "execution_count": null, "id": "019f3e6c-081d-45e1-86e7-1ca485d59998", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "f6619731-c5ea-484c-af3e-cea50d685361", "metadata": { "tags": [] }, "source": [ "# 3. Let's again suddenly increase [U]" ] }, { "cell_type": "code", "execution_count": 16, "id": "32de9623-5221-420b-a6f2-5414df281d44", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 3.152333:\n", "3 species:\n", " Species 0 (U). Conc: 92.63103996217262\n", " Species 1 (X). Conc: 46.26386257327225\n", " Species 2 (S). Conc: 23.178961663145174\n", "Set of chemicals involved in reactions: {'S', 'X', 'U'}\n" ] } ], "source": [ "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 17, "id": "d3618eba-a673-4ff5-85d0-08f5ea592361", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 3.152333:\n", "3 species:\n", " Species 0 (U). Conc: 150.0\n", " Species 1 (X). Conc: 46.26386257327225\n", " Species 2 (S). Conc: 23.178961663145174\n", "Set of chemicals involved in reactions: {'S', 'X', 'U'}\n" ] } ], "source": [ "dynamics.set_single_conc(species_name=\"U\", conc=150.)\n", "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 18, "id": "e8fe3554-d5ab-4306-b890-4e36289b5b4b", "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", "
SYSTEM TIMEUXScaption
622.88610092.69524746.17074523.143666
633.15233392.63104046.26386323.178962
643.152333150.00000046.26386323.178962Set concentration of `U`
\n", "
" ], "text/plain": [ " SYSTEM TIME U X S caption\n", "62 2.886100 92.695247 46.170745 23.143666 \n", "63 3.152333 92.631040 46.263863 23.178962 \n", "64 3.152333 150.000000 46.263863 23.178962 Set concentration of `U`" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.get_history(tail=3)" ] }, { "cell_type": "markdown", "id": "0974480d-ca45-46fe-addd-c8d394780fdb", "metadata": {}, "source": [ "### Yet again, take the system to equilibrium" ] }, { "cell_type": "code", "execution_count": 19, "id": "8fe20f9c-05c4-45a4-b485-a51005440200", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "20 total step(s) taken\n" ] } ], "source": [ "dynamics.single_compartment_react(initial_step=0.01, target_end_time=4.5,\n", " variable_steps=True, explain_variable_steps=False)\n", "\n", "#dynamics.get_history()\n", "\n", "#dynamics.explain_time_advance()" ] }, { "cell_type": "code", "execution_count": 20, "id": "ad01c472-3ebe-4d0d-8913-1bcd85ea7a6c", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Chemical=U
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "U", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "U", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006, 3.1523329654696006, 3.1623329654696004, 3.1723329654696, 3.1843329654696, 3.1987329654696004, 3.2160129654696004, 3.2367489654696002, 3.2616321654696003, 3.2914920054696, 3.3273238134696004, 3.3703219830696005, 3.4219197865896005, 3.4838371508136006, 3.5581379878824007, 3.6472989923649606, 3.7542921977440327, 3.882684044198919, 4.036754259944782, 4.221638518839819, 4.4434996295138625, 4.709732962322715 ], "xaxis": "x", "y": [ 50, 49.5, 49.3025, 49.1279125, 48.974772375, 48.841703944531254, 48.72741553951446, 48.63069439895918, 48.55040187648133, 48.485468937831165, 48.40960342873317, 48.363918726573424, 48.34542943732506, 48.35442192115496, 48.412964817686024, 48.563788409887835, 48.794496507448386, 49.232024381492934, 49.77305626452036, 50.679867944645785, 51.17387187582093, 51.92163025559485, 53.04465236366425, 54.14644146544591, 55.20543277156762, 56.213136060878696, 57.16724543798181, 58.51887038983838, 59.137114110549426, 60.024316815170444, 61.268502405471146, 61.82974583644012, 62.63038456117153, 63.74311816997822, 64.73322726805728, 65.61422032967758, 66.79007362899101, 67.77154751087184, 69.00038827864219, 69.92452094285747, 70.96699268135814, 71.6217214411839, 72.23852916776461, 72.64754791961869, 100, 99.45511793476646, 98.91935136960488, 98.4067839814589, 97.92739229074814, 97.48366780688417, 97.06857107865042, 96.66660355784194, 96.2589889534477, 95.83158398049471, 95.38127708449245, 94.91652617556622, 94.45274477491586, 94.00855842831685, 93.60476208097151, 93.26103670085975, 92.99270695838744, 92.80495219992822, 92.69524685154005, 92.63103996217262, 150, 148.85431693305162, 147.9146310723467, 146.9765354020603, 146.06076869054334, 145.18162677084493, 144.34174631764202, 143.5290505994794, 142.71869213054808, 141.8815617808515, 140.9971630844057, 140.06409475771235, 139.10117913688396, 138.14024247976795, 137.2199275735416, 136.38327219778904, 135.67112419800287, 135.1150883430447, 134.7263151314592, 134.4979966129226, 134.37031316880427 ], "yaxis": "y" }, { "hovertemplate": "Chemical=X
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "X", "line": { "color": "orange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "X", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006, 3.1523329654696006, 3.1623329654696004, 3.1723329654696, 3.1843329654696, 3.1987329654696004, 3.2160129654696004, 3.2367489654696002, 3.2616321654696003, 3.2914920054696, 3.3273238134696004, 3.3703219830696005, 3.4219197865896005, 3.4838371508136006, 3.5581379878824007, 3.6472989923649606, 3.7542921977440327, 3.882684044198919, 4.036754259944782, 4.221638518839819, 4.4434996295138625, 4.709732962322715 ], "xaxis": "x", "y": [ 100, 98.5, 97.79875, 97.119203125, 96.4601836796875, 95.82058637564454, 95.1993720638566, 94.59556372623439, 94.00824271042534, 93.43654519314633, 92.60121569067523, 91.79749250682195, 91.02295079202091, 89.9015974211554, 88.83640557203145, 87.3135783361146, 85.89111990471476, 83.88442037099962, 82.03984691017621, 79.46489556174677, 78.2941056586168, 76.60354592432253, 74.20101800580426, 71.97247802494245, 69.88992436494142, 67.93626460974453, 66.09986774357947, 63.50796023276986, 62.32585757818592, 60.63007083885702, 58.25274168840475, 57.18059176222204, 55.65114528572433, 53.52553850967771, 51.63419108531924, 49.951281868101084, 47.705118490711584, 45.830266678427996, 43.48288445758348, 41.71756819977594, 39.72619577063346, 38.4755059413471, 37.297254430062154, 36.515929976181866, 36.515929976181866, 36.51179052797126, 36.585733267918904, 36.75746203921879, 37.04311527987203, 37.4518774114552, 37.98334560142412, 38.62701809600376, 39.36468822266755, 40.17474637042198, 41.0352790512136, 41.92296282246269, 42.80895910139629, 43.65740235884662, 44.42883434661413, 45.08527243954951, 45.59825424530453, 45.955571410275525, 46.17074471144363, 46.26386257327225, 46.26386257327225, 46.26668439586279, 46.40673422245399, 46.69498339703309, 47.16562824532805, 47.84710076177532, 48.75644729676499, 49.894803032975155, 51.24611340446675, 52.78034611507845, 54.45964345618447, 56.242564139259926, 58.081802792259104, 59.917521672324014, 61.675450405865135, 63.27379631715219, 64.63391690775416, 65.69672451260705, 66.43725339464552, 66.88228088906641, 67.07941550667395 ], "yaxis": "y" }, { "hovertemplate": "Chemical=S
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "S", "line": { "color": "blue", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "S", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006, 3.1523329654696006, 3.1623329654696004, 3.1723329654696, 3.1843329654696, 3.1987329654696004, 3.2160129654696004, 3.2367489654696002, 3.2616321654696003, 3.2914920054696, 3.3273238134696004, 3.3703219830696005, 3.4219197865896005, 3.4838371508136006, 3.5581379878824007, 3.6472989923649606, 3.7542921977440327, 3.882684044198919, 4.036754259944782, 4.221638518839819, 4.4434996295138625, 4.709732962322715 ], "xaxis": "x", "y": [ 0, 2.5, 3.59625, 4.624971875, 5.5902715703125, 6.496005735292969, 7.345796857114502, 8.143047475847274, 8.890953536612024, 9.592516931191366, 10.579577451858441, 11.474670040031214, 12.286190333328987, 13.389558736534692, 14.337664792596508, 15.55884484410973, 16.51988708038848, 17.651530866014525, 18.41404056078308, 19.175368548961664, 19.358150589741353, 19.553193564487778, 19.70967726686726, 19.73463904416575, 19.69921009192334, 19.63746326849809, 19.565641380456917, 19.454298987553386, 19.399914200715244, 19.321295530802107, 19.210253500652975, 19.159916564897735, 19.088085591932618, 18.98822515036587, 18.899354378566212, 18.820277472543765, 18.714734251306396, 18.626638299828322, 18.516338985132133, 18.43338991450913, 18.339818866650276, 18.281051176285132, 18.22568723440864, 18.188974184580783, 18.188974184580783, 19.282877763258465, 20.280468153633986, 21.133874158626078, 21.80700429939433, 22.285691135539125, 22.584416402037693, 22.744678949075027, 22.822238031199703, 22.866989829351244, 22.90707094056414, 22.948888987167532, 22.99045550953466, 23.030384945282346, 23.066545652205498, 23.09755831949365, 23.121235998683233, 23.13942835063069, 23.14366574623894, 23.178961663145174, 23.178961663145174, 25.467505974451402, 27.206827869270043, 28.79477003526374, 30.15565861000269, 31.232469932952228, 32.002884304368365, 32.48992000448346, 32.7593265708545, 32.899354559635924, 32.98885461142149, 33.07207058173274, 33.158663170390355, 33.24481760455746, 33.327518683469, 33.4024835236871, 33.46665893265745, 33.515923037720924, 33.552940578853445, 33.564550121505725, 33.62278239213483 ], "yaxis": "y" } ], "layout": { "autosize": true, "legend": { "title": { "text": "Chemical" }, "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Changes in concentration for `2 S <-> U` and `S <-> X`" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 4.709732962322715 ], "title": { "text": "SYSTEM TIME" }, "type": "linear" }, "yaxis": { "anchor": "x", "autorange": true, "domain": [ 0, 1 ], "range": [ -8.333333333333332, 158.33333333333334 ], "title": { "text": "concentration" }, "type": "linear" } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "dynamics.plot_curves(colors=['green', 'orange', 'blue'])" ] }, { "cell_type": "markdown", "id": "ffbf3294-7a8d-4679-9c4b-5b9a975bf8fc", "metadata": {}, "source": [ "### The (transiently) high value of [U] again led to an increase in [X]" ] }, { "cell_type": "code", "execution_count": 21, "id": "31c9c18f-3a7f-4690-8e2f-70fdb02ef5c7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Verify that the reaction has reached equilibrium\n", "dynamics.is_in_equilibrium(explain=False)" ] }, { "cell_type": "code", "execution_count": null, "id": "6fd8ca29-4a92-4381-8fcb-0acf5e4a1f16", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "64ebc51b-0dc7-4cff-b231-4c35843a7113", "metadata": { "tags": [] }, "source": [ "# 4. Now, instead, let's DECREASE [U]" ] }, { "cell_type": "code", "execution_count": 22, "id": "e7ced06d-f506-41ee-80d6-d4b2a8ed28bc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 4.709733:\n", "3 species:\n", " Species 0 (U). Conc: 134.37031316880427\n", " Species 1 (X). Conc: 67.07941550667395\n", " Species 2 (S). Conc: 33.62278239213483\n", "Set of chemicals involved in reactions: {'S', 'X', 'U'}\n" ] } ], "source": [ "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 23, "id": "52f4843c-0671-4cd9-9c51-74a44feb4fe4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 4.709733:\n", "3 species:\n", " Species 0 (U). Conc: 80.0\n", " Species 1 (X). Conc: 67.07941550667395\n", " Species 2 (S). Conc: 33.62278239213483\n", "Set of chemicals involved in reactions: {'S', 'X', 'U'}\n" ] } ], "source": [ "dynamics.set_single_conc(species_name=\"U\", conc=80.)\n", "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 24, "id": "e5ce5d59", "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", "
SYSTEM TIMEUXScaption
834.443500134.49799766.88228133.564550
844.709733134.37031367.07941633.622782
854.70973380.00000067.07941633.622782Set concentration of `U`
\n", "
" ], "text/plain": [ " SYSTEM TIME U X S caption\n", "83 4.443500 134.497997 66.882281 33.564550 \n", "84 4.709733 134.370313 67.079416 33.622782 \n", "85 4.709733 80.000000 67.079416 33.622782 Set concentration of `U`" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.get_history(tail=3)" ] }, { "cell_type": "markdown", "id": "da46e3d8-58d2-4b48-8b32-887613967fce", "metadata": {}, "source": [ "### Take the system to equilibrium" ] }, { "cell_type": "code", "execution_count": 25, "id": "7e9b72f1-5761-4b13-9686-46356d13366c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "19 total step(s) taken\n" ] } ], "source": [ "dynamics.single_compartment_react(initial_step=0.01, target_end_time=6.,\n", " variable_steps=True, explain_variable_steps=False)" ] }, { "cell_type": "code", "execution_count": 26, "id": "566f944c-bd9e-4b46-ba2f-88bea1c53b42", "metadata": {}, "outputs": [], "source": [ "#dynamics.history.get_dataframe()\n", "#dynamics.explain_time_advance()" ] }, { "cell_type": "code", "execution_count": 27, "id": "c388dae7-c4a6-4644-a390-958e3862d102", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Chemical=U
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "U", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "U", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006, 3.1523329654696006, 3.1623329654696004, 3.1723329654696, 3.1843329654696, 3.1987329654696004, 3.2160129654696004, 3.2367489654696002, 3.2616321654696003, 3.2914920054696, 3.3273238134696004, 3.3703219830696005, 3.4219197865896005, 3.4838371508136006, 3.5581379878824007, 3.6472989923649606, 3.7542921977440327, 3.882684044198919, 4.036754259944782, 4.221638518839819, 4.4434996295138625, 4.709732962322715, 4.709732962322715, 4.719732962322714, 4.729732962322714, 4.741732962322714, 4.756132962322714, 4.773412962322714, 4.794148962322715, 4.819032162322714, 4.848892002322715, 4.884723810322715, 4.9277219799227145, 4.9793197834427145, 5.041237147666714, 5.115537984735514, 5.204698989218074, 5.311692194597146, 5.440084041052033, 5.594154256797896, 5.779038515692933, 6.0008996263669765 ], "xaxis": "x", "y": [ 50, 49.5, 49.3025, 49.1279125, 48.974772375, 48.841703944531254, 48.72741553951446, 48.63069439895918, 48.55040187648133, 48.485468937831165, 48.40960342873317, 48.363918726573424, 48.34542943732506, 48.35442192115496, 48.412964817686024, 48.563788409887835, 48.794496507448386, 49.232024381492934, 49.77305626452036, 50.679867944645785, 51.17387187582093, 51.92163025559485, 53.04465236366425, 54.14644146544591, 55.20543277156762, 56.213136060878696, 57.16724543798181, 58.51887038983838, 59.137114110549426, 60.024316815170444, 61.268502405471146, 61.82974583644012, 62.63038456117153, 63.74311816997822, 64.73322726805728, 65.61422032967758, 66.79007362899101, 67.77154751087184, 69.00038827864219, 69.92452094285747, 70.96699268135814, 71.6217214411839, 72.23852916776461, 72.64754791961869, 100, 99.45511793476646, 98.91935136960488, 98.4067839814589, 97.92739229074814, 97.48366780688417, 97.06857107865042, 96.66660355784194, 96.2589889534477, 95.83158398049471, 95.38127708449245, 94.91652617556622, 94.45274477491586, 94.00855842831685, 93.60476208097151, 93.26103670085975, 92.99270695838744, 92.80495219992822, 92.69524685154005, 92.63103996217262, 150, 148.85431693305162, 147.9146310723467, 146.9765354020603, 146.06076869054334, 145.18162677084493, 144.34174631764202, 143.5290505994794, 142.71869213054808, 141.8815617808515, 140.9971630844057, 140.06409475771235, 139.10117913688396, 138.14024247976795, 137.2199275735416, 136.38327219778904, 135.67112419800287, 135.1150883430447, 134.7263151314592, 134.4979966129226, 134.37031316880427, 80, 81.08982259137079, 81.9830783580286, 82.87416134464577, 83.74319140645791, 84.57644293953784, 85.3713318701573, 86.13934117648195, 86.90417862906399, 87.69366816213925, 88.52747573790518, 89.40711891905876, 90.31490359666022, 91.2208214555547, 92.08844421785942, 92.87719635891345, 93.5485715053419, 94.07276869321186, 94.43929217219416, 94.65449875874775 ], "yaxis": "y" }, { "hovertemplate": "Chemical=X
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "X", "line": { "color": "orange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "X", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006, 3.1523329654696006, 3.1623329654696004, 3.1723329654696, 3.1843329654696, 3.1987329654696004, 3.2160129654696004, 3.2367489654696002, 3.2616321654696003, 3.2914920054696, 3.3273238134696004, 3.3703219830696005, 3.4219197865896005, 3.4838371508136006, 3.5581379878824007, 3.6472989923649606, 3.7542921977440327, 3.882684044198919, 4.036754259944782, 4.221638518839819, 4.4434996295138625, 4.709732962322715, 4.709732962322715, 4.719732962322714, 4.729732962322714, 4.741732962322714, 4.756132962322714, 4.773412962322714, 4.794148962322715, 4.819032162322714, 4.848892002322715, 4.884723810322715, 4.9277219799227145, 4.9793197834427145, 5.041237147666714, 5.115537984735514, 5.204698989218074, 5.311692194597146, 5.440084041052033, 5.594154256797896, 5.779038515692933, 6.0008996263669765 ], "xaxis": "x", "y": [ 100, 98.5, 97.79875, 97.119203125, 96.4601836796875, 95.82058637564454, 95.1993720638566, 94.59556372623439, 94.00824271042534, 93.43654519314633, 92.60121569067523, 91.79749250682195, 91.02295079202091, 89.9015974211554, 88.83640557203145, 87.3135783361146, 85.89111990471476, 83.88442037099962, 82.03984691017621, 79.46489556174677, 78.2941056586168, 76.60354592432253, 74.20101800580426, 71.97247802494245, 69.88992436494142, 67.93626460974453, 66.09986774357947, 63.50796023276986, 62.32585757818592, 60.63007083885702, 58.25274168840475, 57.18059176222204, 55.65114528572433, 53.52553850967771, 51.63419108531924, 49.951281868101084, 47.705118490711584, 45.830266678427996, 43.48288445758348, 41.71756819977594, 39.72619577063346, 38.4755059413471, 37.297254430062154, 36.515929976181866, 36.515929976181866, 36.51179052797126, 36.585733267918904, 36.75746203921879, 37.04311527987203, 37.4518774114552, 37.98334560142412, 38.62701809600376, 39.36468822266755, 40.17474637042198, 41.0352790512136, 41.92296282246269, 42.80895910139629, 43.65740235884662, 44.42883434661413, 45.08527243954951, 45.59825424530453, 45.955571410275525, 46.17074471144363, 46.26386257327225, 46.26386257327225, 46.26668439586279, 46.40673422245399, 46.69498339703309, 47.16562824532805, 47.84710076177532, 48.75644729676499, 49.894803032975155, 51.24611340446675, 52.78034611507845, 54.45964345618447, 56.242564139259926, 58.081802792259104, 59.917521672324014, 61.675450405865135, 63.27379631715219, 64.63391690775416, 65.69672451260705, 66.43725339464552, 66.88228088906641, 67.07941550667395, 67.07941550667395, 67.08439998500182, 66.9581571493157, 66.69167114234772, 66.25244538040174, 65.61348078294705, 64.75862974955746, 63.686898809735624, 62.413645491360214, 60.967482120238685, 59.38436821791284, 57.70352666224543, 55.969594057874644, 54.23897879087219, 52.58170047534571, 51.07486728457867, 49.792621191194954, 48.790662305477085, 48.09253977374844, 47.672961224535555 ], "yaxis": "y" }, { "hovertemplate": "Chemical=S
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "S", "line": { "color": "blue", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "S", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.005, 0.0075, 0.01, 0.0125, 0.015000000000000001, 0.0175, 0.02, 0.0225, 0.024999999999999998, 0.028749999999999998, 0.0325, 0.036250000000000004, 0.041875, 0.0475, 0.0559375, 0.064375, 0.07703125, 0.0896875, 0.108671875, 0.1181640625, 0.13240234375, 0.15375976562500002, 0.17511718750000002, 0.19647460937500003, 0.21783203125000003, 0.23918945312500003, 0.2712255859375, 0.28724365234375004, 0.31127075195312504, 0.3473114013671875, 0.36533172607421877, 0.39236221313476566, 0.432907943725586, 0.47345367431640634, 0.5139994049072266, 0.5748180007934571, 0.6356365966796876, 0.7268644905090333, 0.818092384338379, 0.9549342250823977, 1.0917760658264162, 1.297038826942444, 1.604932968616486, 1.604932968616486, 1.614932968616486, 1.626932968616486, 1.641332968616486, 1.6586129686164859, 1.679348968616486, 1.704232168616486, 1.7340920086164862, 1.7699238166164861, 1.812921986216486, 1.864519789736486, 1.926437153960486, 2.000737991029286, 2.089898995511846, 2.196892200890918, 2.3252840473458045, 2.4793542630916683, 2.6642385219867046, 2.8860996326607484, 3.1523329654696006, 3.1523329654696006, 3.1623329654696004, 3.1723329654696, 3.1843329654696, 3.1987329654696004, 3.2160129654696004, 3.2367489654696002, 3.2616321654696003, 3.2914920054696, 3.3273238134696004, 3.3703219830696005, 3.4219197865896005, 3.4838371508136006, 3.5581379878824007, 3.6472989923649606, 3.7542921977440327, 3.882684044198919, 4.036754259944782, 4.221638518839819, 4.4434996295138625, 4.709732962322715, 4.709732962322715, 4.719732962322714, 4.729732962322714, 4.741732962322714, 4.756132962322714, 4.773412962322714, 4.794148962322715, 4.819032162322714, 4.848892002322715, 4.884723810322715, 4.9277219799227145, 4.9793197834427145, 5.041237147666714, 5.115537984735514, 5.204698989218074, 5.311692194597146, 5.440084041052033, 5.594154256797896, 5.779038515692933, 6.0008996263669765 ], "xaxis": "x", "y": [ 0, 2.5, 3.59625, 4.624971875, 5.5902715703125, 6.496005735292969, 7.345796857114502, 8.143047475847274, 8.890953536612024, 9.592516931191366, 10.579577451858441, 11.474670040031214, 12.286190333328987, 13.389558736534692, 14.337664792596508, 15.55884484410973, 16.51988708038848, 17.651530866014525, 18.41404056078308, 19.175368548961664, 19.358150589741353, 19.553193564487778, 19.70967726686726, 19.73463904416575, 19.69921009192334, 19.63746326849809, 19.565641380456917, 19.454298987553386, 19.399914200715244, 19.321295530802107, 19.210253500652975, 19.159916564897735, 19.088085591932618, 18.98822515036587, 18.899354378566212, 18.820277472543765, 18.714734251306396, 18.626638299828322, 18.516338985132133, 18.43338991450913, 18.339818866650276, 18.281051176285132, 18.22568723440864, 18.188974184580783, 18.188974184580783, 19.282877763258465, 20.280468153633986, 21.133874158626078, 21.80700429939433, 22.285691135539125, 22.584416402037693, 22.744678949075027, 22.822238031199703, 22.866989829351244, 22.90707094056414, 22.948888987167532, 22.99045550953466, 23.030384945282346, 23.066545652205498, 23.09755831949365, 23.121235998683233, 23.13942835063069, 23.14366574623894, 23.178961663145174, 23.178961663145174, 25.467505974451402, 27.206827869270043, 28.79477003526374, 30.15565861000269, 31.232469932952228, 32.002884304368365, 32.48992000448346, 32.7593265708545, 32.899354559635924, 32.98885461142149, 33.07207058173274, 33.158663170390355, 33.24481760455746, 33.327518683469, 33.4024835236871, 33.46665893265745, 33.515923037720924, 33.552940578853445, 33.564550121505725, 33.62278239213483, 33.62278239213483, 31.438152731065387, 29.77788403343589, 28.262204067169552, 26.963369705491257, 25.935831236786097, 25.200904408936772, 24.73661673610931, 24.480195149320632, 24.34737945429164, 24.262878205085624, 24.184433398445854, 24.102796647613737, 24.02157619682724, 23.943608987744266, 23.872937896403233, 23.812433696930075, 23.765998206908012, 23.731073780672048, 23.72023915677775 ], "yaxis": "y" } ], "layout": { "autosize": true, "legend": { "title": { "text": "Chemical" }, "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Changes in concentration for `2 S <-> U` and `S <-> X`" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 6.0008996263669765 ], "title": { "text": "SYSTEM TIME" }, "type": "linear" }, "yaxis": { "anchor": "x", "autorange": true, "domain": [ 0, 1 ], "range": [ -8.333333333333332, 158.33333333333334 ], "title": { "text": "concentration" }, "type": "linear" } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "dynamics.plot_curves(colors=['green', 'orange', 'blue'])" ] }, { "cell_type": "markdown", "id": "a1629b91-2753-4df7-b6a0-dedf86ac3dc1", "metadata": {}, "source": [ "### The (transiently) LOW value of [U] led to an DECREASE in [X]" ] }, { "cell_type": "code", "execution_count": 28, "id": "aff608b1-5c78-4070-845a-118afe7c2108", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Verify that the reaction has reached equilibrium\n", "dynamics.is_in_equilibrium(explain=False)" ] }, { "cell_type": "markdown", "id": "777ebec9-ed31-4cf3-adfc-b44db383bd39", "metadata": {}, "source": [ "**IDEAS TO EXPLORE**: \n", "\n", "* Effect of the stoichiometry and the Delta_G on the \"amplification\" of the signal (from [U] to [X]) \n", "\n", "* Effect of a continuously-varying (maybe oscillating [U]), and its being affected by the reactions' kinetics\n", "\n", "* Combining this experiment and `up_regulate_2` in a *\"bifan motif\"*" ] }, { "cell_type": "code", "execution_count": null, "id": "38b77468", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }