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

56. CHEMICAL EQUILIBRIUM '''56. Chemical equilibrium.'''

Given the number density of ions in a computational element, determine if any of the ions should go in to/out of solution. Determine the pH and adjust H and OH, accordingly.

⟨Function declarations 23⟩$$+\equiv$$ void chemical_equilibrium (boolean);

57. Minimizing function. This is the function to minimize for the chemical_equilibrium routine. The objective of chemical-equilibrium is to determine how many moles of salt should be leached/precipitated. Therefore, minfunc must adjust for the pore volume. The equation minfunc is minimizing the square of

$$\left [ C+ \frac{mx}{V} \right ]^m \left [ C+ \frac{nx}{V} \right ]^n - k_sp = 0$$

where $$x$$ is moles salt, $$m$$ and $$n$$ are stoichiometric ratios, and $$V$$ is the pore solution volume,

real minfunc(real, int, int, int); real minfunc(real x,int i,int j,int k) { real C, A;   int m, n;    m = sol_array[i][j].m    n = soLarray[i][j].n    C = cation[i].c[k]-, A = anion [j].c[k]-, return SQR(potr(C+m*x/(litre[k] * $$\Delta X$$[k]),m) * pow(A + n * x/(litre[k] * $$\Delta X$$[k]), n) — sol-array [i][j].ksp); }

58. chemical_equilibrium. Cycle through sol.array and determine if any ions should go in to/out of solution based upon the concentration, the solubility constant, and the presence of solid salt.

void chemical-equilibrium (boolean Change_Porosity) { int i, j, k, n, m, iterations; real w_max $$\delta$$; real xa, xb, xc, fa, fb, fc, moles, tmp; real dsolid; real $$\delta$$ litre;  /* change in pore volume */ real old_cOH; real charge,temp; boolean NEG_FLAG; for (k= FIRST_CELL+1; k< NUM.SURFACES; k++) { iterations = 0; do { w_max = 0.0; for (j=0; j < num-amons j++) { for (i =0; i < num-cations-, i++) { if ($$\lnot$$(i$$\equiv$$0$$\land$$j $$\equiv$$0)) {
 * 1) defineTOL $$1.0\cdot 10^-06$$