{ "cells": [ { "cell_type": "markdown", "id": "8382e30e-2fac-41f1-ae50-baf0fc9f4f22", "metadata": {}, "source": [ "# An initial concentration pulse (near the left edge of the system) moving towards equilibrium\n", "\n", "The system starts out with a \"concentration pulse\" in bin 2 (the 3rd bin from the left) - i.e. that bin is initially the only one with a non-zero concentration of the only chemical species.\n", "Then the system is left undisturbed, and followed to equilibrium.\n", "\n", "LAST REVISED: July 14, 2023" ] }, { "cell_type": "code", "execution_count": 1, "id": "4ed74c66-2717-46c1-945a-c6c082174ee1", "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": "911ca4cb", "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.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": "7a4dd331-d083-4929-b7f1-089f44776f85", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-> Output will be LOGGED into the file 'diffusion_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", "\n", "# Set up the use of some specified graphic (Vue) components\n", "GraphicLog.config(filename=log_file,\n", " components=[\"vue_heatmap_11\", \"vue_curves_3\"])" ] }, { "cell_type": "code", "execution_count": 4, "id": "14b4a1c2-9854-41c6-b407-6008bb4738be", "metadata": {}, "outputs": [], "source": [ "# Set the heatmap parameters (for the log file)\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": "01b3a969-5122-4c25-900b-ad6fba315553", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0:\n", "10 bins and 1 species:\n", " Species 0 (A). Diff rate: 0.1. Conc: [ 0. 0. 10. 0. 0. 0. 0. 0. 0. 0.]\n" ] } ], "source": [ "# Prepare the initial system, with a single non-zero bin, near the left edge of the system\n", "chem_data = chem(names=[\"A\"], diffusion_rates=[0.1])\n", "bio = BioSim1D(n_bins=10, chem_data=chem_data)\n", "\n", "bio.inject_conc_to_bin(bin_address=2, species_index=0, delta_conc=10.)\n", "\n", "bio.describe_state()" ] }, { "cell_type": "code", "execution_count": 6, "id": "db59014c-fc65-4e5a-bca6-8e0a3ffd3d41", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | A | \n", "
|---|---|
| 0 | \n", "0.0 | \n", "
| 1 | \n", "0.0 | \n", "
| 2 | \n", "10.0 | \n", "
| 3 | \n", "0.0 | \n", "
| 4 | \n", "0.0 | \n", "
| 5 | \n", "0.0 | \n", "
| 6 | \n", "0.0 | \n", "
| 7 | \n", "0.0 | \n", "
| 8 | \n", "0.0 | \n", "
| 9 | \n", "0.0 | \n", "