为建筑物的供暖系统实施MPC控制器的小型项目(Matlab代码实现)

欢迎来到本博客❤️❤️

博主优势:博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

本文目录如下:

目录

1 概述

2 运行结果

3 参考文献

4 Matlab代码实现


1 概述

​目前,我国较为先进的供热系统对二级管网进行平衡调节,并通过安装在散热器上的手动调节阀、温控阀调节水流量,从而改变室温。但供暖期间大多数用户不能合理、及时调节温控装置,导致部分建筑室温分布不均甚至出现开窗散热的现象,供暖能耗浪费严重。因此,通过采用室温控制技术维持室温稳定,可保证房间的热舒适性,减少开窗散热等无效热损失,从而实现高效费比节能。 

这个项目为一栋建筑的供暖系统实现了MPC控制器。本文设计了一个MPC控制器,以最大限度地降低运行的总成本,同时考虑到天气的预测,并研究了额外储热的影响。

本项目需要多次模拟(3次以内)。可以减少问题的范围(但在合理的范围内)或采样时间。大多数情况下,计算器的性能比较重要。

2 运行结果

主函数部分代码:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%              MPC -- Mini Project             %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
​
clc;
close all;
​
yalmip('clear');
clear all;
​
%% Model data
​
load building.mat;
load battery.mat;
​
%
 Parameters of the Building ModelA = ssM.A;
Bu = ssM.Bu;
Bd = ssM.Bd;
C = ssM.C;
Ts = ssM.timestep;
​
% Parameters of the Storage Model
a = ssModel.A;
b = ssModel.Bu;   
​
% Installation Test
yalmip('version')
sprintf('The Project files are successfully installed')
​
% Other parameters
nx = length(A); %number of states
ny = size(C,1); %number of outputs
nu = size(Bu,2); %number of inputs
nd = size(Bd,2); %number of disturbances
​
umax = 15*ones(nu,1); umin = 0*ones(nu,1); %input constraints
ymax = 26*ones(ny,1); ymin = 22*ones(ny,1); %output constraints
​
vmax = 20; vmin = -20;
xbmax = 20; xbmin = 0;
​
%% Controller Design (Setting-up MPC optimizer)
​
figure,
subplot(1,2,1),
stairs(refDist(2:3,:)'); %
plot two of disturbance inputslegend(ssM.disturbance(2:3));
xlabel('Step-Time: 20min');
ylabel('Disturbances (kW)');
subplot(1,2,2),
stairs(refDist(1,:)'); %plot one of disturbance inputs
legend(ssM.disturbance(1));
xlabel('
Step-
Time:
20
min
');
ylabel('
Disturbances (C)
');
​
savefig('
disturbances.fig
'); %save figure
disp('
Click on Enter to continue with the Section 
1
.
'); pause;
%% Section 1: tracking MPC
​
%define objective parameters
param_objective.R = eye(ny); %cost weight
param_objective.yref = [24 24 24]'
; %reference outputs​
%define constraints matrix
param_constraints.Mu = [eye(nu); -eye(nu)];
param_constraints.My = [eye(ny); -eye(ny)];
param_constraints.mu = [umax; -umin];
param_constraints.my = [ymax; -ymin];
​
%Determine the influence of the horizon length on the MPC scheme
param_simulation.horizon_lengths = [4, 15, 30, 50, 72, 90]; %arbitrary values of horizon length
tuning_horizon_length(ssM, param_constraints, param_objective, param_simulation, refDist);
​
%define simulation parameters
param_simulation.N = 72; %prediction horizon chosen - 1 day = 72*20min
param_simulation.T = size(refDist,2)-param_simulation.N; %simulation length in time-steps
​
%run tracking MPC with no night-setbacks and no variable cost
[xt, yt, ut, t] = trackingMPC(ssM, param_constraints, param_objective, param_simulation);
​
%display total economic cost
total_cost = 0.2*sum(ut(:));
sprintf('Total economic cost: $%d', total_cost)
​
disp('Click on Enter to continue with the Section 2.'); pause;
%% Section 2: economic MPC and soft constraints
​
%
define other objective parametersparam_objective.c = 0.2; %fixed electricity price
param_objective.S = 50*eye(ny); %economic cost weight
​
%run economic MPC with no night-setbacks and no variable cost
[xt, yt, ut, t, total_cost] = economicMPC_sc(ssM, param_constraints, param_objective, param_simulation);
​
%display total economic cost
sprintf('Total economic cost: $%d', total_cost)
​
disp('Click on Enter to continue with the Section 3.'); pause;
%% Section 3: economic, soft constraints, and variable cost
​
%
run economic MPC with variable cost, but no night-setbacks[xt, yt, ut, t, total_cost] = economicMPC_sc_vc(ssM, param_constraints, param_objective, param_simulation);
​
%display total economic cost
sprintf('Total economic cost: $%d', total_cost)
​
disp('Click on Enter to continue with the Section 4.'); pause;
%% Section 4 : Night setbacks
​
%
run economic MPC with variable cost 
and
 night-setbacks[xt, yt, ut, t, total_cost] = economicMPC_sc_vc_sb(ssM, param_constraints, param_objective, param_simulation);
​
%display total economic cost
sprintf('Total economic cost: $%d', total_cost)
​
disp('Click on Enter to continue with the Section 5.'); pause;

3 参考文献

[1]张冬冬,王淳,代伟,罗策恒,刘梓宁,武新章.居民区多能源管理模型与优化调度策略分析[J/OL].电力系统及其自动化学报:1-13[2023-05-27].

部分理论引用网络文献,若有侵权联系博主删除。

4 Matlab代码实现

你可能感兴趣的:(模型预测,matlab,开发语言,数学建模)