{
"cells": [
{
"cell_type": "markdown",
"id": "c3b90917-d8b3-4644-a485-b22d440272b9",
"metadata": {},
"source": [
"## One-bin Association/Dissociation reaction `A + B <-> C`\n",
"### with 1st-order kinetics for each species, taken to equilibrium\n",
"\n",
"Diffusion not applicable (just 1 bin)\n",
"\n",
"See also the experiment _\"reactions_single_compartment/react_3\"_ \n",
"\n",
"LAST REVISED: May 6, 2024"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "a8f89c58-e3b5-4a07-96ec-6f7455db1bf5",
"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": "f5117d69",
"metadata": {},
"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.life_1D.bio_sim_1d import BioSim1D\n",
"\n",
"import plotly.express as px\n",
"from src.modules.visualization.graphic_log import GraphicLog"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ada82175-1d15-4213-b834-5a5d8e2dd31e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-> Output will be LOGGED into the file 'reaction_4.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_2\"],\n",
" extra_js=\"https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.21.2/cytoscape.umd.js\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "d8f2d83d-97bc-4f57-8f71-c0923f0334ed",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of reactions: 1 (at temp. 25 C)\n",
"0: A + B <-> C (kF = 5 / kR = 2 / delta_G = -2,271.4 / K = 2.5) | 1st order in all reactants & products\n",
"Set of chemicals involved in the above reactions: {'C', 'A', 'B'}\n"
]
}
],
"source": [
"# Specify the chemicals\n",
"chem_data = chem(names=[\"A\", \"B\", \"C\"]) # NOTE: Diffusion not applicable (using just 1 bin)\n",
"\n",
"\n",
"# Reaction A + B <-> C , with 1st-order kinetics for each species\n",
"chem_data.add_reaction(reactants=[\"A\" , \"B\"], products=[\"C\"],\n",
" forward_rate=5., reverse_rate=2.)\n",
"\n",
"chem_data.describe_reactions()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b351573c-275c-434f-8301-4ed54197e0cc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 0:\n",
"1 bins and 3 species:\n",
" Species 0 (A). Diff rate: None. Conc: [10.]\n",
" Species 1 (B). Diff rate: None. Conc: [50.]\n",
" Species 2 (C). Diff rate: None. Conc: [20.]\n"
]
}
],
"source": [
"# Initialize the system\n",
"bio = BioSim1D(n_bins=1, chem_data=chem_data)\n",
"\n",
"bio.set_uniform_concentration(species_index=0, conc=10.)\n",
"bio.set_uniform_concentration(species_index=1, conc=50.)\n",
"bio.set_uniform_concentration(species_index=2, conc=20.)\n",
"\n",
"bio.describe_state()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "fdb1f449-8415-4fdf-b4a3-24220866c96c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" SYSTEM TIME | \n",
" A | \n",
" B | \n",
" C | \n",
" caption | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0 | \n",
" 10.0 | \n",
" 50.0 | \n",
" 20.0 | \n",
" Initial state | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" SYSTEM TIME A B C caption\n",
"0 0 10.0 50.0 20.0 Initial state"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Save the state of the concentrations of all species at bin 0\n",
"bio.add_snapshot(bio.bin_snapshot(bin_address = 0), caption=\"Initial state\")\n",
"bio.get_history()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "25f70c0f-621e-413f-bc93-336d38d462d7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[GRAPHIC ELEMENT SENT TO LOG FILE `reaction_4.log.htm`]\n"
]
}
],
"source": [
"# Send the plot to the HTML log file\n",
"chem_data.plot_reaction_network(\"vue_cytoscape_2\")"
]
},
{
"cell_type": "markdown",
"id": "356e4db3-02a6-40bd-a951-841bfc6c5522",
"metadata": {
"tags": []
},
"source": [
"### First step"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "b8c0d439-13f7-459c-88e2-0ae357b46c18",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 0.002:\n",
"1 bins and 3 species:\n",
" Species 0 (A). Diff rate: None. Conc: [5.08]\n",
" Species 1 (B). Diff rate: None. Conc: [45.08]\n",
" Species 2 (C). Diff rate: None. Conc: [24.92]\n"
]
}
],
"source": [
"# First step\n",
"bio.react(time_step=0.002, n_steps=1)\n",
"bio.describe_state()"
]
},
{
"cell_type": "markdown",
"id": "4c074e7c-0308-4085-a2f9-2da055ffcef8",
"metadata": {},
"source": [
"_Early in the reaction :_\n",
"[A] = 5.08 , [B] = 45.08 , [C] = [24.92]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "386d8052-2d92-43b0-b817-ab4a1cce3ba0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" SYSTEM TIME | \n",
" A | \n",
" B | \n",
" C | \n",
" caption | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0.000 | \n",
" 10.00 | \n",
" 50.00 | \n",
" 20.00 | \n",
" Initial state | \n",
"
\n",
" \n",
" | 1 | \n",
" 0.002 | \n",
" 5.08 | \n",
" 45.08 | \n",
" 24.92 | \n",
" | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" SYSTEM TIME A B C caption\n",
"0 0.000 10.00 50.00 20.00 Initial state\n",
"1 0.002 5.08 45.08 24.92 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Save the state of the concentrations of all species at bin 0\n",
"bio.add_snapshot(bio.bin_snapshot(bin_address = 0))\n",
"bio.get_history()"
]
},
{
"cell_type": "markdown",
"id": "88ec4bcc-48dc-45eb-84fc-8e6e0b259612",
"metadata": {},
"source": [
"### Numerous more steps"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "8efdf9ef-bdca-48ff-b139-6e2d9952c1d8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 0.06:\n",
"1 bins and 3 species:\n",
" Species 0 (A). Diff rate: None. Conc: [0.29487831]\n",
" Species 1 (B). Diff rate: None. Conc: [40.29487831]\n",
" Species 2 (C). Diff rate: None. Conc: [29.70512169]\n"
]
}
],
"source": [
"# Numerous more steps\n",
"bio.react(time_step=0.002, n_steps=29, snapshots={\"sample_bin\": 0})\n",
"\n",
"bio.describe_state()"
]
},
{
"cell_type": "markdown",
"id": "6b0be45c-ff0e-43d8-847a-b6e8d0e6e0ec",
"metadata": {
"tags": []
},
"source": [
"### Equilibrium"
]
},
{
"cell_type": "markdown",
"id": "7f687d0d-75ab-4e29-8070-5b6f1fc80b4b",
"metadata": {},
"source": [
"Consistent with the 5/2 ratio of forward/reverse rates (and the 1st order reactions),\n",
"the systems settles in the following equilibrium: \n",
"[A] = 0.29487831 , [B] = 40.29487831 , [C] = 29.70512169"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "46a3ea5d-6516-4582-9958-6a80403e8f19",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A + B <-> C\n",
"Final concentrations: [A] = 0.2949 ; [B] = 40.29 ; [C] = 29.71\n",
"1. Ratio of reactant/product concentrations, adjusted for reaction orders: 2.49999\n",
" Formula used: [C] / ([A][B])\n",
"2. Ratio of forward/reverse reaction rates: 2.5\n",
"Discrepancy between the two values: 0.0003107 %\n",
"Reaction IS in equilibrium (within 1% tolerance)\n",
"\n"
]
},
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Verify that the reaction has reached equilibrium\n",
"bio.reaction_dynamics.is_in_equilibrium(rxn_index=0, conc=bio.bin_snapshot(bin_address = 0))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "6975a1e8-d708-401f-ab7f-78c183f765bf",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" SYSTEM TIME | \n",
" A | \n",
" B | \n",
" C | \n",
" caption | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0.000 | \n",
" 10.000000 | \n",
" 50.000000 | \n",
" 20.000000 | \n",
" Initial state | \n",
"
\n",
" \n",
" | 1 | \n",
" 0.002 | \n",
" 5.080000 | \n",
" 45.080000 | \n",
" 24.920000 | \n",
" | \n",
"
\n",
" \n",
" | 2 | \n",
" 0.004 | \n",
" 2.889616 | \n",
" 42.889616 | \n",
" 27.110384 | \n",
" | \n",
"
\n",
" \n",
" | 3 | \n",
" 0.006 | \n",
" 1.758712 | \n",
" 41.758712 | \n",
" 28.241288 | \n",
" | \n",
"
\n",
" \n",
" | 4 | \n",
" 0.008 | \n",
" 1.137262 | \n",
" 41.137262 | \n",
" 28.862738 | \n",
" | \n",
"
\n",
" \n",
" | 5 | \n",
" 0.010 | \n",
" 0.784874 | \n",
" 40.784874 | \n",
" 29.215126 | \n",
" | \n",
"
\n",
" \n",
" | 6 | \n",
" 0.012 | \n",
" 0.581625 | \n",
" 40.581625 | \n",
" 29.418375 | \n",
" | \n",
"
\n",
" \n",
" | 7 | \n",
" 0.014 | \n",
" 0.463266 | \n",
" 40.463266 | \n",
" 29.536734 | \n",
" | \n",
"
\n",
" \n",
" | 8 | \n",
" 0.016 | \n",
" 0.393960 | \n",
" 40.393960 | \n",
" 29.606040 | \n",
" | \n",
"
\n",
" \n",
" | 9 | \n",
" 0.018 | \n",
" 0.353248 | \n",
" 40.353248 | \n",
" 29.646752 | \n",
" | \n",
"
\n",
" \n",
" | 10 | \n",
" 0.020 | \n",
" 0.329288 | \n",
" 40.329288 | \n",
" 29.670712 | \n",
" | \n",
"
\n",
" \n",
" | 11 | \n",
" 0.022 | \n",
" 0.315171 | \n",
" 40.315171 | \n",
" 29.684829 | \n",
" | \n",
"
\n",
" \n",
" | 12 | \n",
" 0.024 | \n",
" 0.306849 | \n",
" 40.306849 | \n",
" 29.693151 | \n",
" | \n",
"
\n",
" \n",
" | 13 | \n",
" 0.026 | \n",
" 0.301940 | \n",
" 40.301940 | \n",
" 29.698060 | \n",
" | \n",
"
\n",
" \n",
" | 14 | \n",
" 0.028 | \n",
" 0.299045 | \n",
" 40.299045 | \n",
" 29.700955 | \n",
" | \n",
"
\n",
" \n",
" | 15 | \n",
" 0.030 | \n",
" 0.297336 | \n",
" 40.297336 | \n",
" 29.702664 | \n",
" | \n",
"
\n",
" \n",
" | 16 | \n",
" 0.032 | \n",
" 0.296328 | \n",
" 40.296328 | \n",
" 29.703672 | \n",
" | \n",
"
\n",
" \n",
" | 17 | \n",
" 0.034 | \n",
" 0.295734 | \n",
" 40.295734 | \n",
" 29.704266 | \n",
" | \n",
"
\n",
" \n",
" | 18 | \n",
" 0.036 | \n",
" 0.295383 | \n",
" 40.295383 | \n",
" 29.704617 | \n",
" | \n",
"
\n",
" \n",
" | 19 | \n",
" 0.038 | \n",
" 0.295176 | \n",
" 40.295176 | \n",
" 29.704824 | \n",
" | \n",
"
\n",
" \n",
" | 20 | \n",
" 0.040 | \n",
" 0.295053 | \n",
" 40.295053 | \n",
" 29.704947 | \n",
" | \n",
"
\n",
" \n",
" | 21 | \n",
" 0.042 | \n",
" 0.294981 | \n",
" 40.294981 | \n",
" 29.705019 | \n",
" | \n",
"
\n",
" \n",
" | 22 | \n",
" 0.044 | \n",
" 0.294939 | \n",
" 40.294939 | \n",
" 29.705061 | \n",
" | \n",
"
\n",
" \n",
" | 23 | \n",
" 0.046 | \n",
" 0.294914 | \n",
" 40.294914 | \n",
" 29.705086 | \n",
" | \n",
"
\n",
" \n",
" | 24 | \n",
" 0.048 | \n",
" 0.294899 | \n",
" 40.294899 | \n",
" 29.705101 | \n",
" | \n",
"
\n",
" \n",
" | 25 | \n",
" 0.050 | \n",
" 0.294890 | \n",
" 40.294890 | \n",
" 29.705110 | \n",
" | \n",
"
\n",
" \n",
" | 26 | \n",
" 0.052 | \n",
" 0.294885 | \n",
" 40.294885 | \n",
" 29.705115 | \n",
" | \n",
"
\n",
" \n",
" | 27 | \n",
" 0.054 | \n",
" 0.294882 | \n",
" 40.294882 | \n",
" 29.705118 | \n",
" | \n",
"
\n",
" \n",
" | 28 | \n",
" 0.056 | \n",
" 0.294880 | \n",
" 40.294880 | \n",
" 29.705120 | \n",
" | \n",
"
\n",
" \n",
" | 29 | \n",
" 0.058 | \n",
" 0.294879 | \n",
" 40.294879 | \n",
" 29.705121 | \n",
" | \n",
"
\n",
" \n",
" | 30 | \n",
" 0.060 | \n",
" 0.294878 | \n",
" 40.294878 | \n",
" 29.705122 | \n",
" | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" SYSTEM TIME A B C caption\n",
"0 0.000 10.000000 50.000000 20.000000 Initial state\n",
"1 0.002 5.080000 45.080000 24.920000 \n",
"2 0.004 2.889616 42.889616 27.110384 \n",
"3 0.006 1.758712 41.758712 28.241288 \n",
"4 0.008 1.137262 41.137262 28.862738 \n",
"5 0.010 0.784874 40.784874 29.215126 \n",
"6 0.012 0.581625 40.581625 29.418375 \n",
"7 0.014 0.463266 40.463266 29.536734 \n",
"8 0.016 0.393960 40.393960 29.606040 \n",
"9 0.018 0.353248 40.353248 29.646752 \n",
"10 0.020 0.329288 40.329288 29.670712 \n",
"11 0.022 0.315171 40.315171 29.684829 \n",
"12 0.024 0.306849 40.306849 29.693151 \n",
"13 0.026 0.301940 40.301940 29.698060 \n",
"14 0.028 0.299045 40.299045 29.700955 \n",
"15 0.030 0.297336 40.297336 29.702664 \n",
"16 0.032 0.296328 40.296328 29.703672 \n",
"17 0.034 0.295734 40.295734 29.704266 \n",
"18 0.036 0.295383 40.295383 29.704617 \n",
"19 0.038 0.295176 40.295176 29.704824 \n",
"20 0.040 0.295053 40.295053 29.704947 \n",
"21 0.042 0.294981 40.294981 29.705019 \n",
"22 0.044 0.294939 40.294939 29.705061 \n",
"23 0.046 0.294914 40.294914 29.705086 \n",
"24 0.048 0.294899 40.294899 29.705101 \n",
"25 0.050 0.294890 40.294890 29.705110 \n",
"26 0.052 0.294885 40.294885 29.705115 \n",
"27 0.054 0.294882 40.294882 29.705118 \n",
"28 0.056 0.294880 40.294880 29.705120 \n",
"29 0.058 0.294879 40.294879 29.705121 \n",
"30 0.060 0.294878 40.294878 29.705122 "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Save the state of the concentrations of all species at bin 0\n",
"bio.get_history()"
]
},
{
"cell_type": "markdown",
"id": "8a4576cc-d927-4776-a691-2001bba5d1b7",
"metadata": {},
"source": [
"## Note: \"A\" (now largely depleted) is largely the limiting reagent"
]
},
{
"cell_type": "markdown",
"id": "d82cb7fe-0bd2-4b3e-bbec-6f5b70d0e5ae",
"metadata": {
"tags": []
},
"source": [
"## Plots of changes of concentration with time"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "14d83e31-e46e-46aa-ac3a-5e45f3475bf0",
"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.002,
0.004,
0.006,
0.008,
0.01,
0.012,
0.014,
0.016,
0.018000000000000002,
0.020000000000000004,
0.022000000000000006,
0.024000000000000007,
0.02600000000000001,
0.02800000000000001,
0.030000000000000013,
0.032000000000000015,
0.034000000000000016,
0.03600000000000002,
0.03800000000000002,
0.04000000000000002,
0.04200000000000002,
0.044000000000000025,
0.04600000000000003,
0.04800000000000003,
0.05000000000000003,
0.05200000000000003,
0.054000000000000034,
0.056000000000000036,
0.05800000000000004,
0.06000000000000004
],
"xaxis": "x",
"y": [
10,
5.08,
2.889616,
1.7587123297254401,
1.1372618579290796,
0.7848744219907284,
0.5816248769235214,
0.4632655516718558,
0.39396011908276785,
0.3532481852190526,
0.3292880755869499,
0.31517138668258465,
0.3068488164329863,
0.3019403326325966,
0.29904475860432483,
0.29733639845169046,
0.2963284041387654,
0.29573362363570993,
0.2953826559253961,
0.29517555379732074,
0.2950533439876077,
0.29498122825863154,
0.29493867279189473,
0.29491356077688685,
0.29489874213972356,
0.2948899976341194,
0.2948848374828887,
0.2948817924660286,
0.2948799955944733,
0.29487893525628817,
0.29487830954816896
],
"yaxis": "y"
},
{
"hovertemplate": "Chemical=B
SYSTEM TIME=%{x}
concentration=%{y}",
"legendgroup": "B",
"line": {
"color": "violet",
"dash": "solid"
},
"marker": {
"symbol": "circle"
},
"mode": "lines",
"name": "B",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
0,
0.002,
0.004,
0.006,
0.008,
0.01,
0.012,
0.014,
0.016,
0.018000000000000002,
0.020000000000000004,
0.022000000000000006,
0.024000000000000007,
0.02600000000000001,
0.02800000000000001,
0.030000000000000013,
0.032000000000000015,
0.034000000000000016,
0.03600000000000002,
0.03800000000000002,
0.04000000000000002,
0.04200000000000002,
0.044000000000000025,
0.04600000000000003,
0.04800000000000003,
0.05000000000000003,
0.05200000000000003,
0.054000000000000034,
0.056000000000000036,
0.05800000000000004,
0.06000000000000004
],
"xaxis": "x",
"y": [
50,
45.08,
42.889616,
41.758712329725434,
41.137261857929076,
40.78487442199072,
40.58162487692351,
40.463265551671846,
40.393960119082756,
40.35324818521904,
40.32928807558694,
40.31517138668257,
40.306848816432975,
40.30194033263258,
40.29904475860431,
40.29733639845168,
40.29632840413875,
40.29573362363569,
40.29538265592538,
40.29517555379731,
40.2950533439876,
40.29498122825862,
40.294938672791886,
40.29491356077688,
40.294898742139715,
40.29488999763411,
40.294884837482876,
40.294881792466015,
40.29487999559446,
40.29487893525627,
40.29487830954815
],
"yaxis": "y"
},
{
"hovertemplate": "Chemical=C
SYSTEM TIME=%{x}
concentration=%{y}",
"legendgroup": "C",
"line": {
"color": "green",
"dash": "solid"
},
"marker": {
"symbol": "circle"
},
"mode": "lines",
"name": "C",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
0,
0.002,
0.004,
0.006,
0.008,
0.01,
0.012,
0.014,
0.016,
0.018000000000000002,
0.020000000000000004,
0.022000000000000006,
0.024000000000000007,
0.02600000000000001,
0.02800000000000001,
0.030000000000000013,
0.032000000000000015,
0.034000000000000016,
0.03600000000000002,
0.03800000000000002,
0.04000000000000002,
0.04200000000000002,
0.044000000000000025,
0.04600000000000003,
0.04800000000000003,
0.05000000000000003,
0.05200000000000003,
0.054000000000000034,
0.056000000000000036,
0.05800000000000004,
0.06000000000000004
],
"xaxis": "x",
"y": [
20,
24.92,
27.110384000000003,
28.241287670274563,
28.862738142070924,
29.215125578009275,
29.418375123076483,
29.53673444832815,
29.606039880917237,
29.646751814780952,
29.670711924413055,
29.68482861331742,
29.693151183567018,
29.698059667367406,
29.70095524139568,
29.702663601548313,
29.703671595861238,
29.70426637636429,
29.704617344074606,
29.704824446202682,
29.704946656012396,
29.705018771741372,
29.70506132720811,
29.705086439223116,
29.705101257860278,
29.70511000236588,
29.70511516251711,
29.70511820753397,
29.705120004405526,
29.70512106474371,
29.70512169045183
],
"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": "Reaction A + B <-> C . Changes in concentrations with time"
},
"xaxis": {
"anchor": "y",
"autorange": true,
"domain": [
0,
1
],
"range": [
0,
0.06000000000000004
],
"title": {
"text": "SYSTEM TIME"
},
"type": "linear"
},
"yaxis": {
"anchor": "x",
"autorange": true,
"domain": [
0,
1
],
"range": [
-2.4665173399213773,
52.76139564946955
],
"title": {
"text": "concentration"
},
"type": "linear"
}
}
},
"text/html": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = px.line(data_frame=bio.get_history(), x=\"SYSTEM TIME\", y=[\"A\", \"B\", \"C\"], \n",
" title=\"Reaction A + B <-> C . Changes in concentrations with time\",\n",
" color_discrete_sequence = ['red', 'violet', 'green'],\n",
" labels={\"value\":\"concentration\", \"variable\":\"Chemical\"})\n",
"fig.show()"
]
},
{
"cell_type": "markdown",
"id": "ea1bbd14-90d4-480d-946c-f0ce30d61df1",
"metadata": {},
"source": [
"## For more in-depth analysis of this reaction, including variable time steps, see the experiment _\"reactions_single_compartment/react_3\"_ "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "57b81064",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"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
}