def test_initialization_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})

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

    m.fs.pc.inlet.flow_mol.fix(27.5e3)
    m.fs.pc.inlet.enth_mol.fix(4000)
    m.fs.pc.inlet.pressure.fix(2e6)
    m.fs.pc.deltaP.fix(-1e3)
    m.fs.pc.efficiency_isentropic.fix(0.83)

    assert degrees_of_freedom(m) == 0

    m.fs.pc.initialize(state_args=init_state, outlvl=5,
                       optarg={'tol': 1e-6})

    assert (pytest.approx(27.5e3, abs=1e-2) ==
            m.fs.pc.outlet.flow_mol[0].value)
    assert (pytest.approx(3999.979732728688, abs=1e-2) ==
            m.fs.pc.outlet.enth_mol[0].value)
    assert (pytest.approx(1999000.0, abs=1e-2) ==
            m.fs.pc.outlet.pressure[0].value)

    solver.solve(m)
def test_initialization_isothermal():
    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.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)

    assert degrees_of_freedom(m) == 0

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

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

    assert (pytest.approx(27500.0, abs=1e-2) ==
            m.fs.pc.outlet.flow_mol[0].value)
    assert (pytest.approx(3999.984582673592, abs=1e-2) ==
            m.fs.pc.outlet.enth_mol[0].value)
    assert (pytest.approx(1999000.0, abs=1e-2) ==
            m.fs.pc.outlet.pressure[0].value)

    solver.solve(m)
Exemple #3
0
    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
def test_set_geometry_include_holdup_true():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.props = pp.Iapws95ParameterBlock()
    m.fs.pc = PressureChanger(default={"property_package": m.fs.props,
                                       "has_holdup": True})

    assert hasattr(m.fs.pc, "volume")
    assert hasattr(m.fs.pc.control_volume, "material_holdup")
def test_make_isothermal():
    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.isothermal})

    assert hasattr(m.fs.pc, "isothermal")
def test_build_pc():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.props = pp.Iapws95ParameterBlock()
    m.fs.pc = PressureChanger(default={"property_package": m.fs.props})

    assert hasattr(m.fs.pc, "inlet")
    assert hasattr(m.fs.pc, "outlet")
    assert len(m.fs.pc.inlet.vars) == 3
    assert len(m.fs.pc.outlet.vars) == 3
Exemple #7
0
    def test_dynamic_build(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": True})

        m.fs.properties = PhysicalParameterTestBlock()

        m.fs.unit = PressureChanger(
            default={"property_package": m.fs.properties})

        assert hasattr(m.fs.unit, "volume")
def test_make_performance():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.props = pp.Iapws95ParameterBlock()
    m.fs.pc = PressureChanger(default={"property_package": m.fs.props})

    assert hasattr(m.fs.pc, "work_mechanical")
    assert m.fs.pc.work_mechanical == m.fs.pc.control_volume.work
    assert hasattr(m.fs.pc, "deltaP")
    assert hasattr(m.fs.pc, "ratioP")
    assert hasattr(m.fs.pc, "ratioP_calculation")
Exemple #9
0
def test_report_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
        })

    m.fs.pc.report()
Exemple #10
0
    def test_pump(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = PhysicalParameterTestBlock()

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

        assert isinstance(m.fs.unit.fluid_work_calculation, Constraint)
Exemple #11
0
    def btx(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = BTXParameterBlock(default={"valid_phase": 'Liq'})

        m.fs.unit = PressureChanger(
            default={
                "property_package": m.fs.properties,
                "thermodynamic_assumption": ThermodynamicAssumption.isothermal
            })

        return m
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")
Exemple #13
0
    def sapon(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = SaponificationParameterBlock()

        m.fs.unit = PressureChanger(
            default={
                "property_package": m.fs.properties,
                "thermodynamic_assumption": ThermodynamicAssumption.pump,
                "compressor": False
            })

        return m
Exemple #14
0
    def iapws(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = iapws95.Iapws95ParameterBlock()

        m.fs.unit = PressureChanger(
            default={
                "property_package": m.fs.properties,
                "thermodynamic_assumption": ThermodynamicAssumption.isentropic,
                "compressor": True
            })

        return m
Exemple #15
0
    def test_isentropic_material_balances_none(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = PhysicalParameterTestBlock()

        with pytest.raises(BalanceTypeNotSupportedError):
            m.fs.unit = PressureChanger(
                default={
                    "property_package": m.fs.properties,
                    "thermodynamic_assumption":
                    ThermodynamicAssumption.isentropic,
                    "material_balance_type": MaterialBalanceType.none
                })
Exemple #16
0
    def test_isentropic_comp_total_balances(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = PhysicalParameterTestBlock()

        m.fs.unit = PressureChanger(
            default={
                "property_package": m.fs.properties,
                "thermodynamic_assumption": ThermodynamicAssumption.isentropic,
                "material_balance_type": MaterialBalanceType.componentTotal
            })

        assert isinstance(m.fs.unit.isentropic_material, Constraint)
        assert len(m.fs.unit.isentropic_material) == 2
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")
Exemple #18
0
    def test_config(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = PhysicalParameterTestBlock()

        m.fs.unit = PressureChanger(
            default={"property_package": m.fs.properties})

        # Check unit config arguments
        assert len(m.fs.unit.config) == 10

        assert m.fs.unit.config.material_balance_type == \
            MaterialBalanceType.useDefault
        assert m.fs.unit.config.energy_balance_type == \
            EnergyBalanceType.useDefault
        assert m.fs.unit.config.momentum_balance_type == \
            MomentumBalanceType.pressureTotal
        assert not m.fs.unit.config.has_phase_equilibrium
        assert m.fs.unit.config.compressor
        assert m.fs.unit.config.thermodynamic_assumption == \
            ThermodynamicAssumption.isothermal
        assert m.fs.unit.config.property_package is m.fs.properties