Closed BenPortner closed 5 months ago
Hello @BenPortner! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Line 36:80: E501 line too long (90 > 79 characters) Line 37:80: E501 line too long (94 > 79 characters) Line 38:80: E501 line too long (101 > 79 characters) Line 39:80: E501 line too long (99 > 79 characters)
This pull request introduces 7 alerts when merging a980d8328d7da16abfaa36b677473f6fa3eb4635 into a7fe99e9087c3bfe6e9ead0286aa8983270afa4d - view on LGTM.com
new alerts:
@BenPortner, thank you so much for your great input! I‘ll have a look at it in the upcoming days.
Can we have a short call before you put too much work into fixing all doc tests? :D just want so see, if that is necessary or if we can find a different solution. especially for larger systems I fear that the current convergence checks and helpers might not like the changes.
This had broken with a couple of things, so I am closing it again for now. I like the idea of the generic reactor. And, with the new structure and capabilities of the fluid property module, it might actually be much easier to implement it than before, only have to find the time for it.
Thank you still for putting in the effort!
Requesting comments by @fwitte before finishing the last todos.
Changes overview
AdiabaticConstPressureReactor
: can be used to model gas phase chemical reactions with arbitrary stoichiometry (under adiabatic, constant pressure conditions)tespy.tools.reaction
: implements helper functions to parse reaction formulas, calculate reaction enthalpies, etc.tespy.tools.fluid_properties
overhaul: include enthalpies of formation in order to correctly represent enthalpy changes during chemical reactionsMotivation
Coolprop
, the library which is currently used to calculate fluid properties, uses arbitrary reference points for the calculation of species' enthalpies. Furthermore, the enthalpies do not account for the enthalpy of formation (see https://github.com/CoolProp/CoolProp/issues/1360, https://github.com/CoolProp/CoolProp/issues/58). As a consequence, it is currently very tedious to simulate chemical reactions inTESPy
. The reaction enthalpy must be accounted for manually, leading to hardcoded values and a limited number of implemented reactions. This PR addresses the issue by:tespy.tools.fluid_properties
account for each species' enthalpy of formation, thus making manual accounting for reaction enthalpies obsoleteAdiabaticConstPressureReactor
, which can be used to model arbitrary stoichiometric reactions (in gas phase, under constant pressure and adiabatic conditions)New component:
AdiabaticConstPressureReactor
The new component can be used to model arbitrary chemical gas phase reactions (under adiabatic, constant pressure conditions). The component accepts a reaction formula (e.g.
CH4 + 2 O2 -> CO2 + 2 H2O
) and a yield parameterX
describing how much of the limiting substance is converted (1: complete conversion, 0: no reaction). Example usage:Possible weak points
Additional dependencies
I had to introduce two new libraries in order to realize the changes:
The libraries are lightweight and should not add too much overhead.
Missing data
Not all species, which exist in
Coolprop
are also available inpyromat
. For non-existent species, the enthalpy of formation is assumed to be zero.Large negative enthalpies
The new enthalpy values, which now include the enthalpy of formation, are large negative numbers (e.g. -15e6 for water), which seem a bit unintuitive at first. However, large thermal engineering softwares like ASPEN+ also produce such negative numbers. In fact, with the new changes, ASPEN+ and TESPy seem to produce the same enthalpy values (at least for the examples I tried).
Todos
[x] make sure tests run successfully [ ] fix doctests [x] implement tests for new components [ ] update API documentation [ ] update online documentation [ ] update What's New file