Esempio n. 1
0
def test_initialize():
    # Speed this up by using a simpler composition and reaction set
    comps = {"CH4", "O2", "H2O", "CO2", "N2", "Ar"}
    rxns = {"ch4_cmb": "CH4"}
    phases = ["Vap"]
    air_comp = {
        "O2": 0.2074,
        "H2O": 0.0099,
        "CO2": 0.0003,
        "N2": 0.7732,
        "Ar": 0.0092
    }
    ng_comp = {  # simplified composition to make it run faster
        "CH4": 1.0,
        "O2": 0.0,
        "H2O": 0.0,
        "CO2": 0.0,
        "N2": 0.0,
        "Ar": 0.0
    }
    with idaes.temporary_config_ctx():
        use_idaes_solver_configuration_defaults()
        idaes.cfg.ipopt["options"]["nlp_scaling_method"] = "user-scaling"
        idaes.cfg.ipopt["options"]["bound_push"] = 1e-6

        m, solver = main(comps=comps,
                         rxns=rxns,
                         phases=phases,
                         air_comp=air_comp,
                         ng_comp=ng_comp,
                         initialize=True)
        res = run_full_load(m, solver)
    assert res.solver.status == pyo.SolverStatus.ok
Esempio n. 2
0
def test_ipopt_idaes_config():
    """
    Test that the default solver options are set
    """
    with idaes.temporary_config_ctx():
        # in this context use idaes default solver options
        isolve.use_idaes_solver_configuration_defaults()
        idaes.cfg.ipopt.options.nlp_scaling_method = "toast-based"
        solver = pyo.SolverFactory('ipopt')
        assert solver.options["nlp_scaling_method"] == "toast-based"
        solver = pyo.SolverFactory('ipopt', options={"tol": 1})
        assert solver.options["tol"] == 1
        idaes.cfg.ipopt.options.tol = 1
        solver = pyo.SolverFactory('ipopt')
        assert solver.options["tol"] == 1
Esempio n. 3
0
                pyo.value(tags["g02_P"]),
                pyo.value(tags["g02_F"]),
                pyo.value(tags["g08_T"]),
                pyo.value(tags["g08_P"]),
                pyo.value(tags["g08_F"]),
                pyo.value(tags["g08_yO2"]),
                pyo.value(tags["g08_yCO2"])])
        write_pfd_results(f"gas_turbine_results_{p}.svg", tags, tag_format)


if __name__ == "__main__":
    #
    # Solver config
    #
    # Use idaes config, because these will apply to all ipopt solvers created
    use_idaes_solver_configuration_defaults()
    idaes.cfg.ipopt["options"]["nlp_scaling_method"] = "user-scaling"
    # due to a lot of component mole fractions being on their lower bound of 0
    # bound push result in much longer solve times, so set it low.
    idaes.cfg.ipopt["options"]["bound_push"] = 1e-10


    comps = { # components present
        "CH4", "C2H6", "C2H4", "CO", "H2S", "H2", "O2", "H2O", "CO2", "N2",
        "Ar", "SO2"}
    rxns = { # reactions and key compoents for conversion
        "ch4_cmb":"CH4",
        "c2h6_cmb":"C2H6",
        "c2h4_cmb":"C2H4",
        "co_cmb":"CO",
        "h2s_cmb":"H2S",