{ "cells": [ { "cell_type": "markdown", "id": "83d68c5f-79b2-4947-920f-9fd1fbdd392f", "metadata": {}, "source": [ "## One-bin `2A + 5B <-> 4C + 3D`, with 1st-order kinetics for each species, taken to equilibrium\n", "\n", "Diffusion not applicable (just 1 bin)\n", "\n", "LAST REVISED: May 6, 2024" ] }, { "cell_type": "code", "execution_count": 1, "id": "0500edb0-a509-453d-b3b4-8fbaae42925d", "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": "8565d1f8", "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.html_log.html_log import HtmlLog as log\n", "from src.modules.visualization.graphic_log import GraphicLog" ] }, { "cell_type": "code", "execution_count": 3, "id": "6635becc-7040-420b-b631-e89a23e80909", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-> Output will be LOGGED into the file 'reaction_6.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": "8acfd3e5-effa-4d10-b400-47777be200fc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0:\n", "1 bins and 4 species:\n", " Species 0 (A). Diff rate: None. Conc: [4.]\n", " Species 1 (B). Diff rate: None. Conc: [7.]\n", " Species 2 (C). Diff rate: None. Conc: [5.]\n", " Species 3 (D). Diff rate: None. Conc: [2.]\n" ] } ], "source": [ "# Initialize the system\n", "chem_data = chem(names=[\"A\", \"B\", \"C\", \"D\"]) # NOTE: Diffusion not applicable (just 1 bin)\n", "\n", "# Specify the reaction\n", "\n", "# Reaction 2A + 5B <-> 4C + 3D , with 1st-order kinetics for each species\n", "chem_data.add_reaction(reactants=[(2,\"A\",1) , (5,\"B\",1)], products=[(4,\"C\",1) , (3,\"D\",1)],\n", " forward_rate=5., reverse_rate=2.)\n", "\n", "bio = BioSim1D(n_bins=1, chem_data=chem_data)\n", "\n", "bio.set_all_uniform_concentrations( [4., 7., 5., 2.] )\n", "\n", "bio.describe_state()" ] }, { "cell_type": "code", "execution_count": 5, "id": "c9eaf7cf-04b7-49f7-ad99-e4b273a39574", "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", "
SYSTEM TIMEABCDcaption
004.07.05.02.0Initial state
\n", "
" ], "text/plain": [ " SYSTEM TIME A B C D caption\n", "0 0 4.0 7.0 5.0 2.0 Initial state" ] }, "execution_count": 5, "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": 6, "id": "5429cc81-fe31-4a1e-87c3-7c42dbd9e06e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of reactions: 1 (at temp. 25 C)\n", "0: 2 A + 5 B <-> 4 C + 3 D (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: {'D', 'C', 'A', 'B'}\n" ] } ], "source": [ "chem_data.describe_reactions()" ] }, { "cell_type": "code", "execution_count": 7, "id": "e95f3814-f76b-476a-963d-ae440e87b2e8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Reaction 2 A + 5 B 4 C + 3 D\n", "[GRAPHIC ELEMENT SENT TO LOG FILE `reaction_6.log.htm`]\n" ] } ], "source": [ "# Send a header and a plot to the HTML log file\n", "log.write(\"Reaction 2 A + 5 B <-> 4 C + 3 D\",\n", " style=log.h2)\n", "chem_data.plot_reaction_network(\"vue_cytoscape_2\")" ] }, { "cell_type": "markdown", "id": "a1bdfcec-2945-4ace-97c0-739e9716edb2", "metadata": { "tags": [] }, "source": [ "### First step" ] }, { "cell_type": "code", "execution_count": 8, "id": "177f241c-6ec9-4a3a-863e-685e031b4feb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0.001:\n", "1 bins and 4 species:\n", " Species 0 (A). Diff rate: None. Conc: [3.76]\n", " Species 1 (B). Diff rate: None. Conc: [6.4]\n", " Species 2 (C). Diff rate: None. Conc: [5.48]\n", " Species 3 (D). Diff rate: None. Conc: [2.36]\n" ] } ], "source": [ "# First step\n", "bio.react(time_step=0.001, n_steps=1)\n", "bio.describe_state()" ] }, { "cell_type": "markdown", "id": "bb01e107-69e1-4ffc-939f-ead43bc358a1", "metadata": {}, "source": [ "_Early in the reaction :_\n", "[A] = 3.76 , [B] = 6.4 , [C] = 5.48 , [D] = 2.36" ] }, { "cell_type": "code", "execution_count": 9, "id": "ffc297af-487e-4020-a406-959f0a6fab98", "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", "
SYSTEM TIMEABCDcaption
00.0004.007.05.002.00Initial state
10.0013.766.45.482.36
\n", "
" ], "text/plain": [ " SYSTEM TIME A B C D caption\n", "0 0.000 4.00 7.0 5.00 2.00 Initial state\n", "1 0.001 3.76 6.4 5.48 2.36 " ] }, "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": "265fcc89-7cfd-44c0-ac69-36846c3f93de", "metadata": {}, "source": [ "### Numerous more steps" ] }, { "cell_type": "code", "execution_count": 10, "id": "d547bdba-3819-40bb-b965-28d06516619c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0.041:\n", "1 bins and 4 species:\n", " Species 0 (A). Diff rate: None. Conc: [2.80284552]\n", " Species 1 (B). Diff rate: None. Conc: [4.00711381]\n", " Species 2 (C). Diff rate: None. Conc: [7.39430896]\n", " Species 3 (D). Diff rate: None. Conc: [3.79573172]\n" ] } ], "source": [ "# Numerous more steps\n", "bio.react(time_step=0.001, n_steps=40, snapshots={\"sample_bin\": 0})\n", "\n", "bio.describe_state()" ] }, { "cell_type": "markdown", "id": "e9db30bd-ed51-491b-b11f-651094524269", "metadata": { "tags": [] }, "source": [ "### Equilibrium" ] }, { "cell_type": "markdown", "id": "a7b6400e-696a-4b2f-98c6-a8dea6515160", "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] = 2.80284552 , [B] = 4.00711381 , [C] = 7.39430896 , [D] = 3.79573172" ] }, { "cell_type": "code", "execution_count": 11, "id": "f888886f-a56d-4f6b-9c28-5a58797b5924", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2 A + 5 B <-> 4 C + 3 D\n", "Final concentrations: [A] = 2.803 ; [B] = 4.007 ; [C] = 7.394 ; [D] = 3.796\n", "1. Ratio of reactant/product concentrations, adjusted for reaction orders: 2.49898\n", " Formula used: ([C][D]) / ([A][B])\n", "2. Ratio of forward/reverse reaction rates: 2.5\n", "Discrepancy between the two values: 0.04092 %\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": "747a27b9-06c9-4097-90ab-827266ae5c6f", "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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 TIMEABCDcaption
00.0004.0000007.0000005.0000002.000000Initial state
10.0013.7600006.4000005.4800002.360000
20.0023.5710915.9277285.8578182.643363
30.0033.4213445.5533606.1573122.867984
40.0043.3019815.2549526.3960393.047029
50.0053.2064195.0160476.5871623.190372
60.0063.1296454.8241136.7407093.305532
70.0073.0677944.6694866.8644113.398309
80.0083.0178544.5446346.9642933.473220
90.0092.9774574.4436437.0450853.533814
100.0102.9447344.3618347.1105323.582899
110.0112.9181954.2954877.1636113.622708
120.0122.8966514.2416277.2066993.655024
130.0132.8791484.1978707.2417043.681278
140.0142.8649204.1623007.2701603.702620
150.0152.8533484.1333707.2933043.719978
160.0162.8439324.1098317.3121353.734101
170.0172.8362694.0906727.3274633.745597
180.0182.8300294.0750737.3399423.754956
190.0192.8249484.0623707.3501043.762578
200.0202.8208094.0520247.3583813.768786
210.0212.8174384.0435967.3651233.773843
220.0222.8146924.0367297.3706173.777962
230.0232.8124544.0311357.3750923.781319
240.0242.8106304.0265767.3787393.784054
250.0252.8091444.0228617.3817113.786283
260.0262.8079334.0198347.3841333.788100
270.0272.8069474.0173667.3861073.789580
280.0282.8061424.0153557.3877163.790787
290.0292.8054874.0137177.3890273.791770
300.0302.8049524.0123817.3900953.792572
310.0312.8045174.0112927.3909663.793225
320.0322.8041624.0104057.3916763.793757
330.0332.8038724.0096817.3922553.794191
340.0342.8036374.0090927.3927273.794545
350.0352.8034444.0086117.3931113.794833
360.0362.8032884.0082197.3934243.795068
370.0372.8031604.0079007.3936803.795260
380.0382.8030564.0076407.3938883.795416
390.0392.8029714.0074287.3940583.795543
400.0402.8029024.0072557.3941963.795647
410.0412.8028464.0071147.3943093.795732
\n", "
" ], "text/plain": [ " SYSTEM TIME A B C D caption\n", "0 0.000 4.000000 7.000000 5.000000 2.000000 Initial state\n", "1 0.001 3.760000 6.400000 5.480000 2.360000 \n", "2 0.002 3.571091 5.927728 5.857818 2.643363 \n", "3 0.003 3.421344 5.553360 6.157312 2.867984 \n", "4 0.004 3.301981 5.254952 6.396039 3.047029 \n", "5 0.005 3.206419 5.016047 6.587162 3.190372 \n", "6 0.006 3.129645 4.824113 6.740709 3.305532 \n", "7 0.007 3.067794 4.669486 6.864411 3.398309 \n", "8 0.008 3.017854 4.544634 6.964293 3.473220 \n", "9 0.009 2.977457 4.443643 7.045085 3.533814 \n", "10 0.010 2.944734 4.361834 7.110532 3.582899 \n", "11 0.011 2.918195 4.295487 7.163611 3.622708 \n", "12 0.012 2.896651 4.241627 7.206699 3.655024 \n", "13 0.013 2.879148 4.197870 7.241704 3.681278 \n", "14 0.014 2.864920 4.162300 7.270160 3.702620 \n", "15 0.015 2.853348 4.133370 7.293304 3.719978 \n", "16 0.016 2.843932 4.109831 7.312135 3.734101 \n", "17 0.017 2.836269 4.090672 7.327463 3.745597 \n", "18 0.018 2.830029 4.075073 7.339942 3.754956 \n", "19 0.019 2.824948 4.062370 7.350104 3.762578 \n", "20 0.020 2.820809 4.052024 7.358381 3.768786 \n", "21 0.021 2.817438 4.043596 7.365123 3.773843 \n", "22 0.022 2.814692 4.036729 7.370617 3.777962 \n", "23 0.023 2.812454 4.031135 7.375092 3.781319 \n", "24 0.024 2.810630 4.026576 7.378739 3.784054 \n", "25 0.025 2.809144 4.022861 7.381711 3.786283 \n", "26 0.026 2.807933 4.019834 7.384133 3.788100 \n", "27 0.027 2.806947 4.017366 7.386107 3.789580 \n", "28 0.028 2.806142 4.015355 7.387716 3.790787 \n", "29 0.029 2.805487 4.013717 7.389027 3.791770 \n", "30 0.030 2.804952 4.012381 7.390095 3.792572 \n", "31 0.031 2.804517 4.011292 7.390966 3.793225 \n", "32 0.032 2.804162 4.010405 7.391676 3.793757 \n", "33 0.033 2.803872 4.009681 7.392255 3.794191 \n", "34 0.034 2.803637 4.009092 7.392727 3.794545 \n", "35 0.035 2.803444 4.008611 7.393111 3.794833 \n", "36 0.036 2.803288 4.008219 7.393424 3.795068 \n", "37 0.037 2.803160 4.007900 7.393680 3.795260 \n", "38 0.038 2.803056 4.007640 7.393888 3.795416 \n", "39 0.039 2.802971 4.007428 7.394058 3.795543 \n", "40 0.040 2.802902 4.007255 7.394196 3.795647 \n", "41 0.041 2.802846 4.007114 7.394309 3.795732 " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = bio.get_history()\n", "df" ] }, { "cell_type": "markdown", "id": "f4ef60c7-9d9e-4324-9a93-525dd426bc6e", "metadata": {}, "source": [ "A and B get depleted, while C and D get produced.\n", "\n", "**2A + 5B <-> 4C + 3D**" ] }, { "cell_type": "markdown", "id": "a1525fa9-e852-4942-aef9-26b4ddcbab4e", "metadata": {}, "source": [ "#### Let's verify that the stoichiometry is being respected" ] }, { "cell_type": "code", "execution_count": 13, "id": "ea6a6286-aa49-4b4f-adff-2a3d3ff729d0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([4., 7., 5., 2.], dtype=float32),\n", " array([3.76, 6.4 , 5.48, 2.36], dtype=float32))" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# We'll check the first two arrays of concentrations, from the run's history\n", "arr0 = bio.reaction_dynamics.get_historical_concentrations(row=0, df=df)\n", "arr1 = bio.reaction_dynamics.get_historical_concentrations(row=1, df=df)\n", "arr0, arr1" ] }, { "cell_type": "code", "execution_count": 14, "id": "8cd8dfee-21c5-4dd6-8bf4-155d275797a5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bio.reaction_dynamics.stoichiometry_checker(rxn_index=0, \n", " conc_arr_before = arr0, \n", " conc_arr_after = arr1)" ] }, { "cell_type": "markdown", "id": "b0e3663b-3c12-4790-b948-79df3e6f740e", "metadata": {}, "source": [ "Indeed, the change in [A] is -2 x 0.12, and the change in [B] is -5 X 0.12, \n", " while the change in [C] is 4 x 0.12, and the change in [D] is 3 X 0.12" ] }, { "cell_type": "code", "execution_count": 15, "id": "72e2ec04-2d7d-4c43-941e-11a613d784e3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([-2.0000002, -4.9999995, 4.0000005, 2.9999993], dtype=float32)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(arr1 - arr0) / 0.12" ] }, { "cell_type": "markdown", "id": "058add5c-cb7b-4ed1-a3ad-87e32670ed39", "metadata": { "tags": [] }, "source": [ "# Plots of changes of concentration with time" ] }, { "cell_type": "code", "execution_count": 16, "id": "68ab68a0-2b22-4f91-b2fc-978401b7dc73", "metadata": { "tags": [] }, "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": "navy", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "A", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009000000000000001, 0.010000000000000002, 0.011000000000000003, 0.012000000000000004, 0.013000000000000005, 0.014000000000000005, 0.015000000000000006, 0.016000000000000007, 0.017000000000000008, 0.01800000000000001, 0.01900000000000001, 0.02000000000000001, 0.02100000000000001, 0.022000000000000013, 0.023000000000000013, 0.024000000000000014, 0.025000000000000015, 0.026000000000000016, 0.027000000000000017, 0.028000000000000018, 0.02900000000000002, 0.03000000000000002, 0.03100000000000002, 0.03200000000000002, 0.03300000000000002, 0.03400000000000002, 0.035000000000000024, 0.036000000000000025, 0.037000000000000026, 0.03800000000000003, 0.03900000000000003, 0.04000000000000003, 0.04100000000000003 ], "xaxis": "x", "y": [ 4, 3.76, 3.5710911999999997, 3.421343984936673, 3.301980728001355, 3.2064188890000027, 3.1296453862394342, 3.0677942598136902, 3.0178536016474613, 2.9774572735702503, 2.9447337853232094, 2.9181946595034987, 2.896650676719295, 2.8791481940685353, 2.864920170128554, 2.8533481325184336, 2.8439323993268655, 2.836268601207023, 2.8300290633553296, 2.8249479697668667, 2.8208094937384085, 2.817438269840165, 2.814691724361387, 2.8124538876914618, 2.810630392954937, 2.8091444272685577, 2.8079334500421775, 2.8069465302591987, 2.8061421841616245, 2.805486618085015, 2.80495229972419, 2.8045167959066166, 2.8041618268042856, 2.803872496040423, 2.8036366638212202, 2.80344443641785, 2.8032877503339826, 2.8031600335513334, 2.8030559295354904, 2.8029710723541625, 2.8029019034285914, 2.802845522201422 ], "yaxis": "y" }, { "hovertemplate": "Chemical=B
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "B", "line": { "color": "cyan", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "B", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009000000000000001, 0.010000000000000002, 0.011000000000000003, 0.012000000000000004, 0.013000000000000005, 0.014000000000000005, 0.015000000000000006, 0.016000000000000007, 0.017000000000000008, 0.01800000000000001, 0.01900000000000001, 0.02000000000000001, 0.02100000000000001, 0.022000000000000013, 0.023000000000000013, 0.024000000000000014, 0.025000000000000015, 0.026000000000000016, 0.027000000000000017, 0.028000000000000018, 0.02900000000000002, 0.03000000000000002, 0.03100000000000002, 0.03200000000000002, 0.03300000000000002, 0.03400000000000002, 0.035000000000000024, 0.036000000000000025, 0.037000000000000026, 0.03800000000000003, 0.03900000000000003, 0.04000000000000003, 0.04100000000000003 ], "xaxis": "x", "y": [ 7, 6.4, 5.927728, 5.553359962341683, 5.254951820003388, 5.016047222500007, 4.824113465598586, 4.669485649534226, 4.544634004118653, 4.443643183925626, 4.361834463308023, 4.295486648758746, 4.2416266917982375, 4.197870485171339, 4.162300425321385, 4.133370331296084, 4.109830998317164, 4.090671503017557, 4.075072658388323, 4.062369924417166, 4.052023734346021, 4.043595674600413, 4.0367293109034685, 4.031134719228654, 4.026575982387343, 4.022861068171395, 4.019833625105444, 4.017366325647997, 4.015355460404061, 4.013716545212537, 4.012380749310474, 4.011291989766541, 4.0104045670107125, 4.009681240101056, 4.009091659553049, 4.0086110910446235, 4.008219375834954, 4.00790008387833, 4.007639823838723, 4.007427680885403, 4.007254758571475, 4.007113805503551 ], "yaxis": "y" }, { "hovertemplate": "Chemical=C
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "C", "line": { "color": "red", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "C", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009000000000000001, 0.010000000000000002, 0.011000000000000003, 0.012000000000000004, 0.013000000000000005, 0.014000000000000005, 0.015000000000000006, 0.016000000000000007, 0.017000000000000008, 0.01800000000000001, 0.01900000000000001, 0.02000000000000001, 0.02100000000000001, 0.022000000000000013, 0.023000000000000013, 0.024000000000000014, 0.025000000000000015, 0.026000000000000016, 0.027000000000000017, 0.028000000000000018, 0.02900000000000002, 0.03000000000000002, 0.03100000000000002, 0.03200000000000002, 0.03300000000000002, 0.03400000000000002, 0.035000000000000024, 0.036000000000000025, 0.037000000000000026, 0.03800000000000003, 0.03900000000000003, 0.04000000000000003, 0.04100000000000003 ], "xaxis": "x", "y": [ 5, 5.48, 5.857817600000001, 6.157312030126654, 6.39603854399729, 6.587162221999995, 6.7407092275211316, 6.8644114803726195, 6.964292796705077, 7.0450854528594995, 7.110532429353581, 7.163610680993003, 7.20669864656141, 7.241703611862929, 7.270159659742892, 7.293303734963133, 7.312135201346269, 7.327462797585954, 7.339941873289341, 7.350104060466267, 7.358381012523183, 7.36512346031967, 7.370616551277226, 7.3750922246170765, 7.378739214090126, 7.3817111454628845, 7.384133099915645, 7.386106939481603, 7.387715631676751, 7.38902676382997, 7.39009540055162, 7.390966408186767, 7.391676346391429, 7.392255007919154, 7.3927266723575595, 7.3931111271643, 7.393424499332035, 7.393679932897333, 7.393888140929019, 7.394057855291675, 7.394196193142817, 7.394308955597156 ], "yaxis": "y" }, { "hovertemplate": "Chemical=D
SYSTEM TIME=%{x}
concentration=%{y}", "legendgroup": "D", "line": { "color": "orange", "dash": "solid" }, "marker": { "symbol": "circle" }, "mode": "lines", "name": "D", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ 0, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009000000000000001, 0.010000000000000002, 0.011000000000000003, 0.012000000000000004, 0.013000000000000005, 0.014000000000000005, 0.015000000000000006, 0.016000000000000007, 0.017000000000000008, 0.01800000000000001, 0.01900000000000001, 0.02000000000000001, 0.02100000000000001, 0.022000000000000013, 0.023000000000000013, 0.024000000000000014, 0.025000000000000015, 0.026000000000000016, 0.027000000000000017, 0.028000000000000018, 0.02900000000000002, 0.03000000000000002, 0.03100000000000002, 0.03200000000000002, 0.03300000000000002, 0.03400000000000002, 0.035000000000000024, 0.036000000000000025, 0.037000000000000026, 0.03800000000000003, 0.03900000000000003, 0.04000000000000003, 0.04100000000000003 ], "xaxis": "x", "y": [ 2, 2.36, 2.6433632, 2.86798402259499, 3.047028907997967, 3.190371666499996, 3.3055319206408487, 3.3983086102794644, 3.473219597528808, 3.533814089644624, 3.582899322015186, 3.622708010744752, 3.655023984921057, 3.6812777088971966, 3.7026197448071687, 3.7199778012223494, 3.734101401009702, 3.745597098189466, 3.754956404967006, 3.7625780453497004, 3.768785759392388, 3.7738425952397527, 3.7779624134579195, 3.781319168462808, 3.7840544105675944, 3.786283359097163, 3.788099824936734, 3.789580204611202, 3.7907867237575634, 3.791770072872478, 3.792571550413715, 3.7932248061400755, 3.7937572597935723, 3.794191255939366, 3.7945450042681697, 3.794833345373225, 3.7950683744990266, 3.7952599496730004, 3.7954161056967646, 3.7955433914687564, 3.795647144857113, 3.795731716697867 ], "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 with time" }, "xaxis": { "anchor": "y", "autorange": true, "domain": [ 0, 1 ], "range": [ 0, 0.04100000000000003 ], "title": { "text": "SYSTEM TIME" }, "type": "linear" }, "yaxis": { "anchor": "x", "autorange": true, "domain": [ 0, 1 ], "range": [ 1.7003161691334914, 7.693992786463665 ], "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\", \"D\"], \n", " title=\"Changes in concentrations with time\",\n", " color_discrete_sequence = ['navy', 'cyan', 'red', 'orange'],\n", " labels={\"value\":\"concentration\", \"variable\":\"Chemical\"})\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "a68a26cd", "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 }