예제 #1
0
 def test_less_expected(self, m):
     check_dof(m, fail_flag=False, expected_dof=-1)
     msg = r"Unexpected degrees of freedom: Degrees of freedom on unknown = 1. Expected -1. Fix 2 variable\(s\)"
     with pytest.raises(ValueError, match=msg):
         check_dof(m, fail_flag=True, expected_dof=-1)
     with pytest.raises(ValueError, match=msg):
         assert_degrees_of_freedom(m, -1)
예제 #2
0
def optimize_set_up(m, water_recovery=None):

    for pump in m.fs.PrimaryPumps.values():
        pump.control_volume.properties_out[0].pressure.unfix()
        pump.control_volume.properties_out[0].pressure.setlb(10e5)
        pump.control_volume.properties_out[0].pressure.setub(85e5)
        pump.deltaP.setlb(0)

    # unfix eq pumps
    for pump in m.fs.BoosterPumps.values():
        pump.control_volume.properties_out[0].pressure.unfix()
        pump.control_volume.properties_out[0].pressure.setlb(10e5)
        pump.control_volume.properties_out[0].pressure.setub(85e5)
        pump.deltaP.setlb(0)

    # unfix stages
    for idx, stage in m.fs.ROUnits.items():
        stage.area.unfix()
        stage.width.unfix()
        stage.area.setlb(1)
        stage.area.setub(1000)
        stage.width.setlb(0.1)
        stage.width.setub(100)
        stage.N_Re[0, 0].unfix()

        if idx > m.fs.StageSet.first():
            stage.B_comp.unfix()
            stage.B_comp.setlb(3.5e-8)
            stage.B_comp.setub(3.5e-8 * 1e3)

    min_avg_flux = 1  # minimum average water flux [kg/m2-h]
    min_avg_flux = (min_avg_flux / 3600 * pyunits.kg / pyunits.m**2 / pyunits.s
                    )  # [kg/m2-s]

    # additional constraints
    if water_recovery is not None:
        m.fs.water_recovery.fix(
            water_recovery)  # product mass flow rate fraction of feed [-]

    # ---checking model---
    assert_units_consistent(m)
    assert_degrees_of_freedom(
        m, 4 * m.fs.NumberOfStages - (1 if (water_recovery is None) else 2))

    return m
예제 #3
0
def main():
    m = build()

    set_operating_conditions(m)
    assert_degrees_of_freedom(m, 0)

    initialize_system(m)  # initialization needed for ozone unit

    results = solve(m)
    display_results(m)

    add_costing(m)
    initialize_costing(m)
    assert_degrees_of_freedom(m, 0)
    assert_units_consistent(m)

    results = solve(m)
    display_costing(m)
    return m, results
예제 #4
0
def optimize_set_up(m):
    # objective
    m.fs.objective = Objective(expr=m.fs.costing.LCOW)

    # unfix decision variables and add bounds
    # pump 1 and pump 2
    m.fs.P1.control_volume.properties_out[0].pressure.unfix()
    m.fs.P1.control_volume.properties_out[0].pressure.setlb(10e5)
    m.fs.P1.control_volume.properties_out[0].pressure.setub(80e5)
    m.fs.P1.deltaP.setlb(0)
    m.fs.P2.control_volume.properties_out[0].pressure.setlb(10e5)
    m.fs.P2.control_volume.properties_out[0].pressure.setub(80e5)
    m.fs.P2.deltaP.setlb(0)

    # RO
    m.fs.RO.area.setlb(1)
    m.fs.RO.area.setub(150)

    # additional specifications
    m.fs.product_salinity = Param(
        initialize=500e-6, mutable=True
    )  # product NaCl mass fraction [-]
    m.fs.minimum_water_flux = Param(
        initialize=1.0 / 3600.0, mutable=True
    )  # minimum water flux [kg/m2-s]

    # additional constraints
    m.fs.eq_product_quality = Constraint(
        expr=m.fs.product.properties[0].mass_frac_phase_comp["Liq", "NaCl"]
        <= m.fs.product_salinity
    )
    iscale.constraint_scaling_transform(
        m.fs.eq_product_quality, 1e3
    )  # scaling constraint
    m.fs.eq_minimum_water_flux = Constraint(
        expr=m.fs.RO.flux_mass_phase_comp[0, 1, "Liq", "H2O"] >= m.fs.minimum_water_flux
    )

    # ---checking model---
    assert_degrees_of_freedom(m, 1)
예제 #5
0
def main():
    m = build()

    set_operating_conditions(m)
    assert_degrees_of_freedom(m, 0)
    assert_units_consistent(m)

    initialize_system(m)

    results = solve(m)
    assert_optimal_termination(results)
    display_results(m)

    add_costing(m)
    initialize_costing(m)
    assert_degrees_of_freedom(m, 0)
    assert_units_consistent(m)

    results = solve(m)
    display_costing(m)

    return m, results
예제 #6
0
def main(erd_type="pressure_exchanger"):
    m = build(erd_type=erd_type)

    set_operating_conditions(m)
    assert_degrees_of_freedom(m, 0)

    initialize_system(m)
    assert_degrees_of_freedom(m, 0)

    solve(m)
    display_results(m)

    add_costing(m)
    initialize_costing(m)
    assert_degrees_of_freedom(m, 0)

    solve(m, tee=True)
    display_costing(m)

    return m
예제 #7
0
def check_dof(blk, dof_expected=0):
    assert_degrees_of_freedom(blk, dof_expected)
예제 #8
0
 def test_expected(self, m):
     check_dof(m, fail_flag=False, expected_dof=1)
     check_dof(m, fail_flag=True, expected_dof=1)
     assert_degrees_of_freedom(m, 1)
예제 #9
0
 def test_build(self, system_frame):
     m = system_frame
     assert_degrees_of_freedom(m, 20)
     assert_units_consistent(m)