In the examples below, the time advance always remains constant, but the number of steps used to arrive there vary
LAST_REVISED = "May 3, 2025"
LIFE123_VERSION = "1.0.0rc3" # Library version this experiment is based on
#import set_path # Using MyBinder? Uncomment this before running the next cell!
#import sys
#sys.path.append("C:/some_path/my_env_or_install") # CHANGE to the folder containing your venv or libraries installation!
# NOTE: If any of the imports below can't find a module, uncomment the lines above, or try: import set_path
from life123 import BioSim1D, ChemData, check_version
check_version(LIFE123_VERSION)
OK
def set_initial_condition():
# Set or reset the initial concentrations
bio.set_uniform_concentration(chem_index=0, conc=0.)
bio.inject_conc_to_bin(bin_address=2, chem_index=0, delta_conc=10.)
chem_data = ChemData(diffusion_rates=0.1)
bio = BioSim1D(n_bins=10, chem_data=chem_data)
set_initial_condition()
bio.describe_state()
SYSTEM STATE at Time t = 0: 10 bins and 1 chemical species:
| Species | Diff rate | Bin 0 | Bin 1 | Bin 2 | Bin 3 | Bin 4 | Bin 5 | Bin 6 | Bin 7 | Bin 8 | Bin 9 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Chemical 1 | 0.1 | 0.0 | 0.0 | 10.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
t_final = 33.3
bio.debug = True
bio.diffuse(total_duration=t_final, n_steps=10)
set_initial_condition() # Reset the concentrations
bio.diffuse(total_duration=t_final, n_steps=20)
set_initial_condition() # Reset the concentrations
bio.diffuse(total_duration=t_final, n_steps=30)
set_initial_condition() # Reset the concentrations
bio.diffuse(total_duration=t_final, n_steps=50)
set_initial_condition() # Reset the concentrations
bio.diffuse(total_duration=t_final, n_steps=100)
set_initial_condition() # Reset the concentrations
bio.diffuse(total_duration=t_final, n_steps=1000)
set_initial_condition() # Reset the concentrations
bio.diffuse(total_duration=t_final, n_steps=10000)
set_initial_condition() # Reset the concentrations
bio.diffuse(total_duration=t_final, n_steps=100000)
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 8 ...
Performing diffusion step 9 ...
System after Delta time 33.3, at end of 10 steps of size 3.33:
SYSTEM STATE at Time t = 33.3:
[[1.94849832 1.89701268 1.76252648 1.51861039 1.18134438 0.81185766
0.48398585 0.24587699 0.10558355 0.04470372]]
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 18 ...
Performing diffusion step 19 ...
System after Delta time 33.3, at end of 20 steps of size 1.665:
SYSTEM STATE at Time t = 66.6:
[[1.93083096 1.89918952 1.78309085 1.53809527 1.18379901 0.79887357
0.46852318 0.23832707 0.10742893 0.05184163]]
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 28 ...
Performing diffusion step 29 ...
System after Delta time 33.3, at end of 30 steps of size 1.11:
SYSTEM STATE at Time t = 99.9:
[[1.92418469 1.90022582 1.79079709 1.54473636 1.18398957 0.79411327
0.46362705 0.23627042 0.10813759 0.05391814]]
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 48 ...
Performing diffusion step 49 ...
System after Delta time 33.3, at end of 50 steps of size 0.666:
SYSTEM STATE at Time t = 133.2:
[[1.91860809 1.90117398 1.79725968 1.55006867 1.18390667 0.79018989
0.45982272 0.23476444 0.10871741 0.05548847]]
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 98 ...
Performing diffusion step 99 ...
System after Delta time 33.3, at end of 100 steps of size 0.333:
SYSTEM STATE at Time t = 166.5:
[[1.91428037 1.90195278 1.80227809 1.55407026 1.18370653 0.78719167
0.45703829 0.2337084 0.10915577 0.05661783]]
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 998 ...
Performing diffusion step 999 ...
System after Delta time 33.3, at end of 1000 steps of size 0.0333:
SYSTEM STATE at Time t = 199.8:
[[1.9102833 1.90270095 1.80691952 1.55766816 1.18342551 0.78445907
0.45458379 0.23280741 0.10955101 0.05760128]]
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 9998 ...
Performing diffusion step 9999 ...
System after Delta time 33.3, at end of 10000 steps of size 0.00333:
SYSTEM STATE at Time t = 233.1:
[[1.90987842 1.90277812 1.80739016 1.5580276 1.18339217 0.78418423
0.45434105 0.23271976 0.10959052 0.05769798]]
Performing diffusion step 0 ...
Performing diffusion step 1 ...
...
Performing diffusion step 99998 ...
Performing diffusion step 99999 ...
System after Delta time 33.3, at end of 100000 steps of size 0.000333:
SYSTEM STATE at Time t = 266.4:
[[1.90983788 1.90278586 1.80743729 1.55806354 1.18338878 0.78415673
0.4543168 0.23271101 0.10959447 0.05770763]]
{'steps': 100000}