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

Implement Compressor #103

Merged
merged 10 commits into from
Jul 25, 2022
Merged

Conversation

BenPortner
Copy link
Collaborator

@BenPortner BenPortner commented Jul 21, 2022

This is a draft PR to implement a compressor unit in biosteam.

Questions to @yoelcortes:

Current status

PR implements a new class units.IsentropicCompressor, which compresses a gas to target pressure P with isentropic efficiency eta:

import biosteam as bst
bst.settings.set_thermo(["H2"])
feed = bst.Stream(H2=1, T=25 + 273.15, P=101325, phase='g')
C = bst.units.IsentropicCompressor(ins=feed, P=50e5, eta=0.7)
C.simulate()
C.show()
"""
IsentropicCompressor: U1
ins...
[0] s1
    phase: 'g', T: 298.15 K, P: 101325 Pa
    flow (kmol/hr): H2  1
outs...
[0] s2
    phase: 'g', T: 1151.3 K, P: 5e+06 Pa
    flow (kmol/hr): H2  1
"""
C.results()
"""
Isentropic compressor                               Units       U1
Design              Power                              kW     7.03
                    Isentropic Power                   kW     4.92
                    Outlet Temperature                  K 1.15e+03
                    Isentropic Outlet Temperature       K      901
Total purchase cost                                   USD        0
Utility cost                                       USD/hr        0
"""

Todo

Related issues

@yoelcortes yoelcortes self-requested a review July 21, 2022 16:09
@yoelcortes yoelcortes self-assigned this Jul 21, 2022
@yoelcortes yoelcortes added the enhancement New feature or request label Jul 21, 2022
@yoelcortes
Copy link
Member

yoelcortes commented Jul 21, 2022

Thanks for taking the initiative on this, it is always exciting to see contributions :)

I went ahead and added an entropy solver in thermosteam Mixture and Stream objects, so this works now:

import biosteam as bst
bst.settings.set_thermo(["H2"])
inlet= bst.Stream(H2=1, T=25 + 273.15, P=101325, phase='g')
outlet = inlet.copy()
outlet.P = 50e5
outlet.S = inlet.S
outlet.show()

Output (EDITED AFTER CORRECTION IN THERMOSTEAM):

Stream: s.3
 phase: 'g', T: 901.13 K, P: 5e+06 Pa
 flow (kmol/hr): H2  1

The solver takes advantage of how we know the functional form of the entropy and is the same way we solve for enthalpy.

To account for phase changes, the best way to do so is by allowing VLE objects to accept S as an argument. This way, if we want to run the compressor without assuming it will remain a gas, we can set S and P then set H and P. I can try to get this done, but it would be nice if the user could assume an outlet phase too (to skip phase equilibrium calculations).

For design and costing, checkout Chapter 16 (Cost Accounting and Capital Cost Estimation) of Seider's Product and Process Design Principles (2017 edition). They have a section on compressors.

Please feel free to choose whichever letter (or combination of letters) for the "area naming convention" you prefer. For example, "COMP" is good too (but preferably not more than 4 letters).

I'll be working on phase equilibrium tools to help with implementing the compressor,
Thanks again!

@yoelcortes
Copy link
Member

Update, thermosteam can now solve T-S and P-S VLE specifications:

import biosteam as bst
bst.settings.set_thermo(['Ethanol', 'H2O'])
inlet= bst.Stream(Ethanol=1, H2O=1, T=25 + 273.15, P=101325, phase='g')
outlet = inlet.copy()
outlet.vle(P=2e5, S=inlet.S)
outlet.show('cwt')

Output:

MultiStream: s.12
 phases: ('g', 'l'), T: 375.1 K, P: 200000 Pa
 composition: (g) Ethanol  0.735
                  H2O      0.265
                  -------  61.2 kg/hr
              (l) Ethanol  0.388
                  H2O      0.612
                  -------  2.93 kg/hr

Hope this helps!

@BenPortner
Copy link
Collaborator Author

BenPortner commented Jul 25, 2022

Update @yoelcortes :

  • Phase change: now implemented with the help of a vle = True parameter
  • There is still a problem with the entropy calculation (see Entropy setter sometimes does not work on MultiStream objects thermosteam#68)
  • _cost: now implemented. Unfortunately, I don't have access to Seider's Product and Process Design Principles (2017 edition), so I used Sinnott and Towler's Chemical Engineering Design instead.
  • Can you give me guidance on how to apply the CEPCI (chemical engineering plant cost index)? Is this already implement somewhere?
  • I went ahead and reserved the letter K for compressors in the area naming convention (yes, I am German 😝)

@yoelcortes
Copy link
Member

yoelcortes commented Jul 25, 2022

Hi Ben,

Excellent work! I like K for compressor jaja

For the chemical engineering price index, you can use:

 cost["Compressor"] = bst.CE / 509.7 * (a + b*S**n)

I prefer to write all cost equations in the original CEPCI, then adjust it in the code at run time, this way it is easy to compare the code with literature and spot number typos in the code.

For costing, I believe the bare module cost factor should be around 2.15. We should also add some material/design factors (they change with electric motor, steam turbine, or gas turbine). Does your reference include any of these?

For the case when the power is too high, would having multiple compressors in series make sense? We can also let the user enforce a compressor type. I would be happy to implement this.

At this point, I would be happy to accept the pull request. I can address whatever is left (including bare module, design, and material factors; CEPCI; and units in series). Whenever you are ready, just like my comment and I will go ahead with the pull.

Thanks!

@BenPortner
Copy link
Collaborator Author

BenPortner commented Jul 25, 2022

Hi @yoelcortes,

I just finished the last todos:

  • CEPCI implemented according to your formula
  • added example to the in-code documentation

Open todos:

  • Bare module/material costs: Unfortunately, my reference does not quote bare module cost factors or material/design factors. I'll leave these to you. Sorry that I can't help you more here.
  • Compressors in series: These would absolutely make sense (multiple stages with intermittent cooling are generally used to approach the isothermal compression limit, which is the most efficient type of compression). However, I recommend implementing this in a separate class. It is not trivial to determine how the total pressure change is to be split among the stages for optimal results. I might try to implement this, so you can focus on other important stuff?
  • It would be nice to have classes for isothermal and polytropic compression, too. I hope I'll get around to implementing these.
  • There are a couple of errors which are not related to the new changes implemented in this PR (see checks in the build pipeline). It would be nice to fix these so that contributors know if they broke something or if stuff had already been broken.

I'll mark this PR as ready for review. Feel free to merge any time :)

@BenPortner BenPortner marked this pull request as ready for review July 25, 2022 14:56
@yoelcortes
Copy link
Member

Sounds good, I'll focus on costing. Once it's done I'll add the compressor to the docs API.

I'll also take care of failing tests and make sure they all pass locally. Unfortunately, github has some sort of cache that makes CI tests run on old installations of thermosteam and biorefineries. So I'll need to figure out how to fix the CI for this (maybe move to another CI platform? Not sure yet).

Thanks!

@yoelcortes yoelcortes merged commit 689f0e1 into BioSTEAMDevelopmentGroup:master Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants