def test_Hfg_ATcT_data(): assert Hfg_ATcT_data.index.is_unique assert Hfg_ATcT_data.shape == (595, 5) assert all([check_CAS(i) for i in Hfg_ATcT_data.index]) tots_calc = [Hfg_ATcT_data[i].abs().sum() for i in ['Hfg_0K', 'Hfg', 'uncertainty']] tots = [300788330, 300592764, 829204] assert_close1d(tots_calc, tots)
def validate_table(self, name): '''Basic method which checks that all CAS numbers are valid, and that all elements of the data have non-nan values. Raises an exception if any of the data is missing or is a nan value. ''' table = self.tables[name] meta = self.metadata[name] components = meta['components'] necessary_keys = meta['necessary keys'] # Check the CASs for key in table: CASs = key.split(' ') # Check the key is the right length assert len(CASs) == components # Check all CAS number keys are valid assert all(check_CAS(i) for i in CASs) values = table[key] for i in necessary_keys: # Assert all necessary keys are present assert i in values val = values[i] # Check they are not None assert val is not None # Check they are not nan assert not isnan(val)
def test_CRC_aqueous_thermodynamics(): assert all([check_CAS(i) for i in CRC_aqueous_thermodynamics.index]) # Check CASs match up assert all([CAS_from_any(i) == i for i in CRC_aqueous_thermodynamics.index]) # Check search by formula matches up for formula, CAS in zip(CRC_aqueous_thermodynamics['Formula'], CRC_aqueous_thermodynamics.index): assert pubchem_db.search_CAS(CAS_from_any(formula)).CASs == CAS # Check the MWs match up for CAS, MW_specified in zip(CRC_aqueous_thermodynamics.index, CRC_aqueous_thermodynamics['MW']): c = pubchem_db.search_CAS(CAS) assert_close(c.MW, MW_specified, atol=0.05) # Checking names is an option too but of 173, only 162 are unique # and many of the others have names that seem ambiguous for ions which can # have more than one charge assert CRC_aqueous_thermodynamics.index.is_unique assert CRC_aqueous_thermodynamics.shape == (173, 7) Hf_tot = CRC_aqueous_thermodynamics['Hf(aq)'].abs().sum() assert_close(Hf_tot, 70592500.0) Gf_tot = CRC_aqueous_thermodynamics['Gf(aq)'].abs().sum() assert_close(Gf_tot, 80924000.0) S_tot = CRC_aqueous_thermodynamics['S(aq)'].abs().sum() assert_close(S_tot, 17389.9) Cp_tot = CRC_aqueous_thermodynamics['Cp(aq)'].abs().sum() assert_close(Cp_tot, 2111.5)
def test_ATcT_l(): assert Hfl_ATcT_data.index.is_unique assert Hfl_ATcT_data.shape == (34,5) assert all([check_CAS(i) for i in Hfl_ATcT_data.index]) tots_calc = [Hfl_ATcT_data[i].abs().sum() for i in ['Hfl_0K', 'Hfl', 'uncertainty']] tots = [2179500.0, 6819443, 19290] assert_close1d(tots_calc, tots)
def test_HPV_data(): assert HPV_data.index.is_unique assert HPV_data.shape == (5067, 0) assert sum(list(HPV_data.index)) == 176952023632 for i in HPV_data.index: assert check_CAS(int_to_CAS(i))
def test_VDI_PPDS_10_data(): """Average deviation of 2.4% from tabulated values. Many chemicals have much higher deviations. 10% or more deviations: ['75-34-3', '107-06-2', '106-93-4', '420-46-2', '71-55-6', '79-34-5', '67-72-1', '76-12-0', '76-13-1', '76-14-2', '540-54-5', '75-01-4', '75-35-4', '79-01-6', '127-18-4', '462-06-6', '108-90-7', '108-86-1', '108-41-8', '100-44-7', '108-93-0', '100-61-8', '121-69-7', '91-66-7'] These have been checked - it appears the tabulated data is just incorrect. """ assert all([check_CAS(i) for i in k_data_VDI_PPDS_10.index]) tots_calc = [ k_data_VDI_PPDS_10[i].abs().sum() for i in [u'A', u'B', u'C', u'D', u'E'] ] tots = [ 2.2974640014599998, 0.015556001460000001, 1.9897655000000001e-05, 6.7747269999999993e-09, 2.3260109999999999e-12 ] assert_close1d(tots_calc, tots) assert k_data_VDI_PPDS_10.index.is_unique assert k_data_VDI_PPDS_10.shape == (275, 6)
def test_CRC_const_inorg_l(): assert rho_data_CRC_inorg_l_const.index.is_unique assert all([check_CAS(i) for i in rho_data_CRC_inorg_l_const.index]) tot_calc = rho_data_CRC_inorg_l_const['Vm'].sum() tot = 0.01106122489849834 assert_allclose(tot_calc, tot)
def test_Hfus_CRC_data(): Hfus_total = Hfus_data_CRC['Hfus'].sum() assert_close(Hfus_total, 29131241) assert Hfus_data_CRC.index.is_unique assert Hfus_data_CRC.shape == (1112, 3) assert all([check_CAS(i) for i in list(Hfus_data_CRC.index)])
def test_Perrys2_8(): assert all([check_CAS(i) for i in Psat_data_Perrys2_8.index]) tots_calc = [Psat_data_Perrys2_8[i].abs().sum() for i in ['C1', 'C2', 'C3', 'C4', 'C5', 'Tmin', 'Tmax']] tots = [30288.457300000002, 2574584.506, 3394.9677, 1.1357374248600194, 1223.7, 70399.92, 187558.921] assert_allclose(tots_calc, tots) assert Psat_data_Perrys2_8.index.is_unique assert Psat_data_Perrys2_8.shape == (340, 8)
def test_AntoineExtended(): sums_calc = [Psat_data_AntoineExtended[i].abs().sum() for i in ['A', 'B', 'C', 'Tc', 'to', 'n', 'E', 'F', 'Tmin', 'Tmax']] sums = [873.55827000000011, 107160.285, 4699.9650000000001, 47592.470000000001, 7647, 241.56537999999998, 22816.815000000002, 1646509.79, 33570.550000000003, 46510.849999999999] assert_allclose(sums_calc, sums) assert Psat_data_AntoineExtended.index.is_unique assert Psat_data_AntoineExtended.shape == (97, 11) assert all([check_CAS(i) for i in Psat_data_AntoineExtended.index])
def test_WagnerPoling(): sums_calc = [Psat_data_WagnerPoling[i].abs().sum() for i in ['A', 'B', 'C', 'D', 'Tmin', 'Tmax', 'Tc', 'Pc']] sums = [894.39071999999999, 271.76480999999995, 525.8134399999999, 538.25393000000008, 24348.006000000001, 59970.149999999994, 63016.021000000001, 357635500] assert_allclose(sums_calc, sums) assert Psat_data_WagnerPoling.index.is_unique assert Psat_data_WagnerPoling.shape == (104, 9) assert all([check_CAS(i) for i in Psat_data_WagnerPoling.index])
def test_AntoinePoling(): sums_calc = [Psat_data_AntoinePoling[i].abs().sum() for i in ['A', 'B', 'C', 'Tmin', 'Tmax']] sums = [2959.75131, 398207.29786, 18732.24601, 86349.09, 120340.66] assert_allclose(sums_calc, sums) assert Psat_data_AntoinePoling.index.is_unique assert Psat_data_AntoinePoling.shape == (325, 6) assert all([check_CAS(i) for i in Psat_data_AntoinePoling.index])
def test_Magomedovk_thermal_cond(): for i in Magomedovk_thermal_cond.index: assert check_CAS(i) assert Magomedovk_thermal_cond.index.is_unique assert Magomedovk_thermal_cond.shape == (39, 3) tot_calc = Magomedovk_thermal_cond['Ai'].abs().sum() tot = 0.10688 assert_close(tot_calc, tot)
def test_IARC_data(): assert IARC_data.index.is_unique assert all([check_CAS(i) for i in IARC_data.index]) assert IARC_data.shape == (863, 4) dict_exp = {11: 76, 1: 75, 3: 438, 12: 274} dict_calc = IARC_data['group'].value_counts().to_dict() assert dict_exp == dict_calc
def test_COSTALD_parameters(): assert all([check_CAS(i) for i in rho_data_COSTALD.index]) assert rho_data_COSTALD.index.is_unique tots_calc = [ rho_data_COSTALD[i].sum() for i in ['omega_SRK', 'Vchar', 'Z_RA'] ] tots = [72.483900000000006, 0.086051663333333334, 49.013500000000001] assert_allclose(tots_calc, tots)
def test_WagnerMcGarry(): sums_calc = [Psat_data_WagnerMcGarry[i].abs().sum() for i in ['A', 'B', 'C', 'D', 'Pc', 'Tc', 'Tmin']] sums = [1889.3027499999998, 509.57053652899992, 1098.2766456999998, 1258.0866876, 1005210819, 129293.19100000001, 68482] assert_allclose(sums_calc, sums) assert Psat_data_WagnerMcGarry.index.is_unique assert Psat_data_WagnerMcGarry.shape == (245, 8) for i in Psat_data_WagnerMcGarry.index: assert check_CAS(i)
def test_fluid_props(): has_CoolProp() # tots = [sum([getattr(f, prop) for f in coolprop_fluids.values()]) for prop in ['Tmin', 'Tmax', 'Pmax', 'Tc', 'Pc', 'Tt', 'omega']] # tots_exp = [18589.301, 71575.0, 31017000000.0, 45189.59849999997, 440791794.7987591, 18589.301, 30.90243968446593] # assert_allclose(tots_exp, tots) assert len(coolprop_fluids) == len(coolprop_dict) assert len(coolprop_dict) == 105 assert all([check_CAS(i) for i in coolprop_dict])
def test_VN2_data(): assert all([check_CAS(i) for i in mu_data_VN3.index]) tots_calc = [ mu_data_VN2[i].abs().sum() for i in ['A', 'B', 'Tmin', 'Tmax'] ] tots = [674.10069999999996, 83331.98599999999, 39580, 47897] assert_close1d(tots_calc, tots) assert mu_data_VN2.index.is_unique assert mu_data_VN2.shape == (135, 6)
def test_VN2E_data(): assert all([check_CAS(i) for i in mu_data_VN2E.index]) tots_calc = [ mu_data_VN2E[i].abs().sum() for i in ['C', 'D', 'Tmin', 'Tmax'] ] tots = [567743298666.74878, 48.8643, 3690, 4860] assert_close1d(tots_calc, tots) assert mu_data_VN2E.index.is_unique assert mu_data_VN2E.shape == (14, 6)
def test_CRC_inorg_l_data2(): tots_calc = [ rho_data_CRC_inorg_l[i].abs().sum() for i in ['rho', 'k', 'Tm', 'Tmax'] ] tots = [882131, 181.916, 193785.09499999997, 233338.04999999996] assert_allclose(tots_calc, tots) assert rho_data_CRC_inorg_l.index.is_unique assert all([check_CAS(i) for i in rho_data_CRC_inorg_l.index])
def test_CRC_virial_poly(): assert rho_data_CRC_virial.index.is_unique assert all([check_CAS(i) for i in rho_data_CRC_virial.index]) tots_calc = [ rho_data_CRC_virial[i].abs().sum() for i in ['a1', 'a2', 'a3', 'a4', 'a5'] ] tots = [ 146559.69999999998, 506997.70000000001, 619708.59999999998, 120772.89999999999, 4483 ] assert_allclose(tots_calc, tots)
def test_VN3_data(): assert all([check_CAS(i) for i in mu_data_VN3.index]) tots_calc = [ mu_data_VN3[i].abs().sum() for i in ['A', 'B', 'C', 'Tmin', 'Tmax'] ] tots = [ 645.18849999999998, 169572.65159999998, 50050.151870000002, 126495, 175660 ] assert_close1d(tots_calc, tots) assert mu_data_VN3.index.is_unique assert mu_data_VN3.shape == (432, 7)
def test_VDI_PPDS_11_data(): """I believe there are no errors here.""" for i in sigma_data_VDI_PPDS_11.index: assert check_CAS(i) assert sigma_data_VDI_PPDS_11.index.is_unique assert sigma_data_VDI_PPDS_11.shape == (272, 8) # Doing the sums on the arrays is faster but much uglier. Worth it? tots_calc = [sigma_data_VDI_PPDS_11[i].abs().sum() for i in [u'A', u'B', u'C', u'D', u'E', u'Tc', u'Tm']] tots = [18.495069999999998, 336.69950000000006, 6.5941200000000002, 7.7347200000000003, 6.4262199999999998, 150142.28, 56917.699999999997] for calc, fixed in zip(tots_calc, tots): assert_close(calc, fixed)
def test_Perry_l_data(): assert rho_data_Perry_8E_105_l.index.is_unique assert all([check_CAS(i) for i in rho_data_Perry_8E_105_l.index]) tots_calc = [ rho_data_Perry_8E_105_l[i].sum() for i in ['C1', 'C2', 'C3', 'C4', 'Tmin', 'Tmax'] ] tots = [ 376364.41000000003, 89.676429999999996, 189873.32999999999, 96.68741, 71151.899999999994, 189873.32999999999 ] assert_allclose(tots_calc, tots)
def test_VDI_PPDS_3_data(): """I believe there are no errors here. Average temperature deviation 0.144% vs tabulated values. """ assert all([check_CAS(i) for i in Psat_data_VDI_PPDS_3.index]) tots_calc = [Psat_data_VDI_PPDS_3[i].abs().sum() for i in [u'A', u'B', u'C', u'D', u'Tc', u'Pc', u'Tm']] tots = [2171.4607300000002, 694.38631999999996, 931.3604499999999, 919.88944000000004, 150225.16000000003, 1265565000, 56957.849999999991] assert_allclose(tots_calc, tots) assert Psat_data_VDI_PPDS_3.index.is_unique assert Psat_data_VDI_PPDS_3.shape == (275, 8)
def test_Dutt_Prasad_data(): assert all([check_CAS(i) for i in mu_data_Dutt_Prasad.index]) tots_calc = [ mu_data_Dutt_Prasad[i].abs().sum() for i in ['A', 'B', 'C', 'Tmin', 'Tmax'] ] tots = [ 195.89260000000002, 65395.299999999996, 9849.1899999999987, 25952, 35016 ] assert_close1d(tots_calc, tots) assert mu_data_Dutt_Prasad.index.is_unique assert mu_data_Dutt_Prasad.shape == (100, 6)
def test_VDI_PPDS_7_data(): assert all([check_CAS(i) for i in mu_data_VDI_PPDS_7.index]) tots_calc = [ mu_data_VDI_PPDS_7[i].abs().sum() for i in [u'A', u'B', u'C', u'D', u'E'] ] tots = [ 507.14607000000001, 1680.7624099999998, 165461.14259999999, 46770.887000000002, 0.057384780000000003 ] assert_close1d(tots_calc, tots) assert mu_data_VDI_PPDS_7.index.is_unique assert mu_data_VDI_PPDS_7.shape == (271, 7)
def test_TSCA_data(): tots_calc = [ TSCA_data[i].sum() for i in [ 'UV', 'E', 'F', 'N', 'P', 'S', 'R', 'T', 'XU', 'SP', 'TP', 'Y1', 'Y2' ] ] tots = [16829, 271, 3, 713, 8371, 1173, 13, 151, 19035, 74, 50, 352, 9] assert tots_calc == tots assert TSCA_data.index.is_unique assert TSCA_data.shape == (67635, 13) assert all([check_CAS(int_to_CAS(i)) for i in TSCA_data.index])
def test_VDI_PPDS_8_data(): # Coefficients for water are incorrect - obtained an average deviation of 150%! assert all([check_CAS(i) for i in mu_data_VDI_PPDS_8.index]) assert mu_data_VDI_PPDS_8.index.is_unique assert mu_data_VDI_PPDS_8.shape == (274, 6) tots_calc = [ mu_data_VDI_PPDS_8[i].abs().sum() for i in [u'A', u'B', u'C', u'D', u'E'] ] tots = [ 0.00032879559999999999, 9.5561339999999995e-06, 2.8377710000000001e-09, 2.8713399999999998e-12, 2.8409200000000004e-15 ] assert_close1d(tots_calc, tots)
def test_VDI_PPDS_4_data(): """I believe there are no errors here.""" assert all([check_CAS(i) for i in phase_change_data_VDI_PPDS_4.index]) tots_calc = [ phase_change_data_VDI_PPDS_4[i].abs().sum() for i in [u'A', u'B', u'C', u'D', u'E', u'Tc', u'MW'] ] tots = [ 1974.2929800000002, 2653.9399000000003, 2022.530649, 943.25633100000005, 3124.9258610000002, 150142.28, 27786.919999999998 ] assert_close1d(tots_calc, tots) assert phase_change_data_VDI_PPDS_4.index.is_unique assert phase_change_data_VDI_PPDS_4.shape == (272, 8)