def setUp(self): self.s1 = pyEQL.Solution(volume='2 L') self.s2 = pyEQL.Solution([['Na+', '4 mol/L'], ['Cl-', '4 mol/L']], volume='2 L') self.s3 = pyEQL.Solution([['Na+', '4 mol/kg'], ['Cl-', '4 mol/kg']], volume='2 L') self.s4 = pyEQL.Solution([['Na+', '8 mol'], ['Cl-', '8 mol']], volume='2 L')
def setUp(self): self.s1 = pyEQL.Solution(volume="2 L") self.s2 = pyEQL.Solution([["Na+", "4 mol/L"], ["Cl-", "4 mol/L"]], volume="2 L") self.s3 = pyEQL.Solution([["Na+", "4 mol/kg"], ["Cl-", "4 mol/kg"]], volume="2 L") self.s4 = pyEQL.Solution([["Na+", "8 mol"], ["Cl-", "8 mol"]], volume="2 L")
def test_molar_conductivity_water(self): self.s1 = pyEQL.Solution(temperature="25 degC") result = self.s1.get_molar_conductivity("H2O").to( "m**2*S/mol").magnitude expected = pyEQL.unit("0 m**2 * S / mol").magnitude self.assertAlmostEqual(result, expected, 5)
def test_activity_pitzer_phreeqc_nacl_2(self): ''' calculate the activity coefficient at each concentration and compare to the output of the PHREEQC model PHREEQC version 3.1.4 was used to calculate density, conductivity, water activity, and NaCl activity coefficient for NaCl solutions up to 6m. The Pitzer model (pitzer.dat) database was used. <http://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/> ''' # list of concentrations to test, mol/kg conc_list = [0.1, 0.25, 0.5, 0.75, 1, 2, 3, 4, 5, 6] # list of modeled activity coefficients phreeqc_pitzer_activity_coeff = [ 0.7771, 0.7186, 0.6799, 0.6629, 0.6561, 0.6675, 0.7128, 0.7825, 0.8729, 0.9874 ] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Na+', conc) sol.add_solute('Cl-', conc) result = sol.get_activity_coefficient('Na+') expected = phreeqc_pitzer_activity_coeff[i] self.assertAlmostEqual(result, expected, 2)
def test_activity_crc_bacl2(self): ''' calculate the activity coefficient of BaCl2 at each concentration and compare to experimental data Experimental activity coefficient values at 25 degC are found in *CRC Handbook of Chemistry and Physics*, Mean Activity Coefficients of Electrolytes as a Function of Concentration, in: W.M. Haynes (Ed.), 92nd ed., 2011. ''' # list of concentrations to test, mol/kg conc_list = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1] # list of published experimental activity coefficients pub_activity_coeff = [ 0.887, 0.849, 0.782, 0.721, 0.653, 0.559, 0.492, 0.436, 0.391, 0.393 ] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc_c = str(conc_list[i]) + 'mol/kg' conc_a = str(conc_list[i] * 2) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Ba+2', conc_c) sol.add_solute('Cl-', conc_a) act_cat = sol.get_activity_coefficient('Ba+2') act_an = sol.get_activity_coefficient('Cl-') result = (act_cat**1 * act_an**2)**(1 / 3) expected = pub_activity_coeff[i] self.assertAlmostEqual(result, expected, 2)
def test_activity_crc_CsI(self): ''' calculate the activity coefficient of CsI at each concentration and compare to experimental data Experimental activity coefficient values at 25 degC are found in *CRC Handbook of Chemistry and Physics*, Mean Activity Coefficients of Electrolytes as a Function of Concentration, in: W.M. Haynes (Ed.), 92nd ed., 2011. ''' cation = 'Cs+' nu_cation = 1 anion = 'I-' nu_anion = 1 # list of concentrations to test, mol/kg conc_list = [0.001,0.002,0.005,0.01,0.02,0.05,0.1,0.2,0.5,1,2] # list of published experimental activity coefficients pub_activity_coeff = [0.965,0.951,0.925,0.898,0.863,0.804,0.749,0.688,0.601,0.534,0.470] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc_c = str(conc_list[i] * nu_cation) + 'mol/kg' conc_a = str(conc_list[i]* nu_anion) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute(cation,conc_c) sol.add_solute(anion,conc_a) act_cat = sol.get_activity_coefficient(cation) act_an = sol.get_activity_coefficient(anion) result=(act_cat ** nu_cation * act_an ** nu_anion) ** (1/(nu_cation+nu_anion)) expected = pub_activity_coeff[i] self.assertWithinExperimentalError(result,expected,self.tol)
def mock_seawater(self, multiple): """ Create a solution of mock seawater. Multiple is a scale factor by which the base composition (regular seawater) is scaled. """ s1 = pyEQL.Solution( [ ["Na+", str(multiple * 0.4197 + multiple * 2 * 0.0288) + "mol/L"], [ "Cl-", str( multiple * 0.4197 + multiple * 2 * 0.0546 + multiple * 2 * 0.01045 + multiple * 0.00093 ) + "mol/L", ], ["Mg+2", str(multiple * 0.0546) + "mol/L"], ["SO4-2", str(multiple * 0.0288) + "mol/L"], ["Ca+2", str(multiple * 0.01045) + "mol/L"], ["K+", str(multiple * 0.00093) + "mol/L"], ] ) return s1
def test_osmotic_pitzer_coppersulfate(self): ''' calculate the osmotic coefficient at each concentration and compare to experimental data for copper sulate References ---------- May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011). A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C. Journal of Chemical & Engineering Data, 56(12), 5066–5077. doi:10.1021/je2009329 ''' # list of concentrations to test, mol/kg conc_list = [0.25, 0.5, 0.75, 1] # list of published experimental osmotic coefficients pub_osmotic_coeff = [0.5, 0.485, 0.48, 0.485, 0.5] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Cu+2', conc) sol.add_solute('SO4-2', conc) result = sol.get_osmotic_coefficient() expected = pub_osmotic_coeff[i] self.assertAlmostEqual(result, expected, 1)
def test_activity_pitzer_nacl_1(self): ''' calculate the activity coefficient at each concentration and compare to experimental data Experimental activity coefficient values at 25 degC are found in *J. Phys. Chem. Reference Data* Vol 13 (1), 1984, p.53. ''' # list of concentrations to test, mol/kg conc_list = [0.1,0.25,0.5,0.75,1,2,3,4,5,6] # list of published experimental activity coefficients pub_activity_coeff = [0.778,0.72,0.681,0.665,0.657,0.669,0.714,0.782,0.873,0.987] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Na+',conc) sol.add_solute('Cl-',conc) result=sol.get_activity_coefficient('Na+') expected = pub_activity_coeff[i] self.assertWithinExperimentalError(result,expected,self.tol)
def test_water_activity_phreeqc_pitzer_nacl_2(self): ''' calculate the water activity at each concentration and compare to the output of the PHREEQC model PHREEQC version 3.1.4 was used to calculate density, conductivity, water activity, and NaCl activity coefficient for NaCl solutions up to 6m. The Pitzer model (pitzer.dat) database was used. <http://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/> ''' # list of concentrations to test, mol/kg conc_list = [0.1,0.25,0.5,0.75,1,2,3,4,5,6] # list of modeled water activities phreeqc_pitzer_water_activity = [0.997,0.992,0.984,0.975,0.967,0.932,0.893,0.851,0.807,0.759] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Na+',conc) sol.add_solute('Cl-',conc) result=sol.get_water_activity() expected = phreeqc_pitzer_water_activity[i] self.assertWithinExperimentalError(result,expected,self.tol)
def test_activity_crc_rbcl(self): ''' calculate the activity coefficient of RbCl at each concentration and compare to experimental data Experimental activity coefficient values at 25 degC are found in *CRC Handbook of Chemistry and Physics*, Mean Activity Coefficients of Electrolytes as a Function of Concentration, in: W.M. Haynes (Ed.), 92nd ed., 2011. ''' # list of concentrations to test, mol/kg conc_list = [0.001,0.002,0.005,0.01,0.02,0.05,0.1,0.2,0.5,1,2,5] # list of published experimental activity coefficients pub_activity_coeff = [0.965,0.951,0.926,0.900,0.867,0.811,0.761,0.707,0.633,0.583,0.546,0.544] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc_c = str(conc_list[i]) + 'mol/kg' conc_a = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Rb+',conc_c) sol.add_solute('Cl-',conc_a) result=sol.get_activity_coefficient('Rb+') expected = pub_activity_coeff[i] self.assertWithinExperimentalError(result,expected,self.tol)
def test_activity_crc_licl(self): ''' calculate the activity coefficient of LiCl at each concentration and compare to experimental data Experimental activity coefficient values at 25 degC are found in *CRC Handbook of Chemistry and Physics*, Mean Activity Coefficients of Electrolytes as a Function of Concentration, in: W.M. Haynes (Ed.), 92nd ed., 2011. ''' # list of concentrations to test, mol/kg conc_list = [0.001,0.002,0.005,0.01,0.02,0.05,0.1,0.2,0.5,1,2,5] # list of published experimental activity coefficients pub_activity_coeff = [0.965,0.952,0.928,0.904,0.874,0.827,0.789,0.756,0.739,0.775,0.924,2.0] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc_c = str(conc_list[i]) + 'mol/kg' conc_a = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Li+',conc_c) sol.add_solute('Cl-',conc_a) act_cat = sol.get_activity_coefficient('Li+') act_an = sol.get_activity_coefficient('Cl-') result=(act_cat ** 1 * act_an ** 1) ** (1/2) expected = pub_activity_coeff[i] self.assertWithinExperimentalError(result,expected,self.tol)
def test_density_pitzer_nacl_1(self): ''' calculate the density at each concentration and compare to experimental data Published density values at 25 degC over a range of NaCl concentrations up to saturation are found in J. Phys. Chem. Reference Data Vol 13 (1), 1984, p.84 ''' # list of concentrations to test, mol/kg conc_list = [0.1, 0.25, 0.5, 0.75, 1, 2, 3, 4, 5, 6] # list of published experimental densities pub_density = [ 1.00117, 1.00722, 1.01710, 1.02676, 1.03623, 1.07228, 1.10577, 1.13705, 1.16644, 1.1942 ] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Na+', conc) sol.add_solute('Cl-', conc) result = sol.get_density().to('g/mL').magnitude expected = pub_density[i] self.assertAlmostEqual(result, expected, 2)
def test_density_pitzer_nacl_phreeqc_1(self): ''' calculate the density at each concentration and compare to the output of the PHREEQC model PHREEQC version 3.1.4 was used to calculate density, conductivity, water activity, and NaCl activity coefficient for NaCl solutions up to 6m. The Pitzer model (pitzer.dat) database was used. <http://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/> ''' # list of concentrations to test, mol/kg conc_list = [0.1, 0.25, 0.5, 0.75, 1, 2, 3, 4, 5, 6] # list of modeled densities phreeqc_pitzer_density = [ 1.00115, 1.00718, 1.01702, 1.02664, 1.03606, 1.07204, 1.10562, 1.13705, 1.16651, 1.19417 ] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('Na+', conc) sol.add_solute('Cl-', conc) result = sol.get_density().to('g/mL').magnitude expected = phreeqc_pitzer_density[i] self.assertAlmostEqual(result, expected, 2)
def test_osmotic_pitzer_ammoniumnitrate(self): """ calculate the osmotic coefficient at each concentration and compare to experimental data for ammonium nitrate References ---------- May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011). A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C. Journal of Chemical & Engineering Data, 56(12), 5066–5077. doi:10.1021/je2009329 """ # list of concentrations to test, mol/kg conc_list = [0.25, 0.5, 0.75, 1, 1.5, 2] # list of published experimental osmotic coefficients pub_osmotic_coeff = [0.86, 0.855, 0.83, 0.825, 0.80, 0.78] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc = str(conc_list[i]) + "mol/kg" sol = pyEQL.Solution() sol.add_solute("NH4+", conc) sol.add_solute("NO3-", conc) result = sol.get_osmotic_coefficient() expected = pub_osmotic_coeff[i] self.assertWithinExperimentalError(result, expected, self.tol)
def test_activity_crc_k2so4(self): ''' calculate the activity coefficient of K2SO4 at each concentration and compare to experimental data Experimental activity coefficient values at 25 degC are found in *CRC Handbook of Chemistry and Physics*, Mean Activity Coefficients of Electrolytes as a Function of Concentration, in: W.M. Haynes (Ed.), 92nd ed., 2011. ''' # list of concentrations to test, mol/kg conc_list = [0.001,0.002,0.005,0.01,0.02,0.05,0.1,0.2,0.5] # list of published experimental activity coefficients pub_activity_coeff = [0.885,0.844,0.772,0.704,0.625,0.511,0.424,0.343,0.251] for i in range(len(conc_list)): with self.subTest(conc=conc_list[i]): conc_c = str(conc_list[i]*2) + 'mol/kg' conc_a = str(conc_list[i]) + 'mol/kg' sol = pyEQL.Solution() sol.add_solute('K+',conc_c) sol.add_solute('SO4-2',conc_a) act_cat = sol.get_activity_coefficient('K+') act_an = sol.get_activity_coefficient('SO4-2') result=(act_cat ** 2 * act_an ** 1) ** (1/3) expected = pub_activity_coeff[i] self.assertWithinExperimentalError(result,expected,self.tol)
def test_molar_conductivity_water(self): self.s1 = pyEQL.Solution(temperature='25 degC') result = self.s1.get_molar_conductivity('H2O').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('0 m**2 * S / mol').magnitude self.assertAlmostEqual(result, expected, 5)
def test_molar_conductivity_hydrogen(self): # H+ - 349.65 x 10 ** -4 m ** 2 S / mol self.s1 = pyEQL.Solution(temperature='25 degC') actual = self.s1.get_molar_conductivity('H+').to('m**2*S/mol') expected = pyEQL.unit('349.65e-4 m**2 * S / mol') result = (actual - expected).magnitude self.assertAlmostEqual(result, 0, self.places)
def test_molar_conductivity_hydroxide(self): # OH- - 198 x 10 ** -4 m ** 2 S / mol self.s1 = pyEQL.Solution(temperature='25 degC') result = self.s1.get_molar_conductivity('OH-').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('198e-4 m**2 * S / mol').magnitude self.assertWithinExperimentalError(result, expected, self.tol)
def test_molar_conductivity_neutral(self): self.s1 = pyEQL.Solution([["FeCl3", "0.001 mol/L"]], temperature="25 degC") result = self.s1.get_molar_conductivity("FeCl3").to( "m**2*S/mol").magnitude expected = pyEQL.unit("0 m**2 * S / mol").magnitude self.assertAlmostEqual(result, expected, 5)
def test_molar_conductivity_neutral(self): self.s1 = pyEQL.Solution([['FeCl3', '0.001 mol/L']], temperature='25 degC') result = self.s1.get_molar_conductivity('FeCl3').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('0 m**2 * S / mol').magnitude self.assertAlmostEqual(result, expected, 5)
def test_molar_conductivity_hydrogen(self): # H+ - 349.65 x 10 ** -4 m ** 2 S / mol self.s1 = pyEQL.Solution(temperature='25 degC') result = self.s1.get_molar_conductivity('H+').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('349.65e-4 m**2 * S / mol').magnitude self.assertWithinExperimentalError(result, expected, self.tol)
def test_dielectric_constant7(self): """ 1 mol/kg LiCl = 64 """ s1 = pyEQL.Solution([["Li+", "1 mol/kg"], ["Cl-", "1 mol/kg"]]) result = s1.get_dielectric_constant().magnitude expected = 64 self.assertWithinExperimentalError(result, expected, self.tol)
def test_dielectric_constant5(self): """ 3.4 mol/kg KBr = 51 """ s1 = pyEQL.Solution([["K+", "3.4 mol/kg"], ["Br-", "3.4 mol/kg"]]) result = s1.get_dielectric_constant().magnitude expected = 51 self.assertWithinExperimentalError(result, expected, self.tol)
def test_dielectric_constant2(self): """ 2 mol/kg NaCl = 58 """ s1 = pyEQL.Solution([["Na+", "2 mol/kg"], ["Cl-", "2 mol/kg"]]) result = s1.get_dielectric_constant().magnitude expected = 58 self.assertWithinExperimentalError(result, expected, self.tol)
def test_molar_conductivity_sodium(self): # Na+ - 50.08 x 10 ** -4 m ** 2 S / mol self.s1 = pyEQL.Solution( [['Na+', '0.001 mol/L'], ['Cl-', '0.001 mol/L']], temperature='25 degC') result = self.s1.get_molar_conductivity('Na+').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('50.08e-4 m**2 * S / mol').magnitude self.assertWithinExperimentalError(result, expected, self.tol)
def test_molar_conductivity_fluoride(self): # F- - 55.4 x 10 ** -4 m ** 2 S / mol self.s1 = pyEQL.Solution( [['Na+', '0.001 mol/L'], ['F-', '0.001 mol/L']], temperature='25 degC') result = self.s1.get_molar_conductivity('F-').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('55.4e-4 m**2 * S / mol').magnitude self.assertWithinExperimentalError(result, expected, self.tol)
def test_molar_conductivity_sulfate(self): # SO4-2 - 160 x 10 ** -4 m ** 2 S / mol self.s1 = pyEQL.Solution( [['Na+', '0.002 mol/L'], ['SO4-2', '0.001 mol/L']], temperature='25 degC') result = self.s1.get_molar_conductivity('SO4-2').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('160.0e-4 m**2 * S / mol').magnitude self.assertWithinExperimentalError(result, expected, self.tol)
def test_molar_conductivity_magnesium(self): # Mg+2 - 106 x 10 ** -4 m ** 2 S / mol self.s1 = pyEQL.Solution( [['Mg+2', '0.001 mol/L'], ['Cl-', '0.002 mol/L']], temperature='25 degC') result = self.s1.get_molar_conductivity('Mg+2').to( 'm**2*S/mol').magnitude expected = pyEQL.unit('106e-4 m**2 * S / mol').magnitude self.assertWithinExperimentalError(result, expected, self.tol)
def test_dielectric_constant9(self): """ 0.5 mol/kg RbCl = 73 """ s1 = pyEQL.Solution([["Rb+", "0.5 mol/kg"], ["Cl-", "0.5 mol/kg"]]) result = s1.get_dielectric_constant().magnitude expected = 73 self.assertWithinExperimentalError(result, expected, self.tol)