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

Support density and internal energy inputs with tabular backends #2077

Open
wants to merge 54 commits into
base: master
Choose a base branch
from

Conversation

joel-martin
Copy link

Description of the Change

An additional table for density and internal energy has been added to the tabular backends. This allows to update the state
with these inputs. This might be beneficial in numerical codes, such as CFD codes, since these inputs are calculated
from the conservation laws. Although the time to generate the tables and the storage size increase somewhat, the runtime
improves significantly compared to the HEOS calculation.

The detection of the two phase region is challenging because both inputs are not constant in this region. Currently a
complicated detection is circumvented by computing a bounding box around the two phase region. The state is assumed two
phase if it is inside this box. This is illustrated by the figure below.

two_phase

Also support for second partial derivatives has been added to the tabular backends. The TTSE backend uses only
constant values from the nearest grid point, while the bicubic backend actually interpolates the result.

Benefits

  • Density and internal energy inputs supported with tabular backends
  • Faster calculations with these inputs
    • Beneficial for numerical codes with conservation equations
  • Second derivative support with tabular backends
    • Beneficial for gradient based optimization

Possible Drawbacks

  • Slower table generation
  • Larger table storage size

Verification Process

Add test scripts under CoolProp/dev/TabularBackend/

  • Comparison with HEOS compare_tabular_backends.cxx
Parameter           HEOS           Bicubic        TTSE           rel. error Bicubic  rel. error TTSE     
----------------------------------------------------------------------------------------------------
umolar              2500           2500           2500           8.88178e-15         8.88178e-15         
rhomolar            1000           1000           1000           0                   0                   
----------------------------------------------------------------------------------------------------
T                   198.751        198.751        198.751        8.45435e-11         1.65924e-10         
p                   1.67285e+06    1.67285e+06    1.67285e+06    3.67689e-10         5.02631e-08         
hmolar              4172.85        4172.85        4172.85        1.48116e-10         3.78615e-09         
smolar              80.2417        80.2417        80.2417        -7.77573e-08        3.66261e-07         
cpmolar             20.8046        20.8046        20.8046        -5.3104e-09         -6.16183e-07        
cvmolar             12.4969        12.4969        12.4969        7.09829e-09         4.04265e-08         
viscosity           1.51953e-05    1.51936e-05    1.51977e-05    -0.000110454        0.000160563         
conductivity        0.11874        0.118727       0.118759       -0.000109754        0.000160453         
phase               1              1              1              true                true                
speed_sound         839.245        839.245        839.247        -6.03369e-09        2.49135e-06         
dpdT|rhomolar       8413.32        8413.32        8413.29        -2.39145e-08        -3.94378e-06        
d2pdT2|rhomolar     -0.12772       -0.127722      -0.121913      1.4945e-05          -0.0454618          
d2pdUmass2|rhomass  -1.29133e-08   -1.29135e-08   -1.22925e-08   1.79641e-05         -0.0480772          
dUmassdDmass2|P     0              -0             -0             0                   0        
  • Validation plot compare_plots.py

single_phase

Applicable Issues

  • Numerical order of TTSE second partial derivatives
  • Detection of two phase regions

@CLAassistant
Copy link

CLAassistant commented Jan 13, 2022

CLA assistant check
All committers have signed the CLA.

@lgtm-com
Copy link

lgtm-com bot commented Jan 13, 2022

This pull request introduces 2 alerts when merging 85a5b85 into 339a7ac - view on LGTM.com

new alerts:

  • 1 for Unnecessary pass
  • 1 for Unused import

@ibell
Copy link
Contributor

ibell commented Jan 17, 2022

Are you planning on adding the proper two-phase detection for u-rho inputs? I have been working on this problem in my day job and have some pointers. You might also be interested in https://mediatum.ub.tum.de/doc/1633144/1633144.pdf

Also, part of me wonders if it is a good idea to integrate this PR if it is not getting the right two-phase boundary. The box around the phase boundary cuts out a lot of important single-phase states.

C++11 is not yet fully supported in CoolProp, can you please (sadly) remove all the C++11 features.

Finally, please revert the whitespace-only changes.

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.

None yet

3 participants