Skip to main content

compflow

The compflow library contains functions to convert back and forth between Mach number and other non-dimensional groups in compressible flows. By using a NumPy--Fortran interface, the code is vectorised and lightning-fast, yielding a speed-up of up to two orders of magnitude.

Full documentation is available online.

Compressible flow quantities

Features

  • Evaluation of ten non-dimensional flow quantities as explicit functions of Mach number;
  • Iteration with Newton's method to invert explicit relations and solve for Mach number;
  • Creation and caching of lookup tables to speed up inversions;
  • Fortran-accelerated, fully-vectorised in both directions.

Basic usage

compflow is available on the Python Package Index, so installation is as simple as,

   python3 -m pip install compflow

Note: as the library uses Fortran subroutines behind the scenes, you will need a working Fortran compiler for the installation to complete successfully.

We can now start doing some calculations. First, an explicit evaluation of stagnation pressure ratio given a Mach number,

   >>> import compflow
   >>> ga = 1.4
   >>> compflow.Po_P_from_Ma(0.3, ga)
   1.0644302861529382

Second, an inversion of flow function where iterative solution for Mach number is required,

   >>> compflow.Ma_from_mcpTo_APo(0.8, ga)
   0.39659360325173604

The names and symbols of non-dimensional quantities are fairly self-explanatory, but a full list is given in the Nomenclature. All functions and the equations used for the calculations are documented in the API.

Numpy arrays are also accepted as inputs,

   >>> import numpy
   >>> Ma1 = numpy.array([0., 0.5, 1., 2.])
   >>> compflow.To_T_from_Ma(Ma1, ga)
   array([1.  , 1.05, 1.2 , 1.8 ])
   >>> Ma2 = numpy.array([[0.1, 0.2], [0.3, 0.4], [0.5, 0.6]])
   >>> compflow.To_T_from_Ma(Ma2, ga)
   array([[1.002, 1.008],
          [1.018, 1.032],
          [1.05 , 1.072]])

When solving for Mach number at a given normalised mass flow, it is assumed that we are on the subsonic branch of the curve unless a flag is specified. Where no solution is possible, i.e. if the flow would choke, NaN is returned,

   >>> capacity = [0.6, 2.]
   >>> compflow.Ma_from_mcpTo_APo(capacity, ga)
   array([0.28442265,        nan])
   >>> compflow.Ma_from_mcpTo_APo(capacity, ga, sup=True)
   array([2.27028708,        nan])

TODO

  • Sort out packaging so that NumPy gets installed automatically (distutils due to be deprecated?).

James Brind Mar 2022

Metadata

Release files for compflow 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compflow 0.5.0
File Size Uploaded
compflow-0.5.0.tar.gz 15.7 kB Details

Release files / compflow-0.5.0.tar.gz

Download URL compflow-0.5.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a6f3cd16fc744e23f83cbf3ffc9fca9a83ca783aeff964ba51ae3cd344dc7481
BLAKE2b-256 checksum
How to use checksums
3569c53098d80fbba36483651759466a5edb06aa2fc46d22f01dbd8bcedb6d0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.5.0 This release

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page