|
13 | 13 | # --- |
14 | 14 |
|
15 | 15 | # %% [markdown] |
16 | | -# ## A complex (multistep) reaction `A <-> C` derived from 2 coupled elementary reactions: |
| 16 | +# ## A complex (composite/multistep) reaction `A <-> C` derived from 2 coupled elementary reactions: |
17 | 17 | # ## `A <-> B` and `B <-> C` |
18 | 18 | # We are given the time evolution of the complex reaction, |
19 | 19 | # and want to determine whether it can be modeled as an elementary reaction. |
|
22 | 22 | # In PART 2, the time functions generated in Part 1 are taken as a _starting point,_ to explore how to model the composite reaction `A <-> C` |
23 | 23 | # |
24 | 24 | # **Background**: please see experiments `cascade_1` and `mystery_reaction_1` |
25 | | -# |
26 | | -# LAST REVISED: June 23, 2024 (using v. 1.0 beta36) |
27 | 25 |
|
28 | 26 | # %% |
29 | | -import set_path # Importing this module will add the project's home directory to sys.path |
| 27 | +LAST_REVISED = "July 26, 2024" |
| 28 | +LIFE123_VERSION = "1.0.0.beta.38" # Version this experiment is based on |
| 29 | + |
| 30 | +# %% |
| 31 | +#import set_path # Using MyBinder? Uncomment this before running the next cell! |
| 32 | + # Importing this module will add the project's home directory to sys.path |
30 | 33 |
|
31 | 34 | # %% tags=[] |
32 | | -from experiments.get_notebook_info import get_notebook_basename |
| 35 | +#import sys |
| 36 | +#sys.path.append("C:/some_path/my_env_or_install") # CHANGE to the folder containing your venv or libraries installation! |
| 37 | +# NOTE: If any of the imports below can't find a module, uncomment the lines above, or try: import set_path |
33 | 38 |
|
34 | | -from life123 import UniformCompartment |
35 | | -from life123.visualization.plotly_helper import PlotlyHelper |
| 39 | +from life123 import check_version, UniformCompartment, PlotlyHelper |
| 40 | + |
| 41 | +# %% |
| 42 | +check_version(LIFE123_VERSION) |
36 | 43 |
|
37 | 44 | # %% |
38 | 45 |
|
|
44 | 51 |
|
45 | 52 | # %% tags=[] |
46 | 53 | # Instantiate the simulator and specify the chemicals |
47 | | -dynamics = UniformCompartment(names=["A", "B", "C"], preset="mid") |
| 54 | +dynamics = UniformCompartment(preset="mid") |
48 | 55 |
|
49 | 56 | # Reaction A <-> B (slower, and with a smaller K) |
50 | 57 | dynamics.add_reaction(reactants="A", products="B", |
|
73 | 80 | dynamics.plot_history(colors=['darkturquoise', 'orange', 'green'], show_intervals=True) |
74 | 81 |
|
75 | 82 | # %% |
76 | | -dynamics.is_in_equilibrium(tolerance=15) |
| 83 | +dynamics.is_in_equilibrium(tolerance=12) |
77 | 84 |
|
78 | 85 | # %% |
79 | 86 |
|
|
87 | 94 | # Let's start by taking stock of the actual data (saved during the simulation of part 1): |
88 | 95 |
|
89 | 96 | # %% |
90 | | -df = dynamics.get_history(columns=["SYSTEM TIME", "A", "C", "caption"]) # We're NOT given the intermediary B |
| 97 | +# For this analysis, we're NOT given the intermediary B |
| 98 | +df = dynamics.get_history(columns=["SYSTEM TIME", "A", "C", "caption"]) |
91 | 99 | df |
92 | 100 |
|
93 | 101 | # %% [markdown] |
|
111 | 119 | # Let's see what happens if we try to do such a linear fit! |
112 | 120 |
|
113 | 121 | # %% |
114 | | -dynamics.estimate_rate_constants(t=t_arr, reactant_conc=A_conc, product_conc=C_conc, reactant_name="A", product_name="C") |
| 122 | +dynamics.estimate_rate_constants_simple(t=t_arr, A_conc=A_conc, B_conc=C_conc, reactant_name="A", product_name="C") |
115 | 123 |
|
116 | 124 | # %% [markdown] |
117 | 125 | # ### The least-square fit is awful : the complex reaction `A <-> C` doesn't seem to be amenable to being modeled as a simple reaction with some suitable rate constants |
118 | | -# Probably not too surprising given our "secret" knowledge from Part 1 that the complex reaction originates from 2 elementary reactions where one doesn't dominate the other one in terms of reaction kinetics |
| 126 | +# Probably not too surprising given our "secret" knowledge from Part 1 that the complex reaction originates from 2 elementary reactions where the intermediate product builds up at one point |
119 | 127 |
|
120 | 128 | # %% [markdown] |
121 | 129 | # ### A glance at the above diagram reveals much-better linear fits, if split into 2 portions, one where A(t) ranges from 0 to about 24, and one from about 24 to 50 |
|
135 | 143 |
|
136 | 144 | # %% [markdown] |
137 | 145 | # ### Let's split the `A_conc` and `C_conc` arrays we extracted earlier (with the entire time evolution of, respectively, [A] and [C]) into two parts: |
138 | | -# 1) points numbered 0-47 |
139 | | -# 2) points 48-end |
| 146 | +# 1) points numbered 0 thru 47 |
| 147 | +# 2) points 48 - end |
140 | 148 |
|
141 | 149 | # %% |
142 | 150 | A_conc_early = A_conc[:48] |
|
161 | 169 | # ### I. Let's start with the EARLY region, when t < 0.1 |
162 | 170 |
|
163 | 171 | # %% |
164 | | -dynamics.estimate_rate_constants(t=t_arr_early, reactant_conc=A_conc_early, product_conc=C_conc_early, |
165 | | - reactant_name="A", product_name="C") |
| 172 | +dynamics.estimate_rate_constants_simple(t=t_arr_early, A_conc=A_conc_early, B_conc=C_conc_early, |
| 173 | + reactant_name="A", product_name="C") |
166 | 174 |
|
167 | 175 | # %% [markdown] |
168 | 176 | # Trying to fit an elementary reaction to that region leads to a **negative** reverse rate constant! |
169 | | -# It's not 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`): |
| 177 | +# 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`): |
170 | 178 |
|
171 | 179 | # %% |
172 | 180 | dynamics.plot_history(colors=['darkturquoise', 'green'], xrange=[0, 0.4], vertical_lines=[0.1], |
|
177 | 185 | # when the reactant `A` is plentiful, the rate of change (gradient) of the product `C` is low - and vice versa. |
178 | 186 | # Does that look like an elementary reaction in its kinetics? Nope! |
179 | 187 |
|
| 188 | +# %% |
| 189 | + |
180 | 190 | # %% [markdown] |
181 | 191 | # ### II. And now let's consider the LATE region, when t > 0.1 |
182 | 192 |
|
183 | 193 | # %% |
184 | | -dynamics.estimate_rate_constants(t=t_arr_late, reactant_conc=A_conc_late, product_conc=C_conc_late, |
185 | | - reactant_name="A", product_name="C") |
| 194 | +dynamics.estimate_rate_constants_simple(t=t_arr_late, A_conc=A_conc_late, B_conc=C_conc_late, |
| 195 | + reactant_name="A", product_name="C") |
186 | 196 |
|
187 | 197 | # %% [markdown] |
188 | 198 | # This time we have an adequate linear fit AND meaningful rate constants : kF of about 8 and kR of about 0. Do those numbers sound familiar? A definite resemblance to the kF=8, kR=2 of the SLOWER elementary reaction `A <-> B`! |
189 | 199 | # |
190 | | -# #### The slower `A <-> B` reaction dominates the kinetics from about t=0.1 |
| 200 | +# #### The slower `A <-> B` reaction dominates the kinetics, from about t=0.1 on |
191 | 201 | # |
192 | 202 | # Let's see the graph again: |
193 | 203 |
|
|
204 | 214 | # The slow link (`A <-> B`) largely determines the kinetics of the supply line. |
205 | 215 |
|
206 | 216 | # %% [markdown] |
207 | | -# ### While it's a well-known Chemistry notion that the slower reaction is the rate-determining step in a chain, we saw in this experiment that the complex reaction could be roughly modeled with the rate constants of the slower reaction only after some time. |
| 217 | +# ### While it's a well-known Chemistry notion that the slower reaction is the rate-determining step in a chain, we saw in this experiment that **the complex reaction could be roughly modeled with the rate constants of the slower reaction ONLY AFTER SOME TIME**. |
208 | 218 |
|
209 | 219 | # %% [markdown] |
210 | 220 | # If we were interested in early transients (for example, if diffusion quickly intervened), we couldn't use that model. |
211 | 221 |
|
| 222 | +# %% [markdown] |
| 223 | +# #### Is that surprising? At early times, compare the inflection of the final product, C, of the composite reaction vs. the inflection of the product of a simple reaction (such as B in experiment `react1`, both appearing in green.) |
| 224 | + |
| 225 | +# %% |
| 226 | + |
212 | 227 | # %% [markdown] |
213 | 228 | # #### In the continuation experiment, `cascade_2_b`, we explore the scenario where the 2 elementary reactions are much more different from each other |
214 | 229 |
|
|
0 commit comments