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
def test_change_env(self): with idaes.temporary_config_ctx(): # default config uses idaes solvers idaes.cfg.use_idaes_solvers = False idaes.reconfig() pf = os.environ["PATH"] pt = os.environ["PATH"] assert pf != pt
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
def test_tmp_config_ctx(self): assert idaes.cfg["logging"]["disable_existing_loggers"] == False with idaes.temporary_config_ctx(): idaes.cfg["logging"]["disable_existing_loggers"] = True assert idaes.cfg["logging"]["disable_existing_loggers"] == True assert idaes.cfg["logging"]["disable_existing_loggers"] == False