Skip to content

Commit

Permalink
Merge 1ae141f into 78d55e8
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Oct 23, 2019
2 parents 78d55e8 + 1ae141f commit 0032358
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 226 deletions.
3 changes: 3 additions & 0 deletions doc/whats_new/v0-1-3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ New Features
- Individual design path specification is available: Specify the design_path individually for single connections or a components in your network, if
you want the individual design parameters be loaded from a different design case than the network's design case given in the network's
design path (`PR #84 <https://github.com/oemof/tespy/pull/84>`_).
- Implement local design and local offdesign features: It is possible to design a plant while some parts of the plant are in offdesign mode. This is useful,
e. g. when designing an extraction turbine, where the district heating condenser is designed for maximum extraction and the backpressure turbine is designed
for minimum extraction (`PR #92 <https://github.com/oemof/tespy/pull/92>`_).
- Implement warning messages for all components, if the component's properties are out of physical bounds. The bounds can be customized when specifying a property
by data containers (read more at :ref:`component parameter specification <using_tespy_components_parametrisation_label>`), (`PR #85 <https://github.com/oemof/tespy/pull/85>`_).

Expand Down
30 changes: 25 additions & 5 deletions tespy/components/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ def __init__(self, label, **kwargs):
else:
self.label = label

self.design_path = None
# defaults
self.interface = False

# set default design and offdesign parameters
self.new_design = True
self.design_path = None
self.design = []
self.offdesign = []
self.interface = False
self.local_design = False
self.local_offdesign = False

# add container for components attributes
var = self.attr()
Expand Down Expand Up @@ -232,11 +235,22 @@ def set_attr(self, **kwargs):
logging.error(msg)
raise ValueError(msg)

elif key == 'local_design' or key == 'local_offdesign':
if not isinstance(kwargs[key], bool):
msg = ('Please provide the ' + key + ' as boolean '
'at ' + self.label + '.')
logging.error(msg)
raise TypeError(msg)
else:
self.__dict__.update({key: kwargs[key]})

elif key == 'design_path':
if isinstance(kwargs[key], str):
self.__dict__.update({key: kwargs[key]})
self.new_design = True
elif np.isnan(kwargs[key]):
self.design_path = None
self.new_design = True
else:
msg = ('Please provide the ' + key + ' parameter as '
'string or as nan.')
Expand Down Expand Up @@ -403,10 +417,15 @@ def set_parameters(self, mode, data):
df : pandas.core.series.Series
Series containing the component parameters.
"""
if mode == 'design' or self.local_design is True:
self.new_design = True

for key, dc in self.attr().items():
if isinstance(dc, dc_cp):
if mode == 'offdesign':
if ((mode == 'offdesign' and self.local_design is False) or
(mode == 'design' and self.local_offdesign is True)):
self.get_attr(key).design = data[key]

else:
self.get_attr(key).design = np.nan

Expand Down Expand Up @@ -859,7 +878,8 @@ def comp_init(self, nw):

component.comp_init(self, nw)

if nw.mode == 'offdesign':
if ((nw.mode == 'offdesign' or self.local_offdesign is True) and
self.local_design is False):
self.dh_s_ref = (self.h_os('pre') - self.inl[0].h.design)

self.fl_deriv = self.fluid_deriv()
Expand Down
14 changes: 14 additions & 0 deletions tespy/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,13 @@ def __init__(self, comp1, outlet_id, comp2, inlet_id, **kwargs):
self.t = comp2
self.t_id = inlet_id

# defaults
self.new_design = True
self.design_path = None
self.design = []
self.offdesign = []
self.local_design = False
self.local_offdesign = False

# set default values for kwargs
var = self.attr()
Expand Down Expand Up @@ -383,11 +387,21 @@ def set_attr(self, **kwargs):
logging.error(msg)
raise ValueError(msg)

elif key == 'local_design' or key == 'local_offdesign':
if not isinstance(kwargs[key], bool):
msg = ('Please provide the ' + key + ' as boolean.')
logging.error(msg)
raise TypeError(msg)
else:
self.__dict__.update({key: kwargs[key]})

elif key == 'design_path':
if isinstance(kwargs[key], str):
self.__dict__.update({key: kwargs[key]})
self.new_design = True
elif np.isnan(kwargs[key]):
self.design_path = None
self.new_design = True
else:
msg = ('Please provide the ' + key + ' parameter as '
'string or as nan.')
Expand Down
Loading

0 comments on commit 0032358

Please sign in to comment.