Skip to content

Commit 4fee00c

Browse files
committed
docs: add {state}_init initial value docs
Document the new `{state}_init` suffix for referencing a state's initial value inside ODE equations. Adds a brief example showing `S` vs `S_init`, explains use cases (e.g. normalization or driving terms by initial concentration), and notes that the referenced state must exist (raises ValueError if not), `_init` symbols are not registered as parameters, and current and initial values may be mixed in the same expression.
1 parent 8aefd60 commit 4fee00c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

docs/basic/model-class.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ model.add_odes(
133133
- **Observable states**: By default, all states are observable; use `observable=False` for hidden states
134134
- **Validation**: The system checks for invalid states not yet added to the model.
135135

136+
#### Referencing Initial Values with `_init`
137+
138+
Equations can reference the **initial value** of any state using the `{state}_init` suffix. While a bare state symbol (e.g. `S`) refers to the current, time-varying value, `S_init` resolves to the concentration the state was initialized with at the start of the simulation.
139+
140+
```python
141+
# `S` is the current value; `S_init` is the initial value of S
142+
model.add_ode("S", "-k * S") # S decays exponentially
143+
model.add_ode("P", "k * S_init") # P grows at a rate set by the initial S
144+
```
145+
146+
This is useful whenever a rate should depend on a starting concentration rather than the current one — for example, normalizing against a total initial pool or driving a term by an initial loading.
147+
148+
**Key points:**
149+
150+
- The referenced state must already exist in the model, otherwise a `ValueError` is raised.
151+
- `_init` symbols are **not** registered as parameters; they are resolved from the simulation's initial conditions per measurement.
152+
- The same equation can mix current values and initial values freely (e.g. `S / S_init`).
153+
136154
### Step 4: Parameter Configuration
137155

138156
Configure model parameters with values, bounds, and constraints:

0 commit comments

Comments
 (0)