From 12d4fb5ad9207a9428807703d5494e3b840a78a7 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Mon, 2 Dec 2024 11:38:54 -0700 Subject: [PATCH 1/7] manually add USD_2023 to costing pkg --- .../costing/tests/test_reflo_watertap_costing_package.py | 4 ++-- .../reflo/costing/watertap_reflo_costing_package.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py b/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py index 3879353e..9208a916 100644 --- a/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py +++ b/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py @@ -332,7 +332,7 @@ def build_heat_and_elec_gen(): #### TREATMENT BLOCK m.fs.treatment = Block() m.fs.treatment.costing = TreatmentCosting() - m.fs.treatment.costing.base_currency = pyunits.USD_2002 + m.fs.treatment.costing.base_currency = pyunits.USD_2023 m.fs.treatment.unit = DummyTreatmentUnit(property_package=m.fs.properties) m.fs.treatment.unit.costing = UnitModelCostingBlock( @@ -348,7 +348,7 @@ def build_heat_and_elec_gen(): #### ENERGY BLOCK m.fs.energy = Block() m.fs.energy.costing = EnergyCosting() - m.fs.energy.costing.base_currency = pyunits.USD_2002 + m.fs.energy.costing.base_currency = pyunits.USD_2023 m.fs.energy.heat_unit = DummyHeatUnit() m.fs.energy.elec_unit = DummyElectricityUnit() diff --git a/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py b/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py index 3efe9871..25e1149e 100644 --- a/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py +++ b/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py @@ -51,6 +51,8 @@ class REFLOCostingData(WaterTAPCostingData): def build_global_params(self): + pyo.units.load_definitions_from_strings(["USD_2023 = 500/797.9 * USD_CE500"]) + super().build_global_params() # Override WaterTAP default value of USD_2018 @@ -377,6 +379,8 @@ class REFLOSystemCostingData(WaterTAPCostingBlockData): def build_global_params(self): super().build_global_params() + pyo.units.load_definitions_from_strings(["USD_2023 = 500/797.9 * USD_CE500"]) + self.base_currency = pyo.units.USD_2021 # Fix the parameters From d6d7c5eeed60941a5770cd88f1ea43267df2bd52 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 4 Dec 2024 12:11:10 -0700 Subject: [PATCH 2/7] add missing logged warnings --- .../reflo/costing/watertap_reflo_costing_package.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py b/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py index 25e1149e..32cce439 100644 --- a/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py +++ b/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py @@ -1000,11 +1000,12 @@ def _check_common_param_equivalence(self, treat_cost, energy_cost): for cp in common_params: tp = getattr(treat_cost, cp) ep = getattr(energy_cost, cp) - if (isinstance(tp, pyo.Var)) or isinstance(tp, pyo.Param): + if (isinstance(tp, pyo.Var)) or (isinstance(tp, pyo.Param)): param_is_equivalent = pyo.value(tp) == pyo.value(ep) else: param_is_equivalent = tp == ep if not param_is_equivalent: + # TODO: Add better logic to raise exception for certain params? warning_msg = f"The common costing parameter {cp} was found to have a different value " warning_msg += f"on the energy and treatment costing blocks. " _log.warning(warning_msg) @@ -1025,6 +1026,7 @@ def _check_common_param_equivalence(self, treat_cost, energy_cost): f"The cost of electricity is different on {treat_cost.name} " ) warning_msg += f"and {self.name} costing blocks." + _log.warning(warning_msg) if pyo.value(energy_cost.electricity_cost) != pyo.value( self.electricity_cost_buy ): @@ -1032,15 +1034,18 @@ def _check_common_param_equivalence(self, treat_cost, energy_cost): f"The cost of electricity is different on {energy_cost.name} " ) warning_msg += f"and {self.name} costing blocks." + _log.warning(warning_msg) if cp == "heat_cost": if pyo.value(treat_cost.heat_cost) != pyo.value(self.heat_cost_buy): warning_msg = f"The cost of heat is different on {treat_cost.name} " warning_msg += f"and {self.name} costing blocks." + _log.warning(warning_msg) if pyo.value(energy_cost.heat_cost) != pyo.value(self.heat_cost_buy): warning_msg = ( f"The cost of heat is different on {energy_cost.name} " ) warning_msg += f"and {self.name} costing blocks." + _log.warning(warning_msg) if cp == "base_currency": self.base_currency = treat_cost.base_currency From dc527ce8c11e4d22c0f7643cff93d13f1203f020 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 4 Dec 2024 12:43:26 -0700 Subject: [PATCH 3/7] test changes for default base_currency = pyunits.USD_2023 --- .../test/test_fo_trevi_flowsheet.py | 4 ++-- ...st_MED_VAGMD_semibatch_flowsheet_multiperiod.py | 6 +++--- .../test/test_VAGMD_batch_flowsheet_multiperiod.py | 4 ++-- .../tests/test_reflo_watertap_costing_package.py | 14 +++++++------- .../costing/watertap_reflo_costing_package.py | 4 ++-- .../surrogate/tests/test_lt_med_surrogate.py | 4 ++-- .../surrogate/tests/test_med_tvc_surrogate.py | 5 +++-- .../surrogate/tests/test_vagmd_surrogate.py | 2 +- .../unit_models/tests/test_air_stripping_0D.py | 5 ++++- .../unit_models/tests/test_chemical_softening.py | 6 +++++- .../unit_models/tests/test_crystallizer_effect.py | 1 + .../unit_models/tests/test_deep_well_injection.py | 2 ++ .../tests/test_multi_effect_crystallizer.py | 6 ++++-- .../tests/test_thermal_energy_storage.py | 5 ++++- .../unit_models/zero_order/tests/test_battery.py | 2 +- .../zero_order/tests/test_forward_osmosis.py | 2 +- 16 files changed, 44 insertions(+), 28 deletions(-) diff --git a/src/watertap_contrib/reflo/analysis/example_flowsheets/test/test_fo_trevi_flowsheet.py b/src/watertap_contrib/reflo/analysis/example_flowsheets/test/test_fo_trevi_flowsheet.py index 26dbad2d..e8c47a30 100644 --- a/src/watertap_contrib/reflo/analysis/example_flowsheets/test/test_fo_trevi_flowsheet.py +++ b/src/watertap_contrib/reflo/analysis/example_flowsheets/test/test_fo_trevi_flowsheet.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. @@ -121,7 +121,7 @@ def test_solution(self, fo_trevi_frame): assert overall_performance["Thermal power requirement (kW)"] == pytest.approx( 569.175, rel=1e-3 ) - assert overall_performance["LCOW ($/m3)"] == pytest.approx(0.454, rel=1e-3) + assert overall_performance["LCOW ($/m3)"] == pytest.approx(0.42375, rel=1e-3) assert operational_parameters["HX1 cold in temp"] == pytest.approx( 21.23, rel=1e-3 diff --git a/src/watertap_contrib/reflo/analysis/multiperiod/ltmed_vagmd_semibatch/test/test_MED_VAGMD_semibatch_flowsheet_multiperiod.py b/src/watertap_contrib/reflo/analysis/multiperiod/ltmed_vagmd_semibatch/test/test_MED_VAGMD_semibatch_flowsheet_multiperiod.py index 1797534a..3887c5aa 100644 --- a/src/watertap_contrib/reflo/analysis/multiperiod/ltmed_vagmd_semibatch/test/test_MED_VAGMD_semibatch_flowsheet_multiperiod.py +++ b/src/watertap_contrib/reflo/analysis/multiperiod/ltmed_vagmd_semibatch/test/test_MED_VAGMD_semibatch_flowsheet_multiperiod.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. @@ -260,11 +260,11 @@ def test_costing(self, MED_VAGMD_semibatch_frame): 68657.789, rel=1e-3 ) assert cost_performance["Annual heat cost ($)"] == pytest.approx( - 128236.19, rel=1e-3 + 113787.72, rel=1e-3 ) assert cost_performance["Annual electricity cost ($)"] == pytest.approx( 4064.964, rel=1e-3 ) assert cost_performance["Overall LCOW ($/m3)"] == pytest.approx( - 1.70261, rel=1e-3 + 1.66306, rel=1e-3 ) diff --git a/src/watertap_contrib/reflo/analysis/multiperiod/vagmd_batch/test/test_VAGMD_batch_flowsheet_multiperiod.py b/src/watertap_contrib/reflo/analysis/multiperiod/vagmd_batch/test/test_VAGMD_batch_flowsheet_multiperiod.py index d0f0be2b..5162b2b1 100644 --- a/src/watertap_contrib/reflo/analysis/multiperiod/vagmd_batch/test/test_VAGMD_batch_flowsheet_multiperiod.py +++ b/src/watertap_contrib/reflo/analysis/multiperiod/vagmd_batch/test/test_VAGMD_batch_flowsheet_multiperiod.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. @@ -280,7 +280,7 @@ def test_costing(self, VAGMD_batch_frame_AS7C15L_Closed): assert pytest.approx(151892.658, rel=1e-3) == value( vagmd.costing.fixed_operating_cost ) - assert pytest.approx(2.500, rel=1e-3) == value(m.fs.costing.LCOW) + assert pytest.approx(2.3206, rel=1e-3) == value(m.fs.costing.LCOW) class TestVAGMDbatchAS7C15L_HighSalinityClosed: diff --git a/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py b/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py index 9208a916..84056e8b 100644 --- a/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py +++ b/src/watertap_contrib/reflo/costing/tests/test_reflo_watertap_costing_package.py @@ -201,7 +201,7 @@ def build_electricity_gen_only_no_heat(): m.fs.treatment.unit.design_var_a.fix() m.fs.treatment.unit.design_var_b.fix() - m.fs.treatment.unit.electricity_consumption.fix(10000) + m.fs.treatment.unit.electricity_consumption.fix(100) m.fs.treatment.costing.cost_process() m.fs.treatment.costing.add_LCOW( m.fs.treatment.unit.properties[0].flow_vol_phase["Liq"] @@ -215,7 +215,7 @@ def build_electricity_gen_only_no_heat(): m.fs.energy.unit.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.energy.costing ) - m.fs.energy.unit.electricity.fix(7500) + m.fs.energy.unit.electricity.fix(75) m.fs.energy.costing.cost_process() #### SYSTEM COSTING @@ -455,9 +455,9 @@ def test_default_build(self, default_build): assert hasattr(m.fs.energy.costing, "lifetime_heat_production") assert not hasattr(m.fs.treatment.costing, "has_electricity_generation") - assert m.fs.treatment.costing.base_currency is pyunits.USD_2021 - assert m.fs.energy.costing.base_currency is pyunits.USD_2021 - assert m.fs.costing.base_currency is pyunits.USD_2021 + assert m.fs.treatment.costing.base_currency is pyunits.USD_2023 + assert m.fs.energy.costing.base_currency is pyunits.USD_2023 + assert m.fs.costing.base_currency is pyunits.USD_2023 assert m.fs.treatment.costing.base_period is pyunits.year assert m.fs.energy.costing.base_period is pyunits.year @@ -717,7 +717,7 @@ def test_init_and_solve(self, elec_gen_only_no_heat): pytest.approx( value(m.fs.costing.aggregate_flow_electricity_purchased), rel=1e-3 ) - == 2500 + == 25 ) assert pytest.approx( value(m.fs.costing.aggregate_flow_electricity), rel=1e-3 @@ -789,7 +789,7 @@ def test_optimize_frac_from_grid(self): pytest.approx( value(m.fs.costing.aggregate_flow_electricity_purchased), rel=1e-3 ) - == 3300 + == 33 ) assert pytest.approx( value(m.fs.costing.aggregate_flow_electricity), rel=1e-3 diff --git a/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py b/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py index 32cce439..1279391c 100644 --- a/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py +++ b/src/watertap_contrib/reflo/costing/watertap_reflo_costing_package.py @@ -56,7 +56,7 @@ def build_global_params(self): super().build_global_params() # Override WaterTAP default value of USD_2018 - self.base_currency = pyo.units.USD_2021 + self.base_currency = pyo.units.USD_2023 self.sales_tax_frac = pyo.Param( initialize=0.05, @@ -381,7 +381,7 @@ def build_global_params(self): pyo.units.load_definitions_from_strings(["USD_2023 = 500/797.9 * USD_CE500"]) - self.base_currency = pyo.units.USD_2021 + self.base_currency = pyo.units.USD_2023 # Fix the parameters self.electricity_cost.fix(0.0) diff --git a/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_lt_med_surrogate.py b/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_lt_med_surrogate.py index 8b08275e..84668c68 100644 --- a/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_lt_med_surrogate.py +++ b/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_lt_med_surrogate.py @@ -312,8 +312,8 @@ def test_costing(self, LT_MED_frame): m.fs.lt_med.costing.fixed_operating_cost ) - assert pytest.approx(1.4818, rel=1e-3) == value(m.fs.costing.LCOW) - assert pytest.approx(678576.13, rel=1e-3) == value( + assert pytest.approx(1.4208, rel=1e-3) == value(m.fs.costing.LCOW) + assert pytest.approx(634017.063, rel=1e-3) == value( m.fs.costing.total_operating_cost ) assert pytest.approx(4609113.13, rel=1e-3) == value( diff --git a/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_med_tvc_surrogate.py b/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_med_tvc_surrogate.py index 9bc5310f..fe5eccd3 100644 --- a/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_med_tvc_surrogate.py +++ b/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_med_tvc_surrogate.py @@ -314,6 +314,7 @@ def test_costing(self, MED_TVC_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 med_tvc.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) @@ -347,9 +348,9 @@ def test_costing(self, MED_TVC_frame): m.fs.med_tvc.costing.fixed_operating_cost ) - assert pytest.approx(1.7355, rel=1e-3) == value(m.fs.costing.LCOW) + assert pytest.approx(1.6756, rel=1e-3) == value(m.fs.costing.LCOW) - assert pytest.approx(740379.40, rel=1e-3) == value( + assert pytest.approx(696623.64, rel=1e-3) == value( m.fs.costing.total_operating_cost ) assert pytest.approx(6018483.5, rel=1e-3) == value( diff --git a/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_vagmd_surrogate.py b/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_vagmd_surrogate.py index 3704c0d6..42a83410 100644 --- a/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_vagmd_surrogate.py +++ b/src/watertap_contrib/reflo/unit_models/surrogate/tests/test_vagmd_surrogate.py @@ -229,4 +229,4 @@ def test_costing(self, VAGMD_frame): assert pytest.approx(294352.922, rel=1e-3) == value( vagmd.costing.fixed_operating_cost ) - assert pytest.approx(2.37915, rel=1e-3) == value(m.fs.costing.LCOW) + assert pytest.approx(2.2047, rel=1e-3) == value(m.fs.costing.LCOW) diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py b/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py index 9d0a0c76..b13b4e46 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. @@ -19,6 +19,7 @@ Expression, value, assert_optimal_termination, + units as pyunits ) from pyomo.network import Port @@ -372,6 +373,7 @@ def test_costing1(self, ax_frame1): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 ax.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() @@ -745,6 +747,7 @@ def test_costing2(self, ax_frame2): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 ax.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_chemical_softening.py b/src/watertap_contrib/reflo/unit_models/tests/test_chemical_softening.py index 23831c9c..4b007399 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_chemical_softening.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_chemical_softening.py @@ -253,6 +253,7 @@ def test_costing(self, chem_soft_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.soft.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() m.fs.costing.add_LCOW(prop_in.flow_vol) @@ -502,12 +503,12 @@ def test_solution(self, chem_soft_frame): def test_costing(self, chem_soft_frame): m = chem_soft_frame - prop_in = m.fs.soft.properties_in[0] m.fs.costing = TreatmentCosting() # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.soft.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() m.fs.costing.add_LCOW(prop_in.flow_vol) @@ -763,6 +764,7 @@ def test_costing(self, chem_soft_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.soft.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() m.fs.costing.add_LCOW(prop_in.flow_vol) @@ -1021,6 +1023,7 @@ def test_costing(self, chem_soft_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.soft.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() m.fs.costing.add_LCOW(prop_in.flow_vol) @@ -1280,6 +1283,7 @@ def test_costing(self, chem_soft_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.soft.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() m.fs.costing.add_LCOW(prop_in.flow_vol) diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_crystallizer_effect.py b/src/watertap_contrib/reflo/unit_models/tests/test_crystallizer_effect.py index e39793f8..6afd59bd 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_crystallizer_effect.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_crystallizer_effect.py @@ -384,6 +384,7 @@ def test_costing(self, effect_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.unit.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.costing, ) diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_deep_well_injection.py b/src/watertap_contrib/reflo/unit_models/tests/test_deep_well_injection.py index de0d030a..dead7d90 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_deep_well_injection.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_deep_well_injection.py @@ -339,6 +339,7 @@ def test_costing(self, dwi_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 # m.fs.costing.base_currency = pyunits.kUSD_2001 # for comparison to original BLM reference m.fs.unit.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() @@ -569,6 +570,7 @@ def test_costing(self, dwi_10000_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 # m.fs.costing.base_currency = pyunits.kUSD_2001 # for comparison to original BLM reference m.fs.unit.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_multi_effect_crystallizer.py b/src/watertap_contrib/reflo/unit_models/tests/test_multi_effect_crystallizer.py index 1b75e0c4..33728bb2 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_multi_effect_crystallizer.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_multi_effect_crystallizer.py @@ -775,7 +775,7 @@ def test_costing(self, MEC2_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) - # m.fs.costing.base_currency = pyunits.USD_2018 + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.unit.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.costing, costing_method_arguments={"cost_type": "mass_basis"}, @@ -1317,7 +1317,7 @@ def test_costing(self, MEC3_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) - # m.fs.costing.base_currency = pyunits.USD_2018 + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.unit.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.costing, costing_method_arguments={"cost_type": "mass_basis"}, @@ -1908,6 +1908,7 @@ def test_costing(self, MEC4_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.unit.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.costing, ) @@ -1998,6 +1999,7 @@ def test_costing_by_volume(self): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.unit.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.costing, costing_method_arguments={"cost_type": "volume_basis"}, diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_thermal_energy_storage.py b/src/watertap_contrib/reflo/unit_models/tests/test_thermal_energy_storage.py index 2ec24b62..62d98ed6 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_thermal_energy_storage.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_thermal_energy_storage.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. @@ -15,6 +15,7 @@ from pyomo.environ import ( ConcreteModel, assert_optimal_termination, + value, units as pyunits, ) from pyomo.network import Port @@ -161,3 +162,5 @@ def test_costing(self, tes): results = solver.solve(m) assert_optimal_termination(results) + + assert pytest.approx(value(m.fs.costing.LCOW), rel=1e-3) == 0.148389 diff --git a/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_battery.py b/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_battery.py index 18c19565..b48debb2 100644 --- a/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_battery.py +++ b/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_battery.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. diff --git a/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_forward_osmosis.py b/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_forward_osmosis.py index b23d4e07..5639460a 100644 --- a/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_forward_osmosis.py +++ b/src/watertap_contrib/reflo/unit_models/zero_order/tests/test_forward_osmosis.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. From 292b9962a1e8bfb336556c8de19954d71f22512a Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 4 Dec 2024 12:44:48 -0700 Subject: [PATCH 4/7] black --- .../reflo/unit_models/tests/test_air_stripping_0D.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py b/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py index b13b4e46..a5f6aaee 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_air_stripping_0D.py @@ -19,7 +19,7 @@ Expression, value, assert_optimal_termination, - units as pyunits + units as pyunits, ) from pyomo.network import Port From 7aa2cb44d60b32eada603776cd6475b8a832aaf1 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Wed, 4 Dec 2024 13:09:29 -0700 Subject: [PATCH 5/7] use base_currency = pyunits.USD_2021 in tests --- .../solar_models/surrogate/trough/test_trough_surrogate.py | 7 ++++--- .../zero_order/tests/test_flat_plate_physical.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/watertap_contrib/reflo/solar_models/surrogate/trough/test_trough_surrogate.py b/src/watertap_contrib/reflo/solar_models/surrogate/trough/test_trough_surrogate.py index 170a423b..22ce075e 100644 --- a/src/watertap_contrib/reflo/solar_models/surrogate/trough/test_trough_surrogate.py +++ b/src/watertap_contrib/reflo/solar_models/surrogate/trough/test_trough_surrogate.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. @@ -285,6 +285,7 @@ def test_costing(self, trough_frame): # set heat and electricity costs to be non-zero m.fs.costing.heat_cost.set_value(0.01) m.fs.costing.electricity_cost.fix(0.07) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.trough.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.costing ) @@ -315,10 +316,10 @@ def test_costing(self, trough_frame): "aggregate_variable_operating_cost": 1313013.020, "aggregate_flow_heat": -149784.738, "aggregate_flow_electricity": 1843.139, - "aggregate_flow_costs": {"heat": -13130130.20, "electricity": 1327705.190}, + "aggregate_flow_costs": {"heat": -11650748.44, "electricity": 1327705.190}, "total_capital_cost": 249933275.0, "maintenance_labor_chemical_operating_cost": 0.0, - "total_operating_cost": -8489411.99, + "total_operating_cost": -7010030.23, "capital_recovery_factor": 0.11955949, "aggregate_direct_capital_cost": 249933275.0, } diff --git a/src/watertap_contrib/reflo/solar_models/zero_order/tests/test_flat_plate_physical.py b/src/watertap_contrib/reflo/solar_models/zero_order/tests/test_flat_plate_physical.py index b985db08..e7815d49 100644 --- a/src/watertap_contrib/reflo/solar_models/zero_order/tests/test_flat_plate_physical.py +++ b/src/watertap_contrib/reflo/solar_models/zero_order/tests/test_flat_plate_physical.py @@ -1,5 +1,5 @@ ################################################################################# -# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, +# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, # through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, # National Renewable Energy Laboratory, and National Energy Technology # Laboratory (subject to receipt of any required approvals from the U.S. Dept. @@ -199,6 +199,7 @@ def test_costing(self, flat_plate_frame): m.fs.costing = TreatmentCosting() m.fs.costing.electricity_cost.fix(0.07) m.fs.costing.heat_cost.set_value(0) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.flatplate.costing = UnitModelCostingBlock( flowsheet_costing_block=m.fs.costing ) From da9247629d41fc725cfefb6f11c1dfbcccc06ae0 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Fri, 6 Dec 2024 16:08:20 -0700 Subject: [PATCH 6/7] base_units = 2021 --- src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py b/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py index de581326..5f370836 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py @@ -197,6 +197,7 @@ def test_costing(self, ss_frame): m.fs.costing = TreatmentCosting() m.fs.costing.electricity_cost.fix(0.07) m.fs.costing.heat_cost.fix(0.01) + m.fs.costing.base_currency = pyunits.USD_2021 m.fs.unit.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() m.fs.costing.add_LCOW( From 853997c31b4cada0763c8806da7ec36439cda4f0 Mon Sep 17 00:00:00 2001 From: kurbansitterley Date: Fri, 6 Dec 2024 17:21:17 -0700 Subject: [PATCH 7/7] use 2023 dollars --- .../unit_models/tests/test_solar_still.py | 68 ++++++++----------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py b/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py index 5f370836..4a0f471b 100644 --- a/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py +++ b/src/watertap_contrib/reflo/unit_models/tests/test_solar_still.py @@ -197,7 +197,6 @@ def test_costing(self, ss_frame): m.fs.costing = TreatmentCosting() m.fs.costing.electricity_cost.fix(0.07) m.fs.costing.heat_cost.fix(0.01) - m.fs.costing.base_currency = pyunits.USD_2021 m.fs.unit.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing) m.fs.costing.cost_process() m.fs.costing.add_LCOW( @@ -207,21 +206,19 @@ def test_costing(self, ss_frame): assert_optimal_termination(results) sys_cost_results = { - "aggregate_capital_cost": 9183991.7, - "aggregate_fixed_operating_cost": 456749.3, - "aggregate_variable_operating_cost": 0.0, - "aggregate_flow_electricity": 2.5094, - "aggregate_flow_costs": {"electricity": 1807.6}, - "aggregate_direct_capital_cost": 4591995.8, - "total_capital_cost": 9183991.7, - "total_operating_cost": 734076.7, - "maintenance_labor_chemical_operating_cost": 275519.7, - "total_fixed_operating_cost": 732269.0, - "total_variable_operating_cost": 1807.6, - "total_annualized_cost": 1762279.2, - "LCOW": 24.124, + "aggregate_capital_cost": 10350527.606, + "aggregate_fixed_operating_cost": 514766.241, + "aggregate_flow_electricity": 2.5095, + "aggregate_flow_costs": {"electricity": 2037.257}, + "aggregate_direct_capital_cost": 5175263.803, + "total_capital_cost": 10350527.606, + "total_operating_cost": 827319.327, + "maintenance_labor_chemical_operating_cost": 310515.828, + "total_fixed_operating_cost": 825282.069, + "total_variable_operating_cost": 2037.257, + "total_annualized_cost": 1986122.47, + "LCOW": 27.188, } - for v, r in sys_cost_results.items(): sc = getattr(m.fs.costing, v) if sc.is_indexed(): @@ -231,33 +228,28 @@ def test_costing(self, ss_frame): assert pytest.approx(value(sc), rel=1e-3) == r ss_cost_results = { - "capital_cost": 9183991.7, - "fixed_operating_cost": 456749.3, - "number_sw_pumps": 3.8717, - "number_fw_pumps": 3.8717, - "capital_cost_per_still": 28.7, - "sw_pump_power": 0.32407, - "fw_pump_power": 0.32407, - "pumping_power_required": 2.509446, - "length_piping": 5788.3, - "capital_cost_solar_still": 9088887.7, - "capital_cost_sw_pumps": 5963.2, - "capital_cost_fw_pumps": 4395.4, - "capital_cost_feed_tank": 20070.9, - "capital_cost_distillate_tank": 21138.3, - "capital_cost_excavation": 9717.1, - "capital_cost_piping": 33818.7, - "operating_cost_labor": 135309.6, - "direct_capital_cost": 4591995.8, + "capital_cost": 10350527.606, + "fixed_operating_cost": 514766.241, + "number_fw_pumps": 3.871801, + "capital_cost_per_still": 32.362, + "sw_pump_power": 0.3240, + "fw_pump_power": 0.3240, + "pumping_power_required": 2.5095, + "length_piping": 5788.56, + "capital_cost_solar_still": 10243343.0, + "capital_cost_sw_pumps": 6720.6, + "capital_cost_fw_pumps": 4953.6, + "capital_cost_feed_tank": 22620.5, + "capital_cost_distillate_tank": 23823.5, + "capital_cost_excavation": 10951.5, + "capital_cost_piping": 38114.6, + "operating_cost_labor": 152497.7, + "direct_capital_cost": 5175263.803, } for v, r in ss_cost_results.items(): ssv = getattr(m.fs.unit.costing, v) - if ssv.is_indexed(): - for i, s in r.items(): - assert pytest.approx(value(ssv[i]), rel=1e-3) == s - else: - assert pytest.approx(value(ssv), rel=1e-3) == r + assert pytest.approx(value(ssv), rel=1e-3) == r @pytest.mark.unit