#! /usr/bin/gawk -f # Last edited on 2019-02-16 02:26:14 by jstolfi @include "gawklib/fill_molar_mass_table_elems.gawk" @include "gawklib/compute_g_w_hydrated.gawk" BEGIN \ { # Computations for the preparation of FeO(OH) from FeCl3 and NaOH. # ---------------------------------------------------------------------- abort = -1; # Molar mass table (grams per mol): split("", g_m); # Indexed by chem formula. fill_molar_mass_table(); # General parameters: g_FeOOH = 50; # Grams of anhydrous FeO(OH) to make. x_NaOH = 0.25; # Mass concentration of reagent NaOH solution. x_FeCl3 = 0.25; # Mass concentration of reagent FeCl3 solution. ex_NaOH = 0.10; # Fractional excess of NaOH. T_sol = 30; # Temperature of reagent solutions (C). T_filt = 30; # Temperature of filtration (C). x_NaOH_wash = 0.10 # Mass concentration of NaOH in wash solution. g_wash_1 = 100; # Mass of washing solution (g) per washing. n_wash = 2; # Number of washings with NaOH and with H2O. T_wash = 90; # Temperature of washing (C). g_rinse_1 = 100; # Mass of rinsing solution (g) per rinsing. n_rinse = 2; # Number of rinsings with NaOH and with H2O. T_rinse = 90; # Temperature of rinsing (C). T_dry = 140; # Temperature of drying (C). g_FeOOH_ass = 5.0 # Mass of anhyd. FeO(OH) to use in final assay. T_ass = 300; # Temperature of calcination in assay (C). # Compute the plan steps: m_FeOOH = g_FeOOH/g_m["FeOOH"]; # Moles of FeO(OH) to make. # Use the right amount of anhydrous FeCl3: m_FeCl3 = m_FeOOH; # Moles of anhydrous FeCl3 to use. g_FeCl3 = m_FeCl3*g_m["FeCl3"]; # Grams of anhydrous FeCl3 to use. # Use a bit excess NaOH: m_NaOH = (1 + ex_NaOH)*3*m_FeOOH; # Moles of anhydrous NaOH to use. g_NaOH = m_NaOH*g_m["NaOH"]; # Grams of anhydrous NaOH to use. # Use enough water to make a 10% sol by mass of each reagent: g_w_FeCl3 = ((1-x_FeCl3)/x_FeCl3)*g_FeCl3; # Water (g) for FeCl3 soln. g_w_NaOH = (1-x_NaOH)/x_NaOH*g_NaOH; # Water (g) for NaOH soln. # Prepare the NaOH solution for all washings: g_wash = n_wash*g_wash_1; # Total wash solution (g). g_NaOH_wash = x_NaOH_wash*g_wash; # Total NaOH in wash sol (g). g_w_wash = g_wash - g_NaOH_wash; # Total water in wash sol (g). # Compute weight of resulting FeO(OH) (anhydrous): m_FeOOH = m_FeCl3; # Moles of FeO(OH) in reacted mix (solid). g_FeOOH = m_FeOOH*g_m["FeOOH"]; # Expected grams of FeO(OH) in reacted mix. # Compute weight of resulting FeO(OH) (monohydrate): m_FeOOHWt1 = m_FeOOH; # Moles of FeO(OH)(H2O) in reacted mix (solid). g_FeOOHWt1 = m_FeOOHWt1*g_m["FeOOHWt1"]; # Expected grams of FeO(OH)(H2O) in reacted mix. # Compute weight of resulting NaCl: m_NaCl = 3*m_FeCl3; # Moles of NaCl in reacted mix (solid). g_NaCl = m_NaCl*g_m["NaCl"]; # Expected grams of NaCl in reacted mix. # Compute how much H2O will be in reacted mix (including as hydration of ppt): # It is the H2O in the two reagent solns plus the dehydration of FeO3H3. g_w_super = g_w_FeCl3 + g_w_NaOH - m_FeOOH*g_m["H2O"]; # Water (g) in supernatant. # Compute excess of NaOH in supernatant: m_ex_NaOH = (ex_NaOH/(1 + ex_NaOH))*m_NaOH; # Moles of excess anhydrous NaOH g_ex_NaOH = m_ex_NaOH*g_m["NaOH"]; # Grams of excess anhydrous NaOH. # Compute mass of Fe2O3 in assay: m_FeOOH_ass = g_FeOOH_ass/g_m["FeOOH"]; # Moles of FeOOH to assay. m_Fe2O3_ass = m_FeOOH_ass/2; # Moles of Fe2O3 yielded by assay. g_Fe2O3_ass = m_Fe2O3_ass*g_m["Fe2O3"]; # Grams of anhydrous FeCl3 to use. # Print the recipe: printf "------------------------------------------------------------\n"; printf "RECIPE\n"; printf "\n"; printf "Ferric chloride reagent solution:\n"; printf " %5.1f g of FeCl3 (anhydrous)\n", g_FeCl3; printf " %5.1f g of water\n", g_w_FeCl3; printf " %5.1f g total weight of solution\n", g_w_FeCl3 + g_FeCl3; printf " Preparation temp = %3.0f C\n", T_sol; printf "\n"; printf "Sodium hydroxide reagent solution:\n"; printf " %5.1f g of NaOH (anhydrous)\n", g_NaOH; printf " %5.1f g of water\n", g_w_NaOH; printf " %5.1f g total weight of solution\n", g_w_NaOH + g_NaOH; printf " Preparation temp = %3.0f C\n", T_sol; printf "\n"; printf "Sodium hydroxide wash solution:\n"; printf " %5.1f g of NaOH (anhydrous)\n", g_NaOH_wash; printf " %5.1f g of water\n", g_w_wash; printf " %5.1f g total weight of solution\n", g_wash; printf " Preparation temp = %3.0f C\n", T_sol; printf "\n"; printf "Reacted mix:\n"; printf " reaction temp = %3.0f C\n", T_sol; printf " %5.1f g of FeO(OH) (anhydrous)\n", g_FeOOH; printf " %5.1f g of NaCl\n", g_NaCl; printf " %5.1f g of NaOH\n", g_ex_NaOH; printf " %5.1f g of H20 (incl. hydration of ppt)\n", g_w_super; printf " %5.1f g total weight of reacted mix\n", g_FeOOH + g_NaCl + g_ex_NaOH + g_w_super; printf "\n"; printf "Filtration 1:\n"; printf " Filter\n"; printf " Expected:\n"; printf " %5.1f g precipitate of FeO(OH) (anhydrous)\n", g_FeOOH; printf " %5.1f g precipitate of FeO(OH)(H2O)\n", g_FeOOHWt1; printf "\n"; printf "Washing with NaOH solution\n"; printf " Repeat %d times\n", n_wash; printf " %5.1f g of NaOH washing solution\n", g_wash_1; printf " Washing temp = %3.0f C\n", T_wash; printf " Filter\n"; printf "\n"; printf "Rinsing with water\n"; printf " Repeat %d times\n", n_rinse; printf " %5.1f g of water\n", g_rinse_1; printf " Rinsing temp = %3.0f C\n", T_rinse; printf " Filter\n"; printf "\n"; printf "Drying:\n"; printf " Drying temp = %3.0f C\n", T_dry; printf " Expected:\n"; printf " %5.1f g of FeO(OH) (anhydrous)\n", g_FeOOH; printf "\n"; printf "Assay:\n"; printf " %6.2f g of FeO(OH) (anhydrous)\n", g_FeOOH_ass; printf " Calcination temp = %3.0f C\n", T_ass; printf " Expected:\n"; printf " %6.2f g of Fe2O3\n", g_Fe2O3_ass; printf "\n"; printf "------------------------------------------------------------\n" } function fill_molar_mass_table() \ { # Fills the necessary entries of the {g_m} globa table: fill_molar_mass_table_elems(); pmm("Na"); pmm("Fe"); pmm("Cl"); g_m["H2O"] = 2*g_m["H"] + g_m["O"]; pmm("H2O"); g_m["OH"] = g_m["O"] + g_m["H"]; pmm("OH"); g_m["FeCl3"] = g_m["Fe"] + 3*g_m["Cl"]; pmm("FeCl3"); g_m["FeOOH"] = g_m["Fe"] + g_m["O"] + g_m["OH"]; pmm("FeOOH"); g_m["FeOOHWt1"] = g_m["FeOOH"] + g_m["H2O"]; pmm("FeOOHWt1"); g_m["Fe2O3"] = 2*g_m["Fe"] + 3*g_m["O"]; pmm("Fe2O3"); g_m["NaOH"] = g_m["Na"] + g_m["OH"]; pmm("NaOH"); g_m["NaCl"] = g_m["Na"] + g_m["Cl"]; pmm("NaCl"); } function pmm(fm) \ { # Prints to {stderr} the molar mass of formula {fm}, # as stored in the global array {g_m}. printf "%-20s molar mass = %8.3f\n", fm, g_m[fm] > "/dev/stderr"; } function prog_error(msg) \ { printf "** PROG ERROR:%s\n", msg > "/dev/stderr"; abort = 1; exit(abort); }