Page:4SIGHT manual- a computer program for modelling degradation of underground low level waste concrete vaults (IA 4sightmanualcomp5612snyd).pdf/133

56. CHEMICAL EQUILIBRIUM      n=sol_array[i][j].n;       m=sol_array[i][j].m;       temp= pow(cation[i].c[k],(double) m) * pow(anion [j].c[k] (double) n); if((sol_array[i][j].s[k]>0.0)$$\lor$$ ( temp > soLarray[i][j].ksp)) { xa=— MIN(cation[i].c[k], anion[j].c[fc])/10.0; xb=—xa xc=0.0; mnbrak(&xa, &xb, &xc, &fa, &fb, &fc, mnifunc, i, j, k); tmp = brent (xa,xb,xc,minfunc,TOL,&moles,i,j,k); if (fabs(moles) > 0.05) moles *= 0.10;   /* no drastic changes */ if (sol_array[i][j].s[k];-moles < 0.0) moles = sol_array [i][j].s[k];  /* insufficient salt */ if (cation[i].moles[k]+m*moles<0.0) moles = -cation[i].moles[k]/m+0.000001; if (anion[j].moles[k]+n*moles<0.0) moles = -anion[i].moles[k]/m+0.000001; $$\Delta$$litre = 0.001 * moles *sol_array[i][j].molar_density/$$\Delta X$$[k]; if (litre[k]+$$\Delta$$<0.0) { $$\Delta$$litre=-litre[k];  /* insufficient  pore space */ moles = $$\Delta$$litre * $$\Delta X$$[k]*1000.0/sol_array[i][j].molar_density; }        cation[i].moles[k]+=m*moles; anion[j].moles[k]+n*moles; if (Change_Porosity$$\equiv$$TRUE) { litre[k]+=$$\Delta$$litre; sol_array[i][j].s[k]-=moles; }          $$\delta$$=fabs(moles); w_max=MAX($$\delta$$,w_max); }      }     }   }   /* readjust the concentrations */ $$\phi'^n$$[k]=1000.0*litre[k]*$$\delta X$$[k]/Vsample; litre[k]=MAX(litre[k],0.0001);  /* avoid zero volume problems */ for (i=0; i < num_cations; i++ ) cation[i].c[k]=cation[i].moles[k]/(litre[k]*$$\delta X$$[k]); for (j=0; i < num_anions; i++ ) anion[j].c[k]=anion[i].moles[k]/(litre[k]*$$\delta X$$[k]); /* Determin [OH] and [H] concentration */   /* store old value */ old_cOH = anion[OH].c[k]; charge=0.0; for (j=1; j < num_anions; j++) charge += anion[j].valence * anion[j].c[k] for (j=1; i < num_anions; i++) charge += cation[j].valence * cation[j].c[k] anion[OH].c[k]=0.5 *(charge+sqrt(SQR(charge)+4.0*sol_arrary[H][OH].ksp)); anion[OH].moles[k]=anion[OH].c[k]*litre[k]*$$\Delta X$$[k]; if (fabs((anion[OH].c[k]=old_cOH)/old_cOH)>1.00) { w_max = 1.0; anion[OH].c[k]=0.5 * (anion[OH].c[k]_old_cOH); anion[OH].moles[k]= anion[OH].c[k]*litre[k]*$$\Delta X$$[k];