oopnet.simulator package¶
Submodules¶
oopnet.simulator.binaryfile_reader module¶
- class oopnet.simulator.binaryfile_reader.BinaryFileReader(filename: str, *args, **kwargs)¶
Bases:
object
oopnet.simulator.epanet2 module¶
- oopnet.simulator.epanet2.ModelSimulator(thing: Network | str, filename: str | None = None, delete: bool = True, path: str | None = None, startdatetime: datetime.datetime | None = None, output: bool = False)¶
Runs an EPANET simulation by calling command line EPANET
- oopnet.simulator.epanet2.thing¶
either an OOPNET network object or the filename of an EPANET input file
- oopnet.simulator.epanet2.filename¶
if thing is an OOPNET network, filename is an option to perform command line EPANET simulations with a specific filename. If filename is a Python None object then a file with a random UUID (universally unique identifier) is generated
- oopnet.simulator.epanet2.delete¶
if delete is True the EPANET Input and Report file is deleted, if False then the simulation results won’t be deleted and are stored in a folder named path
- oopnet.simulator.epanet2.path¶
Path were to perform the simulations. If path is a Python None object then a tmp-folder is generated
- Returns:
OOPNET report object
oopnet.simulator.error_manager module¶
- class oopnet.simulator.error_manager.ErrorManager¶
Bases:
object
Class for managing errors encountered while simulating a hydraulic model.
This class checks the EPANET report file for errors, stores these errors (and if available the error details) and then raises an EPANETSimulationError that contains all the encountered errors.
- found_errors¶
list of errors found in the report file
- _error_exp¶
regular expression used for finding errors
- _error_list¶
list of possible errors that might be found in a report file as tuples where the first item is the
- exception, the second one the general error message and an optional third item stores the error details.
- append_error_details(text_line)¶
Appends the details of an error to the already found error.
EPANET report files use either one or two lines of text for errors. The first one contains the error code and a general error message, while the following line contains a detailed error description. This function adds this second line of text to the corresponding error.
- check_line(text_line)¶
Checks a single line of text for error codes.
If an error is encountered, it is added to the found_errors list together with the error message.
- Parameters:
text_line (
str
) – text line to be checked- Return type:
bool
- Returns:
Returns False if no errors were encountered and True if otherwise.
- raise_errors()¶
Raises an EPANETSimulationError if any errors were encountered while simulating the model.
oopnet.simulator.reportfile_reader module¶
- oopnet.simulator.reportfile_reader.ReportFileReader(filename: str, precision: Reportprecision, startdatetime: datetime | None = None) tuple[DataArray | Dataset | None, DataArray | Dataset | None] ¶
- oopnet.simulator.reportfile_reader.blockkey2typetime(blockkey, startdatetime=None)¶
- Parameters:
blockkey (
str
) –startdatetime (
Optional
[datetime
]) – (Default value = None)
- Return type:
tuple
[str
,datetime
]
Returns:
- oopnet.simulator.reportfile_reader.lst2xray(lst, precision)¶
- Parameters:
lst (
list
) – list:- Return type:
DataArray
Returns:
- oopnet.simulator.reportfile_reader.str2hms(timestring)¶
Converts a string to a tuple containing hours, minutes and seconds.
- Parameters:
timestring (
str
) – string to be parsed- Return type:
tuple
[int
,int
,float
]- Returns:
parsed timestring as a tuple
oopnet.simulator.simulation_errors module¶
- exception oopnet.simulator.simulation_errors.BinaryOutputFileAccessError(description, details)¶
Bases:
EPANETError
- code = 304¶
- exception oopnet.simulator.simulation_errors.CheckValveImmutableError(description, details)¶
Bases:
EPANETError
- code = 207¶
- exception oopnet.simulator.simulation_errors.EPANETError(description, details)¶
Bases:
Exception
Base class for simulation errors.
This exception is not meant to be called manually but is only a super class for the specific EPANET errors listed in the ‘EPANET manual appendix concerning error messages <https://epanet22.readthedocs.io/en/latest/back_matter.html#error-messages>’.
- code¶
error code as listed in the ‘EPANET manual appendix concerning error messages
- <https
//epanet22.readthedocs.io/en/latest/back_matter.html#error-messages>’
- abstract property code¶
Error code as described in the EPANET manual.
- exception oopnet.simulator.simulation_errors.EPANETSimulationError(message)¶
Bases:
Exception
Error raised when any errors were encountered while simulating a hydraulic model.
- check_contained_errors(errors)¶
- property errors¶
Property containing all raised errors.
This property can be used as a shortcut to the raised errors. Useful when looking for a specific kind of error.
- exception oopnet.simulator.simulation_errors.EPANETSyntaxError(description, details)¶
Bases:
EPANETError
- code = 201¶
- exception oopnet.simulator.simulation_errors.HydraulicEquationError(description, details)¶
Bases:
EPANETError
- code = 110¶
- exception oopnet.simulator.simulation_errors.IllegalAnalysisOptionError(description, details)¶
Bases:
EPANETError
- code = 213¶
- exception oopnet.simulator.simulation_errors.IllegalLinkPropertyError(description, details)¶
Bases:
EPANETError
- code = 211¶
- exception oopnet.simulator.simulation_errors.IllegalNodePropertyError(description, details)¶
Bases:
EPANETError
- code = 209¶
- exception oopnet.simulator.simulation_errors.IllegalNumericalValueError(description, details)¶
Bases:
EPANETError
- code = 202¶
- exception oopnet.simulator.simulation_errors.IllegalValveSourceConnectionError(description, details)¶
Bases:
EPANETError
- code = 219¶
- exception oopnet.simulator.simulation_errors.IllegalValveValveConnectionError(description, details)¶
Bases:
EPANETError
- code = 220¶
- exception oopnet.simulator.simulation_errors.InputDataError(description, details)¶
Bases:
EPANETError
- code = 200¶
- exception oopnet.simulator.simulation_errors.InsufficientMemoryError(description, details)¶
Bases:
EPANETError
- code = 101¶
- exception oopnet.simulator.simulation_errors.InvalidCurveError(description, details)¶
Bases:
EPANETError
- code = 230¶
- exception oopnet.simulator.simulation_errors.InvalidEnergyDataError(description, details)¶
Bases:
EPANETError
- code = 217¶
- exception oopnet.simulator.simulation_errors.InvalidIDError(description, details)¶
Bases:
EPANETError
- code = 252¶
- exception oopnet.simulator.simulation_errors.InvalidPumpError(description, details)¶
Bases:
EPANETError
- code = 227¶
- exception oopnet.simulator.simulation_errors.InvalidTankLevelError(description, details)¶
Bases:
EPANETError
- code = 225¶
- exception oopnet.simulator.simulation_errors.LinkReferenceError(description, details)¶
Bases:
EPANETError
- code = 210¶
- exception oopnet.simulator.simulation_errors.MisplacedRuleClause(description, details)¶
Bases:
EPANETError
- code = 221¶
- exception oopnet.simulator.simulation_errors.NodeReferenceError(description, details)¶
Bases:
EPANETError
- code = 208¶
- exception oopnet.simulator.simulation_errors.NotEnoughNodesError(description, details)¶
Bases:
EPANETError
- code = 223¶
- exception oopnet.simulator.simulation_errors.NotEnoughSourcesError(description, details)¶
Bases:
EPANETError
- code = 224¶
- exception oopnet.simulator.simulation_errors.ReportFileAccessError(description, details)¶
Bases:
EPANETError
- code = 303¶
- exception oopnet.simulator.simulation_errors.ReportFileSavingError(description, details)¶
Bases:
EPANETError
- code = 309¶
- exception oopnet.simulator.simulation_errors.ResultFileSavingError(description, details)¶
Bases:
EPANETError
- code = 308¶
Bases:
EPANETError
- exception oopnet.simulator.simulation_errors.TempInputFileAccessError(description, details)¶
Bases:
EPANETError
- code = 302¶
- exception oopnet.simulator.simulation_errors.UnconnectedNodeError(description, details)¶
Bases:
EPANETError
- code = 233¶
- exception oopnet.simulator.simulation_errors.UndefinedCurveError(description, details)¶
Bases:
EPANETError
- code = 206¶
- exception oopnet.simulator.simulation_errors.UndefinedLinkError(description, details)¶
Bases:
EPANETError
- code = 204¶
- exception oopnet.simulator.simulation_errors.UndefinedNodeError(description, details)¶
Bases:
EPANETError
- code = 203¶
- exception oopnet.simulator.simulation_errors.UndefinedPumpError(description, details)¶
Bases:
EPANETError
- code = 216¶
- exception oopnet.simulator.simulation_errors.UndefinedTimePatternError(description, details)¶
Bases:
EPANETError
- code = 205¶
- exception oopnet.simulator.simulation_errors.UndefinedTraceNodeError(description, details)¶
Bases:
EPANETError
- code = 212¶
- oopnet.simulator.simulation_errors.get_error_list()¶
Lists all errors implemented.
- Return type:
list
[Type
[EPANETError
]]