Skip to main content

Xcompact3d Toolbox

QA CI CodeQL pre-commit.ci statusQuality Gate StatusCoverage
Docs Docs badge badge
Package PyPI - Version PyPI - Python Version PyPI - Downloads
Meta Wizard Template Checked with mypy Hatch project Ruff PyPI - License EffVer Versioning

It is a Python package designed to handle the pre and postprocessing of the high-order Navier-Stokes solver XCompact3d. It aims to help users and code developers to build case-specific solutions with a set of tools and automated processes.

The physical and computational parameters are built on top of traitlets, a framework that lets Python classes have attributes with type checking, dynamically calculated default values, and ‘on change’ callbacks. In addition to ipywidgets for an user friendly interface.

Data structure is provided by xarray (see Why xarray?), that introduces labels in the form of dimensions, coordinates and attributes on top of raw NumPy-like arrays, which allows for a more intuitive, more concise, and less error-prone developer experience. It integrates tightly with dask for parallel computing and hvplot for interactive data visualization.

Finally, Xcompact3d-toolbox is fully integrated with the new Sandbox Flow Configuration. The idea is to easily provide everything that XCompact3d needs from a Jupyter Notebook, like initial conditions, solid geometry, boundary conditions, and the parameters. It makes life easier for beginners, that can run any new flow configuration without worrying about Fortran and 2decomp. For developers, it works as a rapid prototyping tool, to test concepts and then compare results to validate any future Fortran implementation.

Useful links

Installation

It is possible to install using pip:

pip install xcompact3d-toolbox

There are other dependency sets for extra functionality:

pip install xcompact3d-toolbox[visu] # interactive visualization with hvplot and others

To install from source, clone de repository:

git clone https://github.com/fschuch/xcompact3d_toolbox.git

And then install it interactively with pip:

cd xcompact3d_toolbox
pip install -e .

You can install additional dependencies as well:

pip install -e .[visu]

Now, any change you make at the source code will be available at your local installation, with no need to reinstall the package every time.

Examples

  • Importing the package:

    import xcompact3d_toolbox as x3d
    
  • Loading the parameters file (both .i3d and .prm are supported, see #7) from the disc:

    prm = x3d.Parameters(loadfile="input.i3d")
    prm = x3d.Parameters(loadfile="incompact3d.prm")
    
  • Specifying how the binary fields from your simulations are named, for instance:

  • If the simulated fields are named like ux-000.bin:

    prm.dataset.filename_properties.set(
       separator = "-",
       file_extension = ".bin",
       number_of_digits = 3
    )
    
  • If the simulated fields are named like ux0000:

    prm.dataset.filename_properties.set(
       separator = "",
       file_extension = "",
       number_of_digits = 4
    )
    
  • There are many ways to load the arrays produced by your numerical simulation, so you can choose what best suits your post-processing application. All arrays are wrapped into xarray objects, with many useful methods for indexing, comparisons, reshaping and reorganizing, computations and plotting. See the examples:

  • Load one array from the disc:

    ux = prm.dataset.load_array("ux-0000.bin")
    
  • Load the entire time series for a given variable:

    ux = prm.dataset["ux"]
    
  • Load all variables from a given snapshot:

    snapshot = prm.dataset[10]
    
  • Loop through all snapshots, loading them one by one:

    for ds in prm.dataset:
       # compute something
       vort = ds.uy.x3d.first_derivative("x") - ds.ux.x3d.first_derivative("y")
       # write the results to the disc
       prm.dataset.write(data = vort, file_prefix = "w3")
    
  • Or simply load all snapshots at once (if you have enough memory):

    ds = prm.dataset[:]
    
  • It is possible to produce a new xdmf file, so all data can be visualized on any external tool:

  • Loop through all snapshots, loading them one by one:

  • User interface for the parameters with IPywidgets:

    ds = prm.dataset[:]
    
  • It is possible to produce a new xdmf file, so all data can be visualized on any external tool:

    prm.dataset.write_xdmf()
    
  • User interface for the parameters with IPywidgets:

    prm = x3d.ParametersGui()
    prm
    

    An animation showing the graphical user interface in action

Copyright and License

© 2020 Felipe N. Schuch. All content is under GPL-3.0 License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xcompact3d_toolbox-1.3.2.tar.gz (405.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xcompact3d_toolbox-1.3.2-py3-none-any.whl (68.4 kB view details)

Uploaded Python 3

File details

Details for the file xcompact3d_toolbox-1.3.2.tar.gz.

File metadata

  • Download URL: xcompact3d_toolbox-1.3.2.tar.gz
  • Upload date:
  • Size: 405.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for xcompact3d_toolbox-1.3.2.tar.gz
Algorithm Hash digest
SHA256 430edc9938b36c1b4333b305f757857910bdcbf52a2856c19a8a14856c90973f
MD5 ab5fa6aa95df90a2300f27a333a27d89
BLAKE2b-256 8c4f83fdac8f52a0c92d97fa28e77c70ebe65e79b8ab1842e7ddc4d472722f01

See more details on using hashes here.

Provenance

The following attestation bundles were made for xcompact3d_toolbox-1.3.2.tar.gz:

Publisher: ci.yaml on fschuch/xcompact3d_toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xcompact3d_toolbox-1.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for xcompact3d_toolbox-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 353f3065fa9a14d37b733305e41d75ab8058440673aff7f340c133997b02cc28
MD5 8316644498b7373ade4979d06c91489c
BLAKE2b-256 addca7ed78ea07493595466648b89037ee9adb69bc116b290111956283a45da4

See more details on using hashes here.

Provenance

The following attestation bundles were made for xcompact3d_toolbox-1.3.2-py3-none-any.whl:

Publisher: ci.yaml on fschuch/xcompact3d_toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page