#!/usr/bin/env python # coding: utf-8 # ### A MINIMALIST, "get-started", demonstration for the reaction `A <-> B`, # with 1st-order kinetics in both directions, taken to equilibrium. # # **"No frills!"** For advanced graphics, analysis, diagnostics, fine-tuning, etc, please see other experiments. # In[1]: LAST_REVISED = "July 24, 2024" LIFE123_VERSION = "1.0.0.beta.37" # Version this experiment is based on # In[ ]: #import set_path # Using MyBinder? Uncomment this before running the next cell! # In[2]: #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 import life123 # In[3]: life123.check_version(LIFE123_VERSION) # In[ ]: # ## Initialize the System # In[4]: # Instantiate the simulator and specify the chemicals dynamics = life123.UniformCompartment(names=["A", "B"]) # Reaction A <-> B , with 1st-order kinetics in both directions dynamics.add_reaction(reactants="A", products="B", forward_rate=3., reverse_rate=2.) dynamics.describe_reactions() # In[5]: # Set the initial concentrations of all the chemicals dynamics.set_conc({"A": 80., "B": 10.}) # ## Run the reaction # In[6]: dynamics.single_compartment_react(initial_step=0.1, target_end_time=1.) # Using defaults for all other parameters # In[7]: dynamics.get_history() # The system's history, saved during the run of single_compartment_react() # ## Plots changes of concentration with time # Notice that adaptive variable time steps were automatically taken # In[8]: dynamics.plot_history(show_intervals=True) # In[9]: # Verify that the reaction has reached equilibrium dynamics.is_in_equilibrium() # In[ ]: