Application Examples

Here, you will find a variety of tutorials, examples and networks. Before proceeding, ensure that the SIR 3S Toolkit is properly installed (see Installation instructions).

The tutorials are designed to help new users to get started with the basic functionalities of the SIR 3S Toolkit. The application examples build on that foundation and demonstrate how the SIR 3S Toolkit can be used in real-world scenarios. The included networks illustrate typical topologies of SIR 3S models.

Tip

πŸ“˜ Are you new to the SIR 3S Toolkit? Start with the Tutorials below.

βš™οΈ Looking for practical scenarios? Jump to the Examples section.

🧭 Interested in model topologies? Explore the Networks.

Tutorials

These tutorials are designed to introduce new users to the functionalities of the SIR 3S Toolkit. Each class holding functions has its own section of tutorials. The section come in pairs of wrapper classes and their respective pure python mantle class.

Each tutorial is available for previewing as a rendered notebook.

Some tutorials are available downloading as a .zip archive containing all required files.

SIR3S_Model

SIR3S_Model() implements basic functionalities regarding interactions between Python and a SIR 3S model.

You can also download all tutorials regarding SIR3S_Model (0 - 49) and their respective data in a joint .zip archive at once here.

Tutorial 0: Importing and initialization of the SIR 3S Toolkit

This tutorial demonstrates how to import the SIR 3S Toolkit and initialize instances of its classes.

View: Notebook | Download: ZIP archive.

Tutorial 1: Creating a new or opening an existing SIR 3S model

This tutorial demonstrates how to create new SIR 3S models or open already existing ones.

View: Notebook | Download: ZIP archive.

Tutorial 2: Accessing and modifying model data

This tutorial demonstrates how to get and set values of objects based on their topological key (tk).

View: Notebook | Download: ZIP archive.

Tutorial 3: Accessing simulation results

This tutorial demonstrates how to get result values of objects based on their tk.

View: Notebook | Download: ZIP archive.

Tutorial 4: Editing a SIR 3S model safely and effectively

This Tutorial demonstrates how to change SIR 3S models properly by grouping changes and saving them.

View: Notebook | Download: ZIP archive.

Tutorial 5: Insert and Connect Elements

This Tutorial demonstrates how new elements such as nodes, pipes, tanks, valves, etc. can be inserted into a SIR 3S model and connected.

View: Notebook | Download: ZIP archive.

Tutorial 6: Miscellaneous

This Tutorial demonstrates miscellaneous functions of the SIR3S_Model() class that cannot be assigned to one of the previous Tutorial topics.

View: Notebook | Download: ZIP archive.

SIR3S_Model_Mantle

SIR3S_Model_Mantle() is a collector class that contains the functions from all other classes defined in the mantle.

Tutorial 50: Mantle Import

View: Notebook | Download: Notebook

SIR3S_Model_Dataframes

SIR3S_Model_Dataframes() implements interactions between SIR 3S and pandas dataframes. You can obtain pandas dfs with meta- or resultdata, insert nodes and pipes via a df, etc.

Tutorial 51: Dataframe Creation

This Tutorial demonstrates how to create dataframes.

View: Notebook | Download: Notebook

SIR3S_Model_Alternative_Models

SIR3S_Model_Alternative_Models() implements the generation of SIR 3S models in alternative model formats such as pandapipes or nx-Graphs.

Tutorial 61: nx-Graph

This Tutorial demonstrates how to create a nx-Graph from a SIR 3S model.

View: Notebook | Download: Notebook

Tutorial 62: pandapipes

This Tutorial demonstrates how to create a pandapipes model from a SIR 3S model.

View: Notebook | Download: Notebook

SIR3S_Model_Plotting

SIR3S_Model_Plotting implements general plotting functions for SIR 3S applications.

Tutorial 71: WORK IN PROGRESS: time curves

This Tutorial demonstrates how to plot time curves.

View: Notebook | Download: Notebook

Examples

These examples are intended for users who are already familiar with the basic functionality of the SIR 3S Toolkit and demonstrate how to apply it to real-world scenarios.

Each example is available for both viewing and downloading as an .ipynb file.

Example 1: Shape Import

This Example demonstrates how to create a connected topological network of nodes and pipes in SIR 3S via teh SIR 3S Toolkit based on shapefile data. The data used comes from β€˜SIR 3SModelleBeispieleWasserManualProjektdaten01 Shape-Dateien’.

View: Notebook | Download: Notebook.

Example 2: Iterate over SIR 3S calculations

This Example demonstrates how to use the Dataframes_SIR3S_Model() class extending SIR3S_Model().

View: Notebook | Download: Notebook.

Example X: Template

Contributor Template

This is not a user-facing example but a template intended for contributors to create their own example.

View: Notebook | Download: Notebook.

Networks

The networks are examples of SIR 3S model topologies.

Each network is available for previewing and downloading as an .py file. You can open and run it using the Python Console in SIR 3S.

You can view the code below

 1from sir3stoolkit.core import wrapper
 2
 3SIR3S_SIRGRAF_DIR = r"C:\3S\SIR 3S Entwicklung\SirGraf-90-15-00-16_Quebec_x64"  # change to local path
 4wrapper.Initialize_Toolkit(SIR3S_SIRGRAF_DIR)
 5
 6model = wrapper.SIR3S_Model()
 7
 8# Abbreviations for ObjectTypes used
 9TNode = model.ObjectTypes.Node
10TPipe = model.ObjectTypes.Pipe
11TPump = model.ObjectTypes.Pump
12TTank = model.ObjectTypes.OpenContainer
13
14# Create Nodes and Pipes
15model.StartEditSession("Insert Elements")
16
17# Add nodes
18node10 = model.AddNewNode("-1", "Node10", "QKON", 200, 700, 213, 0, 1, "DNODE 10", "RefNode 10", 0) 
19node11 = model.AddNewNode("-1", "Node11", "QKON", 300, 700, 213, 0, 1, "DNODE 11", "RefNode 11", 0) 
20node12 = model.AddNewNode("-1", "Node12", "QKON", 500, 700, 210, 0, 1, "DNODE 12", "RefNode 12", 0) 
21node13 = model.AddNewNode("-1", "Node13", "QKON", 700, 700, 208.5, 0, 1, "DNODE 13", "RefNode 13", 0) 
22node21 = model.AddNewNode("-1", "Node21", "QKON", 300, 400, 210, 0, 1, "DNODE 21", "RefNode 21", 0) 
23node22 = model.AddNewNode("-1", "Node22", "QKON", 500, 400, 208.5, 0, 1, "DNODE 22", "RefNode 22", 0) 
24node23 = model.AddNewNode("-1", "Node23", "QKON", 700, 400, 207, 0, 1, "DNODE 23", "RefNode 23", 0) 
25node31 = model.AddNewNode("-1", "Node31", "QKON", 300, 100, 210, 0, 1, "DNODE 31", "RefNode 31", 0) 
26node32 = model.AddNewNode("-1", "Node32", "QKON", 500, 100, 213, 0, 1, "DNODE 32", "RefNode 32", 0) 
27node9 = model.AddNewNode("-1", "Node9", "PKON", 150, 700, 255, 0, 1, "PNODE 9", "RefNode 9", 0) 
28node2 = model.AddNewNode("-1", "Node2", "QKON", 500, 850, 240, 0, 1, "Tank 2", "RefNode 2", 0) 
29
30# Add pipes
31model.AddNewPipe("-1", node10, node11, 3160, "LINESTRING(200 700, 300, 700)", "STDROHR", "450", 0.25, "Ref Pipe 10", "Pipe from Pump to network", 0)
32model.AddNewPipe("-1", node11, node12, 1584, "LINESTRING(300 700, 500, 700)", "STDROHR", "350", 0.25, "Ref Pipe 11", "Pipe from 11 to 12", 0)
33model.AddNewPipe("-1", node12, node13, 1584, "LINESTRING(500 700, 700, 700)", "STDROHR", "250", 0.25, "Ref Pipe 12", "Pipe from 12 to 13", 0)
34model.AddNewPipe("-1", node21, node22, 1584, "LINESTRING(300 400, 500, 400)", "STDROHR", "250", 0.25, "Ref Pipe 21", "Pipe from 21 to 22", 0)
35model.AddNewPipe("-1", node22, node23, 1584, "LINESTRING(500 400, 700, 400)", "STDROHR", "300", 0.25, "Ref Pipe 22", "Pipe from 22 to 23", 0)
36model.AddNewPipe("-1", node31, node32, 1584, "LINESTRING(300 100, 500, 100)", "STDROHR", "150", 0.25, "Ref Pipe 31", "Pipe from 31 to 32", 0)
37model.AddNewPipe("-1", node2, node12,  60, "LINESTRING(500 850, 500, 700)", "STDROHR", "450", 0.25, "Ref Pipe 110", "Pipe from Tank to network", 0)
38model.AddNewPipe("-1", node11, node21, 1584, "LINESTRING(300 700, 300, 400)", "STDROHR", "250", 0.25, "Ref Pipee 111", "Pipe from 11 to 21", 0)
39model.AddNewPipe("-1", node12, node22, 1584, "LINESTRING(500 700, 500, 400)", "STDROHR", "300", 0.25, "Ref Pipee 112", "Pipe from 12 to 22", 0)
40model.AddNewPipe("-1", node13, node23, 1584, "LINESTRING(700 700, 700, 400)", "STDROHR", "200", 0.25, "Ref Pipee 113", "Pipe from 13 to 32", 0)
41model.AddNewPipe("-1", node21, node31, 1584, "LINESTRING(300 400, 300, 100)", "STDROHR", "200", 0.25, "Ref Pipee 121", "Pipe from 21 to 31", 0)
42model.AddNewPipe("-1", node22, node32, 1584, "LINESTRING(500 400, 500, 100)", "STDROHR", "150", 0.25, "Ref Pipee 122", "Pipe from 22 to 32", 0)
43
44# Add pump
45model.AddNewConnectingElement("-1", node9, node10, 175, 700, 0, TPump, 200, 1, 0, "Pumpe", "standard pump")
46
47#add tank
48model.AddNewBypassElement("-1", node2, 500, 850, 255, 1, TTank, "Tank", "Storage tank")
49
50#Stop edit sesssion
51model.EndEditSession();
52
53#Add text
54text = model.InsertElement(model.ObjectTypes.Text, "RefBspText")
55model.SetGeometryInformation(text, "POINT(750 850 0)")
56model.SetValue(text, "Graftext", "Network 1 createed by SIR 3S PythonToolkit")
57model.SetElementColor_RGB(text, 255,0,0,True)       
58
59# draw network in map
60model.RefreshViews()                              
61
62# run steady-state calculation
63model.ExecCalculation(True);                      

You can download the Network file here.