...
 
Commits (2)
......@@ -241,6 +241,121 @@ class ElectricalToThermalConversionUnit(ConversionUnit):
"vector (list or dict) for each time period !")
class ElectricalConversionUnit(ConversionUnit):
"""
**Description**
Electrical Conversion unit with an electricity consumption
and a electricity production
**Attributes**
* elec_production_unit : elec production unit (elec output)
* elec_consumption_unit : electricity consumption unit (electrical
input)
* conversion : Dynamic Constraint linking the electrical input to
the elec output through the electrical to elec ratio
"""
def __init__(self, time, name, pmin_in_elec=1e-5, pmax_in_elec=1e+5,
p_in_elec=None, pmin_out_elec=1e-5, pmax_out_elec=1e+5,
p_out_elec=None, elec_to_elec_ratio=1, operator=None):
"""
:param time: TimeUnit describing the studied time period
:param name: name of the electrical to elec conversion unit
:param pmin_in_elec: minimal incoming electrical power
:param pmax_in_elec: maximal incoming electrical power
:param p_in_elec: power input for the electrical consumption unit
:param pmin_out_elec: minimal power output (elec)
:param pmax_out_elec: maximal power output (elec)
:param p_out_elec: power output (elec)
:param elec_to_elec_ratio: electricity to elec ratio <=1
:param operator : operator of the electrical to elec conversion unit
"""
if p_out_elec is None:
self.elec_production_unit = VariableProductionUnit(
time, name + '_elec_prod', energy_type='Electrical',
pmin=pmin_out_elec, pmax=pmax_out_elec, operator=operator)
else:
self.elec_production_unit = ProductionUnit(
time, name + '_elec_prod', energy_type='Electrical',
p=p_out_elec, operator=operator)
if p_in_elec is None:
self.elec_consumption_unit = VariableConsumptionUnit(
time, name + '_elec_cons', pmin=pmin_in_elec,
pmax=pmax_in_elec, energy_type='Electrical', operator=operator)
else:
self.elec_consumption_unit = ConsumptionUnit(
time, name, p=p_in_elec, energy_type='Electrical',
operator=operator)
ConversionUnit.__init__(self, time, name,
prod_units=[self.elec_production_unit],
cons_units=[self.elec_consumption_unit],
operator=operator)
if isinstance(elec_to_elec_ratio, (int, float)): # e2h_ratio is a
# mean value
if elec_to_elec_ratio <= 1:
self.conversion = DynamicConstraint(
exp_t='{0}_p[t] == {1} * {2}_p[t]'.format(
self.elec_production_unit.name,
elec_to_elec_ratio,
self.elec_consumption_unit.name),
t_range='for t in time.I', name='conversion', parent=self)
else:
raise ValueError('The elec_to_elec_ratio should be lower '
'than 1 (elec_production<elec_consumption)')
elif isinstance(elec_to_elec_ratio, list): # e2h_ratio is a list of
# values
if len(elec_to_elec_ratio) == self.time.LEN: # it must have the
# right size, i.e. the TimeUnit length.
if all(e <= 1 for e in elec_to_elec_ratio):
self.conversion = DynamicConstraint(
exp_t='{0}_p[t] == {1}[t] * {2}_p[t]'.format(
self.elec_production_unit.name,
elec_to_elec_ratio,
self.elec_consumption_unit.name),
t_range='for t in time.I', name='conversion',
parent=self)
else:
raise ValueError('The elec_to_elec_ratio values should be '
'lower than 1 (elec_production<elec_'
'consumption)')
else:
raise IndexError('The length of the elec_to_elec_ratio '
'vector should be of the same length as the '
'TimeUnit of the studied period')
elif isinstance(elec_to_elec_ratio, dict): # e2h_ratio is a dict of
# values
if len(elec_to_elec_ratio) == self.time.LEN:
if all(e <= 1 for e in elec_to_elec_ratio.values()):
self.conversion = DynamicConstraint(
exp_t='{0}_p[t] == {1}[t] * {2}_p[t]'.format(
self.elec_production_unit.name,
elec_to_elec_ratio,
self.elec_consumption_unit.name),
t_range='for t in time.I', name='conversion',
parent=self)
else:
raise ValueError('The elec_to_elec_ratio values should be '
'lower than 1 (elec_production<elec_'
'consumption)')
else:
raise IndexError('The length of the elec_to_elec_ratio '
'dictionary should be of the same length as '
'the TimeUnit of the studied period')
else:
raise TypeError(
"Electricity to elec ratio should be a mean value or a "
"vector (list or dict) for each time period !")
class HeatPump(ConversionUnit):
"""
**Description**
......
This diff is collapsed.