Early implementation
LAST_REVISED = "Feb. 16, 2026"
LIFE123_VERSION = "1.0.0rc7" # Library version this experiment is based on
#import set_path # Using MyBinder? Uncomment this before running the next cell!
# Importing this module will add the project's home directory to sys.path
#import sys, os
#os.getcwd()
#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
import ipynbname
from life123 import check_version, RandomReactionNetwork, UniformCompartment
check_version(LIFE123_VERSION) # To check compatibility
OK
# Initialize the HTML logging (for the graphics)
log_file = ipynbname.name() + ".log.htm" # Use the notebook base filename for the log file
# IN CASE OF PROBLEMS, set manually to any desired name
net = RandomReactionNetwork(n_chems=4, n_rxns=6)
net.chem_data.get_all_labels()
['A', 'B', 'C', 'D']
net.registry.number_of_reactions()
6
for i in range(net.registry.number_of_reactions()):
rxn = net.registry.get_reaction(i)
print(f"({i}) {rxn.describe(concise=False)}")
(0) D + B <-> A Elementary Synthesis reaction (1) A + D <-> B Elementary Synthesis reaction (2) C + A <-> B Elementary Synthesis reaction (3) 2 A <-> B Elementary Synthesis reaction (4) A + B <-> C Elementary Synthesis reaction (5) C <-> A + D Elementary Decomposition reaction
# Instantiate the simulator with our chemicals and reactions
uc = UniformCompartment(reactions=net.registry)
# Send a plot of the network of reactions to the HTML log file
uc.plot_reaction_network(log_file=log_file)
[GRAPHIC ELEMENT SENT TO FILE `random_networks_1.log.htm`]