close all
clear all

Ap = 1.37;

Pc = 2000;  %psi
m = 50/400;  %GPMperpsi.


dP = 0:3000; %(psi)

S = 40;  %Ram speed (in/s)

for i = 1:length(dP)
   Qv(i) =  ReliefValveFlowRate(dP(i),Pc,m);  %GPM
end
Qv = Qv*231/60;  %in^3/s;

Qt = (Ap*S);


Qm = Qt-Qv;

idx = find(Qm < 0);
Qm(idx) = 0;

SpeedPercentage = 100*Qm./Qt;
MotorPower = Qm.*dP;

subplot(2,1,1)
plot(dP,SpeedPercentage,'-');
xlabel('pressure');
ylabel('Effective speed reduction (% of original)')

subplot(2,1,2)
plot(dP,MotorPower)
xlabel('pressure');
ylabel('Motor Power (-)')
