% init.m

% Initialiserer modell B

load globale_verdier_b  % gir b
b.Cv_pc = [2e-2 4e-1];
b.Cv_ventil=1.2e-3;
b.Cv_ngventil=0.08;

b.UA_pc(1) = 8e4;
b.UA_pc(2) = 1.8e4;

tau=0.1;
G=tf(1,[tau 1]);       % Transferfunksjon
G4x4=ss(append(G,G,G,G));

global b
ni=1;
% Innganger
% -----------------------------------------------------------------------
co2tank = [273+8, b.p_co2tank, 10]';    %T,p,V
ngtank  = [273+8, b.p_ngtank, 10]';

% Regulatorparametre
% --------------------------------------------------------------------
z = 0.5;                % Ventilåpning

% Startverdier for PC
% -----------------------------------------------------------------------
load startverdier      % gir [pl pv wng Hng png wl wv Htot xv 
                       %      Tl Vl Nl Tv Nv Tng Vng Nng Tvegg]'

m=18;
p0l = s_ut(2:m:end,end);
p0v = s_ut(3:m:end,end);
w0ng= s_ut(4:m:end,end);
H0ng= s_ut(5:m:end,end);
p0ng= s_ut(6:m:end,end);
T0l = s_ut(11:m:end,end);

for i=1:b.n
    initB(i).y0 = s_ut(m*(i-1)+11:m*(i-1)+19,end);
end

save initialB initB % til s_pc