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

BSM2-P Effluent Metrics #1489

Closed

Conversation

MarcusHolly
Copy link
Contributor

Summary/Motivation:

Adds effluent concentration violations to the BSM2-P flowsheet

Changes proposed in this PR:

  • Adds effluent metrics to the modified ASM2d property package
  • Adds effluent violation constraints to the BSM2-P flowsheet
  • Finishes To-Do item in BSM2 flowsheet related to effluent constraints

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 self-assigned this Sep 12, 2024
@MarcusHolly MarcusHolly added the Priority:Normal Normal Priority Issue or PR label Sep 12, 2024
@MarcusHolly MarcusHolly requested review from luohezhiming, adam-a-a and agarciadiego and removed request for luohezhiming and adam-a-a September 12, 2024 19:22
@@ -210,6 +210,86 @@ def build(self):
doc="ISS fractional content of biomass",
)

# EQI parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some general refs so we know where to look for these in future?

self.eq_SNKj = pyo.Constraint(rule=rule_SNKj)

def rule_BOD5(b):
return b.BOD5 == 0.25 * (
Copy link
Contributor

Choose a reason for hiding this comment

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

From memory, I recall that the factor (0.25) could change depending on whether this is calculated for influent or effluent. Can you double-check this? I handled this in some way for ASM1 (though it might not be ideal approach).

Copy link
Contributor

Choose a reason for hiding this comment

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

If I am recalling correctly, I would at least opt for using a mutable Param instead of the hard-coded 0.25. Then it would be on the user to change the Param value as needed at the flowsheet level.

Copy link
Contributor Author

@MarcusHolly MarcusHolly Sep 12, 2024

Choose a reason for hiding this comment

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

I am familiar with what you are talking about, but the c-code and the literature reference both hard-code 0.25, so I didn't see a need to do what you did in ASM1
image

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem here is if I want to apply to the influent, that value changes, right? Since this can be constructed on any state block and not only one that corresponds to treated effluent, we cannot just hard-code the value to what would correspond to the effluent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you show the same snapshot for BOD5i or whatever corresponds to influent in that file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, the influent value is 0.65
image

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.

My initial response to this PR before dropping any suggestions was "WOW--that was fast!"

Great work--I think some additional ASM2d testing on the new metrics, just as a sanity check, would be good. Most of all though, fingers crossed that the flowsheet can still solve.

Comment on lines 562 to 567
m.fs.Treated.properties[0].TSS
m.fs.Treated.properties[0].COD
m.fs.Treated.properties[0].BOD5
m.fs.Treated.properties[0].SNKj
m.fs.Treated.properties[0].SP_organic
m.fs.Treated.properties[0].SP_inorganic
Copy link
Contributor

Choose a reason for hiding this comment

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

You should touch these before the solve.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are touched before the solve. I placed it at the end of set_operating_conditions. Do you mean these should be touched right before the solve? How would that functionally be any different than the current placement?

Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake- I misread the GH diff and it looked as if these lines were after the solve. That said, I wonder if it makes more sense to touch before applying scaling. Right now, I think you made each an expression so it might not matter. If they were reverted back to vars, then it would matter.

Comment on lines -529 to -530
def add_effluent_violations(m):
# TODO: update "m" to blk; change ref to m.fs.Treated instead of CL1 effluent
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't been able to figure out why, but this change is breaking the BSM2 GUI, so I've reverted it in #1491

@MarcusHolly
Copy link
Contributor Author

Replaced by #1503

@MarcusHolly MarcusHolly closed this Oct 2, 2024
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.

2 participants