omotes-simulator-core 0.0.3.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omotes_simulator_core-0.0.3.dev0.dist-info/LICENSE +621 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/METADATA +55 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/RECORD +59 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/WHEEL +5 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/top_level.txt +1 -0
- simulator_core/__init__.py +15 -0
- simulator_core/__main__.py +21 -0
- simulator_core/adapter/__init__.py +16 -0
- simulator_core/adapter/presentation/__init__.py +16 -0
- simulator_core/adapter/transforms/__init__.py +16 -0
- simulator_core/adapter/transforms/esdl_asset_mapper.py +53 -0
- simulator_core/adapter/transforms/mappers.py +226 -0
- simulator_core/adapter/transforms/string_to_esdl.py +66 -0
- simulator_core/adapter/transforms/transform_utils.py +34 -0
- simulator_core/entities/__init__.py +16 -0
- simulator_core/entities/assets/__init__.py +16 -0
- simulator_core/entities/assets/asset_abstract.py +116 -0
- simulator_core/entities/assets/asset_defaults.py +68 -0
- simulator_core/entities/assets/controller_classes.py +81 -0
- simulator_core/entities/assets/demand_cluster.py +117 -0
- simulator_core/entities/assets/esdl_asset_object.py +60 -0
- simulator_core/entities/assets/junction.py +64 -0
- simulator_core/entities/assets/pipe.py +174 -0
- simulator_core/entities/assets/production_cluster.py +222 -0
- simulator_core/entities/assets/utils.py +154 -0
- simulator_core/entities/esdl_object.py +90 -0
- simulator_core/entities/heat_network.py +82 -0
- simulator_core/entities/network_controller.py +67 -0
- simulator_core/entities/simulation_configuration.py +31 -0
- simulator_core/entities/utility/__init__.py +16 -0
- simulator_core/entities/utility/influxdb_reader.py +129 -0
- simulator_core/infrastructure/__init__.py +16 -0
- simulator_core/infrastructure/app.py +55 -0
- simulator_core/infrastructure/simulation_manager.py +55 -0
- simulator_core/infrastructure/utils.py +45 -0
- simulator_core/py.typed +0 -0
- simulator_core/simulation/__init__.py +18 -0
- simulator_core/simulation/mappers/__init__.py +16 -0
- simulator_core/simulation/mappers/mappers.py +35 -0
- simulator_core/simulation/networksimulation.py +63 -0
- simulator_core/solver/__init__.py +15 -0
- simulator_core/solver/matrix/__init__.py +15 -0
- simulator_core/solver/matrix/core_enum.py +26 -0
- simulator_core/solver/matrix/equation_object.py +56 -0
- simulator_core/solver/matrix/matrix.py +125 -0
- simulator_core/solver/matrix/utility.py +38 -0
- simulator_core/solver/network/__init__.py +15 -0
- simulator_core/solver/network/assets/__init__.py +15 -0
- simulator_core/solver/network/assets/base_asset.py +303 -0
- simulator_core/solver/network/assets/base_item.py +63 -0
- simulator_core/solver/network/assets/base_node_item.py +67 -0
- simulator_core/solver/network/assets/boundary.py +83 -0
- simulator_core/solver/network/assets/fall_type.py +225 -0
- simulator_core/solver/network/assets/node.py +274 -0
- simulator_core/solver/network/assets/production_asset.py +171 -0
- simulator_core/solver/network/assets/solver_pipe.py +541 -0
- simulator_core/solver/network/network.py +398 -0
- simulator_core/solver/solver.py +80 -0
- simulator_core/solver/utils/fluid_properties.py +173 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
"""Module containing the production asset class."""
|
|
16
|
+
import uuid
|
|
17
|
+
|
|
18
|
+
import numpy as np
|
|
19
|
+
|
|
20
|
+
from simulator_core.solver.matrix.core_enum import NUMBER_CORE_QUANTITIES, IndexEnum
|
|
21
|
+
from simulator_core.solver.matrix.equation_object import EquationObject
|
|
22
|
+
from simulator_core.solver.network.assets.fall_type import FallType
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ProductionAsset(FallType):
|
|
26
|
+
"""
|
|
27
|
+
A class to represent a production asset in a network.
|
|
28
|
+
|
|
29
|
+
This class inherits from the FallType class and implements the methods to generate
|
|
30
|
+
the equations for the production asset.
|
|
31
|
+
|
|
32
|
+
Attributes
|
|
33
|
+
----------
|
|
34
|
+
connected_nodes : list[int]
|
|
35
|
+
A list of integers that store the node indices that are connected to the asset.
|
|
36
|
+
number_of_connection_point : int
|
|
37
|
+
The number of connection points for the asset.
|
|
38
|
+
pre_scribe_mass_flow : bool
|
|
39
|
+
A boolean flag that indicates whether the mass flow rate or the pressure is prescribed
|
|
40
|
+
at the connection points.
|
|
41
|
+
|
|
42
|
+
Methods
|
|
43
|
+
-------
|
|
44
|
+
get_equations() -> list[EquationObject]
|
|
45
|
+
Returns a list of EquationObjects that represent the equations for the asset.
|
|
46
|
+
add_pre_scribe_equation(connection_point: int) -> EquationObject
|
|
47
|
+
Returns an EquationObject that represents the prescribed mass flow rate or pressure
|
|
48
|
+
equation for the asset at the given connection point.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
mass_flow_rate_set_point: float
|
|
52
|
+
"""The mass flow rate set point for the asset."""
|
|
53
|
+
|
|
54
|
+
set_pressure: float
|
|
55
|
+
"""The pressure set point for the asset."""
|
|
56
|
+
|
|
57
|
+
pre_scribe_mass_flow: bool
|
|
58
|
+
"""A boolean flag that indicates whether the mass flow rate or the pressure is prescribed
|
|
59
|
+
at the connection points."""
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
name: uuid.UUID,
|
|
64
|
+
supply_temperature: float = 293.15,
|
|
65
|
+
heat_supplied: float = 0.0,
|
|
66
|
+
loss_coefficient: float = 1.0,
|
|
67
|
+
pre_scribe_mass_flow: bool = True,
|
|
68
|
+
mass_flow_rate_set_point: float = 10.0,
|
|
69
|
+
set_pressure: float = 10000.0,
|
|
70
|
+
):
|
|
71
|
+
"""
|
|
72
|
+
Initializes the ProductionAsset object with the given parameters.
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
name : uuid.UUID The unique identifier of the asset.
|
|
77
|
+
number_of_unknowns : int, optional
|
|
78
|
+
The number of unknown variables for the asset. The default is 6, which corresponds to
|
|
79
|
+
the mass flow rate, pressure, and temperature at each connection point.
|
|
80
|
+
number_con_points : int, optional
|
|
81
|
+
The number of connection points for the asset. The default is 2, which corresponds to
|
|
82
|
+
the inlet and outlet.
|
|
83
|
+
"""
|
|
84
|
+
self.pre_scribe_mass_flow = pre_scribe_mass_flow
|
|
85
|
+
self.mass_flow_rate_set_point = mass_flow_rate_set_point
|
|
86
|
+
self.set_pressure = set_pressure
|
|
87
|
+
|
|
88
|
+
super().__init__(
|
|
89
|
+
name=name,
|
|
90
|
+
supply_temperature=supply_temperature,
|
|
91
|
+
heat_supplied=heat_supplied,
|
|
92
|
+
loss_coefficient=loss_coefficient,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def get_equations(self) -> list[EquationObject]:
|
|
96
|
+
"""Returns a list of EquationObjects that represent the equations for the asset.
|
|
97
|
+
|
|
98
|
+
The equations are:
|
|
99
|
+
- Pressure balance at each connection point
|
|
100
|
+
- Thermal balance at each connection point
|
|
101
|
+
- Prescribed mass flow rate or pressure at each connection point
|
|
102
|
+
:return: list[EquationObject]
|
|
103
|
+
A list of EquationObjects that contain the indices, coefficients, and right-hand side
|
|
104
|
+
values of the equations.
|
|
105
|
+
"""
|
|
106
|
+
equations = [
|
|
107
|
+
super().add_press_to_node_equation(0),
|
|
108
|
+
super().add_press_to_node_equation(1),
|
|
109
|
+
self.add_thermal_equations(0),
|
|
110
|
+
self.add_thermal_equations(1),
|
|
111
|
+
self.add_pre_scribe_equation(0),
|
|
112
|
+
self.add_pre_scribe_equation(1),
|
|
113
|
+
]
|
|
114
|
+
return equations
|
|
115
|
+
|
|
116
|
+
def add_pre_scribe_equation(self, connection_point: int) -> EquationObject:
|
|
117
|
+
"""Returns an EquationObject for a pre describe equation.
|
|
118
|
+
|
|
119
|
+
The returned equation object represents the prescribed mass flow rate or pressure
|
|
120
|
+
equation for the asset at the given connection point.
|
|
121
|
+
|
|
122
|
+
The equation is:
|
|
123
|
+
|
|
124
|
+
- If pre_scribe_mass_flow is True, then Mass flow rate at connection point = Mass flow rate
|
|
125
|
+
property
|
|
126
|
+
- If pre_scribe_mass_flow is False, then Pressure at connection point = Set pressure
|
|
127
|
+
property
|
|
128
|
+
:param int connection_point: The connection point for which to add the equation
|
|
129
|
+
:return: EquationObject
|
|
130
|
+
An EquationObject that contains the indices, coefficients, and right-hand side
|
|
131
|
+
value of the equation.
|
|
132
|
+
"""
|
|
133
|
+
# Raise IndexError if the connection point is not available
|
|
134
|
+
if connection_point >= self.number_of_connection_point:
|
|
135
|
+
raise IndexError("The connection point is not available.")
|
|
136
|
+
|
|
137
|
+
# Create equation object
|
|
138
|
+
equation_object = EquationObject()
|
|
139
|
+
if self.pre_scribe_mass_flow:
|
|
140
|
+
equation_object.indices = np.array(
|
|
141
|
+
[
|
|
142
|
+
self.matrix_index
|
|
143
|
+
+ IndexEnum.discharge
|
|
144
|
+
+ connection_point * NUMBER_CORE_QUANTITIES
|
|
145
|
+
]
|
|
146
|
+
)
|
|
147
|
+
equation_object.coefficients = np.array([-1.0 + 2 * connection_point])
|
|
148
|
+
equation_object.rhs = self.mass_flow_rate_set_point
|
|
149
|
+
else:
|
|
150
|
+
equation_object.indices = np.array(
|
|
151
|
+
[self.matrix_index + IndexEnum.pressure + connection_point * NUMBER_CORE_QUANTITIES]
|
|
152
|
+
)
|
|
153
|
+
equation_object.coefficients = np.array([1.0])
|
|
154
|
+
if connection_point == 0:
|
|
155
|
+
equation_object.rhs = 0.5 * self.set_pressure
|
|
156
|
+
else:
|
|
157
|
+
equation_object.rhs = self.set_pressure
|
|
158
|
+
return equation_object
|
|
159
|
+
|
|
160
|
+
def add_thermal_equations(self, connection_point: int) -> EquationObject:
|
|
161
|
+
"""Adds a thermal equation for a connection point of the asset.
|
|
162
|
+
|
|
163
|
+
:param connection_point: The index of the connection point to add the equation for.
|
|
164
|
+
:type connection_point: int
|
|
165
|
+
:return: An equation object representing the thermal equation.
|
|
166
|
+
:rtype: EquationObject
|
|
167
|
+
"""
|
|
168
|
+
if self.prev_sol[IndexEnum.discharge + connection_point * NUMBER_CORE_QUANTITIES] > 0:
|
|
169
|
+
return self.add_prescribe_temp(connection_point)
|
|
170
|
+
else:
|
|
171
|
+
return self.add_temp_to_node_equation(connection_point)
|