Simulation#
- class Simulation(inputfile, reportfile=None, outputfile=None, sim_preconfig=None)[source]#
Base class for a SWMM Simulation.
The model object provides several options to run a simulation.
Initialize the Simulation class.
- Parameters:
inpfile (str) – Name of SWMM input file (default ‘’)
rptfile (str) – Report file to generate (default None)
binfile (str) – Optional binary output file (default None)
sim_preconfig (SimulationPreConfig) – Optional Pre Config (default None)
Examples:
Intialize using with statement. This automatically cleans up after a simulation
from pyswmm import Simulation with Simulation('tests/data/model_weir_setting.inp') as sim: for step in sim: pass
Initialize the simulation and execute. This style does not allow the user to interact with the simulation. However, this approach tends to be the fastest.
from pyswmm import Simulation sim = Simulation('tests/data/model_weir_setting.inp') sim.execute()
Methods
Add callback function/method/object to execute after the simulation is closed.
Add callback function/method/object to execute after the simulation ends.
Add callback function/method/object to execute after a simlation start.
Add callback function/method/object to execute after a simlation step.
Add callback function/method/object to execute after the simulation ends.
Add callback function/method/object to execute before the simlation starts.
Add callback function/method/object to execute before a simlation step.
Intialize a simulation and iterate through a simulation.
Open an input file, run SWMM, then close the file.
Starting in PySWMM-v2 this method/function is set to be deprecated.
Writes to report file after simulation (no longer suggested for user).
Save the current state of the model to a hotstart file.
Start Simulation (no longer suggested to user).
Advances the model by X number of seconds instead of intervening at every routing step.
Inserts a request to stop a simulation and cleanly executing the callbacks.
Use a hotstart file to initialize the simulation.
Attributes
Get Simulation Current Time.
Get/set Simulation end time.
Retrieves the SWMM Engine Version.
Retrieves the Flow Routing Mass Balance Error.
Get Simulation Units (CFS, GPM, MGD, CMS, LPS, MLD).
Get Simulation Percent Complete.
Retrieves the Quality Routing Mass Balance Error.
Get/set Simulation report start time.
Retrieves the Runoff Mass Balance Error.
Check is Model is Open
Check is Simulation is Started
Get/set Simulation start time.
Get system units (US, SI).