close all
clear all

g = 9.81;
nu = 22e-6;  %m^2/s
rho = 866;   %kg/m^3

PAperPSI = 6894.757;

d_t =  0.6*.0254;   %tube ID
L_t = 6*12*.0254;   %tube length

A_t = 0.25*pi*d_t^2;  %Tube cross section


d_p = 2*.0254;  %Piston Diameter
d_r = 1.5*.0254;  %Rod diameter
A_c = 0.25*pi*(d_p^2-d_r^2);  %Hydraulic Ram cross section

spd = 0:.05:1;  %piston speed (m/s)

Q = spd*A_c;

Re = Q*d_t/(nu*A_t);


deltaP_Lam = 128*rho*g*nu*L_t*Q/(pi*d_t^4);

figure
subplot(3,1,1)
plot(spd,deltaP_Lam/PAperPSI)
xlabel('Piston Speed')
ylabel('Pressure Drop (psi)');

title(['Tube ID = ' num2str(d_t/.0254) ' in      Tube Length = '  num2str(L_t/(12*.0254)) ' ft     Oil Visc = ' num2str(1000000*nu) ' cSt     Oil Density = ' num2str(rho) ' kg/m^3']);
subplot(3,1,2)
plot(spd,Q*60*1000/3.81)
xlabel('Piston Speed')
ylabel('Flow Rate (GPM)');

subplot(3,1,3)
plot(spd,Re)
xlabel('Piston Speed')
ylabel('Reynolds number');


