예제 #1
0
    def model(self):
        m = ConcreteModel()
        m.db = Database()

        m.fs = FlowsheetBlock(default={"dynamic": False})
        m.fs.params = WaterParameterBlock(
            default={"solute_list": ["toc", "nitrate", "sulfate", "bar", "crux"]}
        )

        m.fs.unit = WellFieldZO(
            default={
                "property_package": m.fs.params,
                "database": m.db,
                "process_subtype": "emwd",
            }
        )

        m.fs.unit.inlet.flow_mass_comp[0, "H2O"].fix(120)
        m.fs.unit.inlet.flow_mass_comp[0, "toc"].fix(1)
        m.fs.unit.inlet.flow_mass_comp[0, "nitrate"].fix(2)
        m.fs.unit.inlet.flow_mass_comp[0, "sulfate"].fix(0.3)
        m.fs.unit.inlet.flow_mass_comp[0, "bar"].fix(40)
        m.fs.unit.inlet.flow_mass_comp[0, "crux"].fix(0.0005)

        return m
예제 #2
0
def test_costing(subtype):
    m = ConcreteModel()
    m.db = Database()

    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.params = WaterParameterBlock(
        default={"solute_list": ["toc", "nitrate", "sulfate", "bar", "crux"]}
    )
    m.fs.costing = ZeroOrderCosting()
    m.fs.unit = WellFieldZO(
        default={
            "property_package": m.fs.params,
            "database": m.db,
            "process_subtype": subtype,
        }
    )

    m.fs.unit.inlet.flow_mass_comp[0, "H2O"].fix(120)
    m.fs.unit.inlet.flow_mass_comp[0, "toc"].fix(1)
    m.fs.unit.inlet.flow_mass_comp[0, "nitrate"].fix(2)
    m.fs.unit.inlet.flow_mass_comp[0, "sulfate"].fix(0.3)
    m.fs.unit.inlet.flow_mass_comp[0, "bar"].fix(40)
    m.fs.unit.inlet.flow_mass_comp[0, "crux"].fix(0.0005)

    m.fs.unit.load_parameters_from_database()

    assert degrees_of_freedom(m.fs.unit) == 0
    m.fs.unit.costing = UnitModelCostingBlock(
        default={"flowsheet_costing_block": m.fs.costing}
    )
    assert_units_consistent(m.fs)
    assert degrees_of_freedom(m.fs.unit) == 0
    initialization_tester(m)
    _ = solver.solve(m)

    assert isinstance(m.fs.unit.costing.capital_cost_constraint, Constraint)

    if subtype == "default":
        assert pytest.approx(1.665893, rel=1e-5) == value(
            m.fs.unit.costing.capital_cost
        )
    if subtype == "emwd":
        assert pytest.approx(47.921893, rel=1e-5) == value(
            m.fs.unit.costing.capital_cost
        )

    assert m.fs.unit.electricity[0] in m.fs.costing._registered_flows["electricity"]