Skip to content

Commit

Permalink
Merge pull request #148 from kurbansitterley/add_USD_2023
Browse files Browse the repository at this point in the history
Add USD_2023 as currency unit to costing packages
  • Loading branch information
kurbansitterley authored Dec 7, 2024
2 parents f210133 + 853997c commit bab8811
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
)
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ 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
self.base_currency = pyo.units.USD_2021
self.base_currency = pyo.units.USD_2023

self.sales_tax_frac = pyo.Param(
initialize=0.05,
Expand Down Expand Up @@ -377,7 +379,9 @@ class REFLOSystemCostingData(WaterTAPCostingBlockData):
def build_global_params(self):
super().build_global_params()

self.base_currency = pyo.units.USD_2021
pyo.units.load_definitions_from_strings(["USD_2023 = 500/797.9 * USD_CE500"])

self.base_currency = pyo.units.USD_2023

# Fix the parameters
self.electricity_cost.fix(0.0)
Expand Down Expand Up @@ -996,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)
Expand All @@ -1021,22 +1026,26 @@ 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
):
warning_msg = (
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,6 +19,7 @@
Expression,
value,
assert_optimal_termination,
units as pyunits,
)
from pyomo.network import Port

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Loading

0 comments on commit bab8811

Please sign in to comment.