-
Notifications
You must be signed in to change notification settings - Fork 38
BinaryDistillation_CompositionFinder #215
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
base: master
Are you sure you want to change the base?
Conversation
taking N_stages as input, asserting y_top with none value to find it later the same with x_bot
extending the if and elsif to accept y_top,x_bot as unknowns
Updating different lines to make the pytest passing all unittest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for putting this together. I think its in the right direction. I have 3 comments and one super minor.
-
It seems that the new specification (setting the number of stages and one top or bottom composition) is solved numerically (through the while loop). That should work, but did you know that there is a much more direct solution by moving up or down the equilibrium-operating line ladder? The numerical approach is what users do when treating the unit as a black-box (https://biosteam.readthedocs.io/en/latest/tutorial/Process_specifications.html#Numerical-specifications). For speed and robustness, let's use the analytical solution for biosteam internals. For example, setting x_bot and N_stages:
yi = xi = x_bot # begin at operating line for i in range(N_stages): # Go Up x = np.array((xi, 1-xi)) T, y = solve_Ty(x, P) # see compute_stages_McCabeThiele yi = y[0] y_stages.append(yi) T_stages.append(T) # Go Right xi = operating_line(yi) x_stages.append(xi)
In
_run_McCabeThiele
you can edit a few lines of code to implement this. For example:try: if self.N_stages is None: compute_stages_McCabeThiele(P, ss, x_stages, y_stages, T_stages, x_m, solve_Ty) else: # Insert new specification code going up/down the equlibrium/operating line ladder except RuntimeError as e: error[0] = e yi = y_stages[-1] xi = rs(yi) x_stages[-1] = xi if xi < 1 else 0.99999 try: if self.N_stages is None: compute_stages_McCabeThiele(P, rs, x_stages, y_stages, T_stages, y_top, solve_Ty) else: # Insert new specification code going up/down the equlibrium/operating line ladder except RuntimeError as e: error[0] = e
-
I did not see any tests for this new specification. Please add tests for both setting x_bot and N_stages and y_top and N_stages. You can make a new file called
biosteam/tests/test_distillation.py
and add the following:def test_binary_distillation_N_stages_and_y_top(): pass # Add tests here def test_binary_distillation_N_stages_and_x_bot(): pass # Add tests here
-
It is possible that the feed composition lies outside the equilibrium/operating ladder. This can happen if there is an azeotrope or if given the number of stages is too small. We will need to check for this by making sure the feed composition is in between the the top and bottoms composition (and raise an error otherwise).
-
Use
variable is None
instead ofvariable == None
, it's actually faster in Python.
By the way, all of BioSTEAM tests are now passing (hooray!), please pull and don't forget to pip install thermosteam==0.51.9
or pull thermosteam if you have it locally.
Thank for the modifications.md
file, that was helpful! I truly appreciate the work and effort you have made in this pull request. I believe users will be happy to see this new feature soon!
Thanks,
Reversing Mccabe Thiele to find compositions giving number of stages