Empirical fuel manipulation

Evaluating mean fluid properties

In this note we show how to use Cantera to retrieve mixture properties for use in external simulations. This approach should be used only when composition dependency may be neglected or real-time evaluation becomes to expensive.

using WallyToolbox
using PyCanteraTools

using CairoMakie
using Polynomials
using PythonCall

const ct = pyimport("cantera")
const np = pyimport("numpy")
    CondaPkg Found dependencies: /home/runner/.julia/packages/PythonCall/Nr75f/CondaPkg.toml
    CondaPkg Found dependencies: /home/runner/work/WallyToolbox.jl/WallyToolbox.jl/CondaPkg.toml
    CondaPkg Resolving changes
             + cantera
             + libstdcxx-ng
             + matplotlib
             + numpy
             + openssl
             + pandas
             + python
             + pyvista
             + scipy
             + seaborn
    CondaPkg Creating environment
             │ /home/runner/.julia/artifacts/7973f2c7725e2d0eef7a95159454c4145f0945a2/bin/micromamba
             │ -r /home/runner/.julia/scratchspaces/0b3b1443-0f03-428d-bdfb-f27f9c1191ea/root
             │ create
             │ -y
             │ -p /home/runner/work/WallyToolbox.jl/WallyToolbox.jl/docs/.CondaPkg/env
             │ --override-channels
             │ --no-channel-priority
             │ cantera[version='*']
             │ libstdcxx-ng[version='>=3.4,<13.0']
             │ matplotlib[version='*']
             │ numpy[version='*']
             │ openssl[version='>=3, <3.1']
             │ pandas[version='*']
             │ python[version='>=3.8,<4',channel='conda-forge',build='*cpython*']
             │ pyvista[version='*']
             │ scipy[version='*']
             │ seaborn[version='*']
             └ -c conda-forge

Transaction

  Prefix: /home/runner/work/WallyToolbox.jl/WallyToolbox.jl/docs/.CondaPkg/env

  Updating specs:

   - cantera=*
   - libstdcxx-ng[version='>=3.4,<13.0']
   - matplotlib=*
   - numpy=*
   - openssl[version='>=3, <3.1']
   - pandas=*
   - conda-forge::python[version='>=3.8,<4',build=*cpython*]
   - pyvista=*
   - scipy=*
   - seaborn=*


  Package                           Version  Build                    Channel           Size
──────────────────────────────────────────────────────────────────────────────────────────────
  Install:
──────────────────────────────────────────────────────────────────────────────────────────────

  + _libgcc_mutex                       0.1  conda_forge              conda-forge     Cached
  + python_abi                         3.11  5_cp311                  conda-forge     Cached
  + ca-certificates              2024.12.14  hbcca054_0               conda-forge      157kB
  + utfcpp                            4.0.6  h005c6e1_0               conda-forge     Cached
  + libgfortran5                     13.2.0  ha4646dd_0               conda-forge     Cached
  + ld_impl_linux-64                   2.43  h712a8e2_2               conda-forge     Cached
  + libgomp                          12.4.0  h77fa898_1               conda-forge     Cached
  + libgfortran-ng                   13.2.0  h69a702a_0               conda-forge     Cached
  + _openmp_mutex                       4.5  2_gnu                    conda-forge     Cached
  + libgcc                           12.4.0  h77fa898_1               conda-forge     Cached
  + libgcc-ng                        12.4.0  h69a702a_1               conda-forge     Cached
  + libstdcxx                        12.4.0  hc0a3c3a_1               conda-forge     Cached
  + metis                             5.1.0  h59595ed_1007            conda-forge     Cached
  + xorg-libxdmcp                     1.1.3  h7f98852_0               conda-forge     Cached
  + pthread-stubs                       0.4  h36c2ea0_1001            conda-forge     Cached
  + xorg-renderproto                 0.11.1  h7f98852_1002            conda-forge     Cached
  + libunistring                     0.9.10  h7f98852_0               conda-forge     Cached
  + xorg-xf86vidmodeproto             2.3.1  h7f98852_1002            conda-forge     Cached
  + xorg-xproto                      7.0.31  h7f98852_1007            conda-forge     Cached
  + xorg-libice                      1.0.10  h7f98852_0               conda-forge     Cached
  + xorg-kbproto                      1.0.7  h7f98852_1002            conda-forge     Cached
  + libev                              4.33  hd590300_2               conda-forge     Cached
  + c-ares                           1.33.0  ha66036c_0               conda-forge     Cached
  + libpciaccess                       0.18  hd590300_0               conda-forge     Cached
  + attr                              2.5.1  h166bdaf_1               conda-forge     Cached
  + x264                         1!164.3095  h166bdaf_2               conda-forge     Cached
  + nettle                            3.9.1  h7ab15ed_0               conda-forge     Cached
  + libtasn1                         4.19.0  h166bdaf_0               conda-forge     Cached
  + libgettextpo                     0.22.5  he02047a_3               conda-forge     Cached
  + gettext-tools                    0.22.5  he02047a_3               conda-forge     Cached
  + libopus                           1.3.1  h7f98852_1               conda-forge     Cached
  + lame                              3.100  h166bdaf_1003            conda-forge     Cached
  + xkeyboard-config                   2.38  h0b41bf4_0               conda-forge     Cached
  + libiconv                           1.17  hd590300_2               conda-forge     Cached
  + libtool                           2.4.7  he02047a_1               conda-forge     Cached
  + libudev1                            253  h0b41bf4_0               conda-forge     Cached
  + gstreamer-orc                    0.4.39  h4bc722e_0               conda-forge     Cached
  + libnsl                            2.0.1  hd590300_0               conda-forge     Cached
  + libffi                            3.4.2  h7f98852_5               conda-forge     Cached
  + bzip2                             1.0.8  h4bc722e_7               conda-forge     Cached
  + yaml                              0.2.5  h7f98852_2               conda-forge     Cached
  + ncurses                             6.5  he02047a_1               conda-forge     Cached
  + xorg-xextproto                    7.3.0  h0b41bf4_1003            conda-forge     Cached
  + libogg                            1.3.5  h4ab18f5_0               conda-forge     Cached
  + xorg-libxau                      1.0.11  hd590300_0               conda-forge     Cached
  + libuuid                          2.38.1  h0b41bf4_0               conda-forge     Cached
  + libexpat                          2.6.2  h59595ed_0               conda-forge     Cached
  + libbrotlicommon                   1.1.0  hd590300_1               conda-forge     Cached
  + libopenblas                      0.3.27  pthreads_hac2b453_1      conda-forge     Cached
  + libjpeg-turbo                   2.1.5.1  hd590300_1               conda-forge     Cached
  + keyutils                          1.6.1  h166bdaf_0               conda-forge     Cached
  + alsa-lib                          1.2.8  h166bdaf_0               conda-forge     Cached
  + libzlib                           1.3.1  h4ab18f5_1               conda-forge     Cached
  + libwebp-base                      1.4.0  hd590300_0               conda-forge     Cached
  + libdeflate                         1.18  h0b41bf4_0               conda-forge     Cached
  + xz                                5.2.6  h166bdaf_0               conda-forge     Cached
  + openssl                          3.0.14  h4ab18f5_0               conda-forge     Cached
  + libstdcxx-ng                     12.4.0  h4852527_1               conda-forge     Cached
  + libdrm                          2.4.122  h4ab18f5_0               conda-forge     Cached
  + libcap                             2.66  ha37c62d_0               conda-forge     Cached
  + libgettextpo-devel               0.22.5  he02047a_3               conda-forge     Cached
  + p11-kit                          0.24.1  hc5aa10d_0               conda-forge     Cached
  + libedit                    3.1.20191231  he28a2e2_2               conda-forge     Cached
  + readline                            8.2  h8228510_1               conda-forge     Cached
  + xorg-fixesproto                     5.0  h7f98852_1002            conda-forge     Cached
  + libxcb                             1.13  h7f98852_1004            conda-forge     Cached
  + xorg-libsm                        1.2.3  hd9c2040_1000            conda-forge     Cached
  + expat                             2.6.2  h59595ed_0               conda-forge     Cached
  + libbrotlienc                      1.1.0  hd590300_1               conda-forge     Cached
  + libbrotlidec                      1.1.0  hd590300_1               conda-forge     Cached
  + libblas                           3.9.0  24_linux64_openblas      conda-forge     Cached
  + pcre2                             10.44  hba22ea6_2               conda-forge     Cached
  + libsqlite                        3.46.0  hde9e2c9_0               conda-forge     Cached
  + zlib                              1.3.1  h4ab18f5_1               conda-forge     Cached
  + tk                               8.6.13  noxft_h4845f30_101       conda-forge     Cached
  + libpng                           1.6.43  h2797004_0               conda-forge     Cached
  + libzip                            1.9.2  hc929e4a_1               conda-forge     Cached
  + libssh2                          1.10.0  hf14f497_3               conda-forge     Cached
  + libevent                         2.1.10  h28343ad_4               conda-forge     Cached
  + libdb                            6.2.32  h9c3ff4c_0               conda-forge     Cached
  + libvorbis                         1.3.7  h9c3ff4c_0               conda-forge     Cached
  + eigen                             3.4.0  h00ab1b0_0               conda-forge     Cached
  + libglu                            9.0.0  he1b5a44_1001            conda-forge     Cached
  + snappy                            1.2.1  ha2e4443_0               conda-forge     Cached
  + x265                                3.5  h924138e_3               conda-forge     Cached
  + openh264                          2.3.1  hcb278e6_2               conda-forge     Cached
  + libvpx                           1.11.0  h9c3ff4c_3               conda-forge     Cached
  + gmp                               6.3.0  hac33072_2               conda-forge     Cached
  + libaec                            1.1.3  h59595ed_0               conda-forge     Cached
  + libnghttp2                       1.52.0  h61bc06f_0               conda-forge     Cached
  + libasprintf                      0.22.5  he8f35ee_3               conda-forge     Cached
  + mpg123                           1.32.6  h59595ed_0               conda-forge     Cached
  + fftw                             3.3.10  nompi_hf1063bd_110       conda-forge     Cached
  + hdf4                             4.2.15  h501b40f_6               conda-forge     Cached
  + pugixml                          1.11.4  h59595ed_1               conda-forge     Cached
  + nlohmann_json                    3.11.3  he02047a_1               conda-forge     Cached
  + lz4-c                             1.9.4  hcb278e6_0               conda-forge     Cached
  + jsoncpp                           1.9.5  h4bd325d_1               conda-forge     Cached
  + svt-av1                           1.4.1  hcb278e6_0               conda-forge     Cached
  + aom                               3.5.0  h27087fc_0               conda-forge     Cached
  + double-conversion                 3.2.0  h27087fc_1               conda-forge     Cached
  + pixman                           0.43.2  h59595ed_0               conda-forge     Cached
  + yaml-cpp                          0.7.0  h59595ed_3               conda-forge     Cached
  + graphite2                        1.3.13  h59595ed_1003            conda-forge     Cached
  + zstd                              1.5.6  ha6fb4c9_0               conda-forge     Cached
  + mysql-common                     8.0.32  ha901b37_0               conda-forge     Cached
  + nspr                               4.35  h27087fc_0               conda-forge     Cached
  + icu                                70.1  h27087fc_0               conda-forge     Cached
  + qhull                            2020.2  h434a139_5               conda-forge     Cached
  + lerc                              4.0.0  h27087fc_0               conda-forge     Cached
  + fmt                               9.1.0  h924138e_0               conda-forge     Cached
  + krb5                             1.20.1  h81ceb04_0               conda-forge     Cached
  + xcb-util-wm                       0.4.1  h516909a_0               conda-forge     Cached
  + xcb-util-keysyms                  0.4.0  h516909a_0               conda-forge     Cached
  + xcb-util                          0.4.0  h516909a_0               conda-forge     Cached
  + xorg-libx11                       1.8.4  h0b41bf4_0               conda-forge     Cached
  + xcb-util-renderutil               0.3.9  h166bdaf_0               conda-forge     Cached
  + brotli-bin                        1.1.0  hd590300_1               conda-forge     Cached
  + libcblas                          3.9.0  24_linux64_openblas      conda-forge     Cached
  + liblapack                         3.9.0  24_linux64_openblas      conda-forge     Cached
  + libglib                          2.80.3  h315aac3_2               conda-forge     Cached
  + sqlite                           3.46.0  h6d4b2fc_0               conda-forge     Cached
  + gl2ps                             1.4.2  hae5d5c5_1               conda-forge     Cached
  + freetype                         2.12.1  h267a509_2               conda-forge     Cached
  + jack                             1.9.22  h11f4161_0               conda-forge     Cached
  + libtheora                         1.1.1  h4ab18f5_1006            conda-forge     Cached
  + mpfr                              4.2.1  h38ae2d0_2               conda-forge     Cached
  + libasprintf-devel                0.22.5  he8f35ee_3               conda-forge     Cached
  + blosc                            1.21.6  hef167b5_0               conda-forge     Cached
  + mysql-libs                       8.0.32  hd7da12d_0               conda-forge     Cached
  + nss                               3.103  h593d115_0               conda-forge     Cached
  + libxml2                          2.10.3  hca2bb57_4               conda-forge     Cached
  + libtiff                           4.5.1  h8b53f26_1               conda-forge     Cached
  + libcurl                          7.88.1  hdc1c0ab_0               conda-forge     Cached
  + libcups                           2.3.3  h36d4200_3               conda-forge     Cached
  + libpq                              15.2  hb675445_0               conda-forge     Cached
  + xcb-util-image                    0.4.0  h166bdaf_0               conda-forge     Cached
  + xorg-libxfixes                    5.0.3  h7f98852_1004            conda-forge     Cached
  + xorg-libxt                        1.3.0  hd590300_0               conda-forge     Cached
  + xorg-libxext                      1.3.4  h0b41bf4_2               conda-forge     Cached
  + xorg-libxrender                  0.9.10  h7f98852_1003            conda-forge     Cached
  + brotli                            1.1.0  hd590300_1               conda-forge     Cached
  + glib-tools                       2.80.3  h8fdd7da_2               conda-forge     Cached
  + dbus                             1.13.6  h5008d03_3               conda-forge     Cached
  + fontconfig                       2.14.2  h14ed4e7_0               conda-forge     Cached
  + gettext                          0.22.5  he02047a_3               conda-forge     Cached
  + libllvm15                        15.0.7  hadd5161_1               conda-forge     Cached
  + libxkbcommon                      1.5.0  h79f4944_1               conda-forge     Cached
  + libhwloc                          2.9.1  hd6dc26d_0               conda-forge     Cached
  + lcms2                              2.15  haa2dc70_1               conda-forge     Cached
  + openjpeg                          2.5.0  hfec8fc6_2               conda-forge     Cached
  + proj                              9.1.1  h8ffa02c_2               conda-forge     Cached
  + curl                             7.88.1  hdc1c0ab_0               conda-forge     Cached
  + hdf5                             1.14.0  nompi_hb72d44e_103       conda-forge     Cached
  + libva                            2.18.0  h0b41bf4_0               conda-forge     Cached
  + glew                              2.1.0  h9c3ff4c_2               conda-forge     Cached
  + libidn2                           2.3.7  hd590300_0               conda-forge     Cached
  + libgpg-error                       1.50  h4f305b6_0               conda-forge     Cached
  + libflac                           1.4.3  h59595ed_0               conda-forge     Cached
  + libclang13                       15.0.7  default_h5d6823c_5       conda-forge     Cached
  + tbb                            2021.9.0  hf52228f_0               conda-forge     Cached
  + libnetcdf                         4.9.2  nompi_hf3f8848_103       conda-forge     Cached
  + gnutls                            3.7.9  hb077bed_0               conda-forge     Cached
  + libgcrypt                        1.11.0  h4ab18f5_1               conda-forge     Cached
  + libsndfile                        1.2.2  hc60ed4a_1               conda-forge     Cached
  + libclang                         15.0.7  default_h127d8a8_5       conda-forge     Cached
  + suitesparse                      5.10.1  h9e50725_1               conda-forge     Cached
  + tbb-devel                      2021.9.0  hf52228f_0               conda-forge     Cached
  + libsystemd0                         252  h2a991cd_0               conda-forge     Cached
  + sundials                          5.7.0  h558c624_0               conda-forge     Cached
  + pulseaudio                         16.1  ha8d29e2_1               conda-forge     Cached
  + font-ttf-dejavu-sans-mono          2.37  hab24e00_0               conda-forge     Cached
  + font-ttf-inconsolata              3.000  h77eed37_0               conda-forge     Cached
  + font-ttf-source-code-pro          2.038  h77eed37_0               conda-forge     Cached
  + font-ttf-ubuntu                    0.83  h77eed37_3               conda-forge     Cached
  + tzdata                            2024b  hc8b5060_0               conda-forge     Cached
  + fonts-conda-forge                     1  0                        conda-forge     Cached
  + fonts-conda-ecosystem                 1  0                        conda-forge     Cached
  + python                           3.11.0  he550d4f_1_cpython       conda-forge     Cached
  + ffmpeg                            5.1.2  gpl_h8dda1f0_106         conda-forge     Cached
  + cairo                            1.16.0  ha61ee94_1012            conda-forge     Cached
  + harfbuzz                          6.0.0  h8e241bc_0               conda-forge     Cached
  + wheel                            0.45.1  pyhd8ed1ab_1             conda-forge     Cached
  + setuptools                       75.6.0  pyhff2d567_1             conda-forge     Cached
  + pip                              24.3.1  pyh8b19718_0             conda-forge     Cached
  + pycparser                          2.22  pyh29332c3_1             conda-forge     Cached
  + hyperframe                        6.0.1  pyhd8ed1ab_1             conda-forge     Cached
  + hpack                             4.0.0  pyhd8ed1ab_1             conda-forge     Cached
  + pysocks                           1.7.1  pyha55dd90_7             conda-forge     Cached
  + aiohappyeyeballs                  2.4.4  pyhd8ed1ab_1             conda-forge     Cached
  + attrs                            24.2.0  pyh71513ae_1             conda-forge     Cached
  + cached_property                   1.5.2  pyha770c72_1             conda-forge     Cached
  + charset-normalizer                3.4.0  pyhd8ed1ab_1             conda-forge     Cached
  + idna                               3.10  pyhd8ed1ab_1             conda-forge     Cached
  + tomli                             2.2.1  pyhd8ed1ab_1             conda-forge     Cached
  + ply                                3.11  pyhd8ed1ab_3             conda-forge     Cached
  + platformdirs                      4.3.6  pyhd8ed1ab_1             conda-forge     Cached
  + six                              1.17.0  pyhd8ed1ab_0             conda-forge     Cached
  + scooby                           0.10.0  pyhd8ed1ab_0             conda-forge     Cached
  + typing_extensions                4.12.2  pyha770c72_1             conda-forge     Cached
  + munkres                           1.1.4  pyh9f0ad1d_0             conda-forge     Cached
  + toml                             0.10.2  pyhd8ed1ab_1             conda-forge     Cached
  + pyparsing                         3.2.0  pyhd8ed1ab_2             conda-forge     Cached
  + packaging                          24.2  pyhd8ed1ab_2             conda-forge     Cached
  + cycler                           0.12.1  pyhd8ed1ab_1             conda-forge     Cached
  + certifi                       2024.8.30  pyhd8ed1ab_0             conda-forge     Cached
  + pytz                             2024.2  pyhd8ed1ab_1             conda-forge     Cached
  + python-tzdata                    2024.2  pyhd8ed1ab_1             conda-forge     Cached
  + h2                                4.1.0  pyhd8ed1ab_1             conda-forge     Cached
  + cached-property                   1.5.2  hd8ed1ab_1               conda-forge     Cached
  + python-dateutil             2.9.0.post0  pyhff2d567_1             conda-forge     Cached
  + typing-extensions                4.12.2  hd8ed1ab_1               conda-forge     Cached
  + brotli-python                     1.1.0  py311hb755f60_1          conda-forge     Cached
  + multidict                         6.0.5  py311h459d7ec_0          conda-forge     Cached
  + frozenlist                        1.4.1  py311h459d7ec_0          conda-forge     Cached
  + msgpack-python                    1.0.8  py311h52f7536_0          conda-forge     Cached
  + loguru                            0.7.2  py311h38be061_2          conda-forge     Cached
  + ruamel_yaml                     0.15.80  py311h459d7ec_1009       conda-forge     Cached
  + tornado                           6.4.1  py311h331c9d8_0          conda-forge     Cached
  + kiwisolver                        1.4.5  py311h9547e67_1          conda-forge     Cached
  + pillow                            9.5.0  py311h573f0d3_0          conda-forge     Cached
  + numpy                            1.26.4  py311h64a7726_0          conda-forge     Cached
  + cffi                             1.17.0  py311ha8e6434_0          conda-forge     Cached
  + fonttools                        4.53.1  py311h61187de_0          conda-forge     Cached
  + glib                             2.80.3  h315aac3_2               conda-forge     Cached
  + sip                              6.7.12  py311hb755f60_0          conda-forge     Cached
  + yarl                              1.9.4  py311h459d7ec_0          conda-forge     Cached
  + libcantera                        2.6.0  h587f4e0_5               conda-forge     Cached
  + h5py                              3.9.0  nompi_py311h26d1283_100  conda-forge     Cached
  + contourpy                         1.2.1  py311h9547e67_0          conda-forge     Cached
  + scipy                            1.14.0  py311h0a5b728_2          conda-forge     Cached
  + pandas                            2.2.2  py311h14de704_1          conda-forge     Cached
  + zstandard                        0.23.0  py311h5cd10c7_0          conda-forge     Cached
  + gstreamer                        1.22.0  h25f0c4b_2               conda-forge     Cached
  + pyqt5-sip                       12.12.2  py311hb755f60_5          conda-forge     Cached
  + cantera                           2.6.0  py311ha1fc806_5          conda-forge     Cached
  + matplotlib-base                   3.9.1  py311h74b4f7c_2          conda-forge     Cached
  + gst-plugins-base                 1.22.0  h4243ec0_2               conda-forge     Cached
  + qt-main                          5.15.8  h67dfc38_7               conda-forge     Cached
  + pyqt                             5.15.9  py311hf0fb5b6_5          conda-forge     Cached
  + matplotlib                        3.9.1  py311h38be061_1          conda-forge     Cached
  + aiosignal                         1.3.1  pyhd8ed1ab_1             conda-forge     Cached
  + patsy                             1.0.1  pyhd8ed1ab_1             conda-forge     Cached
  + urllib3                           2.2.3  pyhd8ed1ab_1             conda-forge     Cached
  + seaborn-base                     0.13.2  pyhd8ed1ab_3             conda-forge     Cached
  + requests                         2.32.3  pyhd8ed1ab_1             conda-forge     Cached
  + pooch                             1.8.2  pyhd8ed1ab_1             conda-forge     Cached
  + aiohttp                          3.10.5  py311h61187de_0          conda-forge     Cached
  + statsmodels                      0.14.2  py311h18e1886_0          conda-forge     Cached
  + wslink                            2.2.1  pyhd8ed1ab_1             conda-forge     Cached
  + seaborn                          0.13.2  hd8ed1ab_3               conda-forge     Cached
  + vtk                               9.2.6  qt_py311he2e9dde_203     conda-forge     Cached
  + pyvista                          0.44.2  pyhd8ed1ab_0             conda-forge     Cached

  Summary:

  Install: 253 packages

  Total download: 157kB

──────────────────────────────────────────────────────────────────────────────────────────────



Transaction starting
Linking _libgcc_mutex-0.1-conda_forge
Linking python_abi-3.11-5_cp311
Linking ca-certificates-2024.12.14-hbcca054_0
Linking utfcpp-4.0.6-h005c6e1_0
Linking libgfortran5-13.2.0-ha4646dd_0
Linking ld_impl_linux-64-2.43-h712a8e2_2
Linking libgomp-12.4.0-h77fa898_1
Linking libgfortran-ng-13.2.0-h69a702a_0
Linking _openmp_mutex-4.5-2_gnu
Linking libgcc-12.4.0-h77fa898_1
Linking libgcc-ng-12.4.0-h69a702a_1
Linking libstdcxx-12.4.0-hc0a3c3a_1
Linking metis-5.1.0-h59595ed_1007
Linking xorg-libxdmcp-1.1.3-h7f98852_0
Linking pthread-stubs-0.4-h36c2ea0_1001
Linking xorg-renderproto-0.11.1-h7f98852_1002
Linking libunistring-0.9.10-h7f98852_0
Linking xorg-xf86vidmodeproto-2.3.1-h7f98852_1002
Linking xorg-xproto-7.0.31-h7f98852_1007
Linking xorg-libice-1.0.10-h7f98852_0
Linking xorg-kbproto-1.0.7-h7f98852_1002
Linking libev-4.33-hd590300_2
Linking c-ares-1.33.0-ha66036c_0
Linking libpciaccess-0.18-hd590300_0
Linking attr-2.5.1-h166bdaf_1
Linking x264-1!164.3095-h166bdaf_2
Linking nettle-3.9.1-h7ab15ed_0
Linking libtasn1-4.19.0-h166bdaf_0
Linking libgettextpo-0.22.5-he02047a_3
Linking gettext-tools-0.22.5-he02047a_3
Linking libopus-1.3.1-h7f98852_1
Linking lame-3.100-h166bdaf_1003
Linking xkeyboard-config-2.38-h0b41bf4_0
Linking libiconv-1.17-hd590300_2
Linking libtool-2.4.7-he02047a_1
Linking libudev1-253-h0b41bf4_0
Linking gstreamer-orc-0.4.39-h4bc722e_0
Linking libnsl-2.0.1-hd590300_0
Linking libffi-3.4.2-h7f98852_5
Linking bzip2-1.0.8-h4bc722e_7
Linking yaml-0.2.5-h7f98852_2
Linking ncurses-6.5-he02047a_1
Linking xorg-xextproto-7.3.0-h0b41bf4_1003
Linking libogg-1.3.5-h4ab18f5_0
Linking xorg-libxau-1.0.11-hd590300_0
Linking libuuid-2.38.1-h0b41bf4_0
Linking libexpat-2.6.2-h59595ed_0
Linking libbrotlicommon-1.1.0-hd590300_1
Linking libopenblas-0.3.27-pthreads_hac2b453_1
Linking libjpeg-turbo-2.1.5.1-hd590300_1
Linking keyutils-1.6.1-h166bdaf_0
Linking alsa-lib-1.2.8-h166bdaf_0
Linking libzlib-1.3.1-h4ab18f5_1
Linking libwebp-base-1.4.0-hd590300_0
Linking libdeflate-1.18-h0b41bf4_0
Linking xz-5.2.6-h166bdaf_0
Linking openssl-3.0.14-h4ab18f5_0
Linking libstdcxx-ng-12.4.0-h4852527_1
Linking libdrm-2.4.122-h4ab18f5_0
Linking libcap-2.66-ha37c62d_0
Linking libgettextpo-devel-0.22.5-he02047a_3
Linking p11-kit-0.24.1-hc5aa10d_0
Linking libedit-3.1.20191231-he28a2e2_2
Linking readline-8.2-h8228510_1
Linking xorg-fixesproto-5.0-h7f98852_1002
Linking libxcb-1.13-h7f98852_1004
Linking xorg-libsm-1.2.3-hd9c2040_1000
Linking expat-2.6.2-h59595ed_0
Linking libbrotlienc-1.1.0-hd590300_1
Linking libbrotlidec-1.1.0-hd590300_1
Linking libblas-3.9.0-24_linux64_openblas
Linking pcre2-10.44-hba22ea6_2
Linking libsqlite-3.46.0-hde9e2c9_0
Linking zlib-1.3.1-h4ab18f5_1
Linking tk-8.6.13-noxft_h4845f30_101
Linking libpng-1.6.43-h2797004_0
Linking libzip-1.9.2-hc929e4a_1
Linking libssh2-1.10.0-hf14f497_3
Linking libevent-2.1.10-h28343ad_4
Linking libdb-6.2.32-h9c3ff4c_0
Linking libvorbis-1.3.7-h9c3ff4c_0
Linking eigen-3.4.0-h00ab1b0_0
Linking libglu-9.0.0-he1b5a44_1001
Linking snappy-1.2.1-ha2e4443_0
Linking x265-3.5-h924138e_3
Linking openh264-2.3.1-hcb278e6_2
Linking libvpx-1.11.0-h9c3ff4c_3
Linking gmp-6.3.0-hac33072_2
Linking libaec-1.1.3-h59595ed_0
Linking libnghttp2-1.52.0-h61bc06f_0
Linking libasprintf-0.22.5-he8f35ee_3
Linking mpg123-1.32.6-h59595ed_0
Linking fftw-3.3.10-nompi_hf1063bd_110
Linking hdf4-4.2.15-h501b40f_6
Linking pugixml-1.11.4-h59595ed_1
Linking nlohmann_json-3.11.3-he02047a_1
Linking lz4-c-1.9.4-hcb278e6_0
Linking jsoncpp-1.9.5-h4bd325d_1
Linking svt-av1-1.4.1-hcb278e6_0
Linking aom-3.5.0-h27087fc_0
Linking double-conversion-3.2.0-h27087fc_1
Linking pixman-0.43.2-h59595ed_0
Linking yaml-cpp-0.7.0-h59595ed_3
Linking graphite2-1.3.13-h59595ed_1003
Linking zstd-1.5.6-ha6fb4c9_0
Linking mysql-common-8.0.32-ha901b37_0
Linking nspr-4.35-h27087fc_0
Linking icu-70.1-h27087fc_0
Linking qhull-2020.2-h434a139_5
Linking lerc-4.0.0-h27087fc_0
Linking fmt-9.1.0-h924138e_0
Linking krb5-1.20.1-h81ceb04_0
Linking xcb-util-wm-0.4.1-h516909a_0
Linking xcb-util-keysyms-0.4.0-h516909a_0
Linking xcb-util-0.4.0-h516909a_0
Linking xorg-libx11-1.8.4-h0b41bf4_0
Linking xcb-util-renderutil-0.3.9-h166bdaf_0
Linking brotli-bin-1.1.0-hd590300_1
Linking libcblas-3.9.0-24_linux64_openblas
Linking liblapack-3.9.0-24_linux64_openblas
Linking libglib-2.80.3-h315aac3_2
Linking sqlite-3.46.0-h6d4b2fc_0
Linking gl2ps-1.4.2-hae5d5c5_1
Linking freetype-2.12.1-h267a509_2
Linking jack-1.9.22-h11f4161_0
Linking libtheora-1.1.1-h4ab18f5_1006
Linking mpfr-4.2.1-h38ae2d0_2
Linking libasprintf-devel-0.22.5-he8f35ee_3
Linking blosc-1.21.6-hef167b5_0
Linking mysql-libs-8.0.32-hd7da12d_0
Linking nss-3.103-h593d115_0
Linking libxml2-2.10.3-hca2bb57_4
Linking libtiff-4.5.1-h8b53f26_1
Linking libcurl-7.88.1-hdc1c0ab_0
Linking libcups-2.3.3-h36d4200_3
Linking libpq-15.2-hb675445_0
Linking xcb-util-image-0.4.0-h166bdaf_0
Linking xorg-libxfixes-5.0.3-h7f98852_1004
Linking xorg-libxt-1.3.0-hd590300_0
Linking xorg-libxext-1.3.4-h0b41bf4_2
Linking xorg-libxrender-0.9.10-h7f98852_1003
Linking brotli-1.1.0-hd590300_1
Linking glib-tools-2.80.3-h8fdd7da_2
Linking dbus-1.13.6-h5008d03_3
Linking fontconfig-2.14.2-h14ed4e7_0
Linking gettext-0.22.5-he02047a_3
Linking libllvm15-15.0.7-hadd5161_1
Linking libxkbcommon-1.5.0-h79f4944_1
Linking libhwloc-2.9.1-hd6dc26d_0
Linking lcms2-2.15-haa2dc70_1
Linking openjpeg-2.5.0-hfec8fc6_2
Linking proj-9.1.1-h8ffa02c_2
Linking curl-7.88.1-hdc1c0ab_0
Linking hdf5-1.14.0-nompi_hb72d44e_103
Linking libva-2.18.0-h0b41bf4_0
Linking glew-2.1.0-h9c3ff4c_2
Linking libidn2-2.3.7-hd590300_0
Linking libgpg-error-1.50-h4f305b6_0
Linking libflac-1.4.3-h59595ed_0
Linking libclang13-15.0.7-default_h5d6823c_5
Linking tbb-2021.9.0-hf52228f_0
Linking libnetcdf-4.9.2-nompi_hf3f8848_103
Linking gnutls-3.7.9-hb077bed_0
Linking libgcrypt-1.11.0-h4ab18f5_1
Linking libsndfile-1.2.2-hc60ed4a_1
Linking libclang-15.0.7-default_h127d8a8_5
Linking suitesparse-5.10.1-h9e50725_1
Linking tbb-devel-2021.9.0-hf52228f_0
Linking libsystemd0-252-h2a991cd_0
Linking sundials-5.7.0-h558c624_0
Linking pulseaudio-16.1-ha8d29e2_1
Linking font-ttf-dejavu-sans-mono-2.37-hab24e00_0
Linking font-ttf-inconsolata-3.000-h77eed37_0
Linking font-ttf-source-code-pro-2.038-h77eed37_0
Linking font-ttf-ubuntu-0.83-h77eed37_3
Linking tzdata-2024b-hc8b5060_0
Linking fonts-conda-forge-1-0
Linking fonts-conda-ecosystem-1-0
Linking python-3.11.0-he550d4f_1_cpython
Linking ffmpeg-5.1.2-gpl_h8dda1f0_106
Linking cairo-1.16.0-ha61ee94_1012
Linking harfbuzz-6.0.0-h8e241bc_0
Linking wheel-0.45.1-pyhd8ed1ab_1
Linking setuptools-75.6.0-pyhff2d567_1
Linking pip-24.3.1-pyh8b19718_0
Linking pycparser-2.22-pyh29332c3_1
Linking hyperframe-6.0.1-pyhd8ed1ab_1
Linking hpack-4.0.0-pyhd8ed1ab_1
Linking pysocks-1.7.1-pyha55dd90_7
Linking aiohappyeyeballs-2.4.4-pyhd8ed1ab_1
Linking attrs-24.2.0-pyh71513ae_1
Linking cached_property-1.5.2-pyha770c72_1
Linking charset-normalizer-3.4.0-pyhd8ed1ab_1
Linking idna-3.10-pyhd8ed1ab_1
Linking tomli-2.2.1-pyhd8ed1ab_1
Linking ply-3.11-pyhd8ed1ab_3
Linking platformdirs-4.3.6-pyhd8ed1ab_1
Linking six-1.17.0-pyhd8ed1ab_0
Linking scooby-0.10.0-pyhd8ed1ab_0
Linking typing_extensions-4.12.2-pyha770c72_1
Linking munkres-1.1.4-pyh9f0ad1d_0
Linking toml-0.10.2-pyhd8ed1ab_1
Linking pyparsing-3.2.0-pyhd8ed1ab_2
Linking packaging-24.2-pyhd8ed1ab_2
Linking cycler-0.12.1-pyhd8ed1ab_1
Linking certifi-2024.8.30-pyhd8ed1ab_0
Linking pytz-2024.2-pyhd8ed1ab_1
Linking python-tzdata-2024.2-pyhd8ed1ab_1
Linking h2-4.1.0-pyhd8ed1ab_1
Linking cached-property-1.5.2-hd8ed1ab_1
Linking python-dateutil-2.9.0.post0-pyhff2d567_1
Linking typing-extensions-4.12.2-hd8ed1ab_1
Linking brotli-python-1.1.0-py311hb755f60_1
Linking multidict-6.0.5-py311h459d7ec_0
Linking frozenlist-1.4.1-py311h459d7ec_0
Linking msgpack-python-1.0.8-py311h52f7536_0
Linking loguru-0.7.2-py311h38be061_2
Linking ruamel_yaml-0.15.80-py311h459d7ec_1009
Linking tornado-6.4.1-py311h331c9d8_0
Linking kiwisolver-1.4.5-py311h9547e67_1
Linking pillow-9.5.0-py311h573f0d3_0
Linking numpy-1.26.4-py311h64a7726_0
Linking cffi-1.17.0-py311ha8e6434_0
Linking fonttools-4.53.1-py311h61187de_0
Linking glib-2.80.3-h315aac3_2
Linking sip-6.7.12-py311hb755f60_0
Linking yarl-1.9.4-py311h459d7ec_0
Linking libcantera-2.6.0-h587f4e0_5
Linking h5py-3.9.0-nompi_py311h26d1283_100
Linking contourpy-1.2.1-py311h9547e67_0
Linking scipy-1.14.0-py311h0a5b728_2
Linking pandas-2.2.2-py311h14de704_1
Linking zstandard-0.23.0-py311h5cd10c7_0
Linking gstreamer-1.22.0-h25f0c4b_2
Linking pyqt5-sip-12.12.2-py311hb755f60_5
Linking cantera-2.6.0-py311ha1fc806_5
Linking matplotlib-base-3.9.1-py311h74b4f7c_2
Linking gst-plugins-base-1.22.0-h4243ec0_2
Linking qt-main-5.15.8-h67dfc38_7
Linking pyqt-5.15.9-py311hf0fb5b6_5
Linking matplotlib-3.9.1-py311h38be061_1
Linking aiosignal-1.3.1-pyhd8ed1ab_1
Linking patsy-1.0.1-pyhd8ed1ab_1
Linking urllib3-2.2.3-pyhd8ed1ab_1
Linking seaborn-base-0.13.2-pyhd8ed1ab_3
Linking requests-2.32.3-pyhd8ed1ab_1
Linking pooch-1.8.2-pyhd8ed1ab_1
Linking aiohttp-3.10.5-py311h61187de_0
Linking statsmodels-0.14.2-py311h18e1886_0
Linking wslink-2.2.1-pyhd8ed1ab_1
Linking seaborn-0.13.2-hd8ed1ab_3
Linking vtk-9.2.6-qt_py311he2e9dde_203
Linking pyvista-0.44.2-pyhd8ed1ab_0

Transaction finished

To activate this environment, use:

    micromamba activate /home/runner/work/WallyToolbox.jl/WallyToolbox.jl/docs/.CondaPkg/env

Or to execute a single command in this environment, use:

    micromamba run -p /home/runner/work/WallyToolbox.jl/WallyToolbox.jl/docs/.CondaPkg/env mycommand

/home/runner/work/WallyToolbox.jl/WallyToolbox.jl/docs/.CondaPkg/env/lib/python3.11/site-packages/h5py/__init__.py:36: UserWarning: h5py is running against HDF5 1.14.2 when it was built against 1.14.0, this may cause problems
  _warn(("h5py is running against HDF5 {0} when it was built against {1}, "

Since Cantera is not yet available from Julia (I am working on that!), we wrap the interfacing with Python code in function fit_gas_properties provided below. There is a slight possibility that this function or a more generic variant of it will at some point be integrated into PyCanteraTools.

function fit_gas_properties(sol; orders = Dict())
    T = pyconvert(Vector{Float64}, sol.T)

    mu = pyconvert(Vector{Float64}, sol.viscosity)
    kg = pyconvert(Vector{Float64}, sol.thermal_conductivity)
    cp = pyconvert(Vector{Float64}, sol.cp_mass)

    poly_mu = Polynomials.fit(T, mu, get(orders, :mu, 4))
    poly_kg = Polynomials.fit(T, kg, get(orders, :kg, 4))
    poly_cp = Polynomials.fit(T, cp, get(orders, :cp, 4))

    return (mu, kg, cp, poly_mu, poly_kg, poly_cp)
end

For display of results, we also provide a standardized plotting function plot_gas_properties.

function plot_gas_properties(
        T, mu, kg, cp, poly_mu, poly_kg, poly_cp;
        every = 10
    )
    Ts = T[begin:every:end]

    f = Figure(size = (700, 800))

    ax1 = Axis(f[1, 1]; xgridstyle=:dash, ygridstyle=:dash)
    ax2 = Axis(f[2, 1]; xgridstyle=:dash, ygridstyle=:dash)
    ax3 = Axis(f[3, 1]; xgridstyle=:dash, ygridstyle=:dash)

    lines!(ax1, T, mu; color = :red)
    lines!(ax2, T, kg; color = :red)
    lines!(ax3, T, cp; color = :red)

    scatter!(ax1, Ts, poly_mu.(Ts); color = :black)
    scatter!(ax2, Ts, poly_kg.(Ts); color = :black)
    scatter!(ax3, Ts, poly_cp.(Ts); color = :black)

    ax1.ylabel = "Viscosity [Pa.s]"
    ax2.ylabel = "Conductivity [W/(m.K)]"
    ax3.ylabel = "Specific heat [J/(kg.K)]"
    ax3.xlabel = "Temperature [K]"

    return f, (ax1, ax2, ax3)
end

For illustration purposes we make use of a typical composition of air over a broad range of temperatures. Evaluation of the properties table is performed with Cantera SolutionArray class.

T = LinRange(200, 3000, 200)
X = "N2: 0.768, O2: 0.21, H2O: 0.006, Ar: 0.012, CO2: 0.004"

gas = ct.Solution("gri30.yaml")
sol = ct.SolutionArray(gas, shape=length(T))
sol.TPX = pylist(T), ct.one_atm, X

Finally we visualize the results; verification is performed against values proposed in the literature by Mujumdar2006i [8]. As one can inspect below, values diverge from those evaluated from Gri-MECH 3.0 database.

with_theme() do
    rets = fit_gas_properties(sol)

    μmuj = AirViscosityMujumdar2006()
    kmuj = AirHeatConductivityMujumdar2006()

    f, ax = plot_gas_properties(T, rets...)

    lines!(ax[1], T, μmuj.(T); color = :blue)
    lines!(ax[2], T, kmuj.(T); color = :blue)

    ax[1].yticks = 1.0e-05:3.0e-05:1.0e-04
    ax[2].yticks = 0.0:0.05:0.2
    ax[3].yticks = 900:100:1400

    xlims!(ax[1], 300, 3000)
    xlims!(ax[2], 300, 3000)
    xlims!(ax[3], 300, 3000)

    ylims!(ax[1], 1.0e-05, 10.0e-05)
    ylims!(ax[2], 0.0, 0.2)
    ylims!(ax[3], 900.0, 1400)

    f
end

Another application case is the fitting of flue gases properties. One often needs to simulate the post-combustion flow in a segregated manner, i.e. not as an integral part of the combusting system. To that end, fitting properties and simply ignoring species transport can be an alternative to speed up calculations if the physics allows to do so.

Below we evaluate acetylene equilibrium adiabatic combustion products and then inspect the fitted polynomals.

fuel = "C2H2: 1.0"
oxid = "O2: 1.0"
nums = 100

gas = ct.Solution("gri30.yaml")
gas.set_equivalence_ratio(1.0, fuel=fuel, oxidizer=oxid, basis="mole")
gas.equilibrate("HP")

sol = ct.SolutionArray(gas, shape=(nums,))
sol.TP = np.linspace(200, 3800, nums), ct.one_atm

rets = fit_gas_properties(sol)

for p in rets[end-2:end]
    println(repr(p))
end
Polynomial(3.081205307347277e-6 + 5.4247558010721024e-8*x - 1.6613184369737246e-11*x^2 + 3.9677505080811406e-15*x^3 - 3.8013623932160725e-19*x^4)
Polynomial(0.006242391591397946 + 0.00013276848768928543*x - 2.3751176359017937e-8*x^2 + 4.471623756383515e-12*x^3 - 3.9917579021139404e-16*x^4)
Polynomial(1103.403676383008 + 0.41428156929065896*x - 0.00010655706152057004*x^2 + 8.222293810551883e-9*x^3 + 4.4544721879115824e-13*x^4)

As a final validation step, one can again inspect properties graphically.

with_theme() do
    T = pyconvert(Vector{Float64}, sol.T)

    f, ax = plot_gas_properties(T, rets...)
    f
end

Computing an equivalent species

In this tutorial we discuss an approach to unify species in a chemical system for simplified representation in CFD simulations; a typical use case would be simulating a system where energy aspects are more important than actual kinetics features and a major combusting species is present.

We start by importing the required tools:

using WallyToolbox
using PyCanteraTools
using PythonCall

const ct = pyimport("cantera")

In what follows let's assume that the molar composition of the reference fuel is given by the following composition string (in Cantera format). This is a typical natural gas composition where we find methane as major species, other minor hydrocarbons, and residual inert species.

X = "CH4: 0.9194, C2H6: 0.0302, C3H8: 0.0059, CO2: 0.0078, N2: 0.0367"

Assume we want to get a single equivalent hydrocarbon representing all those details in fuel composition; other species remain as they are. For this we can filter the selected species from the provided composition string with functionalities exported by PyCanteraTools.

hydrocarbons = ["CH4", "C2H6", "C3H8"]

ishydrocarbon(x) = x[1] in hydrocarbons

X_dict = filter(ishydrocarbon, cantera_string_to_dict(X))

X_hydr = cantera_dict_to_string(X_dict)
"C3H8: 0.005900000000, CH4: 0.919400000000, C2H6: 0.030200000000"

Next we load a solution with the reference mechanism and set the gas composition to the filtered (relative molar fractions) composition.

gas = ct.Solution("gri30.yaml")
gas.TPX = nothing, nothing, X_hydr

The elemental mass fractions of CHONS can be recoved from Cantera using the wrapper function chons_get_fractions.

Y = chons_get_fractions(gas; basis = :mass)
5-element Vector{Float64}:
 0.7526577798064804
 0.2473422201935198
 0.0
 0.0
 0.0

For preserving the flow characteristics of the simplified fuel, it is important to ensure the new artificial composition preserves the mean molecular mass. Doing so will keep constant inlet flow rate if using mass flow boundary conditions, as it is usual in combustion simulations.

mw = pyconvert(Float64, gas.mean_molecular_weight)
mw
16.659571428571425

Below we compute the stoichiometric coefficient of carbon in the target artificial species; it is simply a mass to mole fraction conversion, as one might promptly recognize.

scaler = :C => Y[1]*mw/1000atomicmass(:C)
:C => 1.043956043956044

Using the mass fractions and the scaler one can easily compute the new hypothetical species using hfo_empirical_formula. It must be emphasized that although this function was initially conceived for handling heavy-fuel oils (HFOs) it is can also be used for any species in the CHONS chemistry family.

empirical_fuel = hfo_empirical_formula(Y; scaler)

String(empirical_fuel)
"C(1.043956)H(4.087912)O(0.000000)N(0.000000)S(0.000000)"

To wrap-up we verify that the new species really matches the target molecular mass; because of round-off errors and possible differences in atomic masses between Cantera and our database [1].

1000ChemicalCompound(Dict(zip("CHONS", empirical_fuel.X))).M ≈ mw
true

There are a few extra steps that one must be aware; with the newly created species we need to create (by some means not described here) a new mechanism containing the hypothetical species. Once that is done, one needs to compute the heating values related to that fuel, e.g. using mixture_heating_value, what will lead to unphysical values at first. The formation enthalpy of the referred species needs to be corrected in mechanism data (generally NASA7 polynomials, for which it is done in the fifth coefficient) to match the reference fuel energy release.

  • 1There should not be any difference because the database used internally by WallyToolbox is an extraction of Cantera source code.