clc;
clear all;

controller;
%% DATA
global rho;
global fric_fac10;
global fric_fac20;
global d_pipe10;
global d_pipe20;
global A_pipe10;
global A_pipe20;

rho=580; %kg/m3
% fric_fac10=0.0283; %friction factor 10 inch pipe
% fric_fac20=0.03; %friction factor 20 inch pipe
d_pipe10=10*0.0254; %diameter for 10 inch pipe
d_pipe20=20*0.0254; %diameter for 20 inch pipe
A_pipe10=pi*(d_pipe10/2)^2; %Areal for 10 inch pipe
A_pipe20=pi*(d_pipe20/2)^2; %Areal for 20 inch pipe

Epsilon=0.001;
p_storage=101400;
p_tanker=201400;

%% Minflow valve
fprintf('Minflow valve')
Cv_minflow=400;

% %% Pressure node: Pump-Pipe
% fprintf('Pressure node: Pump-Pipe')          
% L_pump=2.0;                 
% A_pump=A_pipe20;
% m0_pump=rho*A_pump*L_pump
% p0_pump=9*10^5;

%% Pressure node: Splitter
fprintf('Pressure node: Splitter')
L_splitter=2.0;
A_splitter=A_pipe20;
m0_splitter=rho*A_splitter*L_splitter
p0_splitter=9*10^5

%% Measurment unit valves
fprintf('Measurment unit')
Cv_mUnit=1000;
Cv_mUnitSmall=400;

%% Pressure node: Sum
fprintf('Sum: Pressure node')
L_sum=2.0;
A_sum=A_pipe20;
m0_sum=rho*A_sum*L_sum
p0_sum=6.5*10^5

%% FV-valve
fprintf('FV-valve')
Cv_FV=2700;

%% Pressure node: FV-Pipe
L_FV=13;
A_FV=A_pipe20;
m0_FV=rho*A_FV*L_FV
p0_FV=6.5*10^5

%% Pressure node: End Pipe
L_pipe=10;
m0_pipe=rho*A_pipe20*L_pipe
p0_pipe=6.82*10^5;
%% Safety valve
fprintf('Safety valve')
Cv_safety=1800;
d_safety=20*0.0254;
L_safety=1.3;
A_safety=(pi)*(d_safety/2)^2;
m0_safety=rho*A_safety*L_safety

% %% EndPipe
% p0_endPipe=6*10^5;
% d_endPipe=20*0.0254;
% L_endPipe=20;
% A_endPipe=(pi)*(d_endPipe/2)^2;
% m0_endPipe=rho*A_endPipe*L_endPipe
% Cv_endPipe=5000
