Skip to content

Commit 75c05ee

Browse files
committed
Improve docstrings and register ElementModels directly in FlowSystemModel
1 parent d2182aa commit 75c05ee

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

flixopt/structure.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,10 @@ def _valid_label(label: str) -> str:
763763

764764

765765
class Submodel(SubmodelsMixin):
766-
"""Stores Variables and Constraints."""
766+
"""Stores Variables and Constraints. Its a subset of a FlowSystemModel.
767+
Variables and constraints are stored in the main FLowSystemModel, and are referenced here.
768+
Can have other Submodels assigned, and can be a Submodel of another Submodel.
769+
"""
767770

768771
def __init__(
769772
self, model: FlowSystemModel, label_of_element: str, label_of_model = None
@@ -1003,7 +1006,10 @@ def get(self, name: str, default=None):
10031006

10041007

10051008
class ElementModel(Submodel):
1006-
"""Stores the mathematical Variables and Constraints for Elements"""
1009+
"""
1010+
Stores the mathematical Variables and Constraints for Elements.
1011+
ElementModels are directly registered in the main FLowSystemModel
1012+
"""
10071013

10081014
def __init__(self, model: FlowSystemModel, element: Element):
10091015
"""
@@ -1012,7 +1018,8 @@ def __init__(self, model: FlowSystemModel, element: Element):
10121018
element: The element this model is created for.
10131019
"""
10141020
self.element = element
1015-
super().__init__(model, label_of_element=element.label_full)
1021+
super().__init__(model, label_of_element=element.label_full, label_of_model=element.label_full)
1022+
self._model.add_submodels(self, short_name=self.label_of_model)
10161023

10171024
def results_structure(self):
10181025
return {

0 commit comments

Comments
 (0)