close all
clear all

p = 300;  %psi

C = 0.12;  %O-Ring Compression
fc = 2;  %lbs/inch due to length  Table 5-9, (pg 5-9) Parker O-Ring Book
fh = 18; %lbs/in^2 due to area  Table 5-10, (pg 5-9) Parker O-Ring Book


W = .210;  %O-Ring Size (diameter in inches)
A_1 = .8:.1:4.8  %Bore Diameter


A = A_1;
B1 = A-2*(1-C)*W;
Fs_1 = fc*pi*A+fh*(pi/4)*(A.^2-B1.^2)
F = p*(pi/4)*A.^2;
eta_1 = (F-Fs_1)./F;

C = 0.14;  %O-Ring Compression
W = .275;  %O-Ring Size (diameter in inches)
A_2 = 5:.5:10  %Bore Diameter

A = A_2
B1 = A-2*(1-C)*W;
Fs_2 = fc*pi*A+fh*(pi/4)*(A.^2-B1.^2)
F = p*(pi/4)*A.^2;
eta_2 = (F-Fs_2)./F;


figure('PaperType','usletter','PaperPositionMode','manual','PaperPosition',[.75,.75,8.5-.75,11-.75])

h1 = subplot('Position',[.1 .54 .8 .4]);
h2 = subplot('Position',[.1 .04 .8 .4]);

subplot(h1)
plot(A_1,Fs_1,A_2,Fs_2)
xlabel('Bore Diameter (in)');
ylabel('Drag Force (lbs)');
legend('2-2xx','2-3xx','Location','NorthWest');
title('Piston Seal Drag');

subplot(h2)
plot(A_1,eta_1,A_2,eta_2);
xlabel('Bore Diameter (in)');
ylabel('Efficiency');
legend('2-2xx','2-3xx','Location','NorthWest');
title('Piston Seal efficiency at 200m depth (300psi)');

print -depsc2 ORingDrag.eps