% Juliette Guarriello and Amanda Blankenship
% Last Revision April 27, 2000

% Code "reads" Figure 16.3-1

% Inputs
% Tr - pseduo-reduced temperature
% Pr - pseudo-reduced pressure

% Output
% pD_pD0 - ratio of pressure diffusivity product at elevated pressure to 
%          pressure diffusivity product at same temp, but 1 atm


Tr=input('Enter Tr(between 1 and 3):');
Pr=input('Enter Pr(between .1 and 4):');

if (Tr<=3) & (Tr>2)
   Trh=3;
   Trl=2;
elseif (Tr<=2) & (Tr>1.6)
   Trh=2;
   Trl=1.6;
elseif (Tr<=1.6) & (Tr>1.4)
   Trh=1.6;
   Trl=1.4;
elseif (Tr<=1.4) & (Tr>1.3)
   Trh=1.4;
   Trl=1.3;
elseif (Tr<=1.3) & (Tr>1.2)
   Trh=1.3;
   Trl=1.2;
elseif (Tr<=1.2) & (Tr>1.1)
   Trh=1.2;
   Trl=1.1;
else
   Trh=1.1;
   Trl=1;
end
if Trl==1
   if (Pr<=4) & (Pr>3)
       r1=.24;
       r2=.29;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.17;
       r2=.24;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.14;
       r2=.17;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.12;
       r2=.14;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.3;
       r2=.12;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.53;
       r2=.3;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.65;
       r2=.53;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.69;
       r2=.65;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.74;
       r2=.69;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.79;
       r2=.74;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.85;
       r2=.79;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.88;
       r2=.85;
       Prh=.2;
       Prl=.15;
   else
       r1=.93;
       r2=.88;
       Prh=.15;
       Prl=.1;
   end 
   rl=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trh==1.1
   if (Pr<=4) & (Pr>3)
       r1=.33;
       r2=.37;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.34;
       r2=.33;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.43;
       r2=.34;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.54;
       r2=.43;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.59;
       r2=.54;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.66;
       r2=.59;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.73;
       r2=.66;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.77;
       r2=.73;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.81;
       r2=.77;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.85;
       r2=.81;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.9;
       r2=.85;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.93;
       r2=.9;
       Prh=.2;
       Prl=.15;
   else
       r1=.95;
       r2=.93;
       Prh=.15;
       Prl=.1;
   end 
   rh=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trl==1.1
   if (Pr<=4) & (Pr>3)
       r1=.33;
       r2=.37;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.34;
       r2=.33;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.43;
       r2=.34;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.54;
       r2=.43;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.59;
       r2=.54;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.66;
       r2=.59;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.73;
       r2=.66;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.77;
       r2=.73;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.81;
       r2=.77;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.85;
       r2=.81;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.9;
       r2=.85;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.93;
       r2=.9;
       Prh=.2;
       Prl=.15;
    else
       r1=.95;
       r2=.93;
       Prh=.15;
       Prl=.1;
   end 
   rl=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trh==1.2
   if (Pr<=4) & (Pr>3)
       r1=.42;
       r2=.42;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.51;
       r2=.42;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.59;
       r2=.51;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.66;
       r2=.59;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.7;
       r2=.66;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.75;
       r2=.7;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.8;
       r2=.75;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.83;
       r2=.8;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.86;
       r2=.83;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.89;
       r2=.86;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.93;
       r2=.89;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.95;
       r2=.93;
       Prh=.2;
       Prl=.15;
   else
       r1=.96;
       r2=.95;
       Prh=.15;
       Prl=.1;
   end 
   rh=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trl==1.2
   if (Pr<=4) & (Pr>3)
       r1=.42;
       r2=.42;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.51;
       r2=.42;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.59;
       r2=.51;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.66;
       r2=.59;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.7;
       r2=.66;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.75;
       r2=.7;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.8;
       r2=.75;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.83;
       r2=.8;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.86;
       r2=.83;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.89;
       r2=.86;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.93;
       r2=.89;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.95;
       r2=.93;
       Prh=.2;
       Prl=.15;
   else
       r1=.96;
       r2=.95;
       Prh=.15;
       Prl=.1;
   end 
   rl=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trh==1.3
   if (Pr<=4) & (Pr>3)
       r1=.54;
       r2=.51;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.63;
       r2=.54;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.68;
       r2=.63;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.73;
       r2=.68;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.77;
       r2=.73;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.8;
       r2=.77;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.84;
       r2=.8;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.87;
       r2=.84;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.89;
       r2=.87;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.92;
       r2=.89;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.94;
       r2=.92;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.96;
       r2=.94;
       Prh=.2;
       Prl=.15;
   else
       r1=.96;
       r2=.96;
       Prh=.15;
       Prl=.1;
   end 
   rh=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trl==1.3
   if (Pr<=4) & (Pr>3)
       r1=.54;
       r2=.51;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.63;
       r2=.54;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.68;
       r2=.63;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.73;
       r2=.68;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.77;
       r2=.73;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.8;
       r2=.77;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.84;
       r2=.8;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.87;
       r2=.84;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.89;
       r2=.87;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.92;
       r2=.89;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.94;
       r2=.92;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.96;
       r2=.94;
       Prh=.2;
       Prl=.15;
   else
       r1=.96;
       r2=.96;
       Prh=.15;
       Prl=.1;
   end 
   rl=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trh==1.4
   if (Pr<=4) & (Pr>3)
       r1=.68;
       r2=.65;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.73;
       r2=.68;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.77;
       r2=.73;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.81;
       r2=.77;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.83;
       r2=.81;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.85;
       r2=.83;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.88;
       r2=.85;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.89;
       r2=.88;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.91;
       r2=.89;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.93;
       r2=.91;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.95;
       r2=.93;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.97;
       r2=.95;
       Prh=.2;
       Prl=.15;
   else
       r1=.97;
       r2=.97;
       Prh=.15;
       Prl=.1;
   end 
   rh=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trl==1.4
   if (Pr<=4) & (Pr>3)
       r1=.68;
       r2=.65;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.73;
       r2=.68;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.77;
       r2=.73;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.81;
       r2=.77;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.83;
       r2=.81;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.85;
       r2=.83;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.88;
       r2=.85;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.89;
       r2=.88;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.91;
       r2=.89;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.93;
       r2=.91;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.95;
       r2=.93;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.97;
       r2=.95;
       Prh=.2;
       Prl=.15;
   else
       r1=.97;
       r2=.97;
       Prh=.15;
       Prl=.1;
   end 
   rl=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trh==1.6
   if (Pr<=4) & (Pr>3)
       r1=.83;
       r2=.8;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.86;
       r2=.83;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.88;
       r2=.86;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.89;
       r2=.88;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.9;
       r2=.89;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.92;
       r2=.9;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.93;
       r2=.92;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.94;
       r2=.93;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.94;
       r2=.94;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.95;
       r2=.94;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.96;
       r2=.95;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.97;
       r2=.96;
       Prh=.2;
       Prl=.15;
   else
       r1=.97;
       r2=.97;
       Prh=.15;
       Prl=.1;
   end 
   rh=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trl==1.6
   if (Pr<=4) & (Pr>3)
       r1=.83;
       r2=.8;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.86;
       r2=.83;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.88;
       r2=.86;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.89;
       r2=.88;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.9;
       r2=.89;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.92;
       r2=.9;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.93;
       r2=.92;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.94;
       r2=.93;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.94;
       r2=.94;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.95;
       r2=.94;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.96;
       r2=.95;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.97;
       r2=.96;
       Prh=.2;
       Prl=.15;
   else
       r1=.97;
       r2=.97;
       Prh=.15;
       Prl=.1;
   end 
   rl=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trh==2.0
   if (Pr<=4) & (Pr>3)
       r1=.89;
       r2=.86;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.92;
       r2=.89;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.94;
       r2=.92;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.95;
       r2=.94;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.96;
       r2=.95;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.97;
       r2=.96;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.97;
       r2=.97;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.97;
       r2=.97;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.98;
       r2=.97;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.98;
       r2=.98;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.98;
       r2=.98;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.98;
       r2=.98;
       Prh=.2;
       Prl=.15;
   else
       r1=.98;
       r2=.98;
       Prh=.15;
       Prl=.1;
   end 
   rh=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trl==2.0
   if (Pr<=4) & (Pr>3)
       r1=.89;
       r2=.86;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.92;
       r2=.89;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.94;
       r2=.92;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.95;
       r2=.94;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.96;
       r2=.95;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.97;
       r2=.96;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.97;
       r2=.97;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.97;
       r2=.97;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=.98;
       r2=.97;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=.98;
       r2=.98;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=.98;
       r2=.98;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=.98;
       r2=.98;
       Prh=.2;
       Prl=.15;
   else
       r1=.98;
       r2=.98;
       Prh=.15;
       Prl=.1;
   end 
   rl=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end
if Trh==3.0
   if (Pr<=4) & (Pr>3)
       r1=.95;
       r2=.93;
       Prh=4;
       Prl=3;
   elseif (Pr<=3) & (Pr>2)
       r1=.97;
       r2=.95;
       Prh=3;
       Prl=2;
   elseif (Pr<=2) & (Pr>1.5)
       r1=.98;
       r2=.97;
       Prh=2;
       Prl=1.5;
   elseif (Pr<=1.5) & (Pr>1.2)
       r1=.98;
       r2=.98;
       Prh=1.5;
       Prl=1.2;
   elseif (Pr<=1.2) & (Pr>1)
       r1=.98;
       r2=.98;
       Prh=1.2;
       Prl=1;
   elseif (Pr<=1) & (Pr>.8)
       r1=.99;
       r2=.98;
       Prh=1;
       Prl=.8;
   elseif (Pr<=.8) & (Pr>.6)
       r1=.99;
       r2=.99;
       Prh=.8;
       Prl=.6;
   elseif (Pr<=.6) & (Pr>.5)
       r1=.99;
       r2=.99;
       Prh=.6;
       Prl=.5;
   elseif (Pr<=.5) & (Pr>.4)
       r1=1;
       r2=.99;
       Prh=.5;
       Prl=.4;
   elseif (Pr<=.4) & (Pr>.3)
       r1=1;
       r2=1;
       Prh=.4;
       Prl=.3;
   elseif (Pr<=.3) & (Pr>.2)
       r1=1;
       r2=1;
       Prh=.3;
       Prl=.2;
   elseif (Pr<=.2) & (Pr>.15)
       r1=1;
       r2=1;
       Prh=.2;
       Prl=.15;
   else
       r1=1;
       r2=1;
       Prh=.15;
       Prl=.1;
   end 
   rh=(r2-r1)/(Prh-Prl)*(Pr-Prl)+r1;
end

pD_pD0=(rh-rl)/(Trh-Trl)*(Tr-Trl)+rl







