{
"cells": [
{
"cell_type": "markdown",
"id": "8382e30e-2fac-41f1-ae50-baf0fc9f4f22",
"metadata": {},
"source": [
"# Exploring the change of delta_x (spatial resolution) in diffusion accuracy.\n",
"#### From the same initial setup, diffusion is carried out over a fixed time span,\n",
"#### at different spatial resolutions - and then the respective results are compared\n",
"\n",
"LAST REVISED: July 14, 2023"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "b3ae84bc-72b9-4043-b5b9-70532eafdb44",
"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": "52bd1bf4",
"metadata": {},
"outputs": [],
"source": [
"from experiments.get_notebook_info import get_notebook_basename\n",
"\n",
"from src.life_1D.bio_sim_1d import BioSim1D\n",
"from src.modules.chemicals.chem_data import ChemData as chem\n",
"from src.modules.numerical.numerical import Numerical as num\n",
"\n",
"import plotly.express as px\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 'spatial_resolution_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, 150],\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, 150],\n",
" \"outer_width\": 850, \"outer_height\": 250,\n",
" \"margins\": {\"top\": 30, \"right\": 30, \"bottom\": 30, \"left\": 55}\n",
" }"
]
},
{
"cell_type": "markdown",
"id": "28c89c3d-a7f7-41d9-a99b-b0185620b5c1",
"metadata": {},
"source": [
"## Prepare the initial system"
]
},
{
"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",
"60 bins and 1 species:\n",
" Species 0 (A). Diff rate: 0.1. Conc: [ 10. 13. 17. 21. 25. 28. 30. 38. 42. 55. 65. 47. 35. 32.\n",
" 27. 23. 20. 17. 14. 8. 3. 10. 16. 18. 20. 25. 30. 35.\n",
" 40. 65. 85. 115. 150. 92. 73. 69. 65. 50. 42. 36. 20. 45.\n",
" 50. 55. 69. 82. 95. 77. 60. 43. 37. 31. 25. 22. 20. 18.\n",
" 15. 11. 9. 8.]\n"
]
}
],
"source": [
"chem_data = chem(names=[\"A\"], diffusion_rates=[0.1])\n",
"\n",
"conc_list=[10,13,17,21,25,28,30,38,42,55,65,47,35,32,27,23,20,17,14,8,3,10,16,18,\n",
" 20,25,30,35,40,65,85,115,150,92,73,69,65,50,42,36,20,45,50,55,69,82,95,\n",
" 77,60,43,37,31,25,22,20,18,15,11,9, 8]\n",
"\n",
"bio = BioSim1D(n_bins=len(conc_list), chem_data=chem_data)\n",
"\n",
"bio.set_species_conc(species_name=\"A\", conc_list=conc_list)\n",
"\n",
"bio.describe_state()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "1ae4f7f8-ad6f-4ff0-b484-c6e698164042",
"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}