{ "cells": [ { "cell_type": "markdown", "id": "49bcb5b0-f19d-4b96-a5f1-e0ae30f66d8f", "metadata": {}, "source": [ "## `A` down-regulates `B` , \n", "### by being the *limiting reagent* in reaction `A + 2 B <-> Y` (mostly forward)\n", "1st-order kinetics. \n", "If [A] is low and [B] is high, then [B] remains high. If [A] goes high, [B] goes low. However, at that point, A can no longer bring B up to any substantial extent.\n", "\n", "See also 1D/reactions/down_regulation_1\n", "\n", "LAST REVISED: Nov. 4, 2023" ] }, { "cell_type": "code", "execution_count": 1, "id": "5a07c2cb-c6b8-4614-b1f7-fc582f174c0f", "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": "367ba836", "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 'down_regulate_2.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: 1 (at temp. 25 C)\n", "0: A + 2 B <-> Y (kF = 8 / kR = 2 / delta_G = -3,436.6 / K = 4) | 1st order in all reactants & products\n", "Set of chemicals involved in the above reactions: {'B', 'A', 'Y'}\n", "[GRAPHIC ELEMENT SENT TO LOG FILE `down_regulate_2.log.htm`]\n" ] } ], "source": [ "# Initialize the system\n", "chem_data = chem(names=[\"A\", \"B\", \"Y\"])\n", "\n", "# Reaction A + 2 B <-> Y , with 1st-order kinetics for all species\n", "chem_data.add_reaction(reactants=[(\"A\") , (2, \"B\")], products=[(\"Y\")],\n", " forward_rate=8., reverse_rate=2.)\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 (A). Conc: 5.0\n", " Species 1 (B). Conc: 100.0\n", " Species 2 (Y). Conc: 0.0\n", "Set of chemicals involved in reactions: {'B', 'A', 'Y'}\n" ] } ], "source": [ "dynamics = ReactionDynamics(chem_data=chem_data)\n", "dynamics.set_conc(conc={\"A\": 5., \"B\": 100., \"Y\": 0.},\n", " snapshot=True) # A is scarce, B is plentiful, Y is absent\n", "dynamics.describe_state()" ] }, { "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": "bcf652b8-e0dc-438e-bdbe-02216c1d52a0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "* INFO: the tentative time step (0.0005) 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.00025) [Step started at t=0, and will rewind there]\n", "28 total step(s) taken\n" ] } ], "source": [ "# 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=1.0, abort=1.44)\n", "dynamics.set_thresholds(norm=\"norm_B\", low=0.2, high=0.5, abort=1.5)\n", "dynamics.set_step_factors(upshift=1.4, downshift=0.5, abort=0.5)\n", "dynamics.set_error_step_factor(0.333)\n", "\n", "dynamics.single_compartment_react(initial_step=0.0005, reaction_duration=0.015,\n", " variable_steps=True, explain_variable_steps=False)" ] }, { "cell_type": "markdown", "id": "7dc56592-179d-4e4c-b75a-8eb81dcafe71", "metadata": {}, "source": [ "A, as the scarse limiting reagent, stops the reaction. \n", "When A is low, B is also low." ] }, { "cell_type": "code", "execution_count": 7, "id": "58f4f09c-8af6-46b7-bd85-2f6ca194c42a", "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=A
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "A", "line": { "color": "red", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "A", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999 ], "xaxis": "x", "y": [ 5, 4, 3.2165, 2.9067691305, 2.517590791882847, 2.0498581641968268, 1.5225888605747753, 1.1362331163200294, 0.851194380983752, 0.6398532663849396, 0.4825793102104357, 0.36522241359901236, 0.2774745136471351, 0.21176652756426492, 0.1625072843777499, 0.12554807493803027, 0.09780009276459273, 0.07695779905031393, 0.06129700525114322, 0.04952642690090266, 0.03713855091064221, 0.029053854677946724, 0.02377626983163505, 0.018952316762392143, 0.016472060882598158, 0.014686460392091347, 0.013886535976814492, 0.013832735442295341, 0.01385779599439035 ], "yaxis": "y" }, { "hovertemplate": "Chemical=B
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "B", "line": { "color": "darkorange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "B", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999 ], "xaxis": "x", "y": [ 100, 98, 96.433, 95.813538261, 95.0351815837657, 94.09971632839367, 93.04517772114957, 92.27246623264008, 91.70238876196753, 91.27970653276991, 90.9651586204209, 90.73044482719804, 90.55494902729428, 90.42353305512854, 90.32501456875552, 90.25109614987608, 90.1956001855292, 90.15391559810064, 90.1225940105023, 90.09905285380182, 90.0742771018213, 90.05810770935591, 90.04755253966329, 90.0379046335248, 90.03294412176521, 90.0293729207842, 90.02777307195365, 90.02766547088461, 90.02771559198881 ], "yaxis": "y" }, { "hovertemplate": "Chemical=Y
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "Y", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "Y", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999 ], "xaxis": "x", "y": [ 0, 1, 1.7835, 2.0932308695, 2.482409208117153, 2.9501418358031732, 3.4774111394252247, 3.8637668836799706, 4.148805619016248, 4.3601467336150606, 4.517420689789565, 4.634777586400988, 4.722525486352866, 4.788233472435736, 4.8374927156222505, 4.87445192506197, 4.902199907235407, 4.923042200949686, 4.938702994748857, 4.950473573099098, 4.962861449089358, 4.970946145322054, 4.976223730168365, 4.981047683237608, 4.983527939117402, 4.985313539607909, 4.986113464023186, 4.986167264557705, 4.98614220400561 ], "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 concentrations (reaction A + 2 B <-> Y)" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 0.015318387967999999 ], "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=['red', 'darkorange', 'green'],\n", " title=\"Changes in concentrations (reaction A + 2 B <-> Y)\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "8a07bbaf-c765-4dee-8712-a094ab678f00", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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 TIMEABYcaption
00.0000005.000000100.0000000.000000Initial state
10.0002504.00000098.0000001.000000
20.0005003.21650096.4330001.783500
30.0006252.90676995.8135382.093231
40.0008002.51759195.0351822.482409
50.0010452.04985894.0997162.950142
60.0013881.52258993.0451783.477411
70.0017311.13623392.2724663.863767
80.0020740.85119491.7023894.148806
90.0024170.63985391.2797074.360147
100.0027600.48257990.9651594.517421
110.0031030.36522290.7304454.634778
120.0034460.27747590.5549494.722525
130.0037890.21176790.4235334.788233
140.0041320.16250790.3250154.837493
150.0044750.12554890.2510964.874452
160.0048180.09780090.1956004.902200
170.0051610.07695890.1539164.923042
180.0055040.06129790.1225944.938703
190.0058470.04952690.0990534.950474
200.0063270.03713990.0742774.962861
210.0068070.02905490.0581084.970946
220.0072880.02377690.0475534.976224
230.0079600.01895290.0379054.981048
240.0086320.01647290.0329444.983528
250.0095730.01468690.0293734.985314
260.0108910.01388790.0277734.986113
270.0127360.01383390.0276654.986167
280.0153180.01385890.0277164.986142
\n", "
" ], "text/plain": [ " SYSTEM TIME A B Y caption\n", "0 0.000000 5.000000 100.000000 0.000000 Initial state\n", "1 0.000250 4.000000 98.000000 1.000000 \n", "2 0.000500 3.216500 96.433000 1.783500 \n", "3 0.000625 2.906769 95.813538 2.093231 \n", "4 0.000800 2.517591 95.035182 2.482409 \n", "5 0.001045 2.049858 94.099716 2.950142 \n", "6 0.001388 1.522589 93.045178 3.477411 \n", "7 0.001731 1.136233 92.272466 3.863767 \n", "8 0.002074 0.851194 91.702389 4.148806 \n", "9 0.002417 0.639853 91.279707 4.360147 \n", "10 0.002760 0.482579 90.965159 4.517421 \n", "11 0.003103 0.365222 90.730445 4.634778 \n", "12 0.003446 0.277475 90.554949 4.722525 \n", "13 0.003789 0.211767 90.423533 4.788233 \n", "14 0.004132 0.162507 90.325015 4.837493 \n", "15 0.004475 0.125548 90.251096 4.874452 \n", "16 0.004818 0.097800 90.195600 4.902200 \n", "17 0.005161 0.076958 90.153916 4.923042 \n", "18 0.005504 0.061297 90.122594 4.938703 \n", "19 0.005847 0.049526 90.099053 4.950474 \n", "20 0.006327 0.037139 90.074277 4.962861 \n", "21 0.006807 0.029054 90.058108 4.970946 \n", "22 0.007288 0.023776 90.047553 4.976224 \n", "23 0.007960 0.018952 90.037905 4.981048 \n", "24 0.008632 0.016472 90.032944 4.983528 \n", "25 0.009573 0.014686 90.029373 4.985314 \n", "26 0.010891 0.013887 90.027773 4.986113 \n", "27 0.012736 0.013833 90.027665 4.986167 \n", "28 0.015318 0.013858 90.027716 4.986142 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.get_history()" ] }, { "cell_type": "code", "execution_count": 9, "id": "3180f7aa-390e-4ada-a7ab-3c0db958fcc5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "From time 0 to 0.0005, in 2 steps of 0.00025\n", "From time 0.0005 to 0.000625, in 1 step of 0.000125\n", "From time 0.000625 to 0.0008, in 1 step of 0.000175\n", "From time 0.0008 to 0.001045, in 1 step of 0.000245\n", "From time 0.001045 to 0.005847, in 14 steps of 0.000343\n", "From time 0.005847 to 0.007288, in 3 steps of 0.00048\n", "From time 0.007288 to 0.008632, in 2 steps of 0.000672\n", "From time 0.008632 to 0.009573, in 1 step of 0.000941\n", "From time 0.009573 to 0.01089, in 1 step of 0.00132\n", "From time 0.01089 to 0.01274, in 1 step of 0.00184\n", "From time 0.01274 to 0.01532, in 1 step of 0.00258\n", "(28 steps total)\n" ] } ], "source": [ "dynamics.explain_time_advance(use_history=True)" ] }, { "cell_type": "markdown", "id": "962acf15-3b50-40e4-9daa-3dcca7d3291a", "metadata": {}, "source": [ "#### Equilibrium" ] }, { "cell_type": "code", "execution_count": 10, "id": "2783a665-fca0-44e5-8d42-af2a96eae392", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: A + 2 B <-> Y\n", "Final concentrations: [Y] = 4.986 ; [A] = 0.01386 ; [B] = 90.03\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 3.99663\n", " Formula used: [Y] / ([A][B])\n", "2. Ratio of forward/reverse reaction rates: 4.0\n", "Discrepancy between the two values: 0.08418 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 10, "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": "4faea7f8-0466-4d90-8eba-3d6501cca2d8", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "448ec7fa-6529-438b-84ba-47888c2cd080", "metadata": { "tags": [] }, "source": [ "# 2. Now, let's suddenly increase [A]" ] }, { "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 = 0.015318388:\n", "3 species:\n", " Species 0 (A). Conc: 40.0\n", " Species 1 (B). Conc: 90.02771559198881\n", " Species 2 (Y). Conc: 4.98614220400561\n", "Set of chemicals involved in reactions: {'B', 'A', 'Y'}\n" ] } ], "source": [ "dynamics.set_single_conc(species_name=\"A\", conc=40., snapshot=True)\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SYSTEM TIMEABYcaption
250.0095730.01468690.0293734.985314
260.0108910.01388790.0277734.986113
270.0127360.01383390.0276654.986167
280.0153180.01385890.0277164.986142
290.01531840.00000090.0277164.986142Set concentration of `A`
\n", "
" ], "text/plain": [ " SYSTEM TIME A B Y caption\n", "25 0.009573 0.014686 90.029373 4.985314 \n", "26 0.010891 0.013887 90.027773 4.986113 \n", "27 0.012736 0.013833 90.027665 4.986167 \n", "28 0.015318 0.013858 90.027716 4.986142 \n", "29 0.015318 40.000000 90.027716 4.986142 Set concentration of `A`" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.history.get_dataframe(tail=5)" ] }, { "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": [ "* INFO: the tentative time step (0.0005) 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.00025) [Step started at t=0.015318, and will rewind there]\n", "* INFO: the tentative time step (0.00025) 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.000125) [Step started at t=0.015318, and will rewind there]\n", "* INFO: the tentative time step (0.000125) 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 6.25e-05) [Step started at t=0.015318, and will rewind there]\n", "* INFO: the tentative time step (6.25e-05) 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 3.125e-05) [Step started at t=0.015318, and will rewind there]\n", "47 total step(s) taken\n" ] } ], "source": [ "dynamics.single_compartment_react(initial_step=0.0005, target_end_time=0.055,\n", " variable_steps=True, explain_variable_steps=False)" ] }, { "cell_type": "code", "execution_count": 14, "id": "cc34ca51-8ec3-4170-abc9-f9bccdd7ce00", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Chemical=A
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "A", "line": { "color": "red", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "A", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205 ], "xaxis": "x", "y": [ 5, 4, 3.2165, 2.9067691305, 2.517590791882847, 2.0498581641968268, 1.5225888605747753, 1.1362331163200294, 0.851194380983752, 0.6398532663849396, 0.4825793102104357, 0.36522241359901236, 0.2774745136471351, 0.21176652756426492, 0.1625072843777499, 0.12554807493803027, 0.09780009276459273, 0.07695779905031393, 0.06129700525114322, 0.04952642690090266, 0.03713855091064221, 0.029053854677946724, 0.02377626983163505, 0.018952316762392143, 0.016472060882598158, 0.014686460392091347, 0.013886535976814492, 0.013832735442295341, 0.01385779599439035, 40, 39.10003447796786, 38.237975005266094, 37.0808617187854, 35.988917499434834, 34.95675290844794, 33.979560546614834, 33.053038168865335, 32.173323719760695, 31.336940180985742, 30.222271882132553, 29.180462882864678, 28.204549095314782, 27.288432856197204, 26.426751513819887, 25.289976460531136, 24.241876527080546, 23.272392698984195, 22.372944470148965, 21.536166120095626, 20.443510437718032, 19.44974586467731, 18.54193962640131, 17.70934072987829, 16.636373069946984, 15.677331776192714, 14.81487978472246, 13.723138643803917, 12.769814586812139, 11.930018488338689, 10.886378723172008, 9.996512044225279, 9.228692524489007, 8.291784621655506, 7.511529587076473, 6.587975720028021, 5.847971128159644, 5.000058846687724, 4.087450620249769, 3.4377219374622863, 2.761345746122461, 2.118757215575542, 1.7316682196056807, 1.383073243592625, 1.19433355515071, 1.0433799852870576, 0.9533046931848093, 0.9251887264817047 ], "yaxis": "y" }, { "hovertemplate": "Chemical=B
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "B", "line": { "color": "darkorange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "B", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205 ], "xaxis": "x", "y": [ 100, 98, 96.433, 95.813538261, 95.0351815837657, 94.09971632839367, 93.04517772114957, 92.27246623264008, 91.70238876196753, 91.27970653276991, 90.9651586204209, 90.73044482719804, 90.55494902729428, 90.42353305512854, 90.32501456875552, 90.25109614987608, 90.1956001855292, 90.15391559810064, 90.1225940105023, 90.09905285380182, 90.0742771018213, 90.05810770935591, 90.04755253966329, 90.0379046335248, 90.03294412176521, 90.0293729207842, 90.02777307195365, 90.02766547088461, 90.02771559198881, 90.02771559198881, 88.22778454792453, 86.503665602521, 84.18943902955961, 82.00555059085848, 79.94122140888469, 77.98683668521848, 76.13379192971948, 74.3743630315102, 72.7015959539603, 70.47225935625391, 68.38864135771817, 66.43681378261839, 64.60458130438323, 62.8812186196286, 60.607668513051095, 58.511468646149915, 56.57250098995721, 54.773604532286754, 53.100047832180074, 50.91473646742489, 48.927207321343445, 47.11159484479144, 45.4463970517454, 43.30046173188279, 41.382379144374255, 39.657475161433744, 37.47399287959666, 35.5673447656131, 33.8877525686662, 31.80047303833284, 30.02073968043938, 28.485100640966838, 26.611284835299834, 25.05077476614177, 23.203667032044866, 21.72365784830811, 20.02783328536427, 18.202616832488363, 16.903159466913397, 15.550407084233747, 14.265230023139909, 13.491052031200185, 12.793862079174074, 12.416382702290244, 12.114475562562939, 11.934324978358443, 11.878093044952234 ], "yaxis": "y" }, { "hovertemplate": "Chemical=Y
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "Y", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "Y", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205 ], "xaxis": "x", "y": [ 0, 1, 1.7835, 2.0932308695, 2.482409208117153, 2.9501418358031732, 3.4774111394252247, 3.8637668836799706, 4.148805619016248, 4.3601467336150606, 4.517420689789565, 4.634777586400988, 4.722525486352866, 4.788233472435736, 4.8374927156222505, 4.87445192506197, 4.902199907235407, 4.923042200949686, 4.938702994748857, 4.950473573099098, 4.962861449089358, 4.970946145322054, 4.976223730168365, 4.981047683237608, 4.983527939117402, 4.985313539607909, 4.986113464023186, 4.986167264557705, 4.98614220400561, 4.98614220400561, 5.886107726037747, 6.748167198739512, 7.905280485220206, 8.997224704570774, 10.029389295557671, 11.006581657390779, 11.933104035140278, 12.812818484244918, 13.64920202301987, 14.763870321873059, 15.805679321140934, 16.781593108690828, 17.697709347808406, 18.559390690185722, 19.696165743474474, 20.744265676925064, 21.713749505021415, 22.613197733856644, 23.449976083909984, 24.542631766287577, 25.5363963393283, 26.4442025776043, 27.27680147412732, 28.349769134058626, 29.308810427812894, 30.17126241928315, 31.263003560201692, 32.21632761719347, 33.05612371566692, 34.0997634808336, 34.98963015978033, 35.757449679516604, 36.69435758235011, 37.47461261692914, 38.3981664839776, 39.138171075845975, 39.986083357317895, 40.89869158375585, 41.54842026654333, 42.22479645788316, 42.867384988430075, 43.25447398439994, 43.60306896041299, 43.791808648854904, 43.942762218718556, 44.032837510820805, 44.06095347752391 ], "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 concentrations (reaction A + 2 B <-> Y)" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 0.05962283556013205 ], "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=['red', 'darkorange', 'green'],\n", " title=\"Changes in concentrations (reaction A + 2 B <-> Y)\")" ] }, { "cell_type": "markdown", "id": "158e3787-f2d5-4a01-aaa9-6066e93e584c", "metadata": {}, "source": [ "**A**, still the limiting reagent, is again stopping the reaction. \n", "The (transiently) high value of [A] led to a high value of [B]" ] }, { "cell_type": "code", "execution_count": 15, "id": "2415f119-b3cc-477d-b3a4-cd020aab3615", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SYSTEM TIMEABYcaption
00.0000005.000000100.0000000.000000Initial state
10.0002504.00000098.0000001.000000
20.0005003.21650096.4330001.783500
30.0006252.90676995.8135382.093231
40.0008002.51759195.0351822.482409
..................
720.0349541.38307312.79386243.603069
730.0384271.19433412.41638343.791809
740.0432881.04338012.11447643.942762
750.0500940.95330511.93432544.032838
760.0596230.92518911.87809344.060953
\n", "

77 rows × 5 columns

\n", "
" ], "text/plain": [ " SYSTEM TIME A B Y caption\n", "0 0.000000 5.000000 100.000000 0.000000 Initial state\n", "1 0.000250 4.000000 98.000000 1.000000 \n", "2 0.000500 3.216500 96.433000 1.783500 \n", "3 0.000625 2.906769 95.813538 2.093231 \n", "4 0.000800 2.517591 95.035182 2.482409 \n", ".. ... ... ... ... ...\n", "72 0.034954 1.383073 12.793862 43.603069 \n", "73 0.038427 1.194334 12.416383 43.791809 \n", "74 0.043288 1.043380 12.114476 43.942762 \n", "75 0.050094 0.953305 11.934325 44.032838 \n", "76 0.059623 0.925189 11.878093 44.060953 \n", "\n", "[77 rows x 5 columns]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.get_history()" ] }, { "cell_type": "code", "execution_count": 16, "id": "aff608b1-5c78-4070-845a-118afe7c2108", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: A + 2 B <-> Y\n", "Final concentrations: [Y] = 44.06 ; [A] = 0.9252 ; [B] = 11.88\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 4.00938\n", " Formula used: [Y] / ([A][B])\n", "2. Ratio of forward/reverse reaction rates: 4.0\n", "Discrepancy between the two values: 0.2344 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 16, "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": "cb4749d0-dc12-44ba-a032-8068c80d9c4c", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "f6619731-c5ea-484c-af3e-cea50d685361", "metadata": { "tags": [] }, "source": [ "# 3. Let's again suddenly increase [A]" ] }, { "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 = 0.059622836:\n", "3 species:\n", " Species 0 (A). Conc: 30.0\n", " Species 1 (B). Conc: 11.878093044952234\n", " Species 2 (Y). Conc: 44.06095347752391\n", "Set of chemicals involved in reactions: {'B', 'A', 'Y'}\n" ] } ], "source": [ "dynamics.set_single_conc(species_name=\"A\", conc=30., snapshot=True)\n", "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 18, "id": "007161ef-f4d0-4623-92c5-0fe3d2bda98a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SYSTEM TIMEABYcaption
730.0384271.19433412.41638343.791809
740.0432881.04338012.11447643.942762
750.0500940.95330511.93432544.032838
760.0596230.92518911.87809344.060953
770.05962330.00000011.87809344.060953Set concentration of `A`
\n", "
" ], "text/plain": [ " SYSTEM TIME A B Y caption\n", "73 0.038427 1.194334 12.416383 43.791809 \n", "74 0.043288 1.043380 12.114476 43.942762 \n", "75 0.050094 0.953305 11.934325 44.032838 \n", "76 0.059623 0.925189 11.878093 44.060953 \n", "77 0.059623 30.000000 11.878093 44.060953 Set concentration of `A`" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.history.get_dataframe(tail=5)" ] }, { "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": [ "* INFO: the tentative time step (0.001) 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.0005) [Step started at t=0.059623, and will rewind there]\n", "19 total step(s) taken\n" ] } ], "source": [ "dynamics.single_compartment_react(initial_step=0.001, target_end_time=0.09,\n", " variable_steps=True, explain_variable_steps=False)" ] }, { "cell_type": "code", "execution_count": 20, "id": "4229e039-b484-4849-a446-59409885deb4", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Chemical=A
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "A", "line": { "color": "red", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "A", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205, 0.05962283556013205, 0.06012283556013205, 0.06037283556013205, 0.060722835560132055, 0.06121283556013205, 0.06170283556013205, 0.06238883556013205, 0.06307483556013205, 0.06376083556013205, 0.06444683556013206, 0.06513283556013207, 0.06609323556013207, 0.06705363556013207, 0.06839819556013206, 0.07028057956013206, 0.07291591716013206, 0.07660538980013205, 0.08177065149613205, 0.08900201787053205, 0.09912593079469205 ], "xaxis": "x", "y": [ 5, 4, 3.2165, 2.9067691305, 2.517590791882847, 2.0498581641968268, 1.5225888605747753, 1.1362331163200294, 0.851194380983752, 0.6398532663849396, 0.4825793102104357, 0.36522241359901236, 0.2774745136471351, 0.21176652756426492, 0.1625072843777499, 0.12554807493803027, 0.09780009276459273, 0.07695779905031393, 0.06129700525114322, 0.04952642690090266, 0.03713855091064221, 0.029053854677946724, 0.02377626983163505, 0.018952316762392143, 0.016472060882598158, 0.014686460392091347, 0.013886535976814492, 0.013832735442295341, 0.01385779599439035, 40, 39.10003447796786, 38.237975005266094, 37.0808617187854, 35.988917499434834, 34.95675290844794, 33.979560546614834, 33.053038168865335, 32.173323719760695, 31.336940180985742, 30.222271882132553, 29.180462882864678, 28.204549095314782, 27.288432856197204, 26.426751513819887, 25.289976460531136, 24.241876527080546, 23.272392698984195, 22.372944470148965, 21.536166120095626, 20.443510437718032, 19.44974586467731, 18.54193962640131, 17.70934072987829, 16.636373069946984, 15.677331776192714, 14.81487978472246, 13.723138643803917, 12.769814586812139, 11.930018488338689, 10.886378723172008, 9.996512044225279, 9.228692524489007, 8.291784621655506, 7.511529587076473, 6.587975720028021, 5.847971128159644, 5.000058846687724, 4.087450620249769, 3.4377219374622863, 2.761345746122461, 2.118757215575542, 1.7316682196056807, 1.383073243592625, 1.19433355515071, 1.0433799852870576, 0.9533046931848093, 0.9251887264817047, 30, 28.618689788083255, 28.11966515349685, 27.51269822093916, 26.81377570923404, 26.281379649601366, 25.706419270275298, 25.308487498816163, 25.028828447914865, 24.830209375571307, 24.688103740188456, 24.545018822350595, 24.457554792240757, 24.382270757744955, 24.333340532304486, 24.315962680077988, 24.31698567327952, 24.316329870121027, 24.317285723408364, 24.31479993929142 ], "yaxis": "y" }, { "hovertemplate": "Chemical=B
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "B", "line": { "color": "darkorange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "B", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205, 0.05962283556013205, 0.06012283556013205, 0.06037283556013205, 0.060722835560132055, 0.06121283556013205, 0.06170283556013205, 0.06238883556013205, 0.06307483556013205, 0.06376083556013205, 0.06444683556013206, 0.06513283556013207, 0.06609323556013207, 0.06705363556013207, 0.06839819556013206, 0.07028057956013206, 0.07291591716013206, 0.07660538980013205, 0.08177065149613205, 0.08900201787053205, 0.09912593079469205 ], "xaxis": "x", "y": [ 100, 98, 96.433, 95.813538261, 95.0351815837657, 94.09971632839367, 93.04517772114957, 92.27246623264008, 91.70238876196753, 91.27970653276991, 90.9651586204209, 90.73044482719804, 90.55494902729428, 90.42353305512854, 90.32501456875552, 90.25109614987608, 90.1956001855292, 90.15391559810064, 90.1225940105023, 90.09905285380182, 90.0742771018213, 90.05810770935591, 90.04755253966329, 90.0379046335248, 90.03294412176521, 90.0293729207842, 90.02777307195365, 90.02766547088461, 90.02771559198881, 90.02771559198881, 88.22778454792453, 86.503665602521, 84.18943902955961, 82.00555059085848, 79.94122140888469, 77.98683668521848, 76.13379192971948, 74.3743630315102, 72.7015959539603, 70.47225935625391, 68.38864135771817, 66.43681378261839, 64.60458130438323, 62.8812186196286, 60.607668513051095, 58.511468646149915, 56.57250098995721, 54.773604532286754, 53.100047832180074, 50.91473646742489, 48.927207321343445, 47.11159484479144, 45.4463970517454, 43.30046173188279, 41.382379144374255, 39.657475161433744, 37.47399287959666, 35.5673447656131, 33.8877525686662, 31.80047303833284, 30.02073968043938, 28.485100640966838, 26.611284835299834, 25.05077476614177, 23.203667032044866, 21.72365784830811, 20.02783328536427, 18.202616832488363, 16.903159466913397, 15.550407084233747, 14.265230023139909, 13.491052031200185, 12.793862079174074, 12.416382702290244, 12.114475562562939, 11.934324978358443, 11.878093044952234, 11.878093044952234, 9.115472621118746, 8.117423351945932, 6.903489486830555, 5.505644463420315, 4.4408523441549645, 3.2909315855028267, 2.4950680425845557, 1.9357499407819603, 1.5385117960948453, 1.2543005253291408, 0.9681306896534161, 0.7932026294337404, 0.6426345604421384, 0.5447741095611982, 0.5100184051082033, 0.5120643915112745, 0.5107527851942871, 0.5126644917689619, 0.5076929235350717 ], "yaxis": "y" }, { "hovertemplate": "Chemical=Y
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "Y", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "Y", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205, 0.05962283556013205, 0.06012283556013205, 0.06037283556013205, 0.060722835560132055, 0.06121283556013205, 0.06170283556013205, 0.06238883556013205, 0.06307483556013205, 0.06376083556013205, 0.06444683556013206, 0.06513283556013207, 0.06609323556013207, 0.06705363556013207, 0.06839819556013206, 0.07028057956013206, 0.07291591716013206, 0.07660538980013205, 0.08177065149613205, 0.08900201787053205, 0.09912593079469205 ], "xaxis": "x", "y": [ 0, 1, 1.7835, 2.0932308695, 2.482409208117153, 2.9501418358031732, 3.4774111394252247, 3.8637668836799706, 4.148805619016248, 4.3601467336150606, 4.517420689789565, 4.634777586400988, 4.722525486352866, 4.788233472435736, 4.8374927156222505, 4.87445192506197, 4.902199907235407, 4.923042200949686, 4.938702994748857, 4.950473573099098, 4.962861449089358, 4.970946145322054, 4.976223730168365, 4.981047683237608, 4.983527939117402, 4.985313539607909, 4.986113464023186, 4.986167264557705, 4.98614220400561, 4.98614220400561, 5.886107726037747, 6.748167198739512, 7.905280485220206, 8.997224704570774, 10.029389295557671, 11.006581657390779, 11.933104035140278, 12.812818484244918, 13.64920202301987, 14.763870321873059, 15.805679321140934, 16.781593108690828, 17.697709347808406, 18.559390690185722, 19.696165743474474, 20.744265676925064, 21.713749505021415, 22.613197733856644, 23.449976083909984, 24.542631766287577, 25.5363963393283, 26.4442025776043, 27.27680147412732, 28.349769134058626, 29.308810427812894, 30.17126241928315, 31.263003560201692, 32.21632761719347, 33.05612371566692, 34.0997634808336, 34.98963015978033, 35.757449679516604, 36.69435758235011, 37.47461261692914, 38.3981664839776, 39.138171075845975, 39.986083357317895, 40.89869158375585, 41.54842026654333, 42.22479645788316, 42.867384988430075, 43.25447398439994, 43.60306896041299, 43.791808648854904, 43.942762218718556, 44.032837510820805, 44.06095347752391, 44.06095347752391, 45.44226368944065, 45.941288324027056, 46.548255256584746, 47.247177768289866, 47.77957382792254, 48.35453420724861, 48.75246597870775, 49.03212502960904, 49.230744101952595, 49.37284973733545, 49.51593465517331, 49.603398685283146, 49.67868271977895, 49.72761294521942, 49.744990797445915, 49.74396780424438, 49.74462360740287, 49.743667754115535, 49.74615353823248 ], "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 concentrations (reaction A + 2 B <-> Y)" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 0.09912593079469205 ], "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=['red', 'darkorange', 'green'],\n", " title=\"Changes in concentrations (reaction A + 2 B <-> Y)\")" ] }, { "cell_type": "code", "execution_count": 21, "id": "8c65570a-4ddc-4c28-9970-1244e23faeb6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SYSTEM TIMEABYcaption
00.0000005.000000100.0000000.000000Initial state
10.0002504.00000098.0000001.000000
20.0005003.21650096.4330001.783500
30.0006252.90676995.8135382.093231
40.0008002.51759195.0351822.482409
..................
920.07291624.3159630.51001849.744991
930.07660524.3169860.51206449.743968
940.08177124.3163300.51075349.744624
950.08900224.3172860.51266449.743668
960.09912624.3148000.50769349.746154
\n", "

97 rows × 5 columns

\n", "
" ], "text/plain": [ " SYSTEM TIME A B Y caption\n", "0 0.000000 5.000000 100.000000 0.000000 Initial state\n", "1 0.000250 4.000000 98.000000 1.000000 \n", "2 0.000500 3.216500 96.433000 1.783500 \n", "3 0.000625 2.906769 95.813538 2.093231 \n", "4 0.000800 2.517591 95.035182 2.482409 \n", ".. ... ... ... ... ...\n", "92 0.072916 24.315963 0.510018 49.744991 \n", "93 0.076605 24.316986 0.512064 49.743968 \n", "94 0.081771 24.316330 0.510753 49.744624 \n", "95 0.089002 24.317286 0.512664 49.743668 \n", "96 0.099126 24.314800 0.507693 49.746154 \n", "\n", "[97 rows x 5 columns]" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.get_history()" ] }, { "cell_type": "code", "execution_count": 22, "id": "88f744d6-17fb-4d03-b8cc-bb22b12555e0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: A + 2 B <-> Y\n", "Final concentrations: [Y] = 49.75 ; [A] = 24.31 ; [B] = 0.5077\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 4.02984\n", " Formula used: [Y] / ([A][B])\n", "2. Ratio of forward/reverse reaction rates: 4.0\n", "Discrepancy between the two values: 0.746 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Verify that the reaction has reached equilibrium\n", "dynamics.is_in_equilibrium()" ] }, { "cell_type": "markdown", "id": "81a8be4a-f374-494e-b647-184e35707295", "metadata": {}, "source": [ "**A**, again the scarse limiting reagent, stops the reaction yet again" ] }, { "cell_type": "code", "execution_count": null, "id": "162ae075-48c4-4d55-ba15-1f19e3b75b9b", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "d40258c5-5520-44a2-8dca-c28864386742", "metadata": {}, "source": [ "# 4. A can down-regulate B, but it cannot bring it up to any significant amount\n", "#### Even if A is completely taken out (i.e., [A] set to 0), [B] can only slightly increase, from the reverse reaction (\"Le Chatelier's principle\".) \n", "Let's try it:" ] }, { "cell_type": "code", "execution_count": 23, "id": "84e83a01-76b1-4a6c-92e3-3f540cb47b1e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0.099125931:\n", "3 species:\n", " Species 0 (A). Conc: 0.0\n", " Species 1 (B). Conc: 0.5076929235350717\n", " Species 2 (Y). Conc: 49.74615353823248\n", "Set of chemicals involved in reactions: {'B', 'A', 'Y'}\n" ] } ], "source": [ "dynamics.set_single_conc(species_name=\"A\", conc=0., snapshot=True) # Completely eliminate A\n", "dynamics.describe_state()" ] }, { "cell_type": "code", "execution_count": 24, "id": "31f1e4d5-8027-41de-90cc-f0492c88a9d9", "metadata": { "lines_to_next_cell": 2 }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "19 total step(s) taken\n" ] } ], "source": [ "dynamics.single_compartment_react(initial_step=0.001, target_end_time=0.16,\n", " variable_steps=True, explain_variable_steps=False)" ] }, { "cell_type": "code", "execution_count": 25, "id": "665dfff9-e943-44e1-b76d-af363d94c9f8", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Chemical=A
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "A", "line": { "color": "red", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "A", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205, 0.05962283556013205, 0.06012283556013205, 0.06037283556013205, 0.060722835560132055, 0.06121283556013205, 0.06170283556013205, 0.06238883556013205, 0.06307483556013205, 0.06376083556013205, 0.06444683556013206, 0.06513283556013207, 0.06609323556013207, 0.06705363556013207, 0.06839819556013206, 0.07028057956013206, 0.07291591716013206, 0.07660538980013205, 0.08177065149613205, 0.08900201787053205, 0.09912593079469205, 0.09912593079469205, 0.10012593079469205, 0.10112593079469205, 0.10162593079469205, 0.10212593079469205, 0.10282593079469206, 0.10352593079469206, 0.10450593079469206, 0.10548593079469205, 0.10685793079469205, 0.10822993079469205, 0.11015073079469205, 0.11283985079469205, 0.11552897079469206, 0.11929373879469206, 0.12456441399469206, 0.13194335927469206, 0.14227388266669205, 0.15673661541549205, 0.17698444126381205 ], "xaxis": "x", "y": [ 5, 4, 3.2165, 2.9067691305, 2.517590791882847, 2.0498581641968268, 1.5225888605747753, 1.1362331163200294, 0.851194380983752, 0.6398532663849396, 0.4825793102104357, 0.36522241359901236, 0.2774745136471351, 0.21176652756426492, 0.1625072843777499, 0.12554807493803027, 0.09780009276459273, 0.07695779905031393, 0.06129700525114322, 0.04952642690090266, 0.03713855091064221, 0.029053854677946724, 0.02377626983163505, 0.018952316762392143, 0.016472060882598158, 0.014686460392091347, 0.013886535976814492, 0.013832735442295341, 0.01385779599439035, 40, 39.10003447796786, 38.237975005266094, 37.0808617187854, 35.988917499434834, 34.95675290844794, 33.979560546614834, 33.053038168865335, 32.173323719760695, 31.336940180985742, 30.222271882132553, 29.180462882864678, 28.204549095314782, 27.288432856197204, 26.426751513819887, 25.289976460531136, 24.241876527080546, 23.272392698984195, 22.372944470148965, 21.536166120095626, 20.443510437718032, 19.44974586467731, 18.54193962640131, 17.70934072987829, 16.636373069946984, 15.677331776192714, 14.81487978472246, 13.723138643803917, 12.769814586812139, 11.930018488338689, 10.886378723172008, 9.996512044225279, 9.228692524489007, 8.291784621655506, 7.511529587076473, 6.587975720028021, 5.847971128159644, 5.000058846687724, 4.087450620249769, 3.4377219374622863, 2.761345746122461, 2.118757215575542, 1.7316682196056807, 1.383073243592625, 1.19433355515071, 1.0433799852870576, 0.9533046931848093, 0.9251887264817047, 30, 28.618689788083255, 28.11966515349685, 27.51269822093916, 26.81377570923404, 26.281379649601366, 25.706419270275298, 25.308487498816163, 25.028828447914865, 24.830209375571307, 24.688103740188456, 24.545018822350595, 24.457554792240757, 24.382270757744955, 24.333340532304486, 24.315962680077988, 24.31698567327952, 24.316329870121027, 24.317285723408364, 24.31479993929142, 0, 0.09949230707646496, 0.19822315771010743, 0.24705420275080847, 0.2955633051716507, 0.36297541539190237, 0.4296042835805298, 0.521660862512264, 0.6117974956242754, 0.7349964156326825, 0.8535284056323934, 1.0123064122883219, 1.2192609247384332, 1.402971246901739, 1.6269556781198062, 1.8761462874285597, 2.1108053562236364, 2.2699943910945506, 2.3175282595733697, 2.3075969689698006 ], "yaxis": "y" }, { "hovertemplate": "Chemical=B
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "B", "line": { "color": "darkorange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "B", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205, 0.05962283556013205, 0.06012283556013205, 0.06037283556013205, 0.060722835560132055, 0.06121283556013205, 0.06170283556013205, 0.06238883556013205, 0.06307483556013205, 0.06376083556013205, 0.06444683556013206, 0.06513283556013207, 0.06609323556013207, 0.06705363556013207, 0.06839819556013206, 0.07028057956013206, 0.07291591716013206, 0.07660538980013205, 0.08177065149613205, 0.08900201787053205, 0.09912593079469205, 0.09912593079469205, 0.10012593079469205, 0.10112593079469205, 0.10162593079469205, 0.10212593079469205, 0.10282593079469206, 0.10352593079469206, 0.10450593079469206, 0.10548593079469205, 0.10685793079469205, 0.10822993079469205, 0.11015073079469205, 0.11283985079469205, 0.11552897079469206, 0.11929373879469206, 0.12456441399469206, 0.13194335927469206, 0.14227388266669205, 0.15673661541549205, 0.17698444126381205 ], "xaxis": "x", "y": [ 100, 98, 96.433, 95.813538261, 95.0351815837657, 94.09971632839367, 93.04517772114957, 92.27246623264008, 91.70238876196753, 91.27970653276991, 90.9651586204209, 90.73044482719804, 90.55494902729428, 90.42353305512854, 90.32501456875552, 90.25109614987608, 90.1956001855292, 90.15391559810064, 90.1225940105023, 90.09905285380182, 90.0742771018213, 90.05810770935591, 90.04755253966329, 90.0379046335248, 90.03294412176521, 90.0293729207842, 90.02777307195365, 90.02766547088461, 90.02771559198881, 90.02771559198881, 88.22778454792453, 86.503665602521, 84.18943902955961, 82.00555059085848, 79.94122140888469, 77.98683668521848, 76.13379192971948, 74.3743630315102, 72.7015959539603, 70.47225935625391, 68.38864135771817, 66.43681378261839, 64.60458130438323, 62.8812186196286, 60.607668513051095, 58.511468646149915, 56.57250098995721, 54.773604532286754, 53.100047832180074, 50.91473646742489, 48.927207321343445, 47.11159484479144, 45.4463970517454, 43.30046173188279, 41.382379144374255, 39.657475161433744, 37.47399287959666, 35.5673447656131, 33.8877525686662, 31.80047303833284, 30.02073968043938, 28.485100640966838, 26.611284835299834, 25.05077476614177, 23.203667032044866, 21.72365784830811, 20.02783328536427, 18.202616832488363, 16.903159466913397, 15.550407084233747, 14.265230023139909, 13.491052031200185, 12.793862079174074, 12.416382702290244, 12.114475562562939, 11.934324978358443, 11.878093044952234, 11.878093044952234, 9.115472621118746, 8.117423351945932, 6.903489486830555, 5.505644463420315, 4.4408523441549645, 3.2909315855028267, 2.4950680425845557, 1.9357499407819603, 1.5385117960948453, 1.2543005253291408, 0.9681306896534161, 0.7932026294337404, 0.6426345604421384, 0.5447741095611982, 0.5100184051082033, 0.5120643915112745, 0.5107527851942871, 0.5126644917689619, 0.5076929235350717, 0.5076929235350717, 0.7066775376880016, 0.9041392389552865, 1.0018013290366885, 1.098819533878373, 1.2336437543188765, 1.3669014906961314, 1.5510146485595997, 1.7312879147836227, 1.9776857548004367, 2.2147497347998586, 2.5323057481117153, 2.946214773011938, 3.3136354173385496, 3.761604279774684, 4.259985498392191, 4.729303635982344, 5.047681705724172, 5.142749442681811, 5.122886861474672 ], "yaxis": "y" }, { "hovertemplate": "Chemical=Y
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "Y", "line": { "color": "green", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "Y", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.00025, 0.0005, 0.000625, 0.0008, 0.001045, 0.001388, 0.001731, 0.002074, 0.002417, 0.00276, 0.003103, 0.003446, 0.003789, 0.004132, 0.004475, 0.004817999999999999, 0.005160999999999999, 0.0055039999999999985, 0.005846999999999998, 0.006327199999999998, 0.006807399999999998, 0.007287599999999998, 0.007959879999999999, 0.00863216, 0.009573352, 0.0108910208, 0.01273575712, 0.015318387967999999, 0.015318387967999999, 0.015349637967999999, 0.015380887967999999, 0.015424637968, 0.015468387968, 0.015512137968, 0.015555887968, 0.015599637968000001, 0.015643387968, 0.015687137968, 0.015748387968, 0.015809637967999998, 0.015870887967999996, 0.015932137967999995, 0.015993387967999994, 0.016079137967999993, 0.016164887967999992, 0.01625063796799999, 0.01633638796799999, 0.01642213796799999, 0.01654218796799999, 0.01666223796799999, 0.01678228796799999, 0.01690233796799999, 0.01707040796799999, 0.017238477967999988, 0.017406547967999987, 0.017641845967999985, 0.017877143967999984, 0.018112441967999982, 0.018441859167999983, 0.018771276367999985, 0.019100693567999986, 0.019561877647999985, 0.020023061727999985, 0.020668719439999986, 0.021314377151999988, 0.022218297948799988, 0.023483787064319986, 0.024749276179839984, 0.026520960941567983, 0.029001319607987183, 0.03148167827440638, 0.03495418040739326, 0.03842668254038014, 0.04328818552656177, 0.05009428970721606, 0.05962283556013205, 0.05962283556013205, 0.06012283556013205, 0.06037283556013205, 0.060722835560132055, 0.06121283556013205, 0.06170283556013205, 0.06238883556013205, 0.06307483556013205, 0.06376083556013205, 0.06444683556013206, 0.06513283556013207, 0.06609323556013207, 0.06705363556013207, 0.06839819556013206, 0.07028057956013206, 0.07291591716013206, 0.07660538980013205, 0.08177065149613205, 0.08900201787053205, 0.09912593079469205, 0.09912593079469205, 0.10012593079469205, 0.10112593079469205, 0.10162593079469205, 0.10212593079469205, 0.10282593079469206, 0.10352593079469206, 0.10450593079469206, 0.10548593079469205, 0.10685793079469205, 0.10822993079469205, 0.11015073079469205, 0.11283985079469205, 0.11552897079469206, 0.11929373879469206, 0.12456441399469206, 0.13194335927469206, 0.14227388266669205, 0.15673661541549205, 0.17698444126381205 ], "xaxis": "x", "y": [ 0, 1, 1.7835, 2.0932308695, 2.482409208117153, 2.9501418358031732, 3.4774111394252247, 3.8637668836799706, 4.148805619016248, 4.3601467336150606, 4.517420689789565, 4.634777586400988, 4.722525486352866, 4.788233472435736, 4.8374927156222505, 4.87445192506197, 4.902199907235407, 4.923042200949686, 4.938702994748857, 4.950473573099098, 4.962861449089358, 4.970946145322054, 4.976223730168365, 4.981047683237608, 4.983527939117402, 4.985313539607909, 4.986113464023186, 4.986167264557705, 4.98614220400561, 4.98614220400561, 5.886107726037747, 6.748167198739512, 7.905280485220206, 8.997224704570774, 10.029389295557671, 11.006581657390779, 11.933104035140278, 12.812818484244918, 13.64920202301987, 14.763870321873059, 15.805679321140934, 16.781593108690828, 17.697709347808406, 18.559390690185722, 19.696165743474474, 20.744265676925064, 21.713749505021415, 22.613197733856644, 23.449976083909984, 24.542631766287577, 25.5363963393283, 26.4442025776043, 27.27680147412732, 28.349769134058626, 29.308810427812894, 30.17126241928315, 31.263003560201692, 32.21632761719347, 33.05612371566692, 34.0997634808336, 34.98963015978033, 35.757449679516604, 36.69435758235011, 37.47461261692914, 38.3981664839776, 39.138171075845975, 39.986083357317895, 40.89869158375585, 41.54842026654333, 42.22479645788316, 42.867384988430075, 43.25447398439994, 43.60306896041299, 43.791808648854904, 43.942762218718556, 44.032837510820805, 44.06095347752391, 44.06095347752391, 45.44226368944065, 45.941288324027056, 46.548255256584746, 47.247177768289866, 47.77957382792254, 48.35453420724861, 48.75246597870775, 49.03212502960904, 49.230744101952595, 49.37284973733545, 49.51593465517331, 49.603398685283146, 49.67868271977895, 49.72761294521942, 49.744990797445915, 49.74396780424438, 49.74462360740287, 49.743667754115535, 49.74615353823248, 49.74615353823248, 49.64666123115601, 49.54793038052237, 49.49909933548167, 49.45059023306082, 49.38317812284057, 49.31654925465194, 49.22449267572021, 49.134356042608196, 49.01115712259979, 48.89262513260008, 48.73384712594415, 48.52689261349404, 48.343182291330734, 48.11919786011267, 47.870007250803916, 47.63534818200884, 47.47615914713793, 47.428625278659105, 47.43855656926267 ], "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 concentrations (reaction A + 2 B <-> Y)" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 0.17698444126381205 ], "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=['red', 'darkorange', 'green'],\n", " title=\"Changes in concentrations (reaction A + 2 B <-> Y)\")" ] }, { "cell_type": "code", "execution_count": 26, "id": "22a64e69-703f-4b1b-9808-3c3d5e0218ae", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SYSTEM TIMEABYcaption
00.0000005.000000100.0000000.000000Initial state
10.0002504.00000098.0000001.000000
20.0005003.21650096.4330001.783500
30.0006252.90676995.8135382.093231
40.0008002.51759195.0351822.482409
..................
1120.1245641.8761464.25998547.870007
1130.1319432.1108054.72930447.635348
1140.1422742.2699945.04768247.476159
1150.1567372.3175285.14274947.428625
1160.1769842.3075975.12288747.438557
\n", "

117 rows × 5 columns

\n", "
" ], "text/plain": [ " SYSTEM TIME A B Y caption\n", "0 0.000000 5.000000 100.000000 0.000000 Initial state\n", "1 0.000250 4.000000 98.000000 1.000000 \n", "2 0.000500 3.216500 96.433000 1.783500 \n", "3 0.000625 2.906769 95.813538 2.093231 \n", "4 0.000800 2.517591 95.035182 2.482409 \n", ".. ... ... ... ... ...\n", "112 0.124564 1.876146 4.259985 47.870007 \n", "113 0.131943 2.110805 4.729304 47.635348 \n", "114 0.142274 2.269994 5.047682 47.476159 \n", "115 0.156737 2.317528 5.142749 47.428625 \n", "116 0.176984 2.307597 5.122887 47.438557 \n", "\n", "[117 rows x 5 columns]" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dynamics.get_history()" ] }, { "cell_type": "code", "execution_count": 27, "id": "c3afbcc8-bdae-4938-a3f1-ce00d62816f2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: A + 2 B <-> Y\n", "Final concentrations: [Y] = 47.44 ; [A] = 2.308 ; [B] = 5.123\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 4.01289\n", " Formula used: [Y] / ([A][B])\n", "2. Ratio of forward/reverse reaction rates: 4.0\n", "Discrepancy between the two values: 0.3221 %\n", "Reaction IS in equilibrium (within 1% tolerance)\n", "\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Verify that the reaction has reached equilibrium\n", "dynamics.is_in_equilibrium()" ] }, { "cell_type": "markdown", "id": "92c82a23-3c8e-4cff-9efc-7cd708f0f9ad", "metadata": {}, "source": [ "#### As expected, even the complete withdrawal of A (red), brings about only a modest increase of B's concentration, from the reverse reaction (i.e. [B] slightly increases at the expense of [Y].) \n", "#### The change is modest because our reaction A + 2 B <-> Y is mostly in the forward direction (K = 4)\n", "*Le Chatelier's principle* in action: \"A change in one of the variables that describe a system at equilibrium produces a shift in the position of the equilibrium that counteracts the effect of this change.\"" ] }, { "cell_type": "code", "execution_count": null, "id": "48a86d59", "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 }