{ "cells": [ { "cell_type": "markdown", "id": "58ff55b9-7d22-47fe-8d5b-1d29d2194498", "metadata": {}, "source": [ "## An initial concentration pulse (near the left edge of the system, and halfway vertically) moving towards equilibrium\n", "\n", "The system starts out with a \"concentration pulse\" in just one bin - 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", "(Note: this is the 2D counterpart of the 1D experiment by the same name)\n", "\n", "LAST REVISED: Nov. 28, 2022" ] }, { "cell_type": "code", "execution_count": 1, "id": "7bc27a42-13c8-469a-b99a-af09f545bb53", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Added 'D:\\Docs\\- MY CODE\\BioSimulations\\life123-Win7' to sys.path\n" ] } ], "source": [ "# Extend the sys.path variable, to contain the project's root directory\n", "import set_path\n", "set_path.add_ancestor_dir_to_syspath(3) # The number of levels to go up \n", " # to reach the project's home, from the folder containing this notebook" ] }, { "cell_type": "code", "execution_count": 2, "id": "d9fd4e5f-c784-449f-9cc6-234dbe9eb20e", "metadata": {}, "outputs": [], "source": [ "from experiments.get_notebook_info import get_notebook_basename\n", "\n", "from src.life_2D.bio_sim_2d import BioSim2D\n", "\n", "import plotly.express as px\n", "import plotly.graph_objects as go\n", "\n", "from src.modules.reactions.reaction_data import ReactionData as chem" ] }, { "cell_type": "code", "execution_count": 3, "id": "008a6f6e-0bae-4d70-b486-43dda6214bf4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0:\n", "Species `A`:\n", " 0 1 2 3 4 5 6 7\n", "0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n", "1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n", "2 0.0 10.0 0.0 0.0 0.0 0.0 0.0 0.0\n", "3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n", "4 0.0 0.0 0.0 0.0 0.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, positioned halfway vertically\n", "chem_data = chem(names=[\"A\"], diffusion_rates=[0.02])\n", "bio = BioSim2D(n_bins=(5, 8), chem_data=chem_data)\n", "\n", "bio.inject_conc_to_bin(bin_address=(2, 1), species_index=0, delta_conc=10.)\n", "\n", "bio.describe_state()" ] }, { "cell_type": "code", "execution_count": 4, "id": "51dac46c-74c3-42f2-bc4c-667db8d32554", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | 0 | \n", "1 | \n", "2 | \n", "3 | \n", "4 | \n", "5 | \n", "6 | \n", "7 | \n", "
|---|---|---|---|---|---|---|---|---|
| 0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
| 1 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
| 2 | \n", "0.0 | \n", "10.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
| 3 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
| 4 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "