Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #1

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
156e633
MPC in progress
gyulas Oct 30, 2018
d8386a8
mpc works
gyulas Oct 30, 2018
f9dd121
MPC simulations demanding much computing power
gyulas Nov 5, 2018
1abd4c1
Simscape model of the radiator unit testing
gyulas Nov 5, 2018
bc34215
Simscape model of radiator identified with 2p1z
gyulas Nov 5, 2018
2bfaa5b
Notes minor chg - unit test steps
gyulas Nov 5, 2018
1e216af
Simscape radiator unit test MPC - NOT working
gyulas Nov 5, 2018
fd35c07
minor chg!
gyulas Nov 5, 2018
0cda714
MPC sampling time changed for the house simulation
gyulas Nov 6, 2018
6d176d7
MPC weights adjusted to better performance
gyulas Nov 6, 2018
f514a16
Notes about modeling - much improvement - 28old
gyulas Nov 7, 2018
38de043
Notes - tikz pic and tables
gyulas Nov 7, 2018
39a5461
Notes - diagrams added, structure modified
gyulas Nov 8, 2018
cec5752
Notes about real time simulation
gyulas Nov 9, 2018
ae67cc4
Notes improvements and more tikzpic
gyulas Nov 9, 2018
9b2f7bd
Notes - heating, models
gyulas Nov 10, 2018
7f6c2c0
Notes - tikzpic, ház-fűtés sorrendre csere, új bevezető WIP
gyulas Nov 10, 2018
aa45097
Notes improve - bevezető, modellezés
gyulas Nov 12, 2018
eccd7f7
Simulink Real-time Desktop functionnality wip
gyulas Nov 12, 2018
d2d3f6a
Merge branch 'development' of https://github.com/gyulas/thesis into d…
gyulas Nov 12, 2018
5c835f2
Notes - modeling, intro
gyulas Nov 13, 2018
fc021b7
Real sys dev WIP
gyulas Nov 13, 2018
32aa23c
Notes improve - tables
gyulas Nov 13, 2018
738f721
Notes revised and refined a bit
gyulas Nov 14, 2018
862afb2
Notes - revision and correction
gyulas Nov 19, 2018
48a15c7
Notes changed
gyulas Nov 19, 2018
1eba8b5
Notes - using official template - WIP
gyulas Nov 19, 2018
a253cb2
Notes - references corrected, 12pt font/32p
gyulas Nov 19, 2018
468a44a
Notes - working ref
gyulas Nov 19, 2018
6df6b26
Notes - typos
gyulas Nov 20, 2018
3c0307c
Notes - nomenclature and typos
gyulas Nov 21, 2018
8cc0643
Notes - ident, feasibility, typos
gyulas Nov 22, 2018
e6f119d
Notes - figures added
gyulas Nov 22, 2018
8242fa3
Notes - futotestek
gyulas Nov 22, 2018
4e1ab06
Notes - futotest+haz
gyulas Nov 23, 2018
45e42d2
Notes typos, structure and figure
gyulas Nov 23, 2018
66e0307
Model minor chg to be cute / tidy
gyulas Nov 23, 2018
1224653
Notes - mucc improve
gyulas Nov 26, 2018
5b82f93
Notes - control elotti resz
gyulas Nov 26, 2018
9ca47bf
Notes minors
gyulas Nov 27, 2018
72a7011
Example model added
gyulas Nov 27, 2018
c09de1a
Model - padlofutes parameterek kulon
gyulas Nov 28, 2018
98b4b0a
Simulations - steady state radiator model
gyulas Nov 28, 2018
8612288
Notes - ident fig added
gyulas Nov 28, 2018
520b638
Model - different params for floor. Ident layout.
gyulas Nov 28, 2018
e9f1895
Model - process of identification one again. Influence of t_e.
gyulas Nov 28, 2018
d42899f
merge example simulink simscape network
gyulas Nov 28, 2018
ab2183c
Various chg - model and udp testing
gyulas Nov 29, 2018
dfc485c
Real-sys code for interfacing - running on raspberry Pi
gyulas Nov 29, 2018
e9ea500
Real-sys - Code on Pi modified, to send out manipulated variable
gyulas Nov 29, 2018
1231397
Real-sys interfacing Simulink and Raspberry codes organized in model/…
gyulas Nov 29, 2018
099c964
Notes - review suggestions
gyulas Nov 30, 2018
419739d
Notes - figure added for identification
gyulas Nov 30, 2018
f5fcb0a
Nonlinear idenfification
gyulas Dec 1, 2018
c903749
More identification
gyulas Dec 1, 2018
d514bd9
MPC designed from linear sys. tf20
gyulas Dec 1, 2018
d73a01b
MPC in simulation
gyulas Dec 1, 2018
c838ef8
Simulation - MPC works after setting output scale factor
gyulas Dec 2, 2018
5574eb1
Notes and simulation - ident figures (Model changed - measure can be …
gyulas Dec 2, 2018
3ebb09f
Figures - instead of using big .fig files, automatic script written f…
gyulas Dec 2, 2018
1c3e1da
Simulation RUNNING with previewing block
gyulas Dec 2, 2018
9b6a8d5
Simulation - MPC disturbance rejection and weight test
gyulas Dec 2, 2018
7835462
Simulation - MPC weights modified
gyulas Dec 2, 2018
33ffbdc
Various MPC settings tried
gyulas Dec 2, 2018
c495ad6
Model more cute for notes
gyulas Dec 3, 2018
871300d
Ident signal layout of system
gyulas Dec 3, 2018
29f5979
Ident signal layout of system - pure
gyulas Dec 3, 2018
e90e827
Notes - Figures added
gyulas Dec 3, 2018
8a7a44a
Lab-measurement layout in Simulink
gyulas Dec 3, 2018
241425f
Labsys - (a dummy) MPC running in Simulink Real-time Desktop
gyulas Dec 3, 2018
d1eb565
udp send/receive not working
gyulas Dec 3, 2018
6f7971b
Labsys measurements CAN BE STARTED - temperatures are monitored in Si…
gyulas Dec 3, 2018
657a22f
Labsys measurements in progress and logging with scope
gyulas Dec 3, 2018
790217b
Labsys basic stepfun with low power, just 12V3.5A
gyulas Dec 4, 2018
30d933b
Labsys stepfun measured - in fractions. Temperature log WORKING relia…
gyulas Dec 4, 2018
7d6cf3d
Labsys turnoff measurements
gyulas Dec 4, 2018
4128170
MPC created for the identified model. Tuning needed
gyulas Dec 4, 2018
ed23c0d
Notes - eng. abstract & minor chg
gyulas Dec 4, 2018
49e1138
Cute figures and tables and model layouts
gyulas Dec 5, 2018
e3b4e9e
Notes improved
gyulas Dec 5, 2018
6ba87fd
Better tf and MPC v0.1
gyulas Dec 5, 2018
7207a33
Labsys MPC works at 20s sampling
gyulas Dec 5, 2018
01639cc
Labsys MPC not working at 300s sampling
gyulas Dec 5, 2018
f9c1f18
Labsys simulation with first MPC. Disturbance rejection
gyulas Dec 5, 2018
09bb4c7
Compare various MPCs output signals in Simulink
gyulas Dec 5, 2018
06f1dc1
Compare various MPCs output signals in Simulink - no progress. Weight…
gyulas Dec 6, 2018
302a4cf
For immediate response, INITIAL STATE FOR MPC SHOULD BE DEFINED.
gyulas Dec 6, 2018
3cf82e3
MPC control quality measured depending on horizon, weights and initia…
gyulas Dec 6, 2018
55e67f2
MPC weights tuned, specification can be given to these parameters
gyulas Dec 6, 2018
c82288d
MPC w_u sensitivity
gyulas Dec 6, 2018
6c8acf7
For notes, figures generated via Matlab script. Typos in notes.
gyulas Dec 6, 2018
0fc6ec5
Labsys simulation - 2 hours
gyulas Dec 6, 2018
29fc6e7
Labsys - bug found in t_i process
gyulas Dec 6, 2018
9e2a276
Notes - finalize
gyulas Dec 7, 2018
49aee47
Got'cha!
gyulas Dec 7, 2018
40c7e25
Leadott verzió
gyulas Dec 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added Padlofutes.slxc
Binary file not shown.
Binary file added Padlofutes_msf.mexw64
Binary file not shown.
Binary file added model/Padlofutes.slxc
Binary file not shown.
Binary file added model/Padlofutes_msf.mexw64
Binary file not shown.
Binary file added model/Radiator.slxc
Binary file not shown.
2 changes: 0 additions & 2 deletions model/Radiator_msf.exp

This file was deleted.

Binary file removed model/Radiator_msf.lib
Binary file not shown.
Binary file modified model/Radiator_msf.mexw64
Binary file not shown.
Binary file added model/components/3output.sid
Binary file not shown.
Binary file removed model/components/Radiator.slx
Binary file not shown.
Binary file added model/components/examples/simscape1.slx
Binary file not shown.
Binary file added model/components/ident_radiator_vs_delta_t_e.sid
Binary file not shown.
Binary file not shown.
Binary file added model/components/ident_valves_kelvin.sid
Binary file not shown.
Binary file added model/components/idtf_3Output_Confident.mat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
66 changes: 66 additions & 0 deletions model/components/radiator_unittest/radiator_simscape_data.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
% SLDEMO_HOUSEHEAT_DATA
% This script runs in conjunction with the "sldemo_househeat"
% house thermodynamics example. Note that time is given in units of hours

% Copyright 1990-2012 The MathWorks, Inc.

T_s=60; %% second
timeUnit_1min=60/T_s;
timeUnit_1hour=3600/T_s;
timeUnit_1day=timeUnit_1hour*24;
timeUnit_1week=7*timeUnit_1day;

% TinIC = initial indoor temperature = 20 deg C
TinIC = 5;
TinHeatK=273+5; %[K] heating elements

% -------------------------------
% Radiator parameters
% -------------------------------
% Q=h*A*(Ts-Ti)
% A=n*A0, n tag� radi�torra
% N_heater=15; % ennyi db radiator
% A_heater=3.5; % [m^2]
% h_heater=11; % [W/m^2K]
% T_heater=60;
% -------------------------------
%heat_transfer_const
%h_c_rad=11; % k [W/m^2K]
%h_r_radi=0.1*5.67e-8; % k [W/m^2K^4] q=eps*sigma*A*T^4

% -------------------------------
% Radiator
% -------------------------------

% Steady-state
h_c_radi=7; % k [W/m^2K] Convective heat transfer at radiator surface area.
h_w_radi=150; % k [W/m^2K] Conductive heat from water to metal

% C22 900 mm magas:
height=0.9;
l_r=1.5; % l [m] a radiator hossza
area_radiator=2; % A [m^2]

% Transient behavior

m_r=50.1*l_r; % m [kg] -- tomege
c_metal=464; % c [J/kgK] acel fajhoje
m_w_r=8.9*l_r; % m [kg] = rho*V a viz tomege, 1kg/l/rel szamolva
c_w=4189; % c [J/kgK] viz fajhoje

% https://www.purmo.com/hu/termekek/lapradiatorok/purmo-compact.htm#tab-muszaki-adatok
% -------------------------------

%heat_transfer_const_radiator=h_c_radi;


% -------------------------------
% Room
% -------------------------------

%area 19m^2, height 2.6m

c_air = 1005.4;
densAir = 1.2250;
M_air = 51.5*densAir;

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added model/handout/MPC.mat
Binary file not shown.
Binary file added model/handout/Padlofutes.slx
Binary file not shown.
Binary file added model/handout/Radiator.slx
Binary file not shown.
Binary file added model/handout/househeat.slx
Binary file not shown.
168 changes: 168 additions & 0 deletions model/handout/househeat_data_szakdoga.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
% SLDEMO_HOUSEHEAT_DATA
% This script runs in conjunction with the "sldemo_househeat"
% house thermodynamics example. Note that time is given in units of hours

% Copyright 1990-2012 The MathWorks, Inc.

%% Reference to MPC
%not working this waz
%ref=[20*ones(1,3600*24) 25*ones(1,3600*24) 20*ones(1,3600*24) 25*ones(1,3600*24) 20*ones(1,3600*24) 25*ones(1,3600*24) ];




%%


T_s=1800; %% second
timeUnit_1min=60/T_s;
timeUnit_1hour=3600/T_s;
timeUnit_1day=timeUnit_1hour*24;
timeUnit_1week=7*timeUnit_1day;

% TinIC = initial indoor temperature = 20 deg C
TinIC = 0;
TinHeatK=273+0; %[K] heating elements
supp_water_initial_temp=0; % [Celsius]



% -------------------------------
% Problem constant
% -------------------------------
% converst radians to degrees
r2d = 180/pi;
% -------------------------------
% Define the house geometry
% -------------------------------
% House length = 30 m
lenHouse = 30;
% House width = 10 m
widHouse = 10;
% House height = 4 m
htHouse = 4;
% Roof pitch = 40 deg
pitRoof = 40/r2d;
% Number of windows = 6
numWindows = 6;
% Height of windows = 1 m
htWindows = 1;
% Width of windows = 1 m
widWindows = 1;
windowArea = numWindows*htWindows*widWindows;
wallArea = 2*lenHouse*htHouse + 2*widHouse*htHouse + ...
2*(1/cos(pitRoof/2))*widHouse*lenHouse + ...
tan(pitRoof)*widHouse - windowArea;
% -------------------------------
% Define the type of insulation used
% -------------------------------
% Glass wool in the walls, 0.2 m thick
% k is in units of J/sec/m/C NOT convert to J/hr/m/C multiplying by 3600
kWall = 0.038; % second is the time unit
LWall = .2;
RWall = LWall/(kWall*wallArea);
% Glass windows, 0.01 m thick
kWindow = 0.78; % second is the time unit
LWindow = .01;
RWindow = LWindow/(kWindow*windowArea);
% -------------------------------
% Determine the equivalent thermal resistance for the whole building
% -------------------------------
Req = RWall*RWindow/(RWall + RWindow);
% c = cp of air (273 K) = 1005.4 J/kg-K
c = 1005.4;
% -------------------------------
% Enter the temperature of the heated air
% -------------------------------
% The air exiting the heater has a constant temperature which is a heater
% property. THeater = 50 deg C
THeater = 50;
% Air flow rate Mdot = 1 kg/sec = 3600 kg/hr
Mdot = 3600; % hour is the time unit
% energy per hour is c*Mdot*?t
% -------------------------------
% Radiator parameters
% -------------------------------
% Q=h*A*(Ts-Ti)
% A=n*A0, n tag� radi�torra
N_heater=15; % ennyi db radiator
A_heater=3.5; % [m^2]
h_heater=11; % [W/m^2K]
T_heater=60;
% -------------------------------
water_heat_capacity=4183; % c [J/kgK]
supp_water_flow=0.01; % m [kg/s]
%heat_transfer_const
%h_c_rad=11; % k [W/m^2K]
%h_r_radi=0.1*5.67e-8; % k [W/m^2K^4] q=eps*sigma*A*T^4
h_c_radi=7; % k [W/m^2K]
t_w=90;
t_m=60; % k�zepes h�mk�l
%h_c_radi=5.29*(t_m/60)^0.25; % k [W/m^2K] % Csoknai, 337.o.
h_w_radi=150; % k [W/m^2K]

% C11 450 mm magas:
% l_r=1; % l [m] a radiator hossza
% m_r=14.4*l_r; % m [kg] -- tomege
% c_metal=464; % c [J/kgK] acel fajhoje
% m_w_r=2.3*l_r; % m [kg] = rho*V a viz tomege, 1kg/l/rel szamolva
% c_w=4189; % c [J/kgK] viz fajhoje

%C22 600 mm magas:
l_r=1.5; % l [m] a radiator hossza
area_radiator=l_r*0.8*3; % A [m^2] - 3-as szorzo: lamellak, stb.
m_r=33.4*l_r; % m [kg] -- tomege
c_metal=464; % c [J/kgK] acel fajhoje
m_w_r=6.6*l_r; % m [kg] = rho*V a viz tomege, 1kg/l/rel szamolva
c_w=4189; % c [J/kgK] viz fajhoje


water_heat_capacity=c_w;
heat_transfer_const_radiator=h_c_radi;

% -------------------------------
% Floor heating parameters
% -------------------------------
area_floor=10; % A [m^2]
heat_transfer_const_floorheat=9.5;
supp_water_flow_f=0.035;

% -------------------------------


% -------------------------------
% Custom h�z adatai
% -------------------------------
% Koli: k�ls� falb�l ablak f�mkeretes, 1.75m2/db, ebb�l �veg 1m2/db.
% Kerek�tettem 2m^2-re.
% R�tegtervi h.�b. t�ny. kb. 2-4.5 W/m^2-K
%
% K�ls� fal 4m^2, bels[ falak 80m^2, h.�b. t�ny rendre 1.3 / 1.5.

q_sch_ablak=2*2*4.5; % [W/K]
q_sch_fal_kulso=3.3*(0.25+0.95)*1.3; % [W/K] - kepletben geom. meretekkel
q_sch_fal_belso=2*6*3.3 + ...
2*6*2.6 + 2.6*3.3;%??? [m2]

% Hoveszteseg a kulso homersekletkulonbseg fv.: Q=?t*?q [W]
q_sch_ext=q_sch_ablak+q_sch_fal_kulso;

%Bentire nem szamolok.

% -------------------------------
% Determine total internal air mass = M
% -------------------------------
% Density of air at sea level = 1.2250 kg/m^3
densAir = 1.2250;
M = (lenHouse*widHouse*htHouse+tan(pitRoof)*widHouse*lenHouse)*densAir;
c_air = 1005.4;
M_air = 51.5*densAir;
% -------------------------------
% Enter the cost of electricity and initial internal temperature
% -------------------------------
% Assume the cost of electricity is $0.09 per kilowatt/hour
% Assume all electric energy is transformed to heat energy
% 1 kW-hr = 3.6e6 J
% cost = $0.09 per 3.6e6 J
cost = 0.09/3.6e6;

18 changes: 18 additions & 0 deletions model/handout/labsys/concatScopeData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function data=concatScopeData(varargin)
% Timeseries adatsorokat fuz ossze - ezek labsys_data_i nevu logfile-ok. Ezek utan plotolhatoak.
%Array osszefuzese egyszerubb,
% data=[data1; data2]; mintara tortenik.

data=timeseries('ScopeData');
if nargin>0
time_prev=0;
for i = 1:nargin
time_next=((time_prev+1):(length(varargin{i}.signals(1).values)+time_prev))';
%time=(time:length(varargin{i}.signals(1).values)+time)';
data=append(data,timeseries([varargin{i}.signals(1).values(:,1) ...
varargin{i}.signals(2).values ...
varargin{i}.signals(1).values(:,2)],...
time_next));
time_prev=time_next(end);
end
end
Binary file added model/handout/labsys/create_from_tf8.pdf
Binary file not shown.
Binary file added model/handout/labsys/labsys_heat.slx
Binary file not shown.
Binary file not shown.
Binary file added model/handout/labsys/mpc_param_var05_uweight.mat
Binary file not shown.
Binary file added model/handout/labsys/mpc_param_var05_yweight.mat
Binary file not shown.
Binary file added model/handout/labsys/mpcstate.pdf
Binary file not shown.
97 changes: 97 additions & 0 deletions model/handout/labsys/plotClosedLoopTemp.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
function plotClosedLoopTemp(ValveAndTemp)

hManipulated=subplot(2,1,1);
set(hManipulated, 'OuterPosition', [0,0.60, 1, .34]);

plot(ValveAndTemp.time,ValveAndTemp.signals(2).values(:,1),...
ValveAndTemp.time, ValveAndTemp.signals(2).values(:,2))
%cpy.time,cpy.signals(2).values(:,1),'--',...
%cpy.time,cpy.signals(2).values(:,2),'--',...

%grid on

% set limit
lim=get(gca,'YLim');
lim(1)=-0.1;
lim(2)=1.1;
set(gca,'YLim',lim);

lim=get(gca,'XLim');
lim(1)=3600*24*10*3.4;
lim(2)=3600*24*10*4;
set(gca,'XLim',lim);

%set X axes label
plotting_axesLabel_Days()

legend('Radi�tor szelep','Padl�f�t�s szelep')
leg=get(gca, 'Legend');
leg.Position =[0.705 0.91 0.2193 0.0739];

subtitle=get(hManipulated,'Title');
subtitle.String='Beavatkoz� jelek';
subtitle.FontSize=11;
shg %show it

% leg=get(gca, 'Legend');
% leg.String(1)={'RadiatorValve'};
% leg.String(2)={'FloorValve'};

%% plot2
hMeasured=subplot(2,1,2);
set(hMeasured, 'OuterPosition', [0,0, 1, .55]);

%plot(ValveAndTemp.time,[ValveAndTemp.signals(1).values(:,1:1:2) ValveAndTemp.signals(1).values(:,3)-273])

plot(ValveAndTemp.time, ValveAndTemp.signals(1).values(:,1)-273,'k-',...
ValveAndTemp.time, ValveAndTemp.signals(1).values(:,2)-273,'r-')
%cpy.time,cpy.signals(1).values(:,1)-273,'-.',...
%cpy.time,cpy.signals(1).values(:,2)-273,'-.',...

% ,...
% ValveAndTemp.time, ValveAndTemp.signals(1).values(:,3)-273,'g-',...
% ValveAndTemp.time, ValveAndTemp.signals(1).values(:,4)-273,'c-')

%grid on

lim=get(gca,'YLim');
lim(1)=-15;
lim(2)=40;
set(gca,'YLim',lim);

lim=get(gca,'XLim');
lim(1)=3600*24*10*3.4;
lim(2)=3600*24*10*4;
set(gca,'XLim',lim);

% lab=get(gca,'YTickLabel');
% lab{11}='';
% lab{12}='';
% set(gca,'YTickLabel',lab);
%hMeasured.YTickLabel{12}='';


%set X axes label
plotting_axesLabel_Days()
legend('K�ls� h�m�rs�klet t_e','Helyis�g h�m�rs�klete t_i')
%,'Nemline�ris modell t_i','Lineariz�lt modell t_i')
leg=get(gca, 'Legend');
leg.Position =[0.6200 0.52 0.2927 0.0822];
subtitle=get(hMeasured,'Title');
subtitle.String='M�rt v�ltoz�k';
subtitle.FontSize=11;


shg %show it

%% Misc

function plotting_axesLabel_Days()
%mintav�teli id� 1800s=1 egys�g=f�l �ra. A struct time-ban adja.
% Simulink: 3600*24*10*75 mp, azaz
set(gca,'XTick',0:24*3600:3600*24*7*120)
%set(gca,'XTick',0:30*24*3600:3600*24*7*120)%honap
set(gca,'XTickLabel',{'0','1','2','3','4','5','6','7','8','9','10','11'});%,'13','14','15','16'})
xlab=get(gca,'XLabel');
xlab.String='id� (nap)';
set(gca,'XLabel',xlab)
Loading