In [1]:
from jLM.CME import CMESimulation
from jLM.units import *
In [2]:
outputFile = "lac2state.lm"
In [3]:
# Create our simulation object
sim = CMESimulation()
In [4]:
# Add the reactants
species = ['R2', 'O', 'R2O', 'IR2', 'IR2O', 'I2R2', 'I2R2O', 'mY', 'Y', 'I', 'Iex', 'YI']
sim.defineSpecies(species)
In [5]:
# Add the reactions
# Lac operon regulation
scalar = 2.076e-9
sim.addReaction(reactant = ('R2', 'O'),   product = 'R2O',         rate = 2.43e6 * scalar)
sim.addReaction(reactant = ('IR2', 'O'),  product = 'IR2O',        rate = 1.21e6 * scalar)
sim.addReaction(reactant = ('I2R2', 'O'), product = 'I2R2O',       rate = 2.43e4 * scalar)
sim.addReaction(reactant = 'R2O',         product = ('R2', 'O'),   rate = 6.30e-4)
sim.addReaction(reactant = 'IR2O',        product = ('IR2', 'O'),  rate = 6.30e-4)
sim.addReaction(reactant = 'I2R2O',       product = ('I2R2', 'O'), rate = 3.15e-1)
In [6]:
# Transcription, translation, and degredation
sim.addReaction(reactant = 'O',  product = ('O', 'mY'), rate = 1.26e-1)
sim.addReaction(reactant = 'mY', product = ('mY', 'Y'), rate = 4.44e-2)
sim.addReaction(reactant = 'mY', product = '',          rate = 1.11e-2)
sim.addReaction(reactant = 'Y',  product = '',          rate = 2.10e-4)
In [7]:
# Inducer-repressor interactions
sim.addReaction(reactant = ('I', 'R2'),   product = 'IR2',         rate = 2.27e4 * scalar)
sim.addReaction(reactant = ('I', 'IR2'),  product = 'I2R2',        rate = 1.14e4 * scalar)
sim.addReaction(reactant = ('I', 'R2O'),  product = 'IR2O',        rate = 6.67e2 * scalar)
sim.addReaction(reactant = ('I', 'IR2O'), product = 'I2R2O',       rate = 3.33e2 * scalar)
sim.addReaction(reactant = 'IR2',         product = ('I', 'R2'),   rate = 2.00e-1)
sim.addReaction(reactant = 'I2R2',        product = ('I', 'IR2'),  rate = 4.00e-1)
sim.addReaction(reactant = 'IR2O',        product = ('I', 'R2O'),  rate = 1.00)
sim.addReaction(reactant = 'I2R2O',       product = ('I', 'IR2O'), rate = 2.00)
In [8]:
# Inducer transport
sim.addReaction(reactant = 'Iex',        product = 'I',           rate = 2.33e-3)
sim.addReaction(reactant = 'I',          product = 'Iex',         rate = 2.33e-3)
sim.addReaction(reactant = ('Y', 'Iex'), product = ('YI', 'Iex'), rate = 3.03e4 * scalar)
sim.addReaction(reactant = 'YI',         product = ('Y', 'Iex'),  rate = 1.20e-1)
sim.addReaction(reactant = 'YI',         product = ('Y', 'I'),    rate = 1.20e+1)
In [9]:
# Populate the model with particles
sim.addParticles(species = 'R2',  count = 9)
sim.addParticles(species = 'O',   count = 1)
sim.addParticles(species = 'Y',   count = 30)
sim.addParticles(species = 'I',   count = 7224)
sim.addParticles(species = 'Iex', count = 7224)
In [10]:
# Set up the times
sim.setTimestep(ms(1))
sim.setWriteInterval(1)
sim.setSimulationTime(3600.0)
In [11]:
import os

# Save the simulation state to a file
os.system("rm -rf %s"%(outputFile))
sim.save(outputFile)
In [12]:
# Run the simulation for 10 hours
# This time we use the Next Reaction Solver instead of the Gillespie solver to speed
# up the time to solution.
sim.run(filename = outputFile, method = "lm::cme::NextReactionSolver", replicates = 10)
  0%|          | 0/10 [00:00<?, ?it/s]
2025-09-02 15:32:22) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:22) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:22) Info: Data output thread running.
2025-09-02 15:32:22) Info: Seeding xorwow rng with top word 1 and bottom word 573371301
2025-09-02 15:32:22) Info: Data output thread finished.
2025-09-02 15:32:22) Info: Simulation file closed.
 10%|#         | 1/10 [00:00<00:03,  2.88it/s]
2025-09-02 15:32:22) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:22) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:22) Info: Data output thread running.
2025-09-02 15:32:22) Info: Seeding xorwow rng with top word 2 and bottom word 698312064
2025-09-02 15:32:26) Info: Data output thread finished.
2025-09-02 15:32:26) Info: Simulation file closed.
 20%|##        | 2/10 [00:03<00:18,  2.29s/it]
2025-09-02 15:32:26) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:26) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:26) Info: Data output thread running.
2025-09-02 15:32:26) Info: Seeding xorwow rng with top word 3 and bottom word 347107806
2025-09-02 15:32:26) Info: Data output thread finished.
2025-09-02 15:32:26) Info: Simulation file closed.
 30%|###       | 3/10 [00:04<00:09,  1.35s/it]
2025-09-02 15:32:26) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:26) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:26) Info: Data output thread running.
2025-09-02 15:32:26) Info: Seeding xorwow rng with top word 4 and bottom word 569791139
2025-09-02 15:32:27) Info: Data output thread finished.
2025-09-02 15:32:27) Info: Simulation file closed.
 40%|####      | 4/10 [00:05<00:06,  1.16s/it]
2025-09-02 15:32:27) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:27) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:27) Info: Data output thread running.
2025-09-02 15:32:27) Info: Seeding xorwow rng with top word 5 and bottom word 437378553
2025-09-02 15:32:28) Info: Data output thread finished.
2025-09-02 15:32:28) Info: Simulation file closed.
 50%|#####     | 5/10 [00:05<00:05,  1.02s/it]
2025-09-02 15:32:28) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:28) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:28) Info: Data output thread running.
2025-09-02 15:32:28) Info: Seeding xorwow rng with top word 6 and bottom word 221016466
2025-09-02 15:32:29) Info: Data output thread finished.
2025-09-02 15:32:29) Info: Simulation file closed.
 60%|######    | 6/10 [00:06<00:03,  1.04it/s]
2025-09-02 15:32:29) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:29) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:29) Info: Data output thread running.
2025-09-02 15:32:29) Info: Seeding xorwow rng with top word 7 and bottom word 62178899
2025-09-02 15:32:29) Info: Data output thread finished.
2025-09-02 15:32:29) Info: Simulation file closed.
 70%|#######   | 7/10 [00:07<00:02,  1.27it/s]
2025-09-02 15:32:29) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:29) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:29) Info: Data output thread running.
2025-09-02 15:32:29) Info: Seeding xorwow rng with top word 8 and bottom word 490162536
2025-09-02 15:32:34) Info: Data output thread finished.
2025-09-02 15:32:34) Info: Simulation file closed.
 80%|########  | 8/10 [00:12<00:04,  2.08s/it]
2025-09-02 15:32:34) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:34) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:34) Info: Data output thread running.
2025-09-02 15:32:34) Info: Seeding xorwow rng with top word 9 and bottom word 354472169
2025-09-02 15:32:35) Info: Data output thread finished.
2025-09-02 15:32:35) Info: Simulation file closed.
 90%|######### | 9/10 [00:12<00:01,  1.74s/it]
2025-09-02 15:32:35) Info: Using 32 processor(s) and 1 CUDA device(s) per process.
2025-09-02 15:32:35) Info: Assigning 1.00 processor(s) and 1.00 CUDA device(s) per replicate.
2025-09-02 15:32:35) Info: Data output thread running.
2025-09-02 15:32:35) Info: Seeding xorwow rng with top word 10 and bottom word 321184383
2025-09-02 15:32:35) Info: Data output thread finished.
2025-09-02 15:32:35) Info: Simulation file closed.
100%|##########| 10/10 [00:13<00:00,  1.32s/it]