SimulationPreConfig#
- class SimulationPreConfig[source]#
This class was developed to introduce a simple way to programmatically adjust nearly all model parameters. Once the user instantiates the SimulationPreConfig object the method add_update_by_token can be called for each parameter (by index) that they would like to update. The parameter limits are still up to the user to get right as per the SWMM user’s guide.
The arguments are as follows. In the Base INP file:
[SUBCATCHMENTS] ;; Total Pcnt. Pcnt. Curb ;;Name Raingage Outlet Area Imperv Width Slope Length ;;------ ---------------- -------- ------- ------- ----- ------ -------- S1 SCS_24h_Type_I_1in J1 1 100 500 0.5 0
from pyswmm import Simulation, SimulationPreConfig, Subcatchments # Create Config Handle sim_conf = SimulationPreConfig() # Specifying the update parameters # Parameter Order: # Section, Object ID, Parameter Index, New Value, Obj Row Num (optional) sim_conf.add_update_by_token("SUBCATCHMENTS", "S1", 2, "J2") sim_conf.add_update_by_token("TIMESERIES", "SCS_24h_Type_I_1in", 2, 2, 5) with Simulation(<path-to-inp>, sim_preconfig = sim_conf) as sim: S1 = Subcatchments(sim)["S1"] print(S1.connection) for step in sim: pass
>>> (2, 'J2')
In the New INP file:
[SUBCATCHMENTS] ;; Total Pcnt. Pcnt. Curb ;;Name Raingage Outlet Area Imperv Width Slope Length ;;------ ---------------- -------- ------- ------- ----- ------ -------- S1 SCS_24h_Type_I_1in J2 1 100 500 0.5 0
Methods
This method allows the user to give the parmeter to be updated and where this value should be set in the input file.
If the user wants to modify the new file name simply use this class for find replace then Apply those changes.
Attributes
If the user wants to modify the new file name simply use this class for find replace.
This is set by the Simulation class but can also be set directly if the user wants to simply use this class for find replace.