def test_cv(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond = read_data("prop.txt", col=7) phase = read_data("prop.txt", col=13) for i, c in enumerate(cond): if c[2] == "undefined": continue if (c[0] > 640 and c[0] < 680) and (c[1] > 2.1e7 and c[1] < 3.1e7): #near critical and non-analytic terms were omitted continue if phase[i][2] in ["liquid", "supercritical"]: p = "Liq" else: p = "Vap" model.prop_in.temperature.set_value(c[0]) model.prop_in.pressure = c[1] cv = value(model.prop_in.cv_mol_phase[p] / model.prop_in.mw / 1000) rho = value(model.prop_in.dens_mass_phase[p]) if rho > 250 and rho < 420 and c[0] < 700 and c[0] > 640: tol = 0.03 # steep part in sc region else: tol = 0.003 assert (abs(cv - c[2]) / c[2] < tol)
def test_tau_sat(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond = read_data("sat_prop.txt", col=2) for c in cond: tau = value(model.prop_in.func_tau_sat(c[1] / 1000.0)) T = 647.096 / tau print("{}, {}, {}".format(c[1], c[0], T)) assert (abs(T - c[0]) < 0.1)
def test_liquid_enthalpy_sat(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond = read_data("sat_prop.txt", col=5) for c in cond: if c[0] > 645: # getting very close to ciritical point tol = 0.01 else: tol = 0.001 model.prop_in.pressure = c[1] enth = value(model.prop_in.enth_mol_sat_phase["Liq"] / model.prop_in.mw / 1000.0) assert (abs((enth - c[2]) / c[2]) < tol)
def test_vapor_density_sat(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond = read_data("sat_prop.txt", col=14) for c in cond: if c[0] > 645: # getting very close to ciritical point tol = 0.01 else: tol = 0.001 model.prop_in.temperature.set_value(c[0]) model.prop_in.pressure = c[1] rho = value(model.prop_in.dens_mass_phase["Vap"]) assert (abs(rho - c[2]) / c[2] < tol)
def test_enthalpy_vapor_as_function_of_p_and_tau(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond = read_data("prop.txt", col=5) phase = read_data("prop.txt", col=13) for i, c in enumerate(cond): if phase[i][2] in ["liquid", "supercritical"]: continue model.prop_in.temperature.set_value(c[0]) h = value(model.prop_in.func_hvpt(c[1] / 1000, 647.096 / c[0])) rho = value(model.prop_in.dens_mass_phase["Vap"]) if rho > 250 and rho < 420 and c[0] < 700 and c[0] > 640: tol = 0.03 # steep part in sc region else: tol = 0.003 assert (abs(h - c[2]) / c[2] < tol)
def test_entropy(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond = read_data("prop.txt", col=6) phase = read_data("prop.txt", col=13) for i, c in enumerate(cond): if phase[i][2] in ["liquid", "supercritical"]: p = "Liq" else: p = "Vap" model.prop_in.temperature.set_value(c[0]) model.prop_in.pressure = c[1] s = value(model.prop_in.entr_mol_phase[p] / model.prop_in.mw / 1000) rho = value(model.prop_in.dens_mass_phase[p]) if rho > 250 and rho < 420 and c[0] < 700 and c[0] > 640: tol = 0.03 # steep part in sc region else: tol = 0.003 assert (abs(s - c[2]) / c[2] < tol)
def test_density(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond = read_data("prop.txt", col=2) phase = read_data("prop.txt", col=13) for i, c in enumerate(cond): if phase[i][2] in ["liquid", "supercritical"]: p = "Liq" else: p = "Vap" model.prop_in.temperature.set_value(c[0]) model.prop_in.pressure = c[1] rho = value(model.prop_in.dens_mass_phase[p]) if rho > 250 and rho < 420 and c[0] < 700 and c[0] > 645: tol = 0.03 # steep part in sc region elif c[1] < 20: tol = 0.005 #very low pressure < 20 Pa else: tol = 0.001 assert (abs(rho - c[2]) / c[2] < tol)
def test_enthalpy_of_vaporization(): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock( default={"parameters": model.prop_param}) cond_liq = read_data("sat_prop.txt", col=5) cond_vap = read_data("sat_prop.txt", col=17) for i, c in enumerate(cond_liq): if c[0] > 645: # getting very close to ciritical point tol = 0.05 else: tol = 0.001 model.prop_in.pressure.value = c[1] enth = value(model.prop_in.dh_vap_mol / model.prop_in.mw / 1000.0) enth_dat = cond_vap[i][2] - c[2] if abs(enth_dat) > 1e-8: assert (abs((enth - enth_dat) / enth_dat) < tol) else: assert (abs(enth - enth_dat) < tol) #Over Critical Pressure model.prop_in.pressure = model.prop_in.config.parameters.pressure_crit * 1.1 enth = value(model.prop_in.dh_vap_mol / model.prop_in.mw / 1000.0) assert (abs(enth) < 0.001)
def make_model(self): model = ConcreteModel() model.prop_param = iapws95.Iapws95ParameterBlock() model.prop_in = iapws95.Iapws95StateBlock(default={"parameters":model.prop_param}) return model