{ "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." ] }, { "cell_type": "markdown", "id": "d5cc70a6-8aea-4b15-9351-af69a3664dab", "metadata": {}, "source": [ "### TAGS : \"diffusion 1D\", \"basic\"" ] }, { "cell_type": "code", "execution_count": 1, "id": "2b08132b-3002-444a-aaa4-68eb37342237", "metadata": {}, "outputs": [], "source": [ "LAST_REVISED = \"Oct. 6, 2024\"\n", "LIFE123_VERSION = \"1.0.0.beta.39\" # Library version this experiment is based on" ] }, { "cell_type": "code", "execution_count": 2, "id": "1302ee3c-4c75-4e67-9b77-d75d27d6d29a", "metadata": {}, "outputs": [], "source": [ "#import set_path # Using MyBinder? Uncomment this before running the next cell!" ] }, { "cell_type": "code", "execution_count": 3, "id": "911ca4cb", "metadata": {}, "outputs": [], "source": [ "#import sys\n", "#sys.path.append(\"C:/some_path/my_env_or_install\") # CHANGE to the folder containing your venv or libraries installation!\n", "# NOTE: If any of the imports below can't find a module, uncomment the lines above, or try: import set_path \n", "\n", "from experiments.get_notebook_info import get_notebook_basename\n", "\n", "from life123 import BioSim1D\n", "\n", "import plotly.express as px\n", "import plotly.graph_objects as go\n", "\n", "from life123 import ChemData as chem\n", "from life123 import HtmlLog as log\n", "from life123 import GraphicLog" ] }, { "cell_type": "code", "execution_count": 4, "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": 5, "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": 6, "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": 7, "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", "