Page 364 - Handbook Of Multiphase Flow Assurance
P. 364

Computer code (Makogon, 1994, 1997)              363

            repeat
              begin
              found:=false;
              closed:=false;
              for j:=i+1 to n do              {search for next link}
                begin
                if (nhb[j,1]=nnext)or(nhb[j,2]=nnext) then

                  begin
                  nbond:=j;
                  if nhb[j,1]=nnext then
                   begin                     {one of atoms in bond fits}
                   nothere:=true;
                   for k:=1 to nr do         {verify that atom not present in ring}
                     if nhb[j,2]=rin[k] then
                       nothere:=false;       {found same atom in ring before}
                   if nothere then
                     begin
                     nr:=nr+1;
                     if nr>nmax then goto 1;
                     rin[nr]:=nnext;         {add to temporary chain}
                     bonds[nr]:=nbond;
                     nnext:=nhb[j,2];        {define next atom for search}
                     found:=true;
                     goto 1;
                     end;
                   end
                  else
                   begin                     {another atom in bond fits}
                   nothere:=true;
                   for k:=1 to nr do         {verify that atom not present in ring}
                     if nhb[j,1]=rin[k] then
                       nothere:=false;       {found same atom in ring before}
                   if nothere then
                     begin
                     nr:=nr+1;
                     if nr>nmax then goto 1;
                     rin[nr]:=nnext;         {add to temporary chain}
                     bonds[nr]:=nbond;
                     nnext:=nhb[j,1];        {define next atom for search}
                     found:=true;
                     goto 1;
                     end;
                   end;
                  end;
   359   360   361   362   363   364   365   366   367   368   369