Skip to main content

A python wrapper for Ansys EnSight

Project description

pyansys python ci MIT pre-commit black isort Security Status

Overview

PyEnSight is a Python wrapper for EnSight, the Ansys simulation postprocessor. It supports Pythonic access to EnSight so that you communicate directly with it from Python. With PyEnSight, you can perform these essential actions:

  • Start a new EnSight session or connect to an existing one.

  • Read simulation data from any supported solver output format into the session.

  • Generate complex postprocessing results in a Pythonic fashion.

  • Visualize the processed data, extract it, or get a widget to embed it in an external app.

Documentation and Issues

For comprehensive information on PyEnSight, see the latest release documentation.

On the PyEnSight Issues page, you can create issues to submit questions, report bugs, and request new features. This is the best place to post questions and code.

Installation

To use PyEnSight, you must have a locally installed and licensed copy of Ansys EnSight 2022 R2 or later. The ansys-pyensight-core package supports Python 3.8 through Python 3.11 on Windows and Linux.

Two modes of installation are available:

  • User installation

  • Developer installation

User installation

Install the latest release from PyPI with this command:

pip install ansys-pyensight-core

Developer installation

If you plan on doing local development of PyEnSight with GitHub, consider using a virtual environment.

To clone PyEnSight and then install it in a virtual environment, run these commands:

git clone https://github.com/ansys/pyensight
cd pyensight
pip install virtualenv
virtualenv venv  # create virtual environment
source venv/bin/activate  # (.\venv\Scripts\activate for Windows shell)
pip install .[dev]   # install development dependencies

A developer installation allows you to edit ansys-pyensight files locally. Any changes that you make are reflected in your setup after restarting the Python kernel.

To build and install PyEnSight, run these commands:

python -m build   # build
# this will replace the editable install done previously. If you don't want to replace,
# switch your virtual environments to test the new install separately.
pip install .[tests]   # install test dependencies
pytest  # Run the tests

Pre-commit setup

pre-commit is a multi-language package manager for pre-commit hooks.

To install pre-commit into your git hooks, run this command:

pre-commit install

pre-commit then runs on every commit. Each time you clone a project, installing pre-commit should always be the first action that you take.

If you want to manually run all pre-commit hooks on a repository, run this command:

pre-commit run --all-files

A bunch of formatters run on your source files.

To run individual hooks, use this command, where <hook_id> is obtained from from the .pre-commit-config.yaml file:

pre-commit run <hook_id>

The first time pre-commit runs on a file, it automatically downloads, installs, and runs the hook.

Local GitHub actions

Simulating GitHub Actions on your local desktop is recommended. After installing the act package, you can run a job. For example, this command runs the docs job defined in the ci_cd.yml file:

act -j docs

Deploy and upload steps must always be ignored. If they are not ignored, before running a job, add if: ${{ !env.ACT }} to the workflow step (and commit if required).

Usage

You can use this code to start the simplest PyEnSight session:

>>> from ansys.pyensight.core import LocalLauncher
>>> session = LocalLauncher().start()
>>> data = session.render(1920, 1080, aa=4)
>>> with open("image.png", "wb") as f:
...    f.write(data)

Optionally, EnSight can work with an EnSight Docker container using code like this:

>>> from ansys.pyensight.core import DockerLauncher
>>> launcher = DockerLauncher(data_directory="d:/data", use_dev=True)
>>> launcher.pull()
>>> session = launcher.start()
>>> data = session.render(1920, 1080, aa=4)
>>> with open("image.png", "wb") as f:
...    f.write(data)

In the preceding code, the data_directory argument specifies the host directory to map into the container at the mount point, providing access to the data within the container. This provides a method for EnSight running in the container to access the host’s file system to read or write data. The optional use_dev=True argument specifies that the latest development version of EnSight should be used.

Also, PyEnSight can be launched as other PyAnsys products with the launch_ensight method:

>>> from ansys.pyensight.core import launch_ensight
>>> session = launch_ensight(use_sos=3)
>>> data = session.render(1920, 1080, aa=4)
>>> with open("image.png", "wb") as f:
...    f.write(data)

Dependencies

You will need a locally installed and licensed copy of Ansys to run EnSight, with the first supported version being Ansys 2022 R2.

Documentation and Issues

Please see the latest release documentation page for more details.

Please feel free to post issues and other questions at PyEnSight Issues. This is the best place to post questions and code.

License

PyEnSight is licensed under the MIT license.

PyEnsight makes no commercial claim over Ansys whatsoever. This library extends the functionality of Ansys EnSight by adding a remote Python interface to EnSight without changing the core behavior or license of the original software. The use of interactive control of PyEnSight requires a legally licensed local copy of Ansys.

For more information on EnSight, see the Ansys Ensight page on the Ansys website.

Project details


Download files

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

Source Distribution

ansys_pyensight_core-0.5.2.tar.gz (70.8 kB view details)

Uploaded Source

Built Distribution

ansys_pyensight_core-0.5.2-py3-none-any.whl (78.4 kB view details)

Uploaded Python 3

File details

Details for the file ansys_pyensight_core-0.5.2.tar.gz.

File metadata

  • Download URL: ansys_pyensight_core-0.5.2.tar.gz
  • Upload date:
  • Size: 70.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ansys_pyensight_core-0.5.2.tar.gz
Algorithm Hash digest
SHA256 f5a641b37f32e6714ca409b5fe9dc1edbc239d5e8dae1e610c29cd918d3cf5c2
MD5 d75d265f8f12c08cf067e4f5b28a042b
BLAKE2b-256 cad228ce4c99ff66938a0021069a28619bf97efb52c61899163aa45866dcf18d

See more details on using hashes here.

File details

Details for the file ansys_pyensight_core-0.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ansys_pyensight_core-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1a73d575bc6237f6293682e1768d1a372d754ffc32f0f3a1393adf01fb8c2f6f
MD5 1174dd416205d5bbe9121e583c114bf1
BLAKE2b-256 b17081b9d61bb2d38696bb1309f4aaf96f829fc5fed15287155f650dfb2f128d

See more details on using hashes here.

Supported by

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