{
"cells": [
{
"cell_type": "markdown",
"id": "8d1aaf6c-3d58-4e27-88ac-9482296ac61a",
"metadata": {},
"source": [
"### One-bin `2A <-> 3B` reaction, with 1st-order kinetics in both directions, 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": "1fe1cc26-5763-4feb-b097-3ff995c10c8b",
"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": "592e626f",
"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": "4745cc84-d917-4701-87a8-8c16f9ac428e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-> Output will be LOGGED into the file 'reaction_3.log.htm'\n"
]
}
],
"source": [
"# Initialize the HTML logging\n",
"log_file = get_notebook_basename() + \".log.htm\" # Use the notebook base filename for the log file\n",
"\n",
"# Set up the use of some specified graphic (Vue) components\n",
"GraphicLog.config(filename=log_file,\n",
" components=[\"vue_cytoscape_2\"],\n",
" extra_js=\"https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.21.2/cytoscape.umd.js\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b2660f8d-3447-4874-88d0-da99c0edcfcd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 0:\n",
"1 bins and 2 species:\n",
" Species 0 (A). Diff rate: None. Conc: [10.]\n",
" Species 1 (B). Diff rate: None. Conc: [50.]\n"
]
}
],
"source": [
"# Initialize the system\n",
"chem_data = chem(names=[\"A\", \"B\"]) # NOTE: Diffusion not applicable (just 1 bin)\n",
"\n",
"\n",
"\n",
"# Reaction 2A <-> 3B , with 1st-order kinetics in both directions\n",
"chem_data.add_reaction(reactants=[(2,\"A\",1)], products=[(3,\"B\",1)], forward_rate=5., reverse_rate=2.)\n",
"\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",
"\n",
"bio.describe_state()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "50961a8b-29af-4001-8d46-2a57ed7ccb0d",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" SYSTEM TIME | \n",
" A | \n",
" B | \n",
" caption | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0 | \n",
" 10.0 | \n",
" 50.0 | \n",
" Initial state | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" SYSTEM TIME A B caption\n",
"0 0 10.0 50.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": "0506f3fa-67d8-4aaf-986b-103f955336bb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of reactions: 1 (at temp. 25 C)\n",
"0: 2 A <-> 3 B (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: {'A', 'B'}\n"
]
}
],
"source": [
"chem_data.describe_reactions()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "feae8232-392a-44fd-a9cf-0fb426258fee",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[GRAPHIC ELEMENT SENT TO LOG FILE `reaction_3.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": "ce4ebe89-8187-4c6f-a526-5609937ac65e",
"metadata": {
"tags": []
},
"source": [
"### First step"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "430626a5-2e29-4738-944f-6233edd0e7c7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 0.05:\n",
"1 bins and 2 species:\n",
" Species 0 (A). Diff rate: None. Conc: [15.]\n",
" Species 1 (B). Diff rate: None. Conc: [42.5]\n"
]
}
],
"source": [
"# First step\n",
"bio.react(time_step=0.05, n_steps=1)\n",
"bio.describe_state()"
]
},
{
"cell_type": "markdown",
"id": "27067455-0efd-45d3-abd8-9b66b6f48097",
"metadata": {},
"source": [
"_Early in the reaction :_\n",
"[A] = 15. [B] = 42.5\n",
"\n",
"We're taking a smaller first step than in experimetn \"reaction_2\", to avoid over-shooting the equilibrium value with too large a step!"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "63f11bce-17f0-4757-98a3-a40e7621084f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" SYSTEM TIME | \n",
" A | \n",
" B | \n",
" caption | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0.00 | \n",
" 10.0 | \n",
" 50.0 | \n",
" Initial state | \n",
"
\n",
" \n",
" | 1 | \n",
" 0.05 | \n",
" 15.0 | \n",
" 42.5 | \n",
" | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" SYSTEM TIME A B caption\n",
"0 0.00 10.0 50.0 Initial state\n",
"1 0.05 15.0 42.5 "
]
},
"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": "b12d38ef-c936-47b0-a1de-232fc9d521b7",
"metadata": {},
"source": [
"### Numerous more steps"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "f714a848-01a0-4343-bfbb-89d946a7e343",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 10.05:\n",
"1 bins and 2 species:\n",
" Species 0 (A). Diff rate: None. Conc: [16.25]\n",
" Species 1 (B). Diff rate: None. Conc: [40.625]\n"
]
}
],
"source": [
"# Numerous more steps\n",
"bio.react(time_step=0.1, n_steps=100, snapshots={\"sample_bin\": 0})\n",
"\n",
"bio.describe_state()"
]
},
{
"cell_type": "markdown",
"id": "ff1860cd-a3c7-47a5-9b9f-3c04560962fa",
"metadata": {
"tags": []
},
"source": [
"### Equilibrium"
]
},
{
"cell_type": "markdown",
"id": "20ce715e-e24a-4ec3-a93d-d3eb5858aef5",
"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: [A] = 16.25 , [B] = 40.625"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "796bef2e-8a11-4aff-8ce5-0b9bb5f72680",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2 A <-> 3 B\n",
"Final concentrations: [A] = 16.25 ; [B] = 40.63\n",
"1. Ratio of reactant/product concentrations, adjusted for reaction orders: 2.5\n",
" Formula used: [B] / [A]\n",
"2. Ratio of forward/reverse reaction rates: 2.5\n",
"Discrepancy between the two values: 1.776e-14 %\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": "7527ea21-fd7d-4514-ab49-cc6c16482c10",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" SYSTEM TIME | \n",
" A | \n",
" B | \n",
" caption | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0.00 | \n",
" 10.00 | \n",
" 50.000 | \n",
" Initial state | \n",
"
\n",
" \n",
" | 1 | \n",
" 0.05 | \n",
" 15.00 | \n",
" 42.500 | \n",
" | \n",
"
\n",
" \n",
" | 2 | \n",
" 0.15 | \n",
" 17.00 | \n",
" 39.500 | \n",
" | \n",
"
\n",
" \n",
" | 3 | \n",
" 0.25 | \n",
" 15.80 | \n",
" 41.300 | \n",
" | \n",
"
\n",
" \n",
" | 4 | \n",
" 0.35 | \n",
" 16.52 | \n",
" 40.220 | \n",
" | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 97 | \n",
" 9.65 | \n",
" 16.25 | \n",
" 40.625 | \n",
" | \n",
"
\n",
" \n",
" | 98 | \n",
" 9.75 | \n",
" 16.25 | \n",
" 40.625 | \n",
" | \n",
"
\n",
" \n",
" | 99 | \n",
" 9.85 | \n",
" 16.25 | \n",
" 40.625 | \n",
" | \n",
"
\n",
" \n",
" | 100 | \n",
" 9.95 | \n",
" 16.25 | \n",
" 40.625 | \n",
" | \n",
"
\n",
" \n",
" | 101 | \n",
" 10.05 | \n",
" 16.25 | \n",
" 40.625 | \n",
" | \n",
"
\n",
" \n",
"
\n",
"
102 rows × 4 columns
\n",
"
"
],
"text/plain": [
" SYSTEM TIME A B caption\n",
"0 0.00 10.00 50.000 Initial state\n",
"1 0.05 15.00 42.500 \n",
"2 0.15 17.00 39.500 \n",
"3 0.25 15.80 41.300 \n",
"4 0.35 16.52 40.220 \n",
".. ... ... ... ...\n",
"97 9.65 16.25 40.625 \n",
"98 9.75 16.25 40.625 \n",
"99 9.85 16.25 40.625 \n",
"100 9.95 16.25 40.625 \n",
"101 10.05 16.25 40.625 \n",
"\n",
"[102 rows x 4 columns]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bio.get_history()"
]
},
{
"cell_type": "markdown",
"id": "f2e3dc99-8b9d-4dcd-a2e3-ad099efbcbf4",
"metadata": {
"tags": []
},
"source": [
"# Plots of changes of concentration with time"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "c206e345-03c3-4c13-b1f3-d1d21d6bf100",
"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": "navy",
"dash": "solid"
},
"marker": {
"symbol": "circle"
},
"mode": "lines",
"name": "A",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
0,
0.05,
0.15000000000000002,
0.25,
0.35,
0.44999999999999996,
0.5499999999999999,
0.6499999999999999,
0.7499999999999999,
0.8499999999999999,
0.9499999999999998,
1.0499999999999998,
1.15,
1.25,
1.35,
1.4500000000000002,
1.5500000000000003,
1.6500000000000004,
1.7500000000000004,
1.8500000000000005,
1.9500000000000006,
2.0500000000000007,
2.150000000000001,
2.250000000000001,
2.350000000000001,
2.450000000000001,
2.550000000000001,
2.6500000000000012,
2.7500000000000013,
2.8500000000000014,
2.9500000000000015,
3.0500000000000016,
3.1500000000000017,
3.2500000000000018,
3.350000000000002,
3.450000000000002,
3.550000000000002,
3.650000000000002,
3.750000000000002,
3.8500000000000023,
3.9500000000000024,
4.0500000000000025,
4.150000000000002,
4.250000000000002,
4.350000000000001,
4.450000000000001,
4.550000000000001,
4.65,
4.75,
4.85,
4.949999999999999,
5.049999999999999,
5.149999999999999,
5.249999999999998,
5.349999999999998,
5.4499999999999975,
5.549999999999997,
5.649999999999997,
5.7499999999999964,
5.849999999999996,
5.949999999999996,
6.049999999999995,
6.149999999999995,
6.249999999999995,
6.349999999999994,
6.449999999999994,
6.549999999999994,
6.649999999999993,
6.749999999999993,
6.8499999999999925,
6.949999999999992,
7.049999999999992,
7.1499999999999915,
7.249999999999991,
7.349999999999991,
7.44999999999999,
7.54999999999999,
7.64999999999999,
7.749999999999989,
7.849999999999989,
7.949999999999989,
8.049999999999988,
8.149999999999988,
8.249999999999988,
8.349999999999987,
8.449999999999987,
8.549999999999986,
8.649999999999986,
8.749999999999986,
8.849999999999985,
8.949999999999985,
9.049999999999985,
9.149999999999984,
9.249999999999984,
9.349999999999984,
9.449999999999983,
9.549999999999983,
9.649999999999983,
9.749999999999982,
9.849999999999982,
9.949999999999982,
10.049999999999981
],
"xaxis": "x",
"y": [
10,
15,
17,
15.8,
16.52,
16.088,
16.3472,
16.191679999999998,
16.284992000000003,
16.2290048,
16.262597120000002,
16.242441728,
16.2545349632,
16.24727902208,
16.251632586752002,
16.249020447948798,
16.250587731230723,
16.24964736126157,
16.25021158324306,
16.249873050054166,
16.250076169967503,
16.2499542980195,
16.2500274211883,
16.249983547287023,
16.250009871627785,
16.24999407702333,
16.250003553786005,
16.2499978677284,
16.250001279362962,
16.249999232382226,
16.250000460570668,
16.2499997236576,
16.250000165805442,
16.249999900516734,
16.25000005968996,
16.249999964186024,
16.250000021488386,
16.249999987106968,
16.25000000773582,
16.24999999535851,
16.250000002784898,
16.249999998329063,
16.250000001002565,
16.249999999398465,
16.250000000360924,
16.249999999783448,
16.250000000129933,
16.249999999922046,
16.25000000004678,
16.249999999971937,
16.250000000016843,
16.2499999999899,
16.250000000006064,
16.249999999996366,
16.250000000002185,
16.249999999998693,
16.25000000000079,
16.24999999999953,
16.250000000000288,
16.249999999999833,
16.250000000000107,
16.24999999999994,
16.25000000000004,
16.24999999999998,
16.250000000000018,
16.249999999999996,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004,
16.250000000000007,
16.250000000000004
],
"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.05,
0.15000000000000002,
0.25,
0.35,
0.44999999999999996,
0.5499999999999999,
0.6499999999999999,
0.7499999999999999,
0.8499999999999999,
0.9499999999999998,
1.0499999999999998,
1.15,
1.25,
1.35,
1.4500000000000002,
1.5500000000000003,
1.6500000000000004,
1.7500000000000004,
1.8500000000000005,
1.9500000000000006,
2.0500000000000007,
2.150000000000001,
2.250000000000001,
2.350000000000001,
2.450000000000001,
2.550000000000001,
2.6500000000000012,
2.7500000000000013,
2.8500000000000014,
2.9500000000000015,
3.0500000000000016,
3.1500000000000017,
3.2500000000000018,
3.350000000000002,
3.450000000000002,
3.550000000000002,
3.650000000000002,
3.750000000000002,
3.8500000000000023,
3.9500000000000024,
4.0500000000000025,
4.150000000000002,
4.250000000000002,
4.350000000000001,
4.450000000000001,
4.550000000000001,
4.65,
4.75,
4.85,
4.949999999999999,
5.049999999999999,
5.149999999999999,
5.249999999999998,
5.349999999999998,
5.4499999999999975,
5.549999999999997,
5.649999999999997,
5.7499999999999964,
5.849999999999996,
5.949999999999996,
6.049999999999995,
6.149999999999995,
6.249999999999995,
6.349999999999994,
6.449999999999994,
6.549999999999994,
6.649999999999993,
6.749999999999993,
6.8499999999999925,
6.949999999999992,
7.049999999999992,
7.1499999999999915,
7.249999999999991,
7.349999999999991,
7.44999999999999,
7.54999999999999,
7.64999999999999,
7.749999999999989,
7.849999999999989,
7.949999999999989,
8.049999999999988,
8.149999999999988,
8.249999999999988,
8.349999999999987,
8.449999999999987,
8.549999999999986,
8.649999999999986,
8.749999999999986,
8.849999999999985,
8.949999999999985,
9.049999999999985,
9.149999999999984,
9.249999999999984,
9.349999999999984,
9.449999999999983,
9.549999999999983,
9.649999999999983,
9.749999999999982,
9.849999999999982,
9.949999999999982,
10.049999999999981
],
"xaxis": "x",
"y": [
50,
42.5,
39.5,
41.3,
40.22,
40.867999999999995,
40.4792,
40.71248,
40.572511999999996,
40.6564928,
40.60610432,
40.636337408,
40.6181975552,
40.62908146688,
40.622551119872,
40.62646932807681,
40.62411840315392,
40.62552895810765,
40.624682625135414,
40.625190424918756,
40.62488574504875,
40.62506855297075,
40.624958868217554,
40.62502467906947,
40.62498519255833,
40.62500888446501,
40.624994669321,
40.625003198407406,
40.624998080955564,
40.625001151426666,
40.624999309144,
40.62500041451361,
40.62499975129184,
40.6250001492249,
40.624999910465064,
40.62500005372097,
40.62499996776742,
40.62500001933955,
40.624999988396276,
40.62500000696224,
40.62499999582266,
40.62500000250641,
40.62499999849616,
40.62500000090231,
40.62499999945862,
40.62500000032484,
40.62499999980511,
40.62500000011694,
40.62499999992984,
40.62500000004211,
40.62499999997475,
40.62500000001516,
40.62499999999091,
40.625000000005464,
40.62499999999673,
40.62500000000197,
40.62499999999883,
40.62500000000072,
40.62499999999958,
40.62500000000026,
40.62499999999985,
40.6250000000001,
40.62499999999995,
40.62500000000004,
40.624999999999986,
40.62500000000002,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014,
40.62500000000001,
40.625000000000014
],
"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"
},
"xaxis": {
"anchor": "y",
"autorange": true,
"domain": [
0,
1
],
"range": [
0,
10.049999999999981
],
"title": {
"text": "SYSTEM TIME"
},
"type": "linear"
},
"yaxis": {
"anchor": "x",
"autorange": true,
"domain": [
0,
1
],
"range": [
7.777777777777778,
52.22222222222222
],
"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\"], \n",
" title=\"Changes in concentrations\",\n",
" color_discrete_sequence = ['navy', 'darkorange'],\n",
" labels={\"value\":\"concentration\", \"variable\":\"Chemical\"})\n",
"fig.show()"
]
},
{
"cell_type": "markdown",
"id": "ca41b04c-8626-45b1-b83d-79a97dd9a3cd",
"metadata": {},
"source": [
"### Notice the *early overshoots* (the time step is too large early in the simulation!)\n",
"Variable, adaptive time steps are explored at length in the _\"reactions_single_compartment\"_ experiments"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "243badde",
"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
}