wntr.sim.core module¶
- class wntr.sim.core.WaterNetworkSimulator(wn=None)[source]¶
Bases:
object
Base water network simulator class.
- wnWaterNetworkModel object
Water network model
Warning
The mode parameter has been deprecated. Please set the mode using the network option, wn.options.hydraulic.demand_model.
- class wntr.sim.core.WNTRSimulator(wn)[source]¶
Bases:
wntr.sim.core.WaterNetworkSimulator
WNTR simulator class. The WNTR simulator uses a custom newton solver and linear solvers from scipy.sparse.
- Parameters
wn (WaterNetworkModel object) – Water network model
Note
The mode parameter has been deprecated. Please set the mode using Options.hydraulic.demand_model
- run_sim(solver=<class 'wntr.sim.solvers.NewtonSolver'>, backup_solver=None, solver_options=None, backup_solver_options=None, convergence_error=False, HW_approx='default', diagnostics=False)[source]¶
Run an extended period simulation (hydraulics only).
- Parameters
solver (object) – wntr.sim.solvers.NewtonSolver or Scipy solver
backup_solver (object) – wntr.sim.solvers.NewtonSolver or Scipy solver
solver_options (dict) –
Solver options are specified using the following dictionary keys:
MAXITER: the maximum number of iterations for each hydraulic solve (each timestep and trial) (default = 3000)
TOL: tolerance for the hydraulic equations (default = 1e-6)
BT_RHO: the fraction by which the step length is reduced at each iteration of the line search (default = 0.5)
BT_MAXITER: the maximum number of iterations for each line search (default = 100)
BACKTRACKING: whether or not to use a line search (default = True)
BT_START_ITER: the newton iteration at which a line search should start being used (default = 2)
THREADS: the number of threads to use in constraint and jacobian computations
backup_solver_options (dict) –
convergence_error (bool (optional)) – 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 = False.
HW_approx (str) – Specifies which Hazen-Williams headloss approximation to use. Options are ‘default’ and ‘piecewise’. Please see the WNTR documentation on hydraulics for details.
diagnostics (bool) – If True, then run with diagnostics on