Skip to content

Input conventions

ode2sbml supports three input conventions.

Convention A: scipy-style RHS function

Required structure:

state_vars = ["x"]
param_names = ["k"]
initial_conditions = {"x": 1.0}
parameter_values = {"k": 0.2}


def model(t, y, p):
    x = y[0]
    k = p[0]
    dx = -k * x
    return [dx]

Use this when your model already exists as simulation code.

AST parsing limitations

Convention A depends on static parsing of assignments and return values. Dynamic derivative construction is not a good fit.

Convention B: dict-of-formulas

Required keys:

model = {
    "species": {"x": 1.0},
    "parameters": {"k": 0.2},
    "odes": {"x": "-k*x"},
}

Optional keys:

"compartments"
"parameter_units"
"assignment_rules"
"events"

Use this for transparent, version-control-friendly model files.

Convention C: SymPy symbolic system

Required module-level variables:

odes = {x: -k*x}
params = {k: 0.2}
inits = {x: 1.0}

Use this when symbolic manipulation is part of your workflow.

Selection guide

Use case Recommended convention
Existing scipy simulation function A
Documentation, tests, reproducible examples B
Symbolic derivation or simplification C
Large curated models B or direct ODEModel construction