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

Anaerobic Digester Re-Scaling #1535

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

MarcusHolly
Copy link
Contributor

@MarcusHolly MarcusHolly commented Nov 29, 2024

Summary/Motivation:

Adds the new IDAES scaling routine (scaler objects) to the anaerobic digester unit model. This should be merged after #1519 and #1530 are merged in.

Changes proposed in this PR:

  • Updates the scaling routine of the anaerobic digester
  • Updates testing

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 added the Priority:Normal Normal Priority Issue or PR label Nov 29, 2024
@MarcusHolly MarcusHolly self-assigned this Nov 29, 2024
@MarcusHolly MarcusHolly marked this pull request as ready for review December 17, 2024 17:43
@@ -940,6 +940,9 @@ def model(self):
m.fs.unit.liquid_phase.properties_in[0].TSS
m.fs.unit.liquid_phase.properties_out[0].TSS

iscale.calculate_scaling_factors(m)
iscale.set_scaling_factor(m.fs.unit.liquid_phase.heat, 1e-6)
Copy link
Contributor

Choose a reason for hiding this comment

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

WHy did you need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is not needed. It may have been necessary at some point while I was working on this PR, but I'll undo it

Comment on lines +930 to +941
iscale.set_scaling_factor(self.KH_co2, 1e2)
iscale.set_scaling_factor(self.KH_ch4, 1e2)
iscale.set_scaling_factor(self.KH_h2, 1e2)
iscale.set_scaling_factor(self.hydraulic_retention_time, 1e-6)
iscale.set_scaling_factor(self.volume_AD, 1e-2)
iscale.set_scaling_factor(self.volume_vapor, 1e-2)
iscale.set_scaling_factor(self.liquid_phase.rate_reaction_generation, 1e4)
iscale.set_scaling_factor(self.liquid_phase.mass_transfer_term, 1e2)
iscale.set_scaling_factor(self.liquid_phase.rate_reaction_extent, 1e4)
iscale.set_scaling_factor(self.liquid_phase.enthalpy_transfer, 1e0)
iscale.set_scaling_factor(self.liquid_phase.volume, 1e-2)
iscale.set_scaling_factor(self.electricity_consumption, 1e0)
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 these be handled in the scaler class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Andrew mentioned that we should not mix and match the new and old scaling tools. In other words, the scaler class should not make use of iscale. This is the reason why I've moved all of the iscale.set_scaling_factor to the calculate_scaling_factors function (in this PR and in others), which won't be called when exclusively using the new scaling tools.

If your question is why don't I set these default scaling factors in the ADScaler class, it's because I figured these would make more sense as user-defined scaling factors. I know I did do some testing with having default scaling factors for these variables in the new scaler class, but I forget how thoroughly I played around with this. Currently, the only variable scaled by default in the new scaler class is volume.

@@ -56,71 +56,71 @@ def test_solve(self, system_frame):
0.24219, rel=1e-3
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to check the condition number at the flowsheet level between old scaling approach and new?

Copy link
Contributor

Choose a reason for hiding this comment

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

Then, every time another PR impacts scaling at this flowsheet level, we can track whether condition number improves or not as we go.

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

Successfully merging this pull request may close these issues.

2 participants