Convention B: dict-of-formulas
Convention B is the clearest format for reproducible model exchange inside Python.
Example file
Create decay_dict.py:
model = {
"species": {
"x": 1.0,
},
"parameters": {
"k": 0.2,
},
"parameter_units": {
"k": "per_second",
},
"odes": {
"x": "-k*x",
},
"compartments": {
"cell": 1.0,
},
}
Convert
Add assignment rules
model = {
"species": {"S": 10.0, "P": 0.0},
"parameters": {"k": 0.1},
"odes": {
"S": "-flux",
"P": "flux",
},
"assignment_rules": {
"flux": "k*S",
},
}
Add events
model = {
"species": {"x": 0.0},
"parameters": {"k": 1.0},
"odes": {"x": "k"},
"events": [
{
"trigger": "x >= 10",
"assignments": {"x": "0"},
"delay": 0.0,
}
],
}
Best default
Use Convention B for published examples, tests, and tutorials. It is explicit, readable, and avoids AST parsing ambiguity.