Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOA v2 #157

Merged
merged 27 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ffd0e92
Refactor KBHDP case studies: improve function calls and add degrees o…
zacharybinger Dec 14, 2024
a30ae4d
Refactor KBHDP_SOA.py: clean up commented code and improve formatting…
zacharybinger Dec 14, 2024
84e4e6d
black
zacharybinger Dec 14, 2024
8f43064
Merge branch 'main' of https://github.com/kurbansitterley/watertap-se…
kurbansitterley Dec 15, 2024
1af5a5f
black
kurbansitterley Dec 15, 2024
47e5578
Refactor ro_system.py: comment out unused print statements for clarity
zacharybinger Dec 16, 2024
cf1b1bf
Update figure_device_groups and PV component: correct unit paths and …
zacharybinger Dec 16, 2024
d49e397
Update figure_device_groups and PV component: correct unit paths and …
zacharybinger Dec 16, 2024
9b554bb
Refactor costing implementation in KBHDP_SOA: update treatment costin…
zacharybinger Dec 16, 2024
6aef177
Refactor costing implementation in KBHDP_SOA: update treatment costin…
zacharybinger Dec 16, 2024
6c984ce
Update FPC and PV components: fix heat load value, correct unit paths…
zacharybinger Dec 17, 2024
3e810a4
Update KBHDP YAML configurations: add build defaults for water recove…
zacharybinger Dec 17, 2024
ff07352
Refactor KBHDP analysis scripts: update function parameters, optimize…
zacharybinger Dec 17, 2024
287cf02
Refactor PV and RO system components: improve print formatting and cl…
zacharybinger Dec 17, 2024
51388f2
correct sweep names from RPT_1 to SOA_1
kurbansitterley Dec 17, 2024
e1a5dbd
ignore .h5 files
kurbansitterley Dec 17, 2024
536a1ff
clean up
kurbansitterley Dec 17, 2024
1997a86
don't need seaborn atm
kurbansitterley Dec 17, 2024
8fd1860
black
kurbansitterley Dec 17, 2024
3f45ca4
run for KBHDP
kurbansitterley Dec 18, 2024
d632afa
no need to load_surrogate twice
kurbansitterley Dec 18, 2024
7b2aa68
add some logging
kurbansitterley Dec 18, 2024
9cc9aca
add FPC surrogate for El Paso
kurbansitterley Dec 18, 2024
64c9273
black black black black black I ran black
kurbansitterley Dec 18, 2024
ae8c040
add KBHDP data directory
kurbansitterley Dec 18, 2024
42d9d3b
ignore svg, jpg
kurbansitterley Dec 18, 2024
dfbc3cb
uncomment sweeps
kurbansitterley Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ auto-save-list

# other
*.json
*.h5
*.svg
*.jpg
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main():
# box_solve_problem(m)
# solve(m, debug=True)
# scale_costing(m)
optimize(m, ro_mem_area=None, water_recovery=0.8, grid_frac=None, objective="LCOW")
optimize(m, ro_mem_area=20000, water_recovery=0.8, grid_frac=None, objective="LCOT")
solve(m, debug=False)
# # display_flow_table(m)
# display_system_stream_table(m)
Expand All @@ -89,8 +89,10 @@ def main():

def build_sweep(
grid_frac=None,
heat_price=None,
elec_price=None,
water_recovery=None,
ro_mem_area=None,
objective="LCOT",
):

m = build_system(RE=True)
Expand All @@ -102,7 +104,14 @@ def build_sweep(
init_system(m)
add_costing(m)
scale_costing(m)
optimize(m, ro_mem_area=None, water_recovery=0.8, grid_frac=None, objective="LCOW")
optimize(
m,
ro_mem_area=ro_mem_area,
water_recovery=water_recovery,
grid_frac=grid_frac,
elec_price=elec_price,
objective=objective,
)

return m

Expand Down Expand Up @@ -171,7 +180,7 @@ def build_treatment(m):

build_ec(m, treatment.EC, prop_package=m.fs.UF_properties)
build_UF(m, treatment.UF, prop_package=m.fs.UF_properties)
build_ro(m, treatment.RO, prop_package=m.fs.RO_properties)
build_ro(m, treatment.RO, prop_package=m.fs.RO_properties, number_of_stages=1)
build_DWI(m, treatment.DWI, prop_package=m.fs.RO_properties)

m.fs.units = [
Expand Down Expand Up @@ -311,6 +320,7 @@ def add_energy_costing(m):
)

energy.costing.cost_process()
energy.costing.add_LCOE()
energy.costing.initialize()


Expand All @@ -323,11 +333,11 @@ def add_costing(m):
add_energy_costing(m)

m.fs.costing = REFLOSystemCosting()
m.fs.costing.base_currency = pyunits.USD_2020
m.fs.costing.cost_process()

m.fs.costing.add_annual_water_production(treatment.product.properties[0].flow_vol)
m.fs.costing.add_LCOW(treatment.product.properties[0].flow_vol)
m.fs.costing.add_LCOT(treatment.product.properties[0].flow_vol)

m.fs.costing.initialize()

Expand Down Expand Up @@ -508,7 +518,7 @@ def init_treatment(m, verbose=True, solver=None):
assert_no_degrees_of_freedom(m)
treatment.feed.initialize(optarg=optarg)
propagate_state(treatment.feed_to_translator)

report_MCAS_stream_conc(m, treatment.feed.properties[0.0])
treatment.MCAS_to_TDS_translator.initialize(optarg=optarg)
propagate_state(treatment.translator_to_EC)

Expand All @@ -531,7 +541,7 @@ def init_treatment(m, verbose=True, solver=None):
# propagate_state(treatment.ro_to_dwi)

treatment.product.initialize(optarg=optarg)
# init_DWI(m, treatment.DWI)
init_DWI(m, treatment.DWI)
display_system_stream_table(m)


Expand Down Expand Up @@ -612,6 +622,7 @@ def optimize(
fixed_pressure=None,
ro_mem_area=None,
grid_frac=None,
elec_price=None,
objective="LCOW",
):
treatment = m.fs.treatment
Expand All @@ -620,6 +631,8 @@ def optimize(

if objective == "LCOW":
m.fs.lcow_objective = Objective(expr=m.fs.costing.LCOW)
elif objective == "LCOT":
m.fs.lcow_objective = Objective(expr=m.fs.costing.LCOT)
else:
m.fs.membrane_area_objective = Objective(expr=treatment.RO.stage[1].module.area)

Expand Down Expand Up @@ -651,8 +664,12 @@ def optimize(

if ro_mem_area is not None:
print(f"\n------- Fixed RO Membrane Area at {ro_mem_area} -------\n")
# for idx, stage in treatment.RO.stage.items():
# stage.module.area.fix(ro_mem_area)
treatment.RO.total_membrane_area.fix(ro_mem_area)
for idx, stage in treatment.RO.stage.items():
stage.module.area.fix(ro_mem_area)
stage.module.area.unfix()
stage.module.area.setub(1e6)
else:
lower_bound = 1e3
upper_bound = 2e5
Expand All @@ -669,6 +686,24 @@ def optimize(
m.fs.energy.pv.design_size.unfix()
m.fs.energy.pv.annual_energy.unfix()

if elec_price is not None:
m.fs.costing.frac_elec_from_grid.unfix()
m.fs.energy.pv.design_size.unfix()
m.fs.energy.pv.annual_energy.unfix()

for idx, stage in treatment.RO.stage.items():
stage.module.width.setub(5000)
stage.module.feed_side.velocity[0, 0].unfix()
stage.module.feed_side.velocity[0, 1].setlb(0.0)
stage.module.feed_side.K.setlb(1e-6)
stage.module.feed_side.friction_factor_darcy.setub(50)
stage.module.flux_mass_phase_comp.setub(1)
# stage.module.flux_mass_phase_comp.setlb(1e-5)
stage.module.feed_side.cp_modulus.setub(10)
stage.module.rejection_phase_comp.setlb(1e-4)
stage.module.feed_side.N_Re.setlb(1)
stage.module.recovery_mass_phase_comp.setlb(1e-7)


def report_MCAS_stream_conc(m, stream):
solute_set = m.fs.MCAS_properties.solute_set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ def main():
init_system(m)
add_costing(m)
scale_costing(m)
box_solve_problem(m)
# solve(m, debug=True)
# box_solve_problem(m)
# # solve(m, debug=True)

optimize(m, water_recovery=0.35, grid_frac_heat=0.5, objective="LCOW")
optimize(m, water_recovery=0.35, heat_price=0.005, objective="LCOW")
solve(m, debug=True)
display_system_stream_table(m)
report_LTMED(m)
report_pump(m, m.fs.treatment.pump)
# display_system_stream_table(m)
# report_LTMED(m)
# report_pump(m, m.fs.treatment.pump)
report_fpc(m)

display_costing_breakdown(m)
m.fs.costing.LCOW.display()
m.fs.energy.costing.LCOH.display()
m.fs.costing.LCOT.display()
# display_costing_breakdown(m)

return m

Expand All @@ -99,6 +102,7 @@ def build_sweep(
m,
water_recovery=water_recovery,
grid_frac_heat=grid_frac_heat,
heat_price=heat_price,
objective="LCOW",
)

Expand Down Expand Up @@ -302,6 +306,7 @@ def add_energy_costing(m):
add_fpc_costing(m, energy.costing)

energy.costing.cost_process()
energy.costing.add_LCOH()
energy.costing.initialize()


Expand All @@ -313,11 +318,11 @@ def add_costing(m):
add_energy_costing(m)

m.fs.costing = REFLOSystemCosting()
# m.fs.costing.base_currency = pyunits.USD_2020
m.fs.costing.cost_process()

m.fs.costing.add_annual_water_production(treatment.product.properties[0].flow_vol)
m.fs.costing.add_LCOW(treatment.product.properties[0].flow_vol)
m.fs.costing.add_LCOT(treatment.product.properties[0].flow_vol)

m.fs.costing.initialize()

Expand Down Expand Up @@ -605,6 +610,8 @@ def optimize(

if objective == "LCOW":
m.fs.lcow_objective = Objective(expr=m.fs.costing.LCOW)
if objective == "LCOT":
m.fs.lcot_objective = Objective(expr=m.fs.costing.LCOT)

if water_recovery is not None:
print(f"\n------- Fixed Recovery at {100*water_recovery}% -------")
Expand All @@ -616,7 +623,8 @@ def optimize(
m.fs.costing.frac_heat_from_grid.fix(grid_frac_heat)

if heat_price is not None:
m.fs.energy.FPC.heat_load.unfix()
energy.FPC.heat_load.unfix()
energy.FPC.hours_storage.unfix()
m.fs.costing.frac_heat_from_grid.unfix()
m.fs.costing.heat_cost_buy.fix(heat_price)

Expand Down
Loading
Loading