Water Simulation
sim
contamination
contamination(wn: wntr.network.WaterNetworkModel, inj_nodes: Optional[List[Union[int, str]]] = None, duration: Optional[int] = 24 * 3600, timestep: Optional[int] = 3600, **kwargs: dict) -> pd.DataFrame
Simulate the injection of contaminations in multiple nodes.
The contaminant is injected at the beginning of the simulation.
Parameters:
-
wn(WaterNetworkModel) –The WaterNetworkModel used in the simulations.
-
inj_nodes(Optional[List[Union[int, str]]], default:None) –The list of nodes ids considered as injection points. If None, all the junctions are considered as injection points.
-
duration(Optional[int], default:24 * 3600) –The simulation duration in seconds. By dafault, it is one day (86400 seconds).
-
timestep(Optional[int], default:3600) –The timestep of the simulation in seconds. By dafault, it is one hour (3600 seconds).
-
**kwargs(dict, default:{}) –Additional arguments to pass to the Epanet simulator:
-
file_prefix (str): Default prefix is "temp". All files (.inp, .bin/.out, .hyd, .rpt) use this prefix.
-
use_hyd (bool): Will load hydraulics from
file_prefix + '.hyd'or from file specified inhydfile_name. -
save_hyd (bool): Will save hydraulics to
file_prefix + '.hyd'or to file specified inhydfile_name. -
hydfile (str): Optionally specify a filename for the hydraulics file other than the
file_prefix. -
version (float): Optionally change the version of the EPANET toolkit libraries. Valid choices are either 2.2 (the default if no argument provided) or 2.0.
-
convergence_error (bool): If convergence_error is True, an error will be raised if the simulation does not converge. If convergence_error is False, partial results are returned, a warning will be issued, and results.error_code will be set to 0 if the simulation does not converge. Default is False.
-
Returns:
-
DataFrame–A pandas Dataframe containing the contaminant trace (percentage) for each injection points in each node.
The Dataframe has the following columns:
-
time: Simulation time in seconds. -
node: Node of the water network to which the trace refers. -
<node_id1>, ...,<node_idN>: Nodes of the water network where the contaminant has been injected.
-
Source code in waco/sim.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
water_demand
water_demand(wn: wntr.network.WaterNetworkModel, duration: Optional[int] = 24 * 3600, timestep: Optional[int] = 3600, **kwargs: dict) -> pd.DataFrame
Run a simulation to extract the demand at each node.
Parameters:
-
wn(WaterNetworkModel) –The WaterNetworkModel used in the simulation.
-
duration(Optional[int], default:24 * 3600) –The simulation duration in seconds. By dafault, it is one day (86400 seconds).
-
timestep(Optional[int], default:3600) –The timestep of the simulation in seconds. By dafault, it is one hour (3600 seconds).
-
**kwargs(dict, default:{}) –Additional arguments to pass to the Epanet simulator:
-
file_prefix (str): Default prefix is "temp". All files (.inp, .bin/.out, .hyd, .rpt) use this prefix.
-
use_hyd (bool): Will load hydraulics from
file_prefix + '.hyd'or from file specified inhydfile_name. -
save_hyd (bool): Will save hydraulics to
file_prefix + '.hyd'or to file specified inhydfile_name. -
hydfile (str): Optionally specify a filename for the hydraulics file other than the
file_prefix. -
version (float): Optionally change the version of the EPANET toolkit libraries. Valid choices are either 2.2 (the default if no argument provided) or 2.0.
-
convergence_error (bool): If convergence_error is True, an error will be raised if the simulation does not converge. If convergence_error is False, partial results are returned, a warning will be issued, and results.error_code will be set to 0 if the simulation does not converge. Default is False.
-
Returns:
-
DataFrame–A pandas Dataframe with the demand at each node for each simulation timestep.
The Dataframe has the following columns:
-
time: Simulation time in seconds. -
node: Node of the water network. -
demand: Demand atnodein the simulation timestep identified bytime.
-
Source code in waco/sim.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |