diff --git a/Data/Exp1_WDB.mat b/Data/Experimental_data_WDB/Exp1_WDB.mat similarity index 99% rename from Data/Exp1_WDB.mat rename to Data/Experimental_data_WDB/Exp1_WDB.mat index 8f1ca1a..56dbc91 100644 Binary files a/Data/Exp1_WDB.mat and b/Data/Experimental_data_WDB/Exp1_WDB.mat differ diff --git a/Data/Experimental_data_WDB/Exp2_WDB.mat b/Data/Experimental_data_WDB/Exp2_WDB.mat new file mode 100644 index 0000000..cc693ef Binary files /dev/null and b/Data/Experimental_data_WDB/Exp2_WDB.mat differ diff --git a/Data/Experimental_data_WDB/Exp3_WDB.mat b/Data/Experimental_data_WDB/Exp3_WDB.mat new file mode 100644 index 0000000..fc17a33 Binary files /dev/null and b/Data/Experimental_data_WDB/Exp3_WDB.mat differ diff --git a/Data/Experimental_data_WDB/Exp4_WDB.mat b/Data/Experimental_data_WDB/Exp4_WDB.mat new file mode 100644 index 0000000..e8ed06c Binary files /dev/null and b/Data/Experimental_data_WDB/Exp4_WDB.mat differ diff --git a/Data/Experimental_data_WDB/Exp5_WDB.mat b/Data/Experimental_data_WDB/Exp5_WDB.mat new file mode 100644 index 0000000..b9eaf11 Binary files /dev/null and b/Data/Experimental_data_WDB/Exp5_WDB.mat differ diff --git a/Data/Experimental_data_WDB/Exp6_WDB.mat b/Data/Experimental_data_WDB/Exp6_WDB.mat new file mode 100644 index 0000000..365ad1c Binary files /dev/null and b/Data/Experimental_data_WDB/Exp6_WDB.mat differ diff --git a/Data/Experimental_data_WDB/Exp7_WDB.mat b/Data/Experimental_data_WDB/Exp7_WDB.mat new file mode 100644 index 0000000..6596459 Binary files /dev/null and b/Data/Experimental_data_WDB/Exp7_WDB.mat differ diff --git a/Data/input_WDB.mat b/Data/input_WDB.mat new file mode 100644 index 0000000..f0c0ba8 Binary files /dev/null and b/Data/input_WDB.mat differ diff --git a/Simulink/PolydomeCARNOT.prj b/Simulink/PolydomeCARNOT.prj deleted file mode 100644 index 92c6696..0000000 --- a/Simulink/PolydomeCARNOT.prj +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/Simulink/main.m b/Simulink/main.m deleted file mode 100644 index c9ab292..0000000 --- a/Simulink/main.m +++ /dev/null @@ -1,93 +0,0 @@ -clear all -close all -clc -%%%%%%%%%%%%%%%%%%%%%%% - -%% Load the experimental data -Exp1 = load("../Data/Luca_experimental_data/Exp1.mat"); -py_Exp1 = load("../Data/Exp1_WDB.mat"); - -tin = py_Exp1.Exp1_WDB(:,1); - -% The power trick: when the setpoint is larger than the actual temperature -% the HVAC system is heating the room, otherwise it is cooling the room -Setpoint = Exp1.Exp1.Setpoint.values; -InsideTemp = mean([Exp1.Exp1.InsideTemp.values, Exp1.Exp1.LakeTemp.values], 2); -OutsideTemp = Exp1.Exp1.OutsideTemp.values; -HVAC_COP = 4.5; -Heating_coeff = sign(Setpoint - InsideTemp); -Heating_coeff(Heating_coeff == -1) = -1 * HVAC_COP; - - -%% Set the model parameters - -% Large side windows -window_size = [2 25]; -window_roof_size = [5 5]; -surface_part = 0.1; -U = 1.8; % heat transfer coefficient [W/m2K] -g = 0.7; % total solar energy transmittance -v_g = 0.65; % transmittance in visible range of the sunlight - -% Roof -wall_size = [25 25]; -roof_position = [0 0 0]; -% The roof is supposed to be made of [5cm wood, 10cm insulation, 5cm wood] -node_thickness = [0.05 0.10 0.05]; % Data from 03.03 email with Manuel -% Data from https://simulationresearch.lbl.gov/modelica/releases/latest/help -% /Buildings_HeatTransfer_Data_Solids.html#Buildings.HeatTransfer.Data.Solids.Plywood -node_conductivity = [0.12 0.03 0.12]; -node_capacity = [1210 1200 1210]; -node_density = [540 40 540]; - -% Floor -ceiling_size = [25 25]; -% The floor is supposed to be made of [] -layer_thickness = [0.05 0.10 0.20]; -layer_conductivity = [0.12 0.03 1.4]; -layer_capacity = [1210 1200 840]; -layer_density = [540 40 2240]; - - - -%% Set the run parameters - -air_exchange_rate = tin; -air_exchange_rate(:,2) = 2.0; -t0 = 24; - -power = [tin Heating_coeff .* (Exp1.Exp1.Power.values - 1.67 * 1000)]; - -Te = 60*60*24*365; - -%% Run the simulation -% Note: The simlulink model loads the data separately, includes the -% calculated solar position and radiations from pvlib -simout = sim("polydome_model_1"); - -%% Compare the simulation results with the measured values -SimulatedTemp = simout.SimulatedTemp.Data; - -figure; hold on; grid minor; -plot(tin, InsideTemp); -plot(tin, OutsideTemp); -plot(simout.tout, SimulatedTemp, 'LineWidth', 2); -plot(tin, Setpoint); -legend('InsideTemp', 'OutsideTemp', 'SimulatedTemp', 'Setpoint'); -hold off; - -% calculation notes for furniture wall parameters - -% surface: -% 1/4 * 1.8 [m2/m2 of floor space] * 625 m2 surface = 140 m2 -% 140 m2 = [7 20] m [height width] - -% mass: -% 1/4 * 40 [kg/m2 of floor space] * 625 m2 surface = 6250 kg - -% volume: -% 6250[kg]/600[kg/m3] = 10.41 [m3] - -% thickness: -%10.41[m3]/140[m2] = 0.075m = 7.5cm - diff --git a/Simulink/model_identification.m b/Simulink/model_identification.m new file mode 100644 index 0000000..366fb7f --- /dev/null +++ b/Simulink/model_identification.m @@ -0,0 +1,78 @@ +clear all +close all +clc +%%%%%%%%%%%%%%%%%%%%%%% + +%% Load the experimental data +exp_id = "Exp1"; +exp_path = strcat("../Data/Luca_experimental_data/", exp_id,".mat"); +wdb_path = strcat("../Data/Experimental_data_WDB/", exp_id, "_WDB.mat"); + +Exp_data = load(exp_path); +load(wdb_path); + +% Save the current WDB to the Simulink model import (since Carnot's input file is hardcoded) +save('../Data/input_WDB.mat', 'Exp_WDB'); + +tin = Exp_WDB(:,1); + +% The power trick: when the setpoint is larger than the actual temperature +% the HVAC system is heating the room, otherwise it is cooling the room +Setpoint = Exp_data.(exp_id).Setpoint.values; +InsideTemp = mean([Exp_data.(exp_id).InsideTemp.values, Exp_data.(exp_id).LakeTemp.values], 2); +OutsideTemp = Exp_data.(exp_id).OutsideTemp.values; + +HVAC_COP = 3; +Heating_coeff = sign(Setpoint - InsideTemp); +Heating_coeff(Heating_coeff == -1) = -1 * HVAC_COP; + + +%% Set the model parameters + +surface_part = 0.1; + +%% Set the run parameters + +air_exchange_rate = tin; +air_exchange_rate(:,2) = 2.0; + +% Set the initial temperature to be the measured initial temperature +t0 = Exp_data.(exp_id).InsideTemp.values(1); + +% +power = [tin Heating_coeff .* (Exp_data.(exp_id).Power.values - 1.67 * 1000)]; + +% Turn down the air exchange rate when the HVAC is not running +night_air_exchange_rate = 0; +air_exchange_rate(abs(power(:, 2)) < 100, 2) = night_air_exchange_rate; + + +%% Run the simulation +% Note: The simlulink model loads the data separately, includes the +% calculated solar position and radiations from pvlib +load_system("polydome"); +set_param('polydome', 'StopTime', int2str(tin(end))); +simout = sim("polydome"); + +%% Compare the simulation results with the measured values +SimulatedTemp = simout.SimulatedTemp.Data; + +figure; hold on; grid minor; +plot(tin, InsideTemp); +plot(tin, OutsideTemp); +plot(simout.tout, SimulatedTemp, 'LineWidth', 2); + + +legend('InsideTemp', 'OutsideTemp', 'SimulatedTemp'); + +x0=500; +y0=300; +width=1500; +height=500; +set(gcf,'position',[x0,y0,width,height]); +title(exp_id); +%title(sprintf('Night Air exchange rate %f', night_air_exchange_rate)); + +hold off; + +saveas(gcf, strcat(exp_id, '_simulation'), 'svg') diff --git a/Simulink/polydome.slx b/Simulink/polydome.slx new file mode 100644 index 0000000..21fba62 Binary files /dev/null and b/Simulink/polydome.slx differ diff --git a/Simulink/polydome_model_1.slx b/Simulink/polydome_model_1.slx deleted file mode 100644 index b1153a6..0000000 Binary files a/Simulink/polydome_model_1.slx and /dev/null differ