A up-regulates B ,¶A + X <-> 2B (mostly forward), where X is plentiful¶1st-order kinetics.
If [A] is low, [B] remains low, too. Then, if [A] goes high, then so does [B]. However, at that point, A can no longer bring B down to any substantial extent.
See also the experiment "1D/reactions/up_regulation_1"
LAST REVISED: May 26, 2023
import set_path # Importing this module will add the project's home directory to sys.path
Added 'D:\Docs\- MY CODE\BioSimulations\life123-Win7' to sys.path
from experiments.get_notebook_info import get_notebook_basename
from src.modules.reactions.reaction_data import ReactionData as chem
from src.modules.reactions.reaction_dynamics import ReactionDynamics
import numpy as np
import plotly.express as px
from src.modules.visualization.graphic_log import GraphicLog
# Initialize the HTML logging
log_file = get_notebook_basename() + ".log.htm" # Use the notebook base filename for the log file
# Set up the use of some specified graphic (Vue) components
GraphicLog.config(filename=log_file,
components=["vue_cytoscape_1"],
extra_js="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.21.2/cytoscape.umd.js")
-> Output will be LOGGED into the file 'up_regulate_1.log.htm'
# Initialize the system
chem_data = chem(names=["A", "X", "B"])
# Reaction A + X <-> 2B , with 1st-order kinetics for all species
chem_data.add_reaction(reactants=[("A") , ("X")], products=[(2, "B")],
forward_rate=8., reverse_rate=2.)
chem_data.describe_reactions()
# Send the plot of the reaction network to the HTML log file
graph_data = chem_data.prepare_graph_network()
GraphicLog.export_plot(graph_data, "vue_cytoscape_1")
Number of reactions: 1 (at temp. 25 C) 0: A + X <-> 2 B (kF = 8 / kR = 2 / Delta_G = -3,436.56 / K = 4) | 1st order in all reactants & products [GRAPHIC ELEMENT SENT TO LOG FILE `up_regulate_1.log.htm`]
dynamics = ReactionDynamics(reaction_data=chem_data)
dynamics.set_conc(conc={"A": 5., "X": 100., "B": 0.},
snapshot=True) # A is scarce, X is plentiful, B is absent
dynamics.describe_state()
SYSTEM STATE at Time t = 0: 3 species: Species 0 (A). Conc: 5.0 Species 1 (X). Conc: 100.0 Species 2 (B). Conc: 0.0
dynamics.set_diagnostics() # To save diagnostic information about the call to single_compartment_react()
# All of these settings are currently close to the default values... but subject to change; set for repeatability
dynamics.set_thresholds(norm="norm_A", low=0.5, high=0.8, abort=1.44)
dynamics.set_thresholds(norm="norm_B", low=0.08, high=0.5, abort=1.5)
dynamics.set_step_factors(upshift=1.5, downshift=0.5, abort=0.5)
dynamics.set_error_step_factor(0.5)
dynamics.single_compartment_react(initial_step=0.0005, reaction_duration=0.015,
variable_steps=True, explain_variable_steps=False)
INFO: the tentative time step (0.0005) leads to a least one norm value > its ABORT threshold:
-> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 0.00025) [Step started at t=0, and will rewind there]
Some steps were backtracked and re-done, to prevent negative concentrations or excessively large concentration changes
55 total step(s) taken
dynamics.plot_curves(colors=['red', 'darkorange', 'green'])
A, as the scarse limiting reagent, stops the reaction.
As long as A is low, B also remains low.
dynamics.get_history()
| SYSTEM TIME | A | X | B | caption | |
|---|---|---|---|---|---|
| 0 | 0.000000 | 5.000000 | 100.000000 | 0.000000 | Initial state |
| 1 | 0.000250 | 4.000000 | 99.000000 | 2.000000 | |
| 2 | 0.000500 | 3.209000 | 98.209000 | 3.582000 | |
| 3 | 0.000625 | 2.894743 | 97.894743 | 4.210514 | |
| 4 | 0.000750 | 2.612415 | 97.612415 | 4.775169 | |
| 5 | 0.000875 | 2.358605 | 97.358605 | 5.282790 | |
| 6 | 0.001000 | 2.130295 | 97.130295 | 5.739410 | |
| 7 | 0.001125 | 1.924814 | 96.924814 | 6.150372 | |
| 8 | 0.001250 | 1.739789 | 96.739789 | 6.520422 | |
| 9 | 0.001375 | 1.573112 | 96.573112 | 6.853775 | |
| 10 | 0.001500 | 1.422906 | 96.422906 | 7.154189 | |
| 11 | 0.001625 | 1.287493 | 96.287493 | 7.425013 | |
| 12 | 0.001750 | 1.165380 | 96.165380 | 7.669240 | |
| 13 | 0.001875 | 1.055228 | 96.055228 | 7.889544 | |
| 14 | 0.002000 | 0.955840 | 95.955840 | 8.088319 | |
| 15 | 0.002125 | 0.866144 | 95.866144 | 8.267712 | |
| 16 | 0.002250 | 0.785177 | 95.785177 | 8.429646 | |
| 17 | 0.002375 | 0.712076 | 95.712076 | 8.575848 | |
| 18 | 0.002500 | 0.646066 | 95.646066 | 8.707868 | |
| 19 | 0.002625 | 0.586449 | 95.586449 | 8.827102 | |
| 20 | 0.002750 | 0.532599 | 95.532599 | 8.934801 | |
| 21 | 0.002875 | 0.483952 | 95.483952 | 9.032095 | |
| 22 | 0.003000 | 0.440001 | 95.440001 | 9.119998 | |
| 23 | 0.003125 | 0.400287 | 95.400287 | 9.199426 | |
| 24 | 0.003250 | 0.364399 | 95.364399 | 9.271201 | |
| 25 | 0.003375 | 0.331967 | 95.331967 | 9.336067 | |
| 26 | 0.003500 | 0.302654 | 95.302654 | 9.394693 | |
| 27 | 0.003625 | 0.276158 | 95.276158 | 9.447683 | |
| 28 | 0.003750 | 0.252209 | 95.252209 | 9.495582 | |
| 29 | 0.003875 | 0.230560 | 95.230560 | 9.538881 | |
| 30 | 0.004000 | 0.210988 | 95.210988 | 9.578024 | |
| 31 | 0.004125 | 0.193294 | 95.193294 | 9.613412 | |
| 32 | 0.004250 | 0.177297 | 95.177297 | 9.645406 | |
| 33 | 0.004375 | 0.162834 | 95.162834 | 9.674332 | |
| 34 | 0.004500 | 0.149757 | 95.149757 | 9.700487 | |
| 35 | 0.004625 | 0.137932 | 95.137932 | 9.724135 | |
| 36 | 0.004813 | 0.121895 | 95.121895 | 9.756210 | |
| 37 | 0.005000 | 0.108161 | 95.108161 | 9.783677 | |
| 38 | 0.005188 | 0.096400 | 95.096400 | 9.807201 | |
| 39 | 0.005375 | 0.086326 | 95.086326 | 9.827347 | |
| 40 | 0.005563 | 0.077699 | 95.077699 | 9.844602 | |
| 41 | 0.005750 | 0.070310 | 95.070310 | 9.859381 | |
| 42 | 0.005938 | 0.063980 | 95.063980 | 9.872039 | |
| 43 | 0.006125 | 0.058559 | 95.058559 | 9.882882 | |
| 44 | 0.006313 | 0.053915 | 95.053915 | 9.892169 | |
| 45 | 0.006594 | 0.047949 | 95.047949 | 9.904103 | |
| 46 | 0.006875 | 0.043266 | 95.043266 | 9.913469 | |
| 47 | 0.007156 | 0.039590 | 95.039590 | 9.920821 | |
| 48 | 0.007438 | 0.036704 | 95.036704 | 9.926591 | |
| 49 | 0.007859 | 0.033307 | 95.033307 | 9.933386 | |
| 50 | 0.008281 | 0.031005 | 95.031005 | 9.937989 | |
| 51 | 0.008914 | 0.028667 | 95.028667 | 9.942667 | |
| 52 | 0.009863 | 0.026856 | 95.026856 | 9.946289 | |
| 53 | 0.011287 | 0.026110 | 95.026110 | 9.947779 | |
| 54 | 0.013423 | 0.026209 | 95.026209 | 9.947582 | |
| 55 | 0.016626 | 0.026115 | 95.026115 | 9.947769 |
dynamics.explain_time_advance()
From time 0 to 0.0005, in 2 steps of 0.00025 From time 0.0005 to 0.004625, in 33 steps of 0.000125 From time 0.004625 to 0.006313, in 9 steps of 0.000188 From time 0.006313 to 0.007438, in 4 steps of 0.000281 From time 0.007438 to 0.008281, in 2 steps of 0.000422 From time 0.008281 to 0.008914, in 1 step of 0.000633 From time 0.008914 to 0.009863, in 1 step of 0.000949 From time 0.009863 to 0.01129, in 1 step of 0.00142 From time 0.01129 to 0.01342, in 1 step of 0.00214 From time 0.01342 to 0.01663, in 1 step of 0.0032 (55 steps total)
# Verify that the reaction has reached equilibrium
dynamics.is_in_equilibrium()
A + X <-> 2 B
Final concentrations: [B] = 9.948 ; [A] = 0.02612 ; [X] = 95.03
1. Ratio of reactant/product concentrations, adjusted for reaction orders: 4.00855
Formula used: [B] / ([A][X])
2. Ratio of forward/reverse reaction rates: 4.0
Discrepancy between the two values: 0.2137 %
Reaction IS in equilibrium (within 1% tolerance)
True
dynamics.set_chem_conc(species_name="A", conc=50., snapshot=True)
dynamics.describe_state()
SYSTEM STATE at Time t = 0.016626465: 3 species: Species 0 (A). Conc: 50.0 Species 1 (X). Conc: 95.02611534596562 Species 2 (B). Conc: 9.947769308068802
dynamics.get_history(tail=5)
| SYSTEM TIME | A | X | B | caption | |
|---|---|---|---|---|---|
| 52 | 0.009863 | 0.026856 | 95.026856 | 9.946289 | |
| 53 | 0.011287 | 0.026110 | 95.026110 | 9.947779 | |
| 54 | 0.013423 | 0.026209 | 95.026209 | 9.947582 | |
| 55 | 0.016626 | 0.026115 | 95.026115 | 9.947769 | |
| 56 | 0.016626 | 50.000000 | 95.026115 | 9.947769 | Set concentration of `A` |
dynamics.single_compartment_react(initial_step=0.0005, target_end_time=0.035,
variable_steps=True, explain_variable_steps=False)
INFO: the tentative time step (0.0005) leads to a least one norm value > its ABORT threshold:
-> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 0.00025) [Step started at t=0.016626, and will rewind there]
INFO: the tentative time step (0.00025) leads to a least one norm value > its ABORT threshold:
-> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 0.000125) [Step started at t=0.016626, and will rewind there]
INFO: the tentative time step (0.000125) leads to a least one norm value > its ABORT threshold:
-> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 6.25e-05) [Step started at t=0.016626, and will rewind there]
INFO: the tentative time step (6.25e-05) leads to a least one norm value > its ABORT threshold:
-> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 3.125e-05) [Step started at t=0.016626, and will rewind there]
Some steps were backtracked and re-done, to prevent negative concentrations or excessively large concentration changes
78 total step(s) taken
dynamics.plot_curves(colors=['red', 'darkorange', 'green'])
A, still the limiting reagent, is again stopping the reaction.
The (transiently) high value of [A] led to a high value of [B]
#dynamics.get_history()
#dynamics.explain_time_advance()
# Verify that the reaction has reached equilibrium
dynamics.is_in_equilibrium()
A + X <-> 2 B
Final concentrations: [B] = 108.8 ; [A] = 0.5945 ; [X] = 45.62
1. Ratio of reactant/product concentrations, adjusted for reaction orders: 4.00995
Formula used: [B] / ([A][X])
2. Ratio of forward/reverse reaction rates: 4.0
Discrepancy between the two values: 0.2488 %
Reaction IS in equilibrium (within 1% tolerance)
True
dynamics.set_chem_conc(species_name="A", conc=30., snapshot=True)
dynamics.describe_state()
SYSTEM STATE at Time t = 0.03752232: 3 species: Species 0 (A). Conc: 30.0 Species 1 (X). Conc: 45.62063150861952 Species 2 (B). Conc: 108.75873698276109
dynamics.get_history(tail=5)
| SYSTEM TIME | A | X | B | caption | |
|---|---|---|---|---|---|
| 131 | 0.030573 | 0.673295 | 45.699410 | 108.601180 | |
| 132 | 0.032036 | 0.630941 | 45.657056 | 108.685887 | |
| 133 | 0.034231 | 0.602230 | 45.628346 | 108.743309 | |
| 134 | 0.037522 | 0.594516 | 45.620632 | 108.758737 | |
| 135 | 0.037522 | 30.000000 | 45.620632 | 108.758737 | Set concentration of `A` |
dynamics.single_compartment_react(initial_step=0.0005, target_end_time=0.070,
variable_steps=True, explain_variable_steps=False)
INFO: the tentative time step (0.0005) leads to a least one norm value > its ABORT threshold:
-> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 0.00025) [Step started at t=0.037522, and will rewind there]
INFO: the tentative time step (0.00025) leads to a least one norm value > its ABORT threshold:
-> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.5 (set to 0.000125) [Step started at t=0.037522, and will rewind there]
41 total step(s) taken
dynamics.plot_curves(colors=['red', 'darkorange', 'green'])
A, again the scarce limiting reagent, stops the reaction yet again.
And, again, the (transiently) high value of [A] up-regulated [B]
Notes:
A can up-regulate B, but it cannot bring it down.
X will soon need to be replenished, if A is to continue being the limiting reagent.**
# Look up the some of the intersections of the [A] and [B] curves
dynamics.curve_intersection("A", "B", t_start=0, t_end=0.01)
Min abs distance found at data row: 2
(0.0004607037505267594, 3.333333333333333)
dynamics.curve_intersection("A", "B", t_start=0.0151, t_end=0.02)
Min abs distance found at data row: 73
(0.017062701624030972, 36.64925643602293)
Note: the curve_intersection() function currently cannot location the intersection at t=0.015 (the vertical rise in the red line); this issue will get addressed in future versions...
#dynamics.get_history()
#dynamics.explain_time_advance()
# Verify that the reaction has reached equilibrium
dynamics.is_in_equilibrium()
A + X <-> 2 B
Final concentrations: [B] = 164.2 ; [A] = 2.29 ; [X] = 17.91
1. Ratio of reactant/product concentrations, adjusted for reaction orders: 4.00332
Formula used: [B] / ([A][X])
2. Ratio of forward/reverse reaction rates: 4.0
Discrepancy between the two values: 0.08288 %
Reaction IS in equilibrium (within 1% tolerance)
True