Esempio n. 1
0
def test_vapor_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=17)
    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["Vap"] /
                     model.prop_in.mw / 1000.0)
        assert (abs((enth - c[2]) / c[2]) < tol)
Esempio n. 2
0
def test_make_pump():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.props = pp.Iapws95ParameterBlock()

    m.fs.pc = PressureChanger(
        default={
            "property_package": m.fs.props,
            "thermodynamic_assumption": ThermodynamicAssumption.pump
        })

    assert hasattr(m.fs.pc, "work_fluid")
    assert hasattr(m.fs.pc, "efficiency_pump")
    assert hasattr(m.fs.pc, "fluid_work_calculation")
    assert hasattr(m.fs.pc, "actual_work")
Esempio n. 3
0
def test_liquid_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=2)
    for c in cond:
        if c[0] > 645:  # getting very close to ciritical point
            tol = 0.05
        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["Liq"])
        #print("{:.2f}, {:.2f}, {:.2f}, {:.2f}".format(c[0], c[1], rho, c[2]))
        assert (abs(rho - c[2]) / c[2] < tol)
def test_make_isentropic():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.props = pp.Iapws95ParameterBlock()

    m.fs.pc = PressureChanger(default={
            "property_package": m.fs.props,
            "thermodynamic_assumption": ThermodynamicAssumption.isentropic})

    assert hasattr(m.fs.pc, "efficiency_isentropic")
    assert hasattr(m.fs.pc, "work_isentropic")
    assert hasattr(m.fs.pc, "isentropic_pressure")
    assert hasattr(m.fs.pc, "isentropic_material")
    assert hasattr(m.fs.pc, "isentropic")
    assert hasattr(m.fs.pc, "isentropic_energy_balance")
    assert hasattr(m.fs.pc, "actual_work")
Esempio n. 5
0
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)
Esempio n. 6
0
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)
Esempio n. 7
0
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)
Esempio n. 8
0
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 get_initialized_model(self):
        """
        Returns an initialized model for the PressureChanger unit model
        convergence evaluation

        Returns
        -------
           Pyomo model : returns a pyomo model of the PressureChanger unit
        """
        m = pe.ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})
        m.fs.props = pp.Iapws95ParameterBlock()

        m.fs.pc = PressureChanger(default={
                "property_package": m.fs.props,
                "thermodynamic_assumption": 'isothermal'})

        m.fs.pc.deltaP.fix(-1e3)
        m.fs.pc.inlet[:].flow_mol.fix(27.5e3)
        m.fs.pc.inlet[:].enth_mol.fix(4000)
        m.fs.pc.inlet[:].pressure.fix(2e6)

        init_state = {
                "flow_mol": 27.5e3,
                "pressure": 2e6,
                "enth_mol": 4000
                }

        m.fs.pc.initialize(state_args=init_state, outlvl=0)

        # Create a solver for initialization
        opt = self.get_solver()
        opt.solve(m)

        # return the initialized model
        return m
Esempio n. 10
0
def build_heater():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.properties = iapws95_ph.Iapws95ParameterBlock()
    m.fs.heater = Heater(default={"property_package": m.fs.properties})
    return m
Esempio n. 11
0
def build_turbine():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.properties = iapws95_ph.Iapws95ParameterBlock()
    m.fs.turb = TurbineStage(default={"property_package": m.fs.properties})
    return m
Esempio n. 12
0
 def make_model(self):
     model = ConcreteModel()
     model.prop_param = iapws95.Iapws95ParameterBlock()
     model.prop_in = iapws95.Iapws95StateBlock(default={"parameters":model.prop_param})
     return model
Esempio n. 13
0
def build_valve_vapor():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.properties = iapws95_ph.Iapws95ParameterBlock()
    m.fs.valve = SteamValve(default={"property_package": m.fs.properties})
    return m