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

Add sweep analysis for electroNP flowsheet #1077

Merged
merged 61 commits into from
Jul 19, 2023

Conversation

luohezhiming
Copy link
Contributor

Fixes/Resolves:

(replace this with the issue # fixed or resolved, if no issue exists then a brief statement of what this PR does)

Summary/Motivation:

Changes proposed in this PR:

  • add sweep analysis
  • revise costing data

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.

Comment on lines 179 to 195
# self.magnesium_chloride_cost = pyo.Param(
# mutable=True,
# initialize=0.0786,
# doc="Magnesium chloride cost",
# units=pyo.units.USD_2020 / pyo.units.kg,
# )
# self.add_defined_flow("magnesium chloride", self.magnesium_chloride_cost)
#
# self.phosphorus_recovery_revenue = pyo.Param(
# mutable=True,
# initialize=-0.07,
# doc="Phosphorus recovery revenue",
# units=pyo.units.USD_2020 / pyo.units.kg,
# )
# self.add_defined_flow(
# "phosphorus salt product", self.phosphorus_recovery_revenue
# )
Copy link
Contributor

Choose a reason for hiding this comment

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

delete


def set_up_sensitivity(m):
outputs = {}
# optimize_kwargs = {"fail_flag": False}
Copy link
Contributor

Choose a reason for hiding this comment

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

delete

sf = iscale.get_scaling_factor(
self.energy_electric_flow_mass, default=1e2, warning=True
)
iscale.set_scaling_factor(self.energy_electric_flow_mass, sf)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this set_scaling_factor line be under the if conditional above?

luohezhiming and others added 4 commits July 11, 2023 10:26
Co-authored-by: Adam Atia <aatia@keylogic.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
…p.py

Co-authored-by: Adam Atia <aatia@keylogic.com>
sf = iscale.get_scaling_factor(
self.magnesium_chloride_dosage, default=1e1, warning=True
)
iscale.set_scaling_factor(self.magnesium_chloride_dosage, sf)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here- this set_scaling_factor should be within the if conditional because we only want to set the scaling factor if the user has not provided one in their flowsheet. The way it is written now, if a user supplied a scaling factor for this variable and ran calculate_scaling_factors afterwards, the scaling factor they specified would be overwritten without them realizing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, just realized that you don't need both lines (get_scaling_factor and set_scaling_factor), since the first will set a default scaling factor and show a warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adam-a-a I fixed the indent problem, but I am a little bit unsure why I don't need to set_scaling_factor, I checked other files like nanofiltration_ZO.py, they also do get_scaling_factor then set_scaling_factor even with a warning=True.

Copy link
Contributor

@adam-a-a adam-a-a left a comment

Choose a reason for hiding this comment

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

Just some suggested cleanup, but looks close to being merged

@luohezhiming
Copy link
Contributor Author

Just some suggested cleanup, but looks close to being merged

Thank you for your careful review! I've addressed all revisions as you suggested.

@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Jul 13, 2023
for i in skip_constraint:
m.fs.electroNP.solute_removal_equation[0.0, "Liq", i].deactivate()
m.fs.electroNP.solute_treated_equation[0.0, "Liq", i].deactivate()

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you checked why we can skip this constraints and the model still works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only reason I could imagine is the removal fraction is setting to a really small value 1e-7 and these components should just pass through, but I still want to keep these removal equations just in case if we want to update these removal fractions later.

@adam-a-a adam-a-a enabled auto-merge (squash) July 19, 2023 13:54
@adam-a-a adam-a-a merged commit 06538b4 into watertap-org:main Jul 19, 2023
23 checks passed
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.

4 participants