#! /usr/bin/gawk -f # Last edited on 2017-02-24 05:43:21 by jstolfi function compute_g_w_hydrated(fm,nw, T,fh,wsa,msa,mwt,mwh,mwf,msh,wsh) \ { # Completes the global table {g_w} with the solubilities in water # (g/100g) for the hydrated version of formula {fm} with {nw} # molecules of water of hydration. if (! (fm in g_m)) { prog_error(("missing mol mass for " fm)); } fh = (fm "(H2O)" nw); # Formula of hydrated compound. if (! (fh in g_m)) { prog_error(("missing mol mass for " fh)); } for (T = 0; T <= 200; T++) { if ((fm,T) in g_w) { # Consider a saturated soln of the anhydr {fm} into 100 g H2O: wsa = g_w[fm,T]; # Grams of anhydr {fm} in that soln. msa = wsa/g_m[fm]; # Mols of anhydr {fm} in that soln. mwt = 100.0/g_m["H2O"]; # Mols of H2O in that soln. mwh = nw*msa; # Mols of H2O associated to hydrate. mwf = mwt - mwh; # Mols of H2O not in hydrate. # That solution is also a saturated soln of {msa} # moles of hydrate into {mwf} moles of H2O. msh = msa*mwt/mwf; # Mols of hydrate soluble in 100 g H2O. wsh = msh*g_m[fh]; # Grams of hydrate soluble in 100 mt H2O. g_w[fh,T] = wsh; pws(fh,T); } } }