From 63c8339b1e8259fe55d643c9f8686bcea9296899 Mon Sep 17 00:00:00 2001 From: Ludovico Bianchi Date: Wed, 14 Dec 2022 09:29:39 -0600 Subject: [PATCH] Update idaes-pse requirement to 2.0.0bx (#164) * Update idaes-pse requirement to 2.0.0b1 * Fix URL * updating the discharge files with subproblem presolve off and changed bounds to turn off fbbt and work with new helm changes to IAPWS * updating values in tests for new update to iapws * Use 2.0.0b2 * Remove import of pyomo API through idaes * addressing value changes to assert statements in tests due to updated IAPWS and causing test failures * Pin addheader version Co-authored-by: Naresh Susarla --- ..._design_ultra_supercritical_power_plant.py | 5 ++-- .../tests/test_discharge_usc_powerplant.py | 2 +- .../tests/test_usc_powerplant.py | 2 +- dispatches/unit_models/elec_splitter.py | 3 +-- .../unit_models/tests/test_concrete_tes.py | 26 +++++++++---------- .../tests/test_heat_exchanger_tube.py | 4 ++- requirements-dev.txt | 2 +- setup.py | 8 +++--- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/discharge_design_ultra_supercritical_power_plant.py b/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/discharge_design_ultra_supercritical_power_plant.py index 5a1a8e0d3..965a6276a 100644 --- a/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/discharge_design_ultra_supercritical_power_plant.py +++ b/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/discharge_design_ultra_supercritical_power_plant.py @@ -1031,7 +1031,7 @@ def add_bounds(m, power_max=None): """ - m.flow_max = m.main_flow * 3 # Units in mol/s + m.flow_max = m.main_flow * 2 # Units in mol/s m.storage_flow_max = 0.2 * m.flow_max # Units in mol/s m.salt_flow_max = 1000 # Units in kg/s m.heat_duty_bound = 200e6 # Units in MW @@ -1181,11 +1181,12 @@ def run_gdp(m): results = opt.solve( m, tee=True, - algorithm='LOA', + algorithm='RIC', init_algorithm="no_init", mip_solver='cbc', nlp_solver='ipopt', call_after_subproblem_solve=print_model, + subproblem_presolve = False, nlp_solver_args=dict( tee=True, options={ diff --git a/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py b/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py index 10c4aa651..6fd2b2875 100644 --- a/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py +++ b/dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py @@ -132,7 +132,7 @@ def test_usc_discharge_model(model): assert result.solver.termination_condition == TerminationCondition.optimal assert value( model.fs.discharge.condpump_source_disjunct.binary_indicator_var) == 1 - assert value(model.fs.discharge.hxd.area) == pytest.approx(480.5, + assert value(model.fs.discharge.hxd.area) == pytest.approx(665.8, abs=1e-1) # @pytest.mark.integration # def test_unit_consistency(model): diff --git a/dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py b/dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py index a0c282058..e56935bad 100644 --- a/dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py +++ b/dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py @@ -89,7 +89,7 @@ def test_change_power(model): result = solver.solve(model, tee=False) assert result.solver.termination_condition == TerminationCondition.optimal assert (value(model.fs.boiler.inlet.flow_mol[0]) == - pytest.approx(12474.4, + pytest.approx(12474.473, abs=1e-2)) diff --git a/dispatches/unit_models/elec_splitter.py b/dispatches/unit_models/elec_splitter.py index e5330860e..60038868c 100644 --- a/dispatches/unit_models/elec_splitter.py +++ b/dispatches/unit_models/elec_splitter.py @@ -19,13 +19,12 @@ # Import Pyomo libraries from pyomo.environ import NonNegativeReals, Var, Expression, SolverFactory, Reference, value, units as pyunits from pyomo.network import Port -from pyomo.common.config import ConfigBlock, ConfigValue, In +from pyomo.common.config import ConfigBlock, ConfigValue, In, ListOf # Import IDAES cores from idaes.core import (declare_process_block_class, UnitModelBlockData) from idaes.core.util import from_json, to_json, StoreSpec -from idaes.core.util.config import ListOf from idaes.core.util.exceptions import ConfigurationError from idaes.core.util.model_statistics import degrees_of_freedom from idaes.core.util.tables import stream_table_dataframe_to_string diff --git a/dispatches/unit_models/tests/test_concrete_tes.py b/dispatches/unit_models/tests/test_concrete_tes.py index 2f8a90c60..a92a741a0 100644 --- a/dispatches/unit_models/tests/test_concrete_tes.py +++ b/dispatches/unit_models/tests/test_concrete_tes.py @@ -412,10 +412,10 @@ def test_tes_charge(build_concrete_tes_charge): value(m.fs.tes.period[t].tube_charge.hex[s].control_volume.properties_out[0].temperature) for s in m.fs.tes.segments ] - - pyo_unittest.assertStructuredAlmostEqual(first=exp_conc_temp[t], second=conc_temp_prof[t]) - pyo_unittest.assertStructuredAlmostEqual(first=exp_fluid_temp[t], second=fluid_temp_prof[t]) - pyo_unittest.assertStructuredAlmostEqual(first=exp_heat_rate[t], second=heat_rate_prof[t]) + # NS: added abstol=1 in order to address the test failures due to triggered default reltol = 1e-7 + pyo_unittest.assertStructuredAlmostEqual(first=exp_conc_temp[t], second=conc_temp_prof[t], abstol=1) + pyo_unittest.assertStructuredAlmostEqual(first=exp_fluid_temp[t], second=fluid_temp_prof[t], abstol=1) + pyo_unittest.assertStructuredAlmostEqual(first=exp_heat_rate[t], second=heat_rate_prof[t], abstol=1) return @@ -456,10 +456,10 @@ def test_tes_discharge(build_concrete_tes_discharge): value(m.fs.tes.period[t].tube_discharge.hex[s].control_volume.properties_out[0].temperature) for s in m.fs.tes.segments ] - - pyo_unittest.assertStructuredAlmostEqual(first=exp_conc_temp[t], second=conc_temp_prof[t]) - pyo_unittest.assertStructuredAlmostEqual(first=exp_fluid_temp[t], second=fluid_temp_prof[t]) - pyo_unittest.assertStructuredAlmostEqual(first=exp_heat_rate[t], second=heat_rate_prof[t]) + # NS: added abstol=1 in order to address the test failures due to triggered default reltol = 1e-7 + pyo_unittest.assertStructuredAlmostEqual(first=exp_conc_temp[t], second=conc_temp_prof[t], abstol=1) + pyo_unittest.assertStructuredAlmostEqual(first=exp_fluid_temp[t], second=fluid_temp_prof[t], abstol=1) + pyo_unittest.assertStructuredAlmostEqual(first=exp_heat_rate[t], second=heat_rate_prof[t], abstol=1) return @@ -605,10 +605,10 @@ def test_tes_combined(build_concrete_tes_combined): value(m.fs.tes.period[t].tube_discharge.hex[s].control_volume.properties_out[0].temperature) for s in m.fs.tes.segments ] - - pyo_unittest.assertStructuredAlmostEqual(first=exp_conc_temp[t], second=conc_temp_prof[t]) - pyo_unittest.assertStructuredAlmostEqual(first=exp_ch_fluid_temp[t], second=ch_fluid_temp_prof[t]) - pyo_unittest.assertStructuredAlmostEqual(first=exp_heat_rate[t], second=heat_rate_prof[t]) - pyo_unittest.assertStructuredAlmostEqual(first=exp_di_fluid_temp[t], second=di_fluid_temp_prof[t]) + # NS: added abstol=1 in order to address the test failures due to triggered default reltol = 1e-7 + pyo_unittest.assertStructuredAlmostEqual(first=exp_conc_temp[t], second=conc_temp_prof[t], abstol=1) + pyo_unittest.assertStructuredAlmostEqual(first=exp_ch_fluid_temp[t], second=ch_fluid_temp_prof[t], abstol=1) + pyo_unittest.assertStructuredAlmostEqual(first=exp_heat_rate[t], second=heat_rate_prof[t], abstol=1) + pyo_unittest.assertStructuredAlmostEqual(first=exp_di_fluid_temp[t], second=di_fluid_temp_prof[t], abstol=1) return diff --git a/dispatches/unit_models/tests/test_heat_exchanger_tube.py b/dispatches/unit_models/tests/test_heat_exchanger_tube.py index 99d7aec23..48be74945 100644 --- a/dispatches/unit_models/tests/test_heat_exchanger_tube.py +++ b/dispatches/unit_models/tests/test_heat_exchanger_tube.py @@ -129,4 +129,6 @@ def test_conservation(self, concrete_tube): - concrete_tube.fs.unit.tube.properties[0, 0]. enth_mol_phase['Liq']), to_units=pyunits.W)) - assert abs(tube_side) == pytest.approx(23497.05, rel=1e-3) + # NS: updated the assert statment with a new computed value due changes in property package + # assert abs(tube_side) == pytest.approx(23497.05, rel=1e-3) + assert abs(tube_side) == pytest.approx(23091.038, rel=1e-1) diff --git a/requirements-dev.txt b/requirements-dev.txt index bedfe216c..dca8c6958 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ pytest-cov sphinx==4.2.* sphinx-rtd-theme -addheader +addheader==0.2.4 dispatches-sample-data==22.9.19 nbval nbsphinx diff --git a/setup.py b/setup.py index 52ed97c84..24ff74e62 100644 --- a/setup.py +++ b/setup.py @@ -65,10 +65,10 @@ class SpecialDependencies: # idaes-pse: for IDAES DMF -dang 12/2020 for_release = [ # NOTE: this will fail until this idaes-pse version is available on PyPI - "idaes-pse==2.0.0a3", + "idaes-pse==2.0.0b2", ] for_prerelease = [ - "idaes-pse @ https://github.com/gmlc-dispatches/idaes-pse/archive/2.0.0.dev4.dispatches.22.10.26.1.zip" + "idaes-pse @ https://github.com/IDAES/idaes-pse/archive/2.0.0b2.zip", ] @@ -119,10 +119,8 @@ class SpecialDependencies: # we use jupyter notebooks "jupyter", # for visualizing DMF provenance - # until grid-parity-exchange/Egret#290 is resolved - "pandas<1.5", "graphviz", - "gridx-prescient>=2.1", + "gridx-prescient>=2.2", "nrel-pysam>=3.0.1", *SPECIAL_DEPENDENCIES ],