{
"cells": [
{
"cell_type": "markdown",
"id": "a40f6857",
"metadata": {},
"source": [
"## Exploring reaching equilibrium\n",
"\n",
"The system starts out with a pulse in bins near the *left* and the *right* endpoints\n",
"\n",
"LAST REVISED: July 14, 2023"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c5348222-9a98-42c6-b105-b7f8aafc1be7",
"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": "142ceed5",
"metadata": {},
"outputs": [],
"source": [
"from experiments.get_notebook_info import get_notebook_basename\n",
"\n",
"from src.life_1D.bio_sim_1d import BioSim1D\n",
"\n",
"import plotly.express as px\n",
"\n",
"from src.modules.chemicals.chem_data import ChemData as chem\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": "56c2a43d-d531-414e-921c-bf746c2ba991",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-> Output will be LOGGED into the file 'reach_equilibrium_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",
"GraphicLog.config(filename=log_file,\n",
" components=[\"vue_heatmap_11\", \"vue_curves_3\"])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f14a35e1-83a5-42da-9258-89d9af0ffe31",
"metadata": {},
"outputs": [],
"source": [
"# Set the heatmap parameters\n",
"heatmap_pars = {\"range\": [0, 2.5],\n",
" \"outer_width\": 850, \"outer_height\": 150,\n",
" \"margins\": {\"top\": 30, \"right\": 30, \"bottom\": 30, \"left\": 55}\n",
" }\n",
"\n",
"# Set the parameters of the line plots\n",
"lineplot_pars = {\"range\": [0, 10],\n",
" \"outer_width\": 850, \"outer_height\": 250,\n",
" \"margins\": {\"top\": 30, \"right\": 30, \"bottom\": 30, \"left\": 55}\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "99ab76d6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 0:\n",
"9 bins and 1 species:\n",
" Species 0 (A). Diff rate: 0.1. Conc: [ 0. 0. 10. 0. 0. 0. 10. 0. 0.]\n"
]
}
],
"source": [
"# Initialize the system\n",
"chem_data = chem(names=[\"A\"], diffusion_rates=[0.1])\n",
"bio = BioSim1D(n_bins=9, chem_data=chem_data)\n",
"\n",
"bio.set_uniform_concentration(species_index=0, conc=0.)\n",
"\n",
"# Start out with a pulse in bins near the *left* and the *right* endpoints. \n",
"# A total of 20 \"units of concentration\" is injected\n",
"bio.inject_conc_to_bin(species_index=0, bin_address=2, delta_conc=10.)\n",
"bio.inject_conc_to_bin(species_index=0, bin_address=6, delta_conc=10.)\n",
"\n",
"bio.describe_state()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "012d98f0-4846-4d56-8b50-f30543b31fe0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM SNAPSHOT at time 0:\n",
" A\n",
"0 0.0\n",
"1 0.0\n",
"2 10.0\n",
"3 0.0\n",
"4 0.0\n",
"5 0.0\n",
"6 10.0\n",
"7 0.0\n",
"8 0.0\n"
]
}
],
"source": [
"bio.show_system_snapshot()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "338bd51c-6b12-4cf0-8526-797389fbc55c",
"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
Bin number=%{x}
concentration=%{y}