%% Author: Ida Andersskog

clear
close all
clc;
warning off

%% Run parameters

runtime = 2000;
relTol = 1e-8;
run Parameters.m

%% Run simulink

sim('ClosedSteamCycle.slx')

%% Plot settings 2

set(0,'DefaultTextFontName','Times',...
'DefaultTextFontSize',18,...
'DefaultAxesFontName','Times',...
'DefaultAxesFontSize',16,...
'DefaultLineLineWidth',1,...
'DefaultLineMarkerSize',7.75,...
'DefaultStairLineWidth',1);
set(findall(gcf,'Type','text'),'FontSize',14,'Interpreter','latex');
set(gcf,'color','white');

%To save the files as eps use this command

%print('-depsc2','-r600','StepM1s.png')

%% Plotting

width = 2;
length = 4;

figure(1)
subplot(length,width,1)
plot(time,M1,time,Mturbine)%,time,Mmix)
xlabel('Time [s]')
ylabel('Liquid holdup [kg]')
legend('M_1','M_{turbine}')%,'M_{mix}')

subplot(length,width,2)
plot(time,P1, time, P2,time,P3)
xlabel('Time [s]')
ylabel('Pressure [Pa]')
legend('P_1','P_2','P_3')

subplot(length,width,3)
plot(time,T1,time,T2hot,time,T2)%,time,T3mid,time,TG3)
xlabel('Time [s]')
ylabel('Temperature [K]')
legend('T_1','T_{2hot}','T_2')%,'T{3mid}','T_{G3}')

subplot(length,width,4)
plot(time,m1,time,m2,'.')
xlabel('Time [s]')
ylabel('massflow [kg/s]')
legend('m_1','m_2')
axis([0 runtime 5.0 7])

subplot(length,width,5)
plot(time, Ws/10^6)
xlabel('Time [s]')
ylabel('Power W_s [MW]')

subplot(length,width,6)
plot(time,uT,time,mbypass)
xlabel('Time [s]')
legend('Valve opening','m_{bypass}')

subplot(length,width,7)
plot(time, T4x)%, time,T4)%,time,T0,'.')
xlabel('Time [s]')
ylabel('Temperature [K]')
legend('T_{4x}')%,'T_4')%,'T_0')

subplot(length,width,8)
plot(time, m3,'-',time,mturbine,'.',time,mG)
xlabel('Time [s]')
ylabel('massflow [kg/s]')
legend('m_3','m_{turbine}','m_G')
%axis([0 runtime 5.5 8])


 %% Plotting holdups
% figure(1)
% 
% subplot(3,2,1)
% plot(time,M1)
% xlabel('Time [s]')
% ylabel('M_1 [kg]')
% 
% subplot(3,2,2)
% plot(time,m1,time,m2)
% xlabel('Time [s]')
% ylabel('Mass flows [kg/s]')
% legend('m_1','m_2')
% 
% subplot(3,2,3)
% plot(time,Mmix)
% xlabel('Time [s]')
% ylabel('M_{mix} [kg]')
% 
% subplot(3,2,4)
% plot(time,m2+mbypass,time,m3)
% xlabel('Time [s]')
% ylabel('Mass flows [kg/s]')
% legend('m_2 + m_{bypass}','m_3')
% 
% subplot(3,2,5)
% plot(time,Mturbine)
% xlabel('Time [s]')
% ylabel('M_{turbine} [kg]')
% 
% subplot(3,2,6)
% plot(time,m3,time,mturbine)
% xlabel('Time [s]')
% ylabel('Mass flows [kg/s]')
% legend('m_3','m_{turbine}')


