set_demand_pattern
Create or replace a demand pattern and attach it to junctions, validating the edit against EPANET engine before applying.
Instructions
Add or replace a demand pattern ([PATTERNS]) and attach it to one or more junctions, so base demands vary over the simulation (e.g. an hourly diurnal curve with morning and evening peaks). The edit is validated against the EPANET engine before it is applied: the pattern id must be valid, each multiplier must be between 0 and 10 (and not all zero), every listed junction must exist and be a junction, and the edited model must re-parse with the pattern present at exactly the requested length and values, attached to each junction's demand, with node/link counts unchanged. A previously-solvable model must still solve. An existing pattern with the same id is replaced in place; a junction already using a pattern gets this one instead. Previous simulation results are invalidated — re-run run_simulation afterwards (get_node_results with timesteps returns the hourly variation).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| networkId | Yes | The network id returned by load_network. | |
| patternId | Yes | New or existing demand pattern id (1-31 characters, no spaces and none of: + - . ;). An existing pattern with this id is replaced in place. | |
| junctionIds | Yes | Junctions whose demand should follow this pattern (use get_nodes to list ids). The pattern column is set on each junction's demand (the [JUNCTIONS] demand column, or its [DEMANDS] entries when the model defines demands there). | |
| multipliers | Yes | Multipliers applied to the base demand, one per pattern period (24 values for an hourly diurnal pattern). Each must be between 0 and 10; an all-zero pattern is rejected. The average multiplier scales the daily total — use values averaging 1.0 to keep the daily demand unchanged. |