Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Model Library
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FOCUS
Model Library
Commits
46492d83
Commit
46492d83
authored
7 months ago
by
Christoph von Oy
Browse files
Options
Downloads
Patches
Plain Diff
Reworked flow handling in preperation for new architecture
parent
9ee75e37
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
topology.py
+48
-26
48 additions, 26 deletions
topology.py
with
48 additions
and
26 deletions
topology.py
+
48
−
26
View file @
46492d83
...
...
@@ -117,57 +117,77 @@ class Topology:
output_commodity_2
,
)
=
component
.
get_input_output_commodities
()
if
input_commodity_1
!=
None
:
self
.
_connectors
[
component_name
+
"
.
input_1
"
]
=
Connector
(
self
.
_connectors
[
component_name
,
"
input_1
"
]
=
Connector
(
component_name
+
"
.input_1
"
)
if
input_commodity_2
!=
None
:
self
.
_connectors
[
component_name
+
"
.
input_2
"
]
=
Connector
(
self
.
_connectors
[
component_name
,
"
input_2
"
]
=
Connector
(
component_name
+
"
.input_2
"
)
if
output_commodity_1
!=
None
:
self
.
_connectors
[
component_name
+
"
.
output_1
"
]
=
Connector
(
self
.
_connectors
[
component_name
,
"
output_1
"
]
=
Connector
(
component_name
+
"
.output_1
"
)
if
output_commodity_2
!=
None
:
self
.
_connectors
[
component_name
+
"
.
output_2
"
]
=
Connector
(
self
.
_connectors
[
component_name
,
"
output_2
"
]
=
Connector
(
component_name
+
"
.output_2
"
)
self
.
_flows
=
[]
self
.
_connections
=
[]
self
.
_connections_map
=
dict
()
for
connection
in
configuration
[
"
connections
"
]:
index
=
len
(
self
.
_connections
)
if
connection
[
"
type
"
]
==
"
OneToOne
"
:
flow_from
=
connection
[
"
from
"
]
in_flow
=
flow_from
+
"
_
"
+
str
(
index
)
self
.
_flows
.
append
(
in_flow
)
connector_from
=
self
.
_connectors
[
flow_from
]
flow_from
=
connection
[
"
from
"
].
split
(
"
.
"
)
flow_from_component
=
flow_from
[
0
]
flow_from_connector
=
flow_from
[
1
]
in_flow
=
(
flow_from_component
+
"
.
"
+
flow_from_connector
+
"
__
"
+
str
(
index
)
)
connector_from
=
self
.
_connectors
[
flow_from_component
,
flow_from_connector
]
connector_from
.
flows
.
append
(
in_flow
)
# connector_from.other_sides.append(index)
in_flows
=
[
in_flow
]
flow_to
=
connection
[
"
to
"
]
out_flow
=
str
(
index
)
+
"
_
"
+
flow_to
self
.
_flows
.
append
(
out_flow
)
connector_to
=
self
.
_connectors
[
flow_to
]
flow_to
=
connection
[
"
to
"
].
split
(
"
.
"
)
flow_to_component
=
flow_to
[
0
]
flow_to_connector
=
flow_to
[
1
]
out_flow
=
(
str
(
index
)
+
"
__
"
+
flow_to_component
+
"
.
"
+
flow_to_connector
)
connector_to
=
self
.
_connectors
[
flow_to_component
,
flow_to_connector
]
connector_to
.
flows
.
append
(
out_flow
)
# connector_to.other_sides.append(index)
out_flows
=
[
out_flow
]
self
.
_connections_map
[
flow_from
,
flow_to
]
=
index
self
.
_connections_map
[
connection
[
"
from
"
],
connection
[
"
to
"
]
]
=
index
elif
connection
[
"
type
"
]
==
"
Sum
"
:
in_flows
=
[]
out_flows
=
[]
for
member
in
connection
[
"
members
"
]:
temp
=
member
.
split
(
"
.
"
)
member_component
=
temp
[
0
]
member_connector
=
temp
[
1
]
if
"
output
"
in
member
:
flow
=
member
+
"
_
"
+
str
(
index
)
self
.
_flows
.
append
(
flow
)
flow
=
(
member_component
+
"
.
"
+
member_connector
+
"
__
"
+
str
(
index
)
)
in_flows
.
append
(
flow
)
else
:
flow
=
str
(
index
)
+
"
_
"
+
member
self
.
_flows
.
append
(
flow
)
flow
=
(
str
(
index
)
+
"
__
"
+
member_component
+
"
.
"
+
member_connector
)
out_flows
.
append
(
flow
)
connector
=
self
.
_connectors
[
member
]
connector
=
self
.
_connectors
[
member
_component
,
member_connector
]
connector
.
flows
.
append
(
flow
)
# connector.other_sides.append(index)
if
"
loss_factor
"
in
connection
:
...
...
@@ -403,10 +423,10 @@ class Topology:
self
.
_components
[
component
].
add_state_model
(
d_block
,
o_block
,
s_block
)
self
.
_components
[
component
].
add_additional_model_logic
(
d_block
,
o_block
)
for
flow
in
self
.
_flows
:
for
connector
in
self
.
_connectors
.
values
():
for
flow
in
connector
.
flows
:
o_block
.
add
(
flow
,
pyo
.
Var
(
o_block
.
T
,
bounds
=
(
0
,
None
)))
for
connector
in
self
.
_connectors
.
values
():
connector_var
=
o_block
.
component_dict
[
connector
.
name
]
def
rule
(
m
,
t
):
...
...
@@ -547,7 +567,8 @@ class Topology:
self
.
_components
[
component
].
state_base_variable_names
()
)
for
flow
in
self
.
_flows
:
for
connector
in
self
.
_connectors
.
values
():
for
flow
in
connector
.
flows
:
base_variable_names
.
append
((
flow
,
VariableKind
.
INDEXED
))
result
=
EntityResult
(
architecture
)
...
...
@@ -574,7 +595,8 @@ class Topology:
self
.
_components
[
component
].
state_base_variable_names
()
)
for
flow
in
self
.
_flows
:
for
connector
in
self
.
_connectors
.
values
():
for
flow
in
connector
.
flows
:
operational_base_variable_names
.
append
((
flow
,
VariableKind
.
INDEXED
))
result
.
register_dynamic
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment