Water Heater
The water heater is an essential component in residential energy systems, especially in highly electrified homes where it significantly contributes to power demand during Demand Response (DR) events. The Model Predictive Control (MPC) formulation for the water heater optimizes its operation to maintain hot water availability while minimizing energy costs and respecting grid power limits. This section presents the MPC formulation for the water heater, which models the tank's temperature dynamics, considering heating power, heat losses to the ambient environment, and water consumption. The formulation prioritizes user comfort by minimizing deviations from a desired water temperature, making it suitable for integration into Home Energy Management Systems (HEMS).
The water heater operates with continuous power control, allowing flexible power allocation within the device's capacity limits, unlike binary on/off control. This approach enhances the MPC's ability to finely adjust energy usage, thereby reducing demand peaks during re-energization. The formulation is designed to be computationally efficient, using a linear model of temperature dynamics to ensure real-time optimization on embedded devices. The inclusion of water flow and ambient temperature effects allows for accurate modeling of real-world conditions, making the controller robust to varying usage profiles.
Optimization Formulation
The MPC formulation for the water heater optimizes the power allocated to the device over a prediction horizon , with time steps of duration (e.g., 10 minutes). The objective is to minimize the comfort penalty, defined as the squared deviation between the water temperature and a desired temperature, weighted by a user-defined priority. The power allocation cost is included in the overall MPC objective, while the comfort term is specific to the water heater.
The comfort penalty is formulated as follows:
where:
- is the priority weight for the water heater.
- is the desired water temperature (constant over the horizon, e.g., 80°C).
- is the water temperature at time .
- is the normalization factor (e.g., 50 K).
The temperature dynamics of the water heater are modeled as follows:
where:
- is the power allocated to the water heater at time .
- is the water heater constant (thermal capacity per unit volume, in Wh/°C/L).
- is the tank volume (in liters, converted to m³ for consistency).
- is the water flow rate at time (in m³/s).
- is the inlet water temperature (e.g., 16°C).
- is the ambient temperature.
- is the duration of the time step (in hours).
Constraints ensure that the water heater operates within physical and operational limits:
- Temperature Limits:
where and are the minimum and maximum allowed temperatures (e.g., 30°C and 90°C).
- Power Limits:
where is the maximum power of the water heater (in W).
- Initial Condition:
where is the initial water temperature.
The power injection of the water heater, which contributes to the global power constraint, is simply:
Justification of the Formulation
The continuous power formulation allows for finer granularity in power allocation, which is essential for mitigating DR peaks by avoiding abrupt power surges. The comfort penalty uses a constant desired temperature to simplify user input while ensuring hot water availability consistent with typical residential needs. The temperature dynamics model integrates water flow and thermal losses to the ambient environment, making it sensitive to actual usage patterns. The linearity of the dynamics and the absence of binary variables enhance computational efficiency, allowing MPC execution on resource-constrained embedded devices. The water heater constant simplifies the thermal model by combining thermal capacity and conductance effects, reducing the number of parameters while maintaining good accuracy.
Variable Definitions
Variables and parameters specific to the water heater formulation are summarized in the following table.
Variable/Parameter | Description | Units |
---|---|---|
Power allocated to the water heater at time | W | |
Water temperature at time | °C | |
Desired water temperature (constant) | °C | |
Priority weight for the water heater | - | |
Normalization factor (e.g., 50 K) | K | |
Water heater thermal constant (thermal capacity per volume) | Wh/°C/L | |
Tank volume | m³ | |
Water flow rate at time | m³/s | |
Inlet water temperature | °C | |
Ambient temperature | °C | |
Minimum water temperature | °C | |
Maximum water temperature | °C | |
Maximum water heater power | W | |
Initial water temperature | °C | |
Time step duration | h |
Classes
This module defines the WaterHeaterMPC
class, which models an electric water heater for MPC.
It extends the abstract DeviceMPC
class, providing a concrete implementation for formulating the optimization problem specific to controlling a water heater. This includes defining objectives related to maintaining water temperature within a desired range and incorporating constraints such as power limits, tank volume, and thermal dynamics influenced by ambient temperature and water flow.
WaterHeaterMPC
Represents a water heater for the MPC.
This class models the thermal behavior of an electric water heater. It formulates an optimization problem to control the heater's power consumption to maintain the water temperature within a desired range, while considering hot water usage, heat losses, and system constraints.
Methods
__init__(devices: List[Dict[str, Any]])
Initializes the WaterHeaterMPC
.
Args:
devices
: A list of dictionaries, where each dictionary contains the configuration and parameters of a water heater device.
create_mpc_formulation(start: datetime, stop: datetime, steps_horizon_k: int, interval: int = 10, norm_factor: int = 50)
Creates the optimization formulation for the water heater.
This method constructs a CVXPY optimization problem based on a thermal model of the water heater tank. The objective is to minimize deviations from a desired temperature setpoint. The model includes constraints for:
- The thermal dynamics of the water tank, accounting for heating, heat loss to the ambient environment, and hot water draws.
- Temperature limits (min and max).
- Maximum power output of the heating element.
Args:
start
: The start time of the optimization horizon.stop
: The end time of the optimization horizon.steps_horizon_k
: The number of time steps in the horizon.interval
: The duration of each time step in minutes.norm_factor
: A normalization factor for the objective function.
Returns:
- A tuple containing the objective terms, constraints, and the dispatch variable for the CVXPY optimization problem.