def teest_1phase_first_derivatives(): for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]: CP.set_standard_unit_system(US) S = State("R134a", dict(T=300, D=1)) l = [ (S.get_rho, "T", S.T, "P", S.p, S.PFC.drhodT_constp), (S.get_rho, "P", S.p, "T", S.T, S.PFC.drhodp_constT), (S.get_p, "D", S.rho, "T", S.T, S.PFC.dpdrho_constT), # (S.get_p,'D',S.rho,'H',S.h,S.PFC.dpdrho_consth), #(these inputs not supported) (S.get_p, "T", S.T, "D", S.rho, S.PFC.dpdT_constrho), # (S.get_p,'T',S.T,'H',S.h,S.PFC.dpdT_consth), #(these inputs not supported) (S.get_h, "D", S.rho, "T", S.T, S.PFC.dhdrho_constT), (S.get_h, "D", S.rho, "P", S.p, S.PFC.dhdrho_constp), (S.get_h, "T", S.T, "D", S.rho, S.PFC.dhdT_constrho), (S.get_h, "T", S.T, "P", S.p, S.PFC.dhdT_constp), (S.get_h, "P", S.p, "T", S.T, S.PFC.dhdp_constT), (S.get_s, "D", S.rho, "T", S.T, S.PFC.dsdrho_constT), (S.get_s, "T", S.T, "D", S.rho, S.PFC.dsdT_constrho), (S.get_s, "D", S.rho, "P", S.p, S.PFC.dsdrho_constp), (S.get_s, "T", S.T, "P", S.p, S.PFC.dsdT_constp), (S.get_s, "P", S.p, "T", S.T, S.PFC.dsdp_constT), ] for args in l: yield (check_1phase_first_derivatives,) + (S,) + args
def test_1phase_first_derivatives(): for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]: CP.set_standard_unit_system(US) S = State('R134a', dict(T=300, D=1)) l = [ (S.get_rho, 'T', S.T, 'P', S.p, S.PFC.drhodT_constp), (S.get_rho, 'P', S.p, 'T', S.T, S.PFC.drhodp_constT), (S.get_p, 'D', S.rho, 'T', S.T, S.PFC.dpdrho_constT), #(S.get_p,'D',S.rho,'H',S.h,S.PFC.dpdrho_consth), #(these inputs not supported) (S.get_p, 'T', S.T, 'D', S.rho, S.PFC.dpdT_constrho), #(S.get_p,'T',S.T,'H',S.h,S.PFC.dpdT_consth), #(these inputs not supported) (S.get_h, 'D', S.rho, 'T', S.T, S.PFC.dhdrho_constT), (S.get_h, 'D', S.rho, 'P', S.p, S.PFC.dhdrho_constp), (S.get_h, 'T', S.T, 'D', S.rho, S.PFC.dhdT_constrho), (S.get_h, 'T', S.T, 'P', S.p, S.PFC.dhdT_constp), (S.get_h, 'P', S.p, 'T', S.T, S.PFC.dhdp_constT), (S.get_s, 'D', S.rho, 'T', S.T, S.PFC.dsdrho_constT), (S.get_s, 'T', S.T, 'D', S.rho, S.PFC.dsdT_constrho), (S.get_s, 'D', S.rho, 'P', S.p, S.PFC.dsdrho_constp), (S.get_s, 'T', S.T, 'P', S.p, S.PFC.dsdT_constp), (S.get_s, 'P', S.p, 'T', S.T, S.PFC.dsdp_constT), ] for args in l: yield (check_1phase_first_derivatives, ) + (S, ) + args
def test_State_PROPS(): for parameter, SI_over_kSI in State_Props_listing: CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_SI) val_SI = S.Props(parameter) CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_KSI) val_kSI = S.Props(parameter) yield check, val_SI, val_kSI, SI_over_kSI
def test_State_PROPS(): for parameter, SI_over_kSI in State_Props_listing: CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_SI) val_SI = S.Props(parameter) CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_KSI) val_kSI = S.Props(parameter) yield check, val_SI, val_kSI, SI_over_kSI
def test_sat_second_derivatives(): for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]: CP.set_standard_unit_system(US) S = State('R134a',dict(T=300,Q=1)) l = [(S.get_T,'P',S.p,'Q',0,S.PFC.d2Tdp2_along_sat), (S.get_rho,'P',S.p,'Q',0,S.PFC.d2rhodp2_along_sat_liquid), (S.get_rho,'P',S.p,'Q',1,S.PFC.d2rhodp2_along_sat_vapor), (S.get_h,'P',S.p,'Q',0,S.PFC.d2hdp2_along_sat_liquid), (S.get_h,'P',S.p,'Q',1,S.PFC.d2hdp2_along_sat_vapor), (S.get_s,'P',S.p,'Q',0,S.PFC.d2sdp2_along_sat_liquid), (S.get_s,'P',S.p,'Q',1,S.PFC.d2sdp2_along_sat_vapor), ] for args in l: yield (check_sat_second_derivatives,)+(S,)+args
def teest_sat_second_derivatives(): for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]: CP.set_standard_unit_system(US) S = State('R134a',dict(T=290,Q=1)) l = [(S.get_T,'P',S.p,'Q',0,S.PFC.d2Tdp2_along_sat), (S.get_rho,'P',S.p,'Q',0,S.PFC.d2rhodp2_along_sat_liquid), (S.get_rho,'P',S.p,'Q',1,S.PFC.d2rhodp2_along_sat_vapor), (S.get_h,'P',S.p,'Q',0,S.PFC.d2hdp2_along_sat_liquid), (S.get_h,'P',S.p,'Q',1,S.PFC.d2hdp2_along_sat_vapor), (S.get_s,'P',S.p,'Q',0,S.PFC.d2sdp2_along_sat_liquid), (S.get_s,'P',S.p,'Q',1,S.PFC.d2sdp2_along_sat_vapor), ] for args in l: yield (check_sat_second_derivatives,)+(S,)+args
def check_Props(parameter, SI_over_kSI): CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_SI) val_SI = CP.Props(parameter,'T',300.0,'D',1.0,'R134a') CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_KSI) val_kSI = CP.Props(parameter,'T',300.0,'D',1.0,'R134a') try: val_SI = val_SI() val_kSI = val_kSI() except: pass print val_SI,val_kSI, val_SI/val_kSI - SI_over_kSI if abs(val_SI/val_kSI - SI_over_kSI) > 1e-12: raise ValueError(val_SI/val_kSI-SI_over_kSI)
def check_Props(parameter, SI_over_kSI): CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_SI) val_SI = CP.Props(parameter,'T',300.0,'D',1.0,'R134a') CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_KSI) val_kSI = CP.Props(parameter,'T',300.0,'D',1.0,'R134a') try: val_SI = val_SI() val_kSI = val_kSI() except: pass print(val_SI,val_kSI, val_SI/val_kSI - SI_over_kSI) if abs(val_SI/val_kSI - SI_over_kSI) > 1e-12: raise ValueError(val_SI/val_kSI-SI_over_kSI)
def teest_sat_first_derivatives(): for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]: CP.set_standard_unit_system(US) S = State("R134a", dict(T=300, Q=1)) l = [ (S.get_T, "P", S.p, "Q", 0, S.PFC.dTdp_along_sat), (S.get_rho, "P", S.p, "Q", 0, S.PFC.drhodp_along_sat_liquid), (S.get_rho, "P", S.p, "Q", 1, S.PFC.drhodp_along_sat_vapor), (S.get_rho, "T", S.T, "Q", 0, S.PFC.drhodT_along_sat_liquid), (S.get_rho, "T", S.T, "Q", 1, S.PFC.drhodT_along_sat_vapor), (S.get_h, "P", S.p, "Q", 0, S.PFC.dhdp_along_sat_liquid), (S.get_h, "P", S.p, "Q", 1, S.PFC.dhdp_along_sat_vapor), (S.get_s, "P", S.p, "Q", 0, S.PFC.dsdp_along_sat_liquid), (S.get_s, "P", S.p, "Q", 1, S.PFC.dsdp_along_sat_vapor), ] for args in l: yield (check_sat_first_derivatives,) + (S,) + args
p = CP.Props('P', 'T', 300, 'D', 1, 'Propane') h = CP.Props('H', 'T', 300, 'D', 1, 'Propane') T = CP.Props('T', 'P', p, 'H', h, 'Propane') D = CP.Props('D', 'P', p, 'H', h, 'Propane') print('SINGLE PHASE CYCLE (propane)') print('T,D -> P,H', 300, ',', 1, '-->', p, ',', h) print('P,H -> T,D', p, ',', h, '-->', T, ',', D) except: print(' ') print('************ CAN'T USE REFPROP ************') print(' ') print(' ') print('************ CHANGE UNIT SYSTEM (default is kSI) *************') print(' ') CP.set_standard_unit_system(CoolProp.UNIT_SYSTEM_SI) print('Vapor pressure of water at 373.15 K in SI units (Pa):', CP.Props('P', 'T', 373.15, 'Q', 0, 'Water')) CP.set_standard_unit_system(CoolProp.UNIT_SYSTEM_KSI) print('Vapor pressure of water at 373.15 K in kSI units (kPa):', CP.Props('P', 'T', 373.15, 'Q', 0, 'Water')) print(' ') print('************ BRINES AND SECONDARY WORKING FLUIDS *************') print(' ') print('Density of 50% (mass) ethylene glycol/water at 300 K, 101.325 kPa:', CP.Props('D', 'T', 300, 'P', 101.325, 'EG-50%'), 'kg/m^3') print('Viscosity of Therminol D12 at 350 K, 101.325 kPa:', CP.Props('V', 'T', 350, 'P', 101.325, 'TD12'), 'Pa-s') print(' ')
p = CP.Props('P', 'T', 300, 'D', 1, 'Propane') h = CP.Props('H', 'T', 300, 'D', 1, 'Propane') T = CP.Props('T', 'P', p, 'H', h, 'Propane') D = CP.Props('D', 'P', p, 'H', h, 'Propane') print('SINGLE PHASE CYCLE (propane)') print('T,D -> P,H', 300, ',', 1, '-->', p, ',', h) print('P,H -> T,D', p, ',', h, '-->', T, ',', D) except: print(' ') print('************ CANT USE REFPROP ************') print(' ') print(' ') print('************ CHANGE UNIT SYSTEM (default is kSI) *************') print(' ') CP.set_standard_unit_system(CoolProp.UNIT_SYSTEM_SI) print('Vapor pressure of water at 373.15 K in SI units (Pa):', CP.Props('P', 'T', 373.15, 'Q', 0, 'Water')) CP.set_standard_unit_system(CoolProp.UNIT_SYSTEM_KSI) print('Vapor pressure of water at 373.15 K in kSI units (kPa):', CP.Props('P', 'T', 373.15, 'Q', 0, 'Water')) print(' ') print('************ BRINES AND SECONDARY WORKING FLUIDS *************') print(' ') print('Density of 50% (mass) ethylene glycol/water at 300 K, 101.325 kPa:', CP.Props('D', 'T', 300, 'P', 101.325, 'MEG-50%'), 'kg/m^3') print('Viscosity of Therminol D12 at 350 K, 101.325 kPa:', CP.Props('V', 'T', 350, 'P', 101.325, 'TD12'), 'Pa-s') print(' ')