Skip to content

Commit fddc5b3

Browse files
authored
Merge pull request #70 from BrainAnnex/dev
Dev beta39
2 parents 3fb219c + 288113a commit fddc5b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+55438
-17830
lines changed

experiments/1D/diffusion/diffusion_1.ipynb

Lines changed: 82 additions & 69 deletions
Large diffs are not rendered by default.

experiments/1D/diffusion/diffusion_1.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,22 @@
1717
#
1818
# 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.
1919
# Then the system is left undisturbed, and followed to equilibrium.
20-
#
21-
# LAST REVISED: June 23, 2024 (using v. 1.0 beta34.1)
20+
21+
# %% [markdown]
22+
# ### TAGS : "diffusion 1D", "basic"
2223

2324
# %%
24-
import set_path # Importing this module will add the project's home directory to sys.path
25+
LAST_REVISED = "Oct. 6, 2024"
26+
LIFE123_VERSION = "1.0.0.beta.39" # Library version this experiment is based on
2527

2628
# %%
29+
#import set_path # Using MyBinder? Uncomment this before running the next cell!
30+
31+
# %%
32+
#import sys
33+
#sys.path.append("C:/some_path/my_env_or_install") # CHANGE to the folder containing your venv or libraries installation!
34+
# NOTE: If any of the imports below can't find a module, uncomment the lines above, or try: import set_path
35+
2736
from experiments.get_notebook_info import get_notebook_basename
2837

2938
from life123 import BioSim1D

experiments/1D/reaction_diffusion/rd_1.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@
115115

116116
# Output to the log file a heatmap for each chemical species
117117
for i in range(bio.n_species):
118-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
118+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
119119
bio.single_species_heatmap(species_index=i, heatmap_pars=heatmap_pars, graphic_component="vue_heatmap_11")
120120

121121
# Output to the log file a one-curve line plot for each chemical species
122122
for i in range(bio.n_species):
123-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
123+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
124124
bio.single_species_line_plot(species_index=i, plot_pars=lineplot_pars, graphic_component="vue_curves_3")
125125

126126
# Output to the log file a line plot for ALL the chemicals together (same color as used for plotly elsewhere)
@@ -167,12 +167,12 @@
167167

168168
# Output to the log file a heatmap for each chemical species
169169
for i in range(bio.n_species):
170-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
170+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
171171
bio.single_species_heatmap(species_index=i, heatmap_pars=heatmap_pars, graphic_component="vue_heatmap_11")
172172

173173
# Output to the log file a one-curve line plot for each chemical species
174174
for i in range(bio.n_species):
175-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
175+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
176176
bio.single_species_line_plot(species_index=i, plot_pars=lineplot_pars, graphic_component="vue_curves_3")
177177

178178
# Output to the log file a line plot for ALL the chemicals together (same color as used for plotly elsewhere)
@@ -213,12 +213,12 @@
213213

214214
# Output to the log file a heatmap for each chemical species
215215
for i in range(bio.n_species):
216-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
216+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
217217
bio.single_species_heatmap(species_index=i, heatmap_pars=heatmap_pars, graphic_component="vue_heatmap_11")
218218

219219
# Output to the log file a one-curve line plot for each chemical species
220220
for i in range(bio.n_species):
221-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
221+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
222222
bio.single_species_line_plot(species_index=i, plot_pars=lineplot_pars, graphic_component="vue_curves_3")
223223

224224
# Output to the log file a line plot for ALL the chemicals together (same color as used for plotly elsewhere)
@@ -260,12 +260,12 @@
260260

261261
# Output to the log file a heatmap for each chemical species
262262
for i in range(bio.n_species):
263-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
263+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
264264
bio.single_species_heatmap(species_index=i, heatmap_pars=heatmap_pars, graphic_component="vue_heatmap_11")
265265

266266
# Output to the log file a one-curve line plot for each chemical species
267267
for i in range(bio.n_species):
268-
log.write(f"{bio.chem_data.get_name(i)}:", also_print=False)
268+
log.write(f"{bio.chem_data.get_label(i)}:", also_print=False)
269269
bio.single_species_line_plot(species_index=i, plot_pars=lineplot_pars, graphic_component="vue_curves_3")
270270

271271
# Output to the log file a line plot for ALL the chemicals together (same color as used for plotly elsewhere)

experiments/reactions_single_compartment/cascade_1.ipynb

Lines changed: 356 additions & 243 deletions
Large diffs are not rendered by default.

experiments/reactions_single_compartment/cascade_1.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@
4040
# ![2 Coupled Reactions](../../docs/2_coupled_reactions.png)
4141

4242
# %%
43-
LAST_REVISED = "July 26, 2024"
44-
LIFE123_VERSION = "1.0.0.beta.38" # Version this experiment is based on
43+
LAST_REVISED = "Oct. 11, 2024"
44+
LIFE123_VERSION = "1.0.0.beta.39" # Library version this experiment is based on
4545

4646
# %%
47-
#import set_path # Using MyBinder? Uncomment this before running the next cell!
48-
# Importing this local file will add the project's home directory to sys.path
47+
#import set_path # Using MyBinder? Uncomment this before running the next cell!
4948

5049
# %% tags=[]
5150
#import sys
@@ -184,13 +183,13 @@
184183
# %%
185184
# Concentration increments due to reaction 0 (A <-> B)
186185
# Note that [C] is not affected
187-
dynamics.diagnostics.get_diagnostic_rxn_data(rxn_index=0)
186+
dynamics.diagnostics.get_rxn_data(rxn_index=0)
188187

189188
# %%
190189
# Concentration increments due to reaction 1 (B <-> C)
191190
# Also notice that the 0-th row from the A <-> B reaction isn't seen here (start time 0 and step 0.02),
192191
# because that step was aborted early on, BEFORE even getting to THIS reaction
193-
dynamics.diagnostics.get_diagnostic_rxn_data(rxn_index=1)
192+
dynamics.diagnostics.get_rxn_data(rxn_index=1)
194193

195194
# %%
196195

experiments/reactions_single_compartment/cascade_2_a.ipynb

Lines changed: 5 additions & 4 deletions
Large diffs are not rendered by default.

experiments/reactions_single_compartment/cascade_2_a.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
# %% tags=[]
5353
# Instantiate the simulator and specify the chemicals
54+
# Here we use the "mid" preset for the variable steps, a compromise between speed and accuracy
5455
dynamics = UniformCompartment(preset="mid")
5556

5657
# Reaction A <-> B (slower, and with a smaller K)
@@ -67,7 +68,7 @@
6768
# ### Run the simulation
6869

6970
# %%
70-
dynamics.set_conc({"A": 50.}, snapshot=True) # Set the initial concentrations of all the chemicals, in their index order
71+
dynamics.set_conc({"A": 50.}, snapshot=True) # Set the initial concentrations of all the chemicals
7172
dynamics.describe_state()
7273

7374
# %%
@@ -132,8 +133,8 @@
132133
# We'll pick time **t=0.1** as the divider between the 2 domains of the `A <-> C` time evolution that we want to model.
133134

134135
# %%
135-
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], xrange=[0, 0.4],
136-
vertical_lines=[0.1])
136+
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], range_x=[0, 0.4],
137+
vertical_lines_to_add=[0.1])
137138

138139
# %% [markdown]
139140
# #### Let's locate where the t = 0.1 point occurs in the data
@@ -177,8 +178,8 @@
177178
# It's no surprise that an elementary reaction is a good fit, if one observes what happens to the time evolution of the concentrations. Repeating the earlier plot, but only showing `A` and `C` (i.e. hiding the intermediary `B`):
178179

179180
# %%
180-
dynamics.plot_history(colors=['darkturquoise', 'green'], xrange=[0, 0.4], vertical_lines=[0.1],
181-
chemicals=['A', 'C'], title="Changes in concentration for `A <-> C`")
181+
dynamics.plot_history(colors=['darkturquoise', 'green'], range_x=[0, 0.4], vertical_lines_to_add=[0.1],
182+
chemicals=['A', 'C'], title="Changes in concentration for `A <-> C`")
182183

183184
# %% [markdown]
184185
# In the zone to the left of the vertical dashed line:
@@ -202,8 +203,8 @@
202203
# Let's see the graph again:
203204

204205
# %%
205-
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], xrange=[0, 0.4],
206-
vertical_lines=[0.1])
206+
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], range_x=[0, 0.4],
207+
vertical_lines_to_add=[0.1])
207208

208209
# %% [markdown]
209210
# A possible conclusion to draw is that, in this case, the earlier part of the complex (compound) reaction `A <-> C` cannot be modeled by an elementary reaction, while the later part can indeed be modeled by a 1st order elementary reaction, with kinetics similar to the slower `A <-> B` reaction

experiments/reactions_single_compartment/cascade_2_b.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@
125125
# Note that this is a much smaller time than we saw in experiment `cascade_2_a`
126126

127127
# %%
128-
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], xrange=[0, 0.4],
129-
vertical_lines=[0.028])
128+
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], range_x=[0, 0.4],
129+
vertical_lines_to_add=[0.028])
130130

131131
# %% [markdown]
132132
# #### Let's locate where the t = 0.028 point occurs in the data
@@ -175,8 +175,8 @@
175175
# Let's see the graph again:
176176

177177
# %%
178-
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], xrange=[0, 0.4],
179-
vertical_lines=[0.028])
178+
dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], range_x=[0, 0.4],
179+
vertical_lines_to_add=[0.028])
180180

181181
# %% [markdown]
182182
# Just as we concluded in experiment `cascade_2_a`, the earlier part of the complex (compound) reaction `A <-> C` cannot be modeled by an elementary reaction, while the later part can indeed be modeled by a 1st order elementary reaction, with kinetics similar to the slower `A <-> B` reaction. This time, with a greater disparity between the two elementary reaction, the transition happens much sooner.

experiments/reactions_single_compartment/cascade_2_c.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@
121121
# Let's visually locate at what times those [A] values occur:
122122

123123
# %%
124-
dynamics.plot_history(chemicals='A', colors='darkturquoise', xrange=[0, 0.15],
125-
vertical_lines=[0.028, 0.1], title="[A] as a function of time")
124+
dynamics.plot_history(chemicals='A', colors='darkturquoise', range_x=[0, 0.15],
125+
vertical_lines_to_add=[0.028, 0.1], title="[A] as a function of time")
126126

127127
# %%
128128
dynamics.get_history(columns=["SYSTEM TIME", "A"], t_start=0.02, t_end=0.03)
@@ -190,8 +190,8 @@
190190
# Let's see the time evolution again, but just for `A` and `C`:
191191

192192
# %%
193-
dynamics.plot_history(chemicals=['A', 'C'], colors=['darkturquoise', 'green'], xrange=[0, 0.25],
194-
vertical_lines=[0.028, 0.1], title='A <-> C compound reaction')
193+
dynamics.plot_history(chemicals=['A', 'C'], colors=['darkturquoise', 'green'], range_x=[0, 0.25],
194+
vertical_lines_to_add=[0.028, 0.1], title='A <-> C compound reaction')
195195

196196
# %% [markdown]
197197
# For t > 0.1, the product [C] appears to have a lot of response to nearly non-existing changes in [A] !

experiments/reactions_single_compartment/cycles_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202

203203
# %%
204204
# Show the timestepe taken (vertical dashed lines) in a small section of the plot
205-
dynamics.plot_history(chemicals=["A", "B", "C"], show_intervals=True, xrange=[2.5, 3.5])
205+
dynamics.plot_history(chemicals=["A", "B", "C"], show_intervals=True, range_x=[2.5, 3.5])
206206

207207
# %%
208208
dynamics.explain_time_advance() # Notice a lot of timestep adjustments, as needed

0 commit comments

Comments
 (0)