Skip to content

Pricetaker implementation for flexible desalination #1592

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

radhakrishnatg
Copy link

@radhakrishnatg radhakrishnatg commented Jun 9, 2025

Summary/Motivation:

This PR adds price-taker implementation for flexible desalination.
NOTE: This PR requires changes in this branch: https://github.com/radhakrishnatg/idaes-pse/tree/pt-improvements. So, until the above branch is merged with IDAES main, this PR should not be merged.

EDIT by @adam-a-a: we'll need to point to this IDAES PR: IDAES/idaes-pse#1633
EDIT by @lbianchi-lbl: this also depends on the changes in IDAES/idaes-pse#1579

Changes proposed in this PR:

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.

@adam-a-a
Copy link
Contributor

adam-a-a commented Jun 9, 2025

Note to self and @MarcusHolly - just a reminder that we'll need to add tests, in addition to review/suggesting changes (or implementing changes ourselves)

Copy link
Contributor

@MarcusHolly MarcusHolly left a comment

Choose a reason for hiding this comment

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

Thanks for all your work on this Radhakrishna! I've mainly left comments on the tutorial, but I can address most/all of them if you don't have the time to do so. As far as testing goes, it's prob easier to wait for the IDAES PR to be put up and merged.

For the file locations, I think we could either keep it as it is currently or just leave the .ipynb file in this tutorial folder and move the rest of the files to a place like watertap/flowsheets/flex_ro. I lean more towards the latter

"""Adds the delayed startup constraints to the model"""
params: um_params.FlexDesalParams = m.params

# "Shutdown" posttreamt unit if RO startup is initiated
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# "Shutdown" posttreamt unit if RO startup is initiated
# "Shutdown" post-treatment unit if RO startup is initiated

)

else:
raise ValueError("Water production targets not specidied in params")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise ValueError("Water production targets not specidied in params")
raise ValueError("Water production targets not specified in params")

" end_date=\"2022-07-15 00:00:00\",\n",
" annual_production_AF=1200,\n",
")\n",
"m.params.intake.nominal_flowrate = 1063.5\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

As a general comment, I think the tutorial should be explicit in what the units so that users are not left guessing. I can go through and add these when I start working on this

"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to the top of the tutorial with the rest of the imports

@@ -0,0 +1,863 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Would probably be helpful to have more text-based descriptions of what the following code will do so that users have an easier time going through and understanding this workflow on their own rather than relying solely on the in-line comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Would also probably be helpful to have an introductory blurb of what this tutorial will show and briefly introduce the important files (flowsheet.py, params.py, etc.)

Comment on lines +187 to +196
"fs.constrain_water_production(m)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"utils.fix_recovery(m, recovery=m.params.ro.nominal_recovery)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline comments and/or text-based descriptions

"\n",
"# Update the time-varying parameters other than the LMP, such as\n",
"# demand costs and emissions intensity. LMP value is updated by default\n",
"m.update_operation_params({\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Requires the pricetaker updates in IDAES to be merged

"metadata": {},
"outputs": [],
"source": [
"fs.constrain_water_production(m)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline-comment or description

"metadata": {},
"outputs": [],
"source": [
"utils.fix_recovery(m, recovery=m.params.ro.nominal_recovery)"
Copy link
Contributor

Choose a reason for hiding this comment

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

In-line comment or description

Comment on lines +762 to +765
"# solver = utils.get_gurobi_solver_model(m, mip_gap=0.005)\n",
"solver = pyo.SolverFactory(\"gurobi\")\n",
"solver.options[\"MIPGap\"] = 0.03\n",
"solver.solve(m, tee=True)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we provide an alternative here for those who don't have access to Gurobi

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed- it'd be ideal if we had the options in place where we could use the other solver options that we were using when a couple of us lost access to Gurobi (e.g., GAMS solvers, potentially mindtpy if not much trouble to add option, with caveat of bug encountered)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDAES pricetaker Priority:Normal Normal Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants