{
"cells": [
{
"cell_type": "markdown",
"id": "a40f6857",
"metadata": {},
"source": [
"## Attaining a Concentration Gradient \n",
"### by continuosly injecting and draining, at opposite ends\n",
"\n",
"The system starts out with a uniform concentration. \n",
"Then identical concentrations are repeatedly *injected to the left* and *drained from the right*\n",
"\n",
"LAST REVISED: June 4, 2023"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d142d450-f2af-42fa-9026-2b44919c5b40",
"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": "9897632a-191c-4cdc-9bc2-a1143c2f0d36",
"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",
"import plotly.graph_objects as go\n",
"\n",
"from src.modules.reactions.reaction_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 'gradient_1.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\": [75, 125],\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\": [75, 125],\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.6. Conc: [100. 100. 100. 100. 100. 100. 100. 100. 100.]\n"
]
}
],
"source": [
"# Initialize the system with a uniform concentration (of the only species)\n",
"chem_data = chem(names=[\"A\"], diffusion_rates=[0.6])\n",
"bio = BioSim1D(n_bins=9, chem_data=chem_data)\n",
"\n",
"bio.set_uniform_concentration(species_index=0, conc=100.)\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 100.0\n",
"1 100.0\n",
"2 100.0\n",
"3 100.0\n",
"4 100.0\n",
"5 100.0\n",
"6 100.0\n",
"7 100.0\n",
"8 100.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": "Bin number=%{x}
[A]=%{y}