Commit e2bc5c39 authored by SHodencq's avatar SHodencq
Browse files

[Adding Thermal Conversion Unit]

parent 8e0caa0c
......@@ -296,6 +296,120 @@ class ElectricalConversionUnit(ConversionUnit):
"vector (list or dict) on the whole time period !")
class ThermalConversionUnit(ConversionUnit):
"""
**Description**
Thermal Conversion unit with a thermal consumption
and a thermal production
**Attributes**
* therm_production_unit : thermal production unit (thermal output)
* therm_consumption_unit : thermal consumption unit (thermal
input)
* conversion : Definition Dynamic Constraint linking the thermal
input to the thermal output through the therm_to_therm ratio
"""
def __init__(self, time, name, pmin_in_therm=1e-5, pmax_in_therm=1e+5,
p_in_therm=None, pmin_out_therm=1e-5, pmax_out_therm=1e+5,
p_out_therm=None, therm_to_therm_ratio=1):
"""
:param time: TimeUnit describing the studied time period
:param name: name of the thermal to therm conversion unit
:param pmin_in_therm: minimal incoming thermal power
:param pmax_in_therm: maximal incoming thermal power
:param p_in_therm: power input for the thermal consumption unit
:param pmin_out_therm: minimal power output (therm)
:param pmax_out_therm: maximal power output (therm)
:param p_out_therm: power output (therm)
:param therm_to_therm_ratio: thermal to thermal ratio <=1
"""
if p_out_therm is None:
self.therm_production_unit = VariableProductionUnit(
time, name + '_therm_prod', energy_type='Thermal',
p_min=pmin_out_therm, p_max=pmax_out_therm)
else:
self.therm_production_unit = FixedProductionUnit(
time, name + '_therm_prod', energy_type='Thermal',
p=p_out_therm)
if p_in_therm is None:
self.therm_consumption_unit = VariableConsumptionUnit(
time, name + '_therm_cons', p_min=pmin_in_therm,
p_max=pmax_in_therm, energy_type='Thermal')
else:
self.therm_consumption_unit = FixedConsumptionUnit(
time, name, p=p_in_therm, energy_type='Thermal')
ConversionUnit.__init__(self, time, name,
prod_units=[self.therm_production_unit],
cons_units=[self.therm_consumption_unit])
if isinstance(therm_to_therm_ratio, (int, float)): # e2h_ratio is a
# mean value
if therm_to_therm_ratio <= 1:
self.conversion = DefinitionDynamicConstraint(
exp_t='{0}_p[t] == {1} * {2}_p[t]'.format(
self.therm_production_unit.name,
therm_to_therm_ratio,
self.therm_consumption_unit.name),
t_range='for t in time.I', name='conversion', parent=self)
else:
raise ValueError('The therm_to_therm_ratio should be lower '
'than 1 (therm_production<therm_consumption)')
elif isinstance(therm_to_therm_ratio, list): # e2h_ratio is a list of
# values
if len(therm_to_therm_ratio) == self.time.LEN: # it must have the
# right size, i.e. the TimeUnit length.
if all(e <= 1 for e in therm_to_therm_ratio):
self.conversion = DefinitionDynamicConstraint(
exp_t='{0}_p[t] == {1}[t] * {2}_p[t]'.format(
self.therm_production_unit.name,
therm_to_therm_ratio,
self.therm_consumption_unit.name),
t_range='for t in time.I', name='conversion',
parent=self)
else:
raise ValueError('The therm_to_therm_ratio values should '
'be '
'lower than 1 (therm_production<therm_'
'consumption)')
else:
raise IndexError('The length of the therm_to_therm_ratio '
'vector should be of the same length as the '
'TimeUnit of the studied period')
elif isinstance(therm_to_therm_ratio, dict): # e2h_ratio is a dict of
# values
if len(therm_to_therm_ratio) == self.time.LEN:
if all(e <= 1 for e in therm_to_therm_ratio.values()):
self.conversion = DefinitionDynamicConstraint(
exp_t='{0}_p[t] == {1}[t] * {2}_p[t]'.format(
self.therm_production_unit.name,
therm_to_therm_ratio,
self.therm_consumption_unit.name),
t_range='for t in time.I', name='conversion',
parent=self)
else:
raise ValueError('The therm_to_therm_ratio values should '
'be '
'lower than 1 (therm_production<therm_'
'consumption)')
else:
raise IndexError('The length of the therm_to_therm_ratio '
'dictionary should be of the same length as '
'the TimeUnit of the studied period')
else:
raise TypeError(
"Thermal to thermal ratio should be a mean value or a "
"vector (list or dict) on the whole time period !")
# Todo : make this class generic for conversion units ?
class ReversibleConversionUnit(ConversionUnit):
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment