function par = v4_new_4d_parameters()
% ********** Constants and parameters for the New simple model ***********
par.g = 9.81;                       % Gravity (m/s2)
par.R = 8314;                       % Gas constant (J/(K.Kmol))
%par.rho_L = 832.2;                 % Liquid density (Kg/m3)
par.rho_L = 1000;                   % Liquid density (Kg/m3)
par.rho_w = 1000;
par.theta= (1/360)*2*pi;            % Feed pipe inclination (Rad) = 1 Deg
par.r1 = 0.05;                      % Radius of pipe (m)
par.r2 = 0.05;                      % Radius of riser (m)
par.hc = 2*par.r1/cos(par.theta);   % Critical liquid level (m)
par.A1 = pi*par.r1^2;               % Cross section area of pipeline (m2)
par.A2 = pi*par.r2^2;               % Cross section area of riser (m2)
par.L1 = 10.8063;%16;               % Length of upstream pipe (m)
par.L2 =11;%.37415;                 %  Length of riser           
par.L3 = 0;                         % length of horozontal top section (m)
par.T1 = 273.15+15;                 % Pipeline temprature (K)
par.T2 = 273.15+15;                 % Riser temprature (K)
par.M_G = 29;                       % Molecular weight of Gas (kg/kmol)
par.P0 = 1.15e5;                    % Pressure after choke valve (Pa)
par.V2 = par.A2*(par.L2+par.L3);    % Total volume in riser (m3)
par.V1 = par.A1*par.L1;             % Total volume in upstream (m3)
par.Vb = 8.12494*(pi*0.2^2);        % Buffer tank volume

% *************************************************************************
par.Pnormal = 101325;              % Atmospheric conditions for Usg
Tnormal = 293.15;                  % Temperature in Normal conditions
RTnormal =par.R*Tnormal/par.M_G;   % Compressibility in Normal Conditions
par.Rog_n = par.Pnormal/RTnormal;  % Gas density in normal conditions
par.visl= 1.4260e-4;
par.eps = 2.8e-5;                  % Roughness of pipe
% *************** Finding Orifice Coefficients ****************************
% ******** Steady State Values Baesd on Experiment *************
z0= 0.2;
P1 = 2.5e5;
P2_t = 2e5;
%Qg_in = 0.0023569; %[m3/sec]
wG_in = 0.0023569;% Qg_in*par.Rog_n; %[kg/sec]
QL_in = 0.39202239; %[L/sec]
wL_in = QL_in*par.rho_w/1000; %[kg/sec]

% rho_G_in = (P1)*par.M_G/(par.R*par.T1);
% alpha_l_in=(rho_G_in*wL_in)/(rho_G_in*wL_in+par.rho_L*wG_in);
% rho_mix_av_riser=alpha_l_in*par.rho_L+ (1-alpha_l_in)*rho_G_in;
% P2_t = P1 - rho_mix_av_riser*par.g*par.L2
% ********************************************************
w_G1 = wG_in;
w_L1 = wL_in;
wG_out = wG_in;
wL_out = wL_in;
w_mix = wG_out + wL_out;

rho_G1 = P1*par.M_G/(par.R*par.T1);
Alpha_L1_av = wL_in*rho_G1/(wL_in*rho_G1 + wG_in*par.rho_L);

par.k_h = 1;%2.2;% 
h1ss = par.k_h*Alpha_L1_av*par.hc;
h1 = h1ss;
Uslin = wL_in/(par.A1*par.rho_L);

Re1=par.rho_L*Uslin*(2*par.r1)/par.visl;
temp1 = -1.8*log10((par.eps/(par.r1*2)/3.7)^1.11+6.9/Re1);  % Haaland friction factor
Lambda1=(1/temp1)^2;


% Old Lambda1=0.0056 + 0.5*Re1^(-0.32);

Fric_pipe=0.5*Alpha_L1_av*Lambda1*par.rho_L*Uslin^2*par.L1/(2*par.r1);

P2_av = (P1+par.rho_L*par.g*h1-Fric_pipe+P2_t)/2;
rho_G2_av = (P2_av)*par.M_G/(par.R*par.T2);
Alpha_L2_av = rho_G2_av*wL_in/(rho_G2_av*wL_in+par.rho_L*wG_in);
rho_mix_av = rho_G2_av*(1-Alpha_L2_av)+par.rho_L*Alpha_L2_av;

Usl2 = wL_in/(par.rho_L*par.A2);
Usg2 = wG_in/(rho_G2_av*par.A2);
Um = Usl2 + Usg2;

Re2=rho_mix_av*Um*2*par.r2/par.visl;
temp2 = -1.8*log10((par.eps/(par.r1*2)/3.7)^1.11+6.9/Re2);
Lambda2=(1/temp2)^2;


% Old Lambda2=0.0056 + 0.5*Re2^(-0.32);


Fric_riser=0.5*Alpha_L2_av*Lambda2*rho_mix_av*Um^2*(par.L2+par.L3)/(2*par.r2);

P2_b = P2_t + rho_mix_av*par.g*par.L2 + Fric_riser;

rho_G2 = P2_t*par.M_G/(par.R*par.T2);
Alpha_Lt = rho_G2*w_L1/(rho_G2*w_L1+par.rho_L*w_G1);

rho_t = Alpha_Lt*par.rho_L + (1-Alpha_Lt)*rho_G2;

A_g = (h1<par.hc)*(par.A1/par.hc^2)*(par.hc - h1)^2;
A_l = par.A1 - A_g;

v_G1 = w_G1/(rho_G1*A_g);

par.K_g = 0.5*v_G1/sqrt((P1-Fric_pipe-P2_b)/rho_G1); % decreasing--> unstable


par.K_L = 4*w_L1/(A_l*sqrt(par.rho_L*(P1-Fric_pipe+par.rho_L*par.g*h1-P2_b))); % increasing--> unstable
 

par.K_pc = 2*w_mix/(z0*sqrt(rho_t*(P2_t-par.P0))); % increasing--> unstable

end