Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoran29 committed Jan 16, 2025
2 parents e6de647 + 6042e3a commit 0134f23
Show file tree
Hide file tree
Showing 62 changed files with 50,259 additions and 1,449 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- noneditable
include:
- os: linux
os-version: ubuntu-latest
os-version: ubuntu-22.04
- os: win64
os-version: windows-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,10 @@ auto-save-list

# other
*.json
*.h5
*.svg
*.jpg
*.csv
*.png
*.pkl
*.rtf
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

0 comments on commit 0134f23

Please sign in to comment.