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

Revised vapor composition constraints fix ZeroDivisionError when gdp.hull reformulation is applied #47

Open
wants to merge 2 commits into
base: kaibel
Choose a base branch
from

Conversation

tristantc
Copy link
Contributor

@tristantc tristantc commented Aug 13, 2024

This PR fix the ZeroDivisionError when gdp.hull reformulation is applied in the Kaibel instance.

File:gdplib/kaibel/kaibel_solve_gdp.py

    tray_exists[1,1].bottom_vapor_composition[1]
    tray_exists[2,1].feedside_vapor_composition[1]
    tray_exists[3,1].productside_vapor_composition[1]
    tray_exists[4,1].top_vapor_composition[1]

@ZedongPeng
Copy link
Member

As long as there are no errors, this PR is ready to be merged. @bernalde

Copy link
Member

@bernalde bernalde left a comment

Choose a reason for hiding this comment

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

Besides some small changes the most important part is verifying that both the Big-M and HR can provided the right solution to the problem and that the new introduced variables/constraints did not modify the optimal solution

@@ -245,7 +243,7 @@ def build_model():
for comp in m.comp:
m.dHvap[comp] = dHvapb[comp] / m.Hscale

## Heat capacity calculation for liquid and vapor phases using Ruczika-D method for each component in the feed, section, and tray
## Heat capacity calculation for liquid and vapor phases for each component in the feed, section, and tray
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the comment on the method? Is that method not used? If it is used, leave the comment and add a reference

m.prop[comp, 'TC'] / m.Tup,
m.prop[comp, 'TC'] / m.Tlo,
), # (0, None),
initialize=lambda m, sec, tray, comp: m.T0[sec, tray] / m.Tlo,
Copy link
Member

Choose a reason for hiding this comment

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

I like this way of defining bounds and initializations!

m.prop[comp, 'TC']
/ m.T[1, n_tray]
m.Tr[1, n_tray, comp]
# m.prop[comp, 'TC']
Copy link
Member

Choose a reason for hiding this comment

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

Why leave these lines here? If the code works, remove the comments as they become confusing

@@ -1472,7 +1502,7 @@ def bottom_vapor_composition(disj, comp):
)
)
)
/ m.P[1, n_tray]
# / m.P[1, n_tray]
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment as pressure multiplied in the other side of the equality

The constraint equation to calculate the temperature term for the top section vapor composition.
"""
return m.Tr[4, n_tray, comp] * m.T[4, n_tray] == m.prop[comp, 'TC']

@disj.Constraint(m.comp, doc="Top scetion 4 vapor composition")
Copy link
Member

Choose a reason for hiding this comment

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

Typo here in section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants