
%% Reservoir model, calculate flow from reservoir


%% -----------RESERVOIR---------------------%
  % Boundary conditions 
P(1,i)=Pbh;
P(end,i)=Pres;
% Pressure distribution calc
    for j=2:size(xl,2)-1
        P(j,i+1)=P(j,i) + (dt/(k*h^2))*(P(j+1,i)-2*P(j,i)+P(j-1,i)) + (dt/(k*2*j*h^2))*(P(j+1,i)-P(j-1,i));
    end
% flux calc
Q=(c/h)*(P(2,i) - P(1,i)); % [m/s]
%% -----------------------------------------%
% inflow to the pipeline
%
param = 0.60*3*7.7006e+004; % scaling parameter

w = param*Q; % [kg/s]

%% -----------------------------------------%