...
 
Commits (3)
#! usr/bin/env python3
# coding=utf-8 #
"""
**This module defines the reversible units**
The reversible_units module defines various kinds of reversible units with
associated attributes and methods, from simple to specific ones.
It includes :
- ReversibleUnit : simple reversible unit inheriting from EnergyUnit,
that can both produce and consume energy but not at the same time.
..
Copyright 2018 G2Elab / MAGE
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from pulp import LpBinary
from .energy_units import VariableEnergyUnit
from ...general.optimisation.elements import DynamicConstraint, \
ExternalConstraint, ExtDynConstraint, Constraint
from ...general.optimisation.elements import Objective
from ...general.optimisation.elements import Quantity
__docformat__ = "restructuredtext en"
class ReversibleUnit(VariableEnergyUnit):
"""
**Description**
Simple Reversible unit
**Attributes**
* pc_max : maximal instantaneous consumption power [kW]
* pp_max : maximal instantaneous production power [kW]
* pc (Quantity) : instantaneous consumption power [kW]
* pp (Quantity) : instantaneous production power [kW]
* uc (Quantity) : binary variable describing whether the unit is
consuming or not: 0: Not consuming & 1: consuming
* on_off_stor (DynamicConstraint) : making u[t] matching with
storage modes (on/off)
* def_max_cons (DynamicConstraint) : defining the max consumption
power, avoiding consumption and production at the same time
* def_max_prod (DynamicConstraint) : defining the max
production power, avoiding consumption and production at the same time
* def_min_cons (DynamicConstraint) : defining the min consumption
power, avoiding consumption and production at the same time
* def_min_prod (DynamicConstraint) : defining the min
production power, avoiding consumption and production at the same time
"""
def __init__(self, time, name, pc_min=1e-5, pc_max=None,
pp_min=1e-5, pp_max=None, energy_type=None):
"""
:param time: TimeUnit describing the studied time period
:param name: name of the storage unit
:param pc_min: minimal charging power [kW]
:param pc_max: maximal charging power [kW]
:param pp_min: minimal discharging power [kW]
:param pp_max: maximal discharging power [kW]
:param energy_type: energy type the storage unit is used with
"""
VariableEnergyUnit.__init__(self, time, name, flow_direction='in',
p_min=-1e5, p_max=1e5,
energy_type=energy_type)
self.pc_max = Quantity(name='pc_max', description='maximum '
'consumption '
'power', unit='kW',
value=pc_max, lb=0, parent=self)
self.pp_max = Quantity(name='pp_max', description='maximum '
'production power',
unit='kW', value=pp_max, lb=0, parent=self)
# --- Consumption and production powers ---
self.pc = Quantity(name='pc', opt=True, unit='kW', vlen=time.LEN, lb=0,
ub=pc_max,
parent=self)
self.pp = Quantity(name='pp', opt=True, unit='kW', vlen=time.LEN, lb=0,
ub=pp_max,
parent=self)
self.uc = Quantity(name="uc", vtype=LpBinary, vlen=time.LEN, opt=True,
description='binary variable 0:No consumption & '
'1:consumption', parent=self)
# CONSTRAINTS
# Power flow equals charging power minus discharging power
self.calc_p = DynamicConstraint(
exp_t='{0}_p[t] == {0}_pc[t] - {0}_pp[t]'.format(self.name),
t_range='for t in time.I', name='calc_p', parent=self)
# For reversible units, as the power can be both positive and negative,
# an other constraint is needed to make u[t] match with cons/prod
self.on_off_rev = DynamicConstraint(
exp_t='{0}_pc[t] + {0}_pp[t] - {0}_u[t] * {eps}'
' >= 0'.format(self.name, eps=0.001),
t_range='for t in time.I',
name='on_off_rev', parent=self)
# Limits to avoid consumption and production at the same time
self.def_max_charging = DynamicConstraint(
exp_t='{0}_pc[t] - {0}_uc[t] * {1} <= 0'.format(self.name, pc_max),
t_range='for t in time.I',
name='def_max_cons', parent=self)
self.def_max_discharging = DynamicConstraint(
exp_t='{0}_pp[t] - (1 - {0}_uc[t]) * {1} <= 0'.format(self.name,
pp_max),
t_range='for t in time.I',
name='def_max_prod', parent=self)
self.def_min_charging = DynamicConstraint(
exp_t='{0}_pc[t] - {0}_uc[t] * {1} >= 0'.format(self.name, pc_min),
t_range='for t in time.I',
name='def_min_cons', parent=self)
self.def_min_discharging = DynamicConstraint(
exp_t='{0}_pp[t] + ({0}_uc[t] - {0}_u[t]) * {1} '
'>= 0'.format(self.name, pp_min), t_range='for t in time.I',
name='def_min_prod', parent=self)
\ No newline at end of file
......@@ -49,17 +49,17 @@ class StorageUnit(VariableEnergyUnit):
**Attributes**
* capacity (Quantity): maximal energy that can be stored
* e (Quantity): energy at time t in the storage
* capacity (Quantity): maximal energy that can be stored [kWh]
* e (Quantity): energy at time t in the storage [kWh]
* pc_max : maximal charging power [kW]
* pd_max : maximal discharging power [kW]
* set_soc_min (DynamicConstraint): constraining the energy to be
above the value : soc_min*capacity
* set_soc_max (DynamicConstraint): constraining the energy to be
below the value : soc_max*capacity
* pc (Quantity) : charging power
* pd (Quantity) : discharging power
* u_c (Quantity) : binary variable describing the charge of the
* pc (Quantity) : charging power [kW]
* pd (Quantity) : discharging power [kW]
* uc (Quantity) : binary variable describing the charge of the
storage unit : 0 : Not charging & 1 : charging
* calc_e (DynamicConstraint) : energy calculation at time t ;
relation power/energy
......@@ -441,15 +441,15 @@ class StorageUnitTm1(StorageUnit):
In this case, e_f is not defined as a quantity
**Attributes**
* capacity (Quantity): maximal energy that can be stored
* e (Quantity): energy at time t in the storage
* capacity (Quantity): maximal energy that can be stored [kWh]
* e (Quantity): energy at time t in the storage [kWh]
* set_soc_min (DynamicConstraint): constraining the energy to be
above the value : soc_min*capacity
* set_soc_max (DynamicConstraint): constraining the energy to be
below the value : soc_max*capacity
* pc (Quantity) : charging power
* pd (Quantity) : discharging power
* u_c (Quantity) : binary variable describing the charge of the
* pc (Quantity) : charging power [kW]
* pd (Quantity) : discharging power [kW]
* uc (Quantity) : binary variable describing the charge of the
storage unit : 0 : Not charging & 1 : charging
* calc_e (DynamicConstraint) : energy calculation at time t ;
relation power/energy
......