Ejemplo n.º 1
0
def test_initialize():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})

    m.fs.properties = BTXParameterBlock()

    m.fs.ff = FeedFlash(default={"property_package": m.fs.properties})

    m.fs.ff.flow_mol.fix(1)
    m.fs.ff.temperature.fix(368)
    m.fs.ff.pressure.fix(101325)
    m.fs.ff.mole_frac[0, "benzene"].fix(0.5)
    m.fs.ff.mole_frac[0, "toluene"].fix(0.5)

    assert degrees_of_freedom(m) == 0

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

    assert (pytest.approx(101325.0,
                          abs=1e3) == m.fs.ff.outlet.pressure[0].value)
    assert (pytest.approx(368.00,
                          abs=1e-0) == m.fs.ff.outlet.temperature[0].value)
    assert (pytest.approx(1.0, abs=1e-2) == m.fs.ff.outlet.flow_mol[0].value)
    assert (pytest.approx(0.355, abs=1e-3) == m.fs.ff.control_volume.
            properties_out[0].flow_mol_phase["Vap"].value)
Ejemplo n.º 2
0
    def btx(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = BTXParameterBlock()

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

        return m
Ejemplo n.º 3
0
    def iapws(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

        m.fs.properties = iapws95.Iapws95ParameterBlock(default={
                "phase_presentation": iapws95.PhaseType.LG})

        m.fs.unit = FeedFlash(default={"property_package": m.fs.properties,
                                       "flash_type": FlashType.isenthalpic})

        return m
Ejemplo n.º 4
0
    def btx(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})

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

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

        return m
Ejemplo n.º 5
0
def test_config():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})

    m.fs.properties = PhysicalParameterTestBlock()

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

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

    assert not m.fs.unit.config.dynamic
    assert not m.fs.unit.config.has_holdup
    assert m.fs.unit.config.material_balance_type == \
        MaterialBalanceType.useDefault
    assert m.fs.unit.config.flash_type == FlashType.isothermal
    assert m.fs.unit.config.property_package is m.fs.properties
Ejemplo n.º 6
0
def test_build():
    m = ConcreteModel()
    m.fs = FlowsheetBlock(default={"dynamic": False})

    m.fs.properties = BTXParameterBlock()

    m.fs.ff = FeedFlash(default={"property_package": m.fs.properties})

    assert hasattr(m.fs.ff, "flow_mol")
    assert hasattr(m.fs.ff, "mole_frac")
    assert hasattr(m.fs.ff, "temperature")
    assert hasattr(m.fs.ff, "pressure")

    assert hasattr(m.fs.ff, "outlet")
    assert len(m.fs.ff.outlet.vars) == 4
    assert hasattr(m.fs.ff.outlet, "flow_mol")
    assert hasattr(m.fs.ff.outlet, "mole_frac")
    assert hasattr(m.fs.ff.outlet, "temperature")
    assert hasattr(m.fs.ff.outlet, "pressure")

    assert hasattr(m.fs.ff, "isothermal")