function dP = pipeLoadDelta(t,d,P,Leff,E,Sy)
% pipeLoadDelta  Difference between applied and critical loads for a pipe in compression
%
% Synopsis:  dP = pipeLoadDelta(t,d,P,Leff,E,Sy)
%
% Input: t = pipe wall thickness
%        d = pipe diameter
%        P = applied load
%        Leff = effective length of the pipe
%        E = elastic modulus of the pipe material
%        Sy = yield stress of pipe material
%
% Output:  dP = Pcr - P = amount by which the critical buckling load exceeds
%               the applied load for the pipe.
%
% Note:  The user is responsible for insuring that all input variables
%        have consistent units

ro = d/2;
ri = ro - t;
I = 0.25*pi*(ro^4 - ri^4);
A = pi*(ro^2 - ri^2);
k = 0.25*sqrt(ro^2 + ri^2);

dP = beamPcr(A,I,Leff,E,Sy) - P;