Examples and tutorials#

Running premade examples#

MUSICA provides a selection of pre-made example configurations for the user to work with:

Each example (found in configs/v0) includes an associated set of JSON files acccessible through the a MICM solver:

import musica

solver = musica.MICM(
    config_path="/configs/v0/analytical",
    solver_type=musica.SolverType.rosenbrock_standard_order)
state = solver.create_state()

#set conditions
temperature = 272.5
pressure = 101253.3
concentrations = {
    "A": 0.75,
    "B": 0,
    "C": 0.4,
    "D": 0.8,
    "E": 0,
    "F": 0.1
}

state.set_conditions(temperature, pressure)
state.set_concentrations(concentrations)

#solve
sim_length =  100
time_step = 1
curr_time = time_step
while curr_time <= sim_length:
    solver.solve(state, time_step)
    concentrations = state.get_concentrations()
    print(concentrations)
    curr_time += time_step

Interactive tutorial notebooks#

Looking for hands on examples of the concepts covered in this guide? Explore our Tutorials page for detailed, interactive walkthroughs.