{ "cells": [ { "cell_type": "markdown", "id": "5556432f", "metadata": {}, "source": [ "# Tutorial 3: Getting and Setting Values" ] }, { "cell_type": "markdown", "id": "8899e69a", "metadata": {}, "source": [ "This Tutorial demonstrates how to get and set values of object based on their tk." ] }, { "cell_type": "markdown", "id": "aa6fc9ab", "metadata": {}, "source": [ "# Toolkit Release" ] }, { "cell_type": "code", "execution_count": 1, "id": "044539c5", "metadata": {}, "outputs": [], "source": [ "#pip install sir3stoolkit" ] }, { "cell_type": "markdown", "id": "2ec45128", "metadata": {}, "source": [ "# Imports" ] }, { "cell_type": "markdown", "id": "5ae3d26b", "metadata": {}, "source": [ "The Toolkit requires the Sir3S_Toolkit.dll included in SIR 3S installations (from Quebec and Up). Furthermore the Sir3S_Repository.Interfaces.dll is required to input native SIR 3S datatypes into some Toolkit functions." ] }, { "cell_type": "code", "execution_count": 2, "id": "f91c11de", "metadata": {}, "outputs": [], "source": [ "import clr as clr" ] }, { "cell_type": "code", "execution_count": 3, "id": "c53876e7", "metadata": {}, "outputs": [], "source": [ "SIR3S_SIRGRAF_DIR = r\"C:\\3S\\SIR 3S Entwicklung\\SirGraf-90-15-00-11_Quebec_x64\"" ] }, { "cell_type": "code", "execution_count": 4, "id": "115b8015", "metadata": {}, "outputs": [], "source": [ "clr.AddReference(SIR3S_SIRGRAF_DIR+r\"\\Sir3S_Repository.Interfaces\")\n", "import Sir3S_Repository.Interfaces as Interfaces" ] }, { "cell_type": "code", "execution_count": 5, "id": "b5e997d5", "metadata": {}, "outputs": [], "source": [ "clr.AddReference(SIR3S_SIRGRAF_DIR+r\"\\Sir3S_Toolkit\")\n", "import Sir3S_Toolkit" ] }, { "cell_type": "markdown", "id": "1bac2bff", "metadata": {}, "source": [ "## PythonWrapperToolkit" ] }, { "cell_type": "code", "execution_count": 6, "id": "3ea16e3d", "metadata": {}, "outputs": [], "source": [ "import sir3stoolkit" ] }, { "cell_type": "markdown", "id": "5fb318de", "metadata": {}, "source": [ "The core of sir3stoolkit is a Python Wrapper around C#, that can be used to read, write, etc. to a SIR 3S Model. In the future pure python subpackages may be added." ] }, { "cell_type": "code", "execution_count": 7, "id": "e1cad8f6", "metadata": {}, "outputs": [], "source": [ "from sir3stoolkit.core import wrapper" ] }, { "cell_type": "code", "execution_count": 8, "id": "ee9b4080", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sir3stoolkit" ] }, { "cell_type": "markdown", "id": "e3acc1e7", "metadata": {}, "source": [ "The [wrapper package](https://3sconsult.github.io/sir3stoolkit/references/sir3stoolkit.core.html#sir3stoolkit.core.wrapper.Initialize_Toolkit) has to be initialized with reference to a SIR Graf installation." ] }, { "cell_type": "code", "execution_count": 9, "id": "3d4e829d", "metadata": {}, "outputs": [], "source": [ "wrapper.Initialize_Toolkit(SIR3S_SIRGRAF_DIR)" ] }, { "cell_type": "markdown", "id": "37f67f8f", "metadata": {}, "source": [ "# Initialization" ] }, { "cell_type": "markdown", "id": "49b21e98", "metadata": {}, "source": [ "Toolkit contains two classes: [SIR3S_Model](https://3sconsult.github.io/sir3stoolkit/references/sir3stoolkit.core.html#sir3stoolkit.core.wrapper.SIR3S_Model)(model and data) and [SIR3S_View](https://3sconsult.github.io/sir3stoolkit/references/sir3stoolkit.core.html#sir3stoolkit.core.wrapper.SIR3S_View)(depiction in SIR Graf). All Toolkit functionality is accessed via the methods of these classes." ] }, { "cell_type": "code", "execution_count": 10, "id": "a6ffe9da", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initialization complete\n" ] } ], "source": [ "s3s = wrapper.SIR3S_Model()" ] }, { "cell_type": "code", "execution_count": 11, "id": "4d9d92b5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initialization complete\n" ] } ], "source": [ "s3s_view = wrapper.SIR3S_View()" ] }, { "cell_type": "markdown", "id": "34309a14", "metadata": {}, "source": [ "# Open Model" ] }, { "cell_type": "code", "execution_count": 12, "id": "0918738e", "metadata": {}, "outputs": [], "source": [ "dbFilePath=r\"Tutorial3_Model.db3\"" ] }, { "cell_type": "code", "execution_count": 13, "id": "e984b61e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model is open for further operation\n" ] } ], "source": [ "s3s.OpenModel(dbName=dbFilePath, \n", " providerType=Interfaces.SirDBProviderType.SQLite, \n", " Mid=\"M-1-0-1\", \n", " saveCurrentlyOpenModel=False, \n", " namedInstance=\"\", \n", " userID=\"\", \n", " password=\"\")" ] }, { "cell_type": "markdown", "id": "59002c02", "metadata": {}, "source": [ "This model has been prepared and contains two nodes connected by a pipe." ] }, { "cell_type": "markdown", "id": "8862300c", "metadata": {}, "source": [ "# Getting Values" ] }, { "cell_type": "markdown", "id": "720e5b9f", "metadata": {}, "source": [ "Our goal is to find out what the typ of the nodes is (PKON, QKON, etc.), and what length and roughness the pipe has." ] }, { "cell_type": "markdown", "id": "7d784e11", "metadata": {}, "source": [ "The [GetValue](https://3sconsult.github.io/sir3stoolkit/references/sir3stoolkit.core.html#sir3stoolkit.core.wrapper.SIR3S_Model.GetValue) function requires a tk to the object and the internal SIR 3S attribute name of the value we want to obtain. This guide will walk you through how to obtain those." ] }, { "cell_type": "markdown", "id": "83cf88cd", "metadata": {}, "source": [ "## Interfaces.Sir3SObjectTypes" ] }, { "cell_type": "markdown", "id": "2835cf9c", "metadata": {}, "source": [ "First, we need to obtian the internal SIR 3S element types to later pass to our function for obtaining the attribute names." ] }, { "cell_type": "markdown", "id": "63ee3086", "metadata": {}, "source": [ "We use the Interfaces from Sir3S_Repository.dll" ] }, { "cell_type": "markdown", "id": "d4f44083", "metadata": {}, "source": [ "You can use dir() to get an overview over the different element types existing in SIR 3S." ] }, { "cell_type": "code", "execution_count": 14, "id": "8000c752", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['AGSN_HydraulicProfile', 'AirVessel', 'Arrow', 'Atmosphere', 'BlockConnectionNode', 'CalcPari', 'CharacteristicLossTable', 'CharacteristicLossTable_Row', 'Circle', 'CompareTo', 'Compressor', 'CompressorTable', 'CompressorTable_Row', 'ControlEngineeringNexus', 'ControlMode', 'ControlPointTable', 'ControlPointTable_Row', 'ControlValve', 'ControlVariableConverter', 'ControlVariableConverterRSTE', 'CrossSectionTable', 'CrossSectionTable_Row', 'DPGR_DPKT_DatapointDpgrConnection', 'DPGR_DataPointGroup', 'DPKT_Datapoint', 'DamageRatesTable', 'DamageRatesTable_Row', 'DeadTimeElement', 'Demand', 'DifferentialRegulator', 'DirectionalArrow', 'DistrictHeatingConsumer', 'DistrictHeatingFeeder', 'Divider', 'DriveEfficiencyTable', 'DriveEfficiencyTable_Row', 'DrivePowerTable', 'DrivePowerTable_Row', 'EBES_FeederGroups', 'EfficiencyConverterTable', 'EfficiencyConverterTable_Row', 'ElementQuery', 'EnergyRecoveryTable', 'EnergyRecoveryTable_Row', 'EnvironmentTemp', 'Equals', 'FWBZ_DistrictHeatingReferenceValues', 'Finalize', 'FlapValve', 'FlowControlUnit', 'FluidQualityParamSet', 'FluidQualityParamSet_OS', 'FluidThermalPropertyGroup', 'Format', 'FreeDuct', 'FunctionGenerator', 'FunctionTable', 'FunctionTable_Row', 'GasComponent', 'GasMixture', 'GeneralSection', 'GetHashCode', 'GetName', 'GetNames', 'GetType', 'GetTypeCode', 'GetUnderlyingType', 'GetValues', 'Gravitation', 'HasFlag', 'HeatExchanger', 'HeatFeederConsumerStation', 'HeaterCooler', 'Histeresis', 'House', 'Hydrant', 'Integrator', 'IsDefined', 'LAYR_Layer', 'LoadFactorTable', 'LoadFactorTable_Row', 'LogicalComparison', 'LogicalStorage', 'MeasuredVariableTable', 'MeasuredVariableTable_Row', 'MemberwiseClone', 'MinMaxSelection', 'Multiplier', 'NetValve', 'Node', 'NonReturnValvesTable', 'NonReturnValvesTable_Row', 'NumericalDisplay', 'ObjectContainerSymbol', 'OpenContainer', 'Oval', 'Overloads', 'PARZ_TransientCalculationParameters', 'Parse', 'PhaseSeparation', 'PidController', 'Pipe', 'PipeGroup', 'PipeTable', 'PipeTable_Row', 'PipeVertex', 'Polygon', 'Polyline', 'PressureRegulator', 'PressureZone', 'Pt1Controller', 'Pump', 'PumpCharTable', 'PumpCharTable_Row', 'PumpGroup', 'PumpOfPumpGroup', 'PumpSpeedTable', 'PumpSpeedTable_Row', 'RART_ControlMode', 'REGP_ControlParameters', 'RMES_DPTS_RmesInternalDataPoint', 'Rectangle', 'ReferenceEquals', 'RegulatorsTable', 'RegulatorsTable_Row', 'ReturnTemperaturTable', 'ReturnTemperaturTable_Row', 'RoundRectangle', 'SIRGRAF', 'SPLZ_TimeSeries', 'SafetyValve', 'SetpointDevice', 'SolarCollector', 'StandPipe', 'Street', 'SummingPoint', 'SwitchInBlock', 'TemperatureTable', 'TemperatureTable_Row', 'Text', 'ThermalOutputTable', 'ThermalOutputTable_Row', 'ThermophysPropTable', 'ThermophysPropTable_Row', 'ToObject', 'ToString', 'TransitionSymbol', 'Transmitter', 'TransportVariable', 'TryParse', 'USCH_UserDefinedProperties', 'Unknown', 'VARA_ColorScale', 'VARA_ROWS_WidthOrScale', 'VRCT_ViewRectangle', 'Valve', 'ValveLiftTable', 'ValveLiftTable_Row', 'VarFlowTable', 'VarFlowTable_Row', 'VarPressureTable', 'VarPressureTable_Row', 'VentOpenCloseTable', 'VentOpenCloseTable_Row', 'VentValve', 'VentilatedPressureAirVessel', 'WBLZ_ThermalBalance', 'WeatherDataTable', 'WeatherDataTable_Row', '__and__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__float__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__or__', '__overloads__', '__rand__', '__reduce__', '__reduce_ex__', '__repr__', '__ror__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__xor__', 'value__']\n" ] } ], "source": [ "print(dir(Interfaces.Sir3SObjectTypes))" ] }, { "cell_type": "markdown", "id": "9553616e", "metadata": {}, "source": [ "In our simple example we are only interested in the types of nodes and pipes." ] }, { "cell_type": "code", "execution_count": 15, "id": "21506747", "metadata": {}, "outputs": [], "source": [ "node_type=Interfaces.Sir3SObjectTypes.Node" ] }, { "cell_type": "code", "execution_count": 16, "id": "a5081ead", "metadata": {}, "outputs": [], "source": [ "pipe_type=Interfaces.Sir3SObjectTypes.Pipe" ] }, { "cell_type": "markdown", "id": "438d38a1", "metadata": {}, "source": [ "## GetTksofElementType()" ] }, { "cell_type": "markdown", "id": "c8826bee", "metadata": {}, "source": [ "Now, we obtain the tks of the nodes and pipes in this model." ] }, { "cell_type": "markdown", "id": "fc0778a1", "metadata": {}, "source": [ "We use [GetTksofElementType()](https://3sconsult.github.io/sir3stoolkit/references/sir3stoolkit.core.html#sir3stoolkit.core.wrapper.SIR3S_Model.GetTksofElementType) to create a list of all node tks in the model." ] }, { "cell_type": "code", "execution_count": 17, "id": "f7379f50", "metadata": {}, "outputs": [], "source": [ "nodes=s3s.GetTksofElementType(node_type)" ] }, { "cell_type": "code", "execution_count": 18, "id": "5f4efeca", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['4921762654790163024', '5483574590487309449']\n" ] } ], "source": [ "print(nodes)" ] }, { "cell_type": "markdown", "id": "e3cbfef1", "metadata": {}, "source": [ "If you dont want to predefine your element type you can also just pass it like done below" ] }, { "cell_type": "code", "execution_count": 19, "id": "19372c81", "metadata": {}, "outputs": [], "source": [ "pipes=s3s.GetTksofElementType(ElementType=Interfaces.Sir3SObjectTypes.Pipe)" ] }, { "cell_type": "code", "execution_count": 20, "id": "173ad436", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['4722505344321420574']\n" ] } ], "source": [ "print(pipes)" ] }, { "cell_type": "markdown", "id": "db3d47b6", "metadata": {}, "source": [ "## GetPropertiesofElementType()" ] }, { "cell_type": "markdown", "id": "cf25c5cb", "metadata": {}, "source": [ "Now, we obtain the internal SIR 3S attribute names. The will be necessary for our value query." ] }, { "cell_type": "markdown", "id": "2f40f6f6", "metadata": {}, "source": [ "We use [GetPropertiesofElementType()](https://3sconsult.github.io/sir3stoolkit/references/sir3stoolkit.core.html#sir3stoolkit.core.wrapper.SIR3S_Model.GetPropertiesofElementType) to create a list of all properties of nodes and pipes." ] }, { "cell_type": "code", "execution_count": 21, "id": "ab4ddfe1", "metadata": {}, "outputs": [], "source": [ "node_properties=s3s.GetPropertiesofElementType(node_type)" ] }, { "cell_type": "code", "execution_count": 22, "id": "6caf0598", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Name', 'Ktyp', 'Zkor', 'QmEin', 'Lfakt', 'Fkpzon', 'Fkfstf', 'Fkutmp', 'Fkfqps', 'Fkcont', 'Fk2lknot', 'Beschreibung', 'Geomfix', 'Idreferenz', 'Iplanung', 'Kvr', 'Qakt', 'Xkor', 'Ykor', 'NodeNamePosition', 'KvrKlartext', 'NumberOfVERB', 'HasBlockConnection', 'Tk', 'Pk', 'IsMarked', 'InVariant', 'SymbolFactor', 'bz.Drakonz', 'bz.Fk', 'bz.Fkpvar', 'bz.Fkqvar', 'bz.Fklfkt', 'bz.PhEin', 'bz.Tm', 'bz.Te', 'bz.PhMin']\n" ] } ], "source": [ "print(node_properties)" ] }, { "cell_type": "markdown", "id": "a1f5cec2", "metadata": {}, "source": [ "## GetValue()" ] }, { "cell_type": "markdown", "id": "1ea252ea", "metadata": {}, "source": [ "Now, we can access and value of indiviudal nodes with a corresponding tk." ] }, { "cell_type": "markdown", "id": "e48ac31f", "metadata": {}, "source": [ "We use [GetValue](https://3sconsult.github.io/sir3stoolkit/references/sir3stoolkit.core.html#sir3stoolkit.core.wrapper.SIR3S_Model.GetValue) for such individual value query." ] }, { "cell_type": "markdown", "id": "c38f5cc8", "metadata": {}, "source": [ "### Node 1" ] }, { "cell_type": "markdown", "id": "bb722962", "metadata": {}, "source": [ "As tk we just use the first tk from our nodes list." ] }, { "cell_type": "code", "execution_count": 24, "id": "5aa6e4ae", "metadata": {}, "outputs": [], "source": [ "node1_ktyp=s3s.GetValue(nodes[0], 'Ktyp')" ] }, { "cell_type": "code", "execution_count": 25, "id": "2bd59d64", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "('PKON', 'string')\n" ] } ], "source": [ "print(node1_ktyp)" ] }, { "cell_type": "markdown", "id": "1e73764c", "metadata": {}, "source": [ "As you can see it returns a tuple value consisting of the actual value (here: 'PKON') of the attribute and the attribute data type." ] }, { "cell_type": "markdown", "id": "380c7be0", "metadata": {}, "source": [ "You can access the indiviudal components as follows." ] }, { "cell_type": "code", "execution_count": 26, "id": "333b92e8", "metadata": {}, "outputs": [], "source": [ "actual_value=node1_ktyp[0]" ] }, { "cell_type": "code", "execution_count": 27, "id": "47960f8f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PKON\n" ] } ], "source": [ "print(actual_value)" ] }, { "cell_type": "code", "execution_count": 28, "id": "107d8d85", "metadata": {}, "outputs": [], "source": [ "data_type=node1_ktyp[1]" ] }, { "cell_type": "code", "execution_count": 29, "id": "728d80fe", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "string\n" ] } ], "source": [ "print(data_type)" ] }, { "cell_type": "markdown", "id": "a2005118", "metadata": {}, "source": [ "### Node 2" ] }, { "cell_type": "markdown", "id": "25df42c6", "metadata": {}, "source": [ "Now we use the second tk from our nodes list." ] }, { "cell_type": "code", "execution_count": 30, "id": "e9b7e4fa", "metadata": {}, "outputs": [], "source": [ "node2_ktyp_actual_value=s3s.GetValue(nodes[1], 'Ktyp')[0]" ] }, { "cell_type": "code", "execution_count": 31, "id": "f86a4429", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "QKON\n" ] } ], "source": [ "print(node2_ktyp_actual_value)" ] }, { "cell_type": "markdown", "id": "3024fa9b", "metadata": {}, "source": [ "### Pipe" ] }, { "cell_type": "markdown", "id": "b2d63c3a", "metadata": {}, "source": [ "For the pipe we will just ignore the datatypes of the attributes and instantly just access the value." ] }, { "cell_type": "code", "execution_count": 32, "id": "05a547c9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Name', 'Ktyp', 'Zkor', 'QmEin', 'Lfakt', 'Fkpzon', 'Fkfstf', 'Fkutmp', 'Fkfqps', 'Fkcont', 'Fk2lknot', 'Beschreibung', 'Geomfix', 'Idreferenz', 'Iplanung', 'Kvr', 'Qakt', 'Xkor', 'Ykor', 'NodeNamePosition', 'KvrKlartext', 'NumberOfVERB', 'HasBlockConnection', 'Tk', 'Pk', 'IsMarked', 'InVariant', 'SymbolFactor', 'bz.Drakonz', 'bz.Fk', 'bz.Fkpvar', 'bz.Fkqvar', 'bz.Fklfkt', 'bz.PhEin', 'bz.Tm', 'bz.Te', 'bz.PhMin']\n" ] } ], "source": [ "print(node_properties)" ] }, { "cell_type": "code", "execution_count": 33, "id": "a2ec773f", "metadata": {}, "outputs": [], "source": [ "pipe_length=s3s.GetValue(pipes[0], 'L')[0]" ] }, { "cell_type": "code", "execution_count": 34, "id": "f0c92dcc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5\n" ] } ], "source": [ "print(pipe_length)" ] }, { "cell_type": "code", "execution_count": 35, "id": "25a08515", "metadata": {}, "outputs": [], "source": [ "pipe_roughness=s3s.GetValue(pipes[0], 'RAU')[0]" ] }, { "cell_type": "code", "execution_count": 36, "id": "30d64c63", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3\n" ] } ], "source": [ "print(pipe_roughness)" ] }, { "cell_type": "markdown", "id": "e1a42205", "metadata": {}, "source": [ "# WORK IN PROGRESS BELOW" ] }, { "cell_type": "markdown", "id": "396fc345", "metadata": {}, "source": [ "# Getting Result Values" ] }, { "cell_type": "markdown", "id": "98b6c514", "metadata": {}, "source": [ "## GetResultProperties_from_elementKey()" ] }, { "cell_type": "code", "execution_count": 37, "id": "ea82946e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['A',\n", " 'ACALC',\n", " 'CPI',\n", " 'CPK',\n", " 'DH',\n", " 'DP',\n", " 'DRAGRED',\n", " 'DRAKONZ',\n", " 'DSI',\n", " 'DSK',\n", " 'DTTR',\n", " 'DWVERL',\n", " 'DWVERLABS',\n", " 'ETAAV',\n", " 'FS',\n", " 'HR',\n", " 'HVEC',\n", " 'IAKTIV',\n", " 'IRTRENN',\n", " 'JV',\n", " 'JV2',\n", " 'LAMBDA',\n", " 'LECKEINAUS',\n", " 'LECKMENGE',\n", " 'LECKORT',\n", " 'LINEPACK',\n", " 'LINEPACKGEOM',\n", " 'LINEPACKRATE',\n", " 'MAINELEMENT',\n", " 'MAV',\n", " 'MI',\n", " 'MK',\n", " 'MKOND',\n", " 'MMAX_INST',\n", " 'MMIN_INST',\n", " 'MVEC',\n", " 'MVECMAX_INST',\n", " 'MVECMIN_INST',\n", " 'PAV',\n", " 'PDAMPF',\n", " 'PHR',\n", " 'PHVEC',\n", " 'PMAX',\n", " 'PMIN',\n", " 'PR',\n", " 'PVEC',\n", " 'PVECMAX_INST',\n", " 'PVECMIN_INST',\n", " 'QI2',\n", " 'QK2',\n", " 'QMAV',\n", " 'QMI',\n", " 'QMK',\n", " 'QMMAX_INST',\n", " 'QMMIN_INST',\n", " 'QMVEC',\n", " 'QSVB',\n", " 'RHOAV',\n", " 'RHOI',\n", " 'RHOK',\n", " 'RHOVEC',\n", " 'SVEC',\n", " 'TAV',\n", " 'TI',\n", " 'TK',\n", " 'TTRVEC',\n", " 'TVEC',\n", " 'TVECMAX_INST',\n", " 'TVECMIN_INST',\n", " 'VAV',\n", " 'VI',\n", " 'VK',\n", " 'VMAX_INST',\n", " 'VMIN_INST',\n", " 'VOLDA',\n", " 'WALTERI',\n", " 'WALTERK',\n", " 'WVL',\n", " 'ZAUS',\n", " 'ZEIN',\n", " 'ZHKNR',\n", " 'ZVEC']" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s3s.GetResultProperties_from_elementType(pipe_type, False)" ] }, { "cell_type": "markdown", "id": "9a2f151f", "metadata": {}, "source": [ "## GetResultValue()" ] }, { "cell_type": "code", "execution_count": 38, "id": "65c5f0d0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('', '')" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s3s.GetResultValue(pipes[0], 'PMIN')" ] }, { "cell_type": "code", "execution_count": 39, "id": "4541c2e2", "metadata": {}, "outputs": [ { "ename": "ZeroDivisionError", "evalue": "division by zero", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[39], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;241m1\u001b[39m\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m0\u001b[39m\n", "\u001b[1;31mZeroDivisionError\u001b[0m: division by zero" ] } ], "source": [ "1/0" ] }, { "cell_type": "markdown", "id": "e3a5f544", "metadata": {}, "source": [ "# Model Creation" ] }, { "cell_type": "code", "execution_count": null, "id": "7beedf40", "metadata": {}, "outputs": [], "source": [ "dbFilePath=r\"Tutorial3_Model.db3\"" ] }, { "cell_type": "code", "execution_count": null, "id": "065c7979", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "New model is created with the model identifier: M-1-0-1\n" ] } ], "source": [ "s3s.NewModel(dbName=dbFilePath,\n", " providerType=Interfaces.SirDBProviderType.SQLite, \n", " namedInstance=\"\", \n", " netType=Interfaces.NetworkType.DistrictHeating,\n", " modelDescription=\"Tutorial 3 Model\",\n", " userID=\"\", \n", " password=\"\")" ] }, { "cell_type": "code", "execution_count": null, "id": "2a2ff71f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "New node added\n" ] } ], "source": [ "nodeA=s3s.AddNewNode(\"-1\", \"Node A\", \"PKON\", 0.0, 0.0, 0.0, 10.0, 5.0, \"Node A Description\", \"A\", 1)" ] }, { "cell_type": "code", "execution_count": null, "id": "bda42da7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "New node added\n" ] } ], "source": [ "nodeB=s3s.AddNewNode(\"-1\", \"Node B\", \"QKON\", 10.0, 10.0, 0.0, 5.0, 5.0, \"Node B Description\", \"B\", 1)" ] }, { "cell_type": "code", "execution_count": null, "id": "e8657a36", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "New pipe added\n" ] }, { "data": { "text/plain": [ "'4722505344321420574'" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s3s.AddNewPipe(\"-1\", nodeA, nodeB, 5.0, \"LINESTRING (120 76, 500 300, 620 480)\", \"ST\", \"50\", 3.0, \"AB\", \"Pipe from A to B\", 1)" ] }, { "cell_type": "code", "execution_count": null, "id": "ad105d54", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Changes saved successfully\n" ] } ], "source": [ "s3s.SaveChanges()" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.8" } }, "nbformat": 4, "nbformat_minor": 5 }