Skip to content

Update SWRO flowsheet costing#1847

Merged
adam-a-a merged 7 commits into
watertap-org:mainfrom
adam-a-a:swro_update
Jul 9, 2026
Merged

Update SWRO flowsheet costing#1847
adam-a-a merged 7 commits into
watertap-org:mainfrom
adam-a-a:swro_update

Conversation

@adam-a-a

@adam-a-a adam-a-a commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fixes/Resolves:

Summary/Motivation:

A bug was identified for costing of the seawater RO flowsheet. Because two cost packages are used in the flowsheet, at least one shared parameter (each costing package has its own parameter)--i.e., wacc factor-- had a different values used. For example, the ZO costing package used a value of 5% for WACC, while the watertap costing package used a value near 10%.

This PR eliminates usage of two costing packages and associated complexities (e.g., add custom constraints to remedy usage of more than one costing package) of doing so.

Changes proposed in this PR:

  • reduce down to usage of the ZO costing package, which is compatible with ZO and detailed models
  • set base currency to latest available in IDAES now, which is USD_2023

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@MarcusHolly MarcusHolly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions about why things have been commented out, but we also need to ensure the GUI builds properly. From my preliminary testing, the flowsheet is unable to build. Maybe you're already aware of this.... regardless, I can look more into the failure, if necessary.

Comment on lines +656 to +671
# # For non-zero order unit operations, we need to register costed flows
# # separately.
# # We will register electricity flow for detailed models with the ZO
# # Costing package
# m.fs.costing.cost_flow(desal.P1.work_mechanical[0], "electricity")
# if m.erd_type == "pressure_exchanger":
# m.fs.costing.cost_flow(desal.P2.work_mechanical[0], "electricity")
# elif m.erd_type == "pump_as_turbine":
# pass
# # m.fs.costing.cost_flow(
# # desal.ERD.work_mechanical[0], "electricity")
# else:
# raise ConfigurationError(
# f"erd_type was {m.erd_type}, costing only implemented "
# "for pressure_exchanger or pump_as_turbine"
# )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be deleted. Now that costing is consolidated to one package, I am just accounting for electricity cost in detailed models through the cost_electricity_flow arg (e.g., https://github.com/watertap-org/watertap/pull/1847/changes#r3538762503)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

desal.PXR.costing = UnitModelCostingBlock(
flowsheet_costing_block=m.fs.ro_costing
)
# desal.S1.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was previously commented out, and my guess is because we didn't deem it necessary to cost out a splitter.

@adam-a-a

adam-a-a commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@MichaelPesce @dangunter can you verify whether this will work with idaes-flowsheet-processor? @MarcusHolly and I tried opening in the GUI (by manually adding the flowsheet and export files), and for some reason there is a failure during the build process. I am wondering if this might have to do with the way we tried testing and whether this is a real failure or not. If it is a real failure, I am unsure what is wrong with the export file.

@MarcusHolly

MarcusHolly commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@MichaelPesce @dangunter can you verify whether this will work with idaes-flowsheet-processor? @MarcusHolly and I tried opening in the GUI (by manually adding the flowsheet and export files), and for some reason there is a failure during the build process. I am wondering if this might have to do with the way we tried testing and whether this is a real failure or not. If it is a real failure, I am unsure what is wrong with the export file.

FWIW, when I run this GUI flowsheet locally using the dev installation, I don't get any errors. Hopefully this issue is just a byproduct of the latest GUI release (1.7.dev0) being outdated.

@MichaelPesce

Copy link
Copy Markdown
Contributor

@MarcusHolly @adam-a-a I tested it out with the latest WaterTAP GUI build and I get the following error when trying to build the flowsheet:

File "/Users/michaelpesce/.nawi/custom_flowsheets/seawater_RO_desalination_ui.py", line 717, in build_flowsheet
m.fs.costing.initialize()
^^^^^^^^^^^^
File "pyomo/core/base/block.py", line 550, in getattr
AttributeError: '_ScalarFlowsheetBlock' object has no attribute 'costing'. Did you mean: 'ro_costing'?

Not sure if that error makes sense given any recent WaterTAP updates, but either way, I can build a version of the GUI based off of the current WaterTAP main and see if this flowsheet will build in that version.

@MarcusHolly

Copy link
Copy Markdown
Contributor

@MarcusHolly @adam-a-a I tested it out with the latest WaterTAP GUI build and I get the following error when trying to build the flowsheet:

File "/Users/michaelpesce/.nawi/custom_flowsheets/seawater_RO_desalination_ui.py", line 717, in build_flowsheet
m.fs.costing.initialize()
^^^^^^^^^^^^
File "pyomo/core/base/block.py", line 550, in getattr
AttributeError: '_ScalarFlowsheetBlock' object has no attribute 'costing'. Did you mean: 'ro_costing'?

Not sure if that error makes sense given any recent WaterTAP updates, but either way, I can build a version of the GUI based off of the current WaterTAP main and see if this flowsheet will build in that version.

That error implies the GUI is pulling from the wrong version of the SWRO flowsheet. ro_costing has been replaced with costing in this PR.

@adam-a-a

adam-a-a commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@MarcusHolly @adam-a-a I tested it out with the latest WaterTAP GUI build and I get the following error when trying to build the flowsheet:

File "/Users/michaelpesce/.nawi/custom_flowsheets/seawater_RO_desalination_ui.py", line 717, in build_flowsheet
m.fs.costing.initialize()
^^^^^^^^^^^^
File "pyomo/core/base/block.py", line 550, in getattr
AttributeError: '_ScalarFlowsheetBlock' object has no attribute 'costing'. Did you mean: 'ro_costing'?

Not sure if that error makes sense given any recent WaterTAP updates, but either way, I can build a version of the GUI based off of the current WaterTAP main and see if this flowsheet will build in that version.

That error implies the GUI is pulling from the wrong version of the SWRO flowsheet. ro_costing has been replaced with costing in this PR.

That's exactly it. This PR changes ro_costing and zo_costing to just costing, so it makes sense to build a version of the GUI off of this PR to account for the changes @MichaelPesce. Thanks in advance!

@MichaelPesce

Copy link
Copy Markdown
Contributor

@adam-a-a @MarcusHolly OK great. I just built a version of the GUI using this PR for the WaterTAP version and verified that the flowsheet does indeed work there.

@adam-a-a
adam-a-a requested a review from MarcusHolly July 8, 2026 19:14

@MarcusHolly MarcusHolly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - GUI works fine on my end

Comment on lines -800 to +715
m = main(erd_type="pressure_exchanger", RO_1D=False)
m = main(erd_type="pump_as_turbine", RO_1D=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that the default config option was changed here. I don't think it's a big deal either way, but if there's a good reason we had pressure_exchanger as the default before, we should consider undoing this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be ok because the default is still the same; this just calls pump_as_turbine in main if someone tries running the file itself.

@kurbansitterley kurbansitterley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine with me. @adam-a-a I will leave it to you to decide if you want to add ERD costing in this PR.

@adam-a-a
adam-a-a merged commit 3df4d0b into watertap-org:main Jul 9, 2026
24 checks passed
@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:Normal Normal Priority Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants