add_valve
Insert a pressure-reducing valve (PRV) into an existing pipe to cap downstream pressure at a set value, splitting the pipe and validating the edit against the EPANET engine.
Instructions
Insert a pressure-reducing valve (PRV) in series with an existing pipe: the pipe is split — a new junction is created at a fraction along it, the original pipe is shortened to that junction, and a new PRV link runs from the junction to the pipe's downstream node, capping pressure there at the requested setting (e.g. to protect low-lying tap stands from excess static head). The edit is validated against the EPANET engine before it is applied — unique ids, realistic bounds, the edited model must re-parse with the junction as a junction, the valve as a PRV with the requested setting, and the pipe shortened as requested, node/link counts must increase by exactly one each, and the edited model must still solve hydraulically if the base model did. Previous simulation results are invalidated; re-run run_simulation to see the effect.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| linkId | Yes | Id of the pipe to split with the valve (use get_links to list pipe ids). The PRV is inserted in series: the pipe is shortened and a new junction is created at the split point, so the valve caps pressure at the pipe's downstream node (node2) at the setting. | |
| setting | Yes | PRV pressure setting in the model's pressure units (m for SI models, psi for US-unit models). Range: 0 to 10000. | |
| valveId | Yes | New unique valve id (1-31 characters, no spaces and none of: + - . ;). | |
| diameter | No | Diameter of the new valve (mm for SI models, inches for US-unit models); defaults to the split pipe's diameter. | |
| minorLoss | No | Minor-loss coefficient of the new valve; defaults to 0. | |
| networkId | Yes | The network id returned by load_network. | |
| splitPosition | No | Where along the pipe (fraction from node1 toward node2) the split junction sits; defaults to 0.9 (near the downstream end, so most of the pipe keeps its length). | |
| splitJunctionId | No | New unique junction id at the split point; defaults to '<valveId>J'. |