% Calculate initial conditions for the pipeline model
% Gisle Otto Eikrem
% 19.05.04

% m_gas_riser = m(1,i); 
% m_oil_riser = m(2,i);
% m_gas_pipeline = m(3,i); 
% m_oil_pipeline = m(4,i);

m_oil_riser_init = 0.5*V_total_riser*rho_oil
m_oil_pipeline_init = 0.5*V_total_pipeline*rho_oil

p_top_riser_bara_init = 15;

m_gas_riser_init = p_top_riser_bara_init * (0.5*V_total_riser*M) / (R1*T_riser)

p_top_pipeline_bara_init = 10;

m_gas_pipeline_init = p_top_pipeline_bara_init * (0.5*V_total_pipeline*M) / (R1*T_pipeline)

% 50/50 vol % gas and liquid

% 1 m^3 liquid => 1m^3 * rho_oil = rho_oil [kg]
% 1 m^3 gas @ 10 bara and 293 K

rho_gas_pipeline_init = p_top_pipeline_bara_init*M/(R1*T_pipeline)

volume_fracton_liquid = 0.5; %[-]

Volume_inflow = 1; %[m^3]

gas_mass_fraction = (Volume_inflow * (1-volume_fracton_liquid) * rho_gas_pipeline_init) / (Volume_inflow * volume_fracton_liquid * rho_oil)

liquid_mass_inflow = 1; % [kg]

gas_mass_inflow = liquid_mass_inflow * gas_mass_fraction

