function X = Brobekk_calc(x,Prob,w_V,Tc_V,k)

% Parameters
p1B = Prob.p1B;         p1V = Prob.p1V;         rho_h = Prob.rho_h;
rho_c = Prob.rho_c;     Kv_HB = Prob.Kv_HB;     Kv_AC = Prob.Kv_AC;
Kv_HE = Prob.Kv_HE;     Tci_air = Prob.Tci_air; Thi_F = Prob.Thi_F;
w_fg = Prob.w_fg;       eta_p = Prob.eta_p;     scx = Prob.scx;
UA_F = Prob.UA_F;       A_HE = Prob.A_HE;       A_AC = Prob.A_AC;
cp_air = Prob.cp_air;   cph = Prob.cph;         cpc = Prob.cpc;

% Redefining x
x = [x(1);x(2);x(3);x(4);x(5);x(6);x(7);x(8);x(9);x(10);x(11)];

% De-scaling the variables
x = x.*scx;

% Variables written in symbolic form
uHB = x(1);         uAC = x(2);     uHE = x(3);
uCB = x(4);         uCI = x(5);     P_B = x(6);
P_V = x(7);         w_air = x(8);   P_f = x(9);
Tci_F = x(10);      w_B = x(11);

% Calculating discharge pressures [bar], assuming A1 = A2, and dz = 0
p2B = p1B-(rho_h*eta_p*P_B/(w_B*10^5));
p2V = p1V-(rho_h*eta_p*P_V/(w_V*10^5));

% Calculating liquid flow rates [kg/s]
wCB = Kv_Viken(uCB)*sqrt((p1V-p2V)*(1000/rho_c))*(rho_c/3600);
wCI = Kv_Viken(uCI)*sqrt((p1V-p2V)*(1000/rho_c))*(rho_c/3600);

wHB = uHB*Kv_HB*sqrt((p1B-p2B)*(1000/rho_h))*(rho_h/3600);
wAC = uAC*Kv_AC*sqrt((p1B-p2B)*(1000/rho_h))*(rho_h/3600);
wHE = uHE*Kv_HE*sqrt((p1B-p2B)*(1000/rho_h))*(rho_h/3600);

% Calculating heat transfer coefficients [W/m2*K]
% Assuming hh = hc
h_HE = hHE(wCI);
h_AC = hAC(w_air);

% Calculating UA numbers for the heat exchanger and air cooler
UA_HE = 0.5*h_HE*A_HE;
UA_AC = 0.5*h_AC*A_AC;

% Calculating furnace heat duty [W] and outlet temperatures [°C]
F = NTU_calc(Tci_F,w_B,Thi_F,w_fg,UA_F,cp_air,cph);

% Calculating heat exchanger heat duty [W] and outlet temperatures [°C]
HE = NTU_calc(Tc_V,wCI,F(2),wHE,UA_HE,cph,cpc);

% Calculating air cooler heat duty [W] and outlet temperatures [°C]
AC = NTU_calc(Tci_air,w_air,F(2),wAC,UA_AC,cph,cp_air);

% Calculating the temperature towards Viken/Oslo [°C]
T_Viken = ((wCB*Tc_V)+(2*wCI*HE(2)))/(wCB+(2*wCI));

if k == 1
    X = T_Viken;
elseif k == 2
    X = HE(1);
elseif k == 3
    X = HE(2);
elseif k == 4
    X = AC(1);
elseif k == 5
    X = HE(3);
elseif k == 6
    X = AC(3);
elseif k == 7
    X = F(3);
end