# -*- coding: utf-8"""Module for custom component groups.It is possible to create subsystems of component groups in tespy. The subsystemclass is the base class for custom subsystems.This file is part of project TESPy (github.com/oemof/tespy). It's copyrightedby the contributors recorded in the version control history of the file,available from its original location tespy/components/subsystems.pySPDX-License-Identifier: MIT"""fromtespy.toolsimportlogger
[docs]classSubsystem:r""" Class Subsystem is the base class of all TESPy subsystems. Parameters ---------- label : str The label of the subsystem. Example ------- Basic example for a setting up a Subsystem object. This example does not run a TESPy calculation! >>> from tespy.components import Subsystem >>> mysub = Subsystem('mySubsystem') >>> type(mysub) <class 'tespy.components.subsystem.Subsystem'> >>> mysub.get_attr('label') 'mySubsystem' """def__init__(self,label):ifnotisinstance(label,str):msg='Subsystem label must be of type str!'logger.error(msg)raiseValueError(msg)eliflen([xforxin[';',', ','.']ifxinlabel])>0:msg='Can\'t use '+str([';',', ','.'])+' in label.'logger.error(msg)raiseValueError(msg)else:self.label=labelself.comps={}self.conns={}self.create_comps()self.create_conns()
[docs]defget_attr(self,key):r""" Get the value of a subsystem's attribute. Parameters ---------- key : str The attribute you want to retrieve. Returns ------- out : Value of specified attribute. """ifkeyinself.__dict__:returnself.__dict__[key]else:msg='Subsystem '+self.label+' has no attribute '+key+'.'logger.error(msg)raiseKeyError(msg)
[docs]defcreate_comps(self):"""Create the subsystem's components."""return
[docs]defcreate_conns(self):"""Create the subsystem's connections."""return