program saltVisc;
uses CRT;
{Computes temperatures required to reduce apparent bead size
in NaCl solutions heated by laser beam.  Uses Equation 11 from
VISCOSITY OF AQUEOUS SODIUM CHLORIDE SOLUTIONS FROM 0-150 deg C
by H. Ozbeck,  Lawrence Berkeley National Laboratory, paper LBL-5931
http://escholarship.org/uc/item/3jp6n2bf }

const
c1 =  0.1256735;
c2 = 1.265347;
c3 = -1.105369;
c4 = 0.2044679;
c5 = 1.308779;
a1 = - 0.04296718;
a2 = 0.3710073;
a3 = 0.4230889;
a4 = - 0.3259828;
var
T, m, Visc, initVisc, initDia, lessVisc, lessDia:  real;

begin
Clrscr;
writeln;
writeln('What molarity of NaCl ?');
readln(m);
if m>5.0 then
   begin
   writeln('NaCl solutions saturate above 5 Molar');
   repeat until keypressed;
   halt;
   end;
writeln ('What is the ambient {coldest} temperature?' );
readln(T);
if T < 0 then
   begin
   writeln('Only works OK for temp>0');
   repeat until keypressed;
   halt;
   end;
initVisc := c1 + c2*exp(a1*T) + c3*exp(a2*m) + c4*exp(a3*(0.01*T+m)) + c5*exp(a4*(0.01*T-m));
writeln('initial viscosity = ',initVisc:2:3);
writeln('What is apparent bead diameter at ambient temperature?');
readln(initDia);
writeln('What is reduced diameter at higher temperature?');
readln(lessDia);
repeat
T:=0.0;
repeat
 visc := c1 + c2*exp(a1*T) + c3*exp(a2*m) + c4*exp(a3*(0.01*T+m)) + c5*exp(a4*(0.01*T-m));
 T:=T+0.01;
until visc < initVisc * lessDia / initDia;
writeln('Raised temp = ',T:2:2,'              visc=',visc:2:3);
writeln('Enter another reduced diameter. Type 0 to quit');
readln(lessDia);
until lessDia = 0;
end.