Tutorial 9: Model Validation
[1]:
SIR3S_SIRGRAF_DIR = r"C:\3S\SIR 3S\SirGraf-90-15-00-24_Quebec-Upd2" #change to local path
Imports
Note: The SIR 3S Toolkit requires the Sir3S_Toolkit.dll included in SIR 3S installations (version Quebec and higher).
[2]:
import sir3stoolkit
The core of sir3stoolkit is a Python wrapper around basic functionality of SIR 3S, offering a low-level access to the creation, modification and simulation of SIR 3S models. In the future pure python subpackages may be added.
[3]:
from sir3stoolkit.core import wrapper
[4]:
sir3stoolkit
[4]:
<module 'sir3stoolkit' from 'C:\\Users\\aUsername\\3S\\sir3stoolkit\\src\\sir3stoolkit\\__init__.py'>
The wrapper package has to be initialized with reference to a SIR 3S (SirGraf) installation.
[5]:
wrapper.Initialize_Toolkit(SIR3S_SIRGRAF_DIR)
[2026-06-05 14:55:01,300] INFO in sir3stoolkit.core.wrapper: [Initialization] Using provided SirGraf path: C:\3S\SIR 3S\SirGraf-90-15-00-24_Quebec-Upd2
[2026-06-05 14:55:01,300] INFO in sir3stoolkit.core.wrapper: [Initialization] Using provided SirGraf path: C:\3S\SIR 3S\SirGraf-90-15-00-24_Quebec-Upd2
[2026-06-05 14:55:01,412] INFO in sir3stoolkit.core.wrapper: [Initialization] Initializing toolkit with SirGraf path: C:\3S\SIR 3S\SirGraf-90-15-00-24_Quebec-Upd2
Initialization
The SIR 3S Toolkit contains two classes: SIR3S_Model (model and data) and SIR3S_View (depiction in SIR Graf). All SIR 3S Toolkit functionality is accessed via the methods of these classes.
[6]:
s3s = wrapper.SIR3S_Model()
[2026-06-05 14:55:03,067] INFO in sir3stoolkit.core.wrapper: [Model Class Initialization] Initialization complete
[7]:
s3s_view = wrapper.SIR3S_View()
[2026-06-05 14:55:03,901] INFO in sir3stoolkit.core.wrapper: Initialization complete
Open Model
[8]:
dbFilePath=r"Toolkit_Tutorial9_Model.db3"
[9]:
s3s.OpenModel(dbName=dbFilePath,
providerType=s3s.ProviderTypes.SQLite,
Mid="M-1-0-1",
saveCurrentlyOpenModel=False,
namedInstance="",
userID="",
password="")
[2026-06-05 14:55:21,977] INFO in sir3stoolkit.core.wrapper: Model is open for further operation
Now the model has been opened and the previous one has been closed without saving it. All SIR 3S Toolkit commands now apply to this model until another one is opened.
ExecuteModelValidation()
We can use the function ExecuteModelValidation() to obtain model validation information.
[10]:
model_check = s3s.ExecuteModelValidation()
We use json to unpack the return.
[11]:
import json
[12]:
model_check = json.loads(model_check)
Pumps
model_check is a list of lists, where every sublists represent a certain object type like pipe or pump.
[13]:
model_check_pumps = model_check[0]
[14]:
len(model_check_pumps)
[14]:
1
model_check_pumps has only one element, as only one pump show some irregularity.
[20]:
model_check_pumps[0]
[20]:
{'ElementType': 'PUMP',
'Element': '5107435976103290045',
'ElementName': 'Pumpe',
'MessageCodes': ['21300040', '21300080', '21300210', '21400070'],
'Messages': ['Pumpe ist noch nicht am Knoten KI angeschlossen.',
'Pumpe ist noch nicht am Knoten KK angeschlossen.',
'Verstellgeschwindigkeit sollte größer 0 sein, wenn ein Fahrprogramm für diese Pumpe aktiv ist.',
'Instationäre Fahrweise: Pumpe läuft mit stationärer Drehzahl weiter, solange kein Zugriff der Ebenen 2 bis 5 erfolgt.'],
'Categories': ['Reference', 'Reference', 'Value', 'Value'],
'Weights': ['10', '10', '2', '1'],
'Datapoint': '-1',
'DatapointName': ''}
The description of the irregularity itself is a dict with the following keys.
[24]:
model_check_pumps[0].keys()
[24]:
dict_keys(['ElementType', 'Element', 'ElementName', 'MessageCodes', 'Messages', 'Categories', 'Weights', 'Datapoint', 'DatapointName'])
Pipes
[16]:
modeL_check_pipes = model_check[1]
[17]:
len(modeL_check_pipes)
[17]:
2
modeL_check_pipes has two elements corresponding to two different irregularities.
[21]:
modeL_check_pipes[0]
[21]:
{'ElementType': 'ROHR',
'Element': '5327930626528922667',
'ElementName': 'Rohr K0000 K0001',
'MessageCodes': ['25200070'],
'Messages': ['Rohrlänge darf nicht kleiner oder gleich 0 sein.'],
'Categories': ['Value'],
'Weights': ['10'],
'Datapoint': '-1',
'DatapointName': ''}
[22]:
modeL_check_pipes[1]
[22]:
{'ElementType': 'ROHR',
'Element': '5452633072606077074',
'ElementName': 'Rohr K0004 K0005',
'MessageCodes': ['25200070'],
'Messages': ['Rohrlänge darf nicht kleiner oder gleich 0 sein.'],
'Categories': ['Value'],
'Weights': ['10'],
'Datapoint': '-1',
'DatapointName': ''}