Package: ansys-pyensight-core
OverviewPyEnSight is a Python wrapper forEnSight, 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 IssuesDocumentation for the latest stable release of PyEnSight is hosted atPyEnSight documentation.In the upper right corner of the documentation’s title bar, there is an option for switching from
viewing the documentation for the latest stable release to viewing the documentation for the
development version or previously released versions.You can alsoviewordownloadthe
PyEnSight cheat sheet. This one-page reference provides syntax rules and commands
for using PyEnSight.On thePyEnSight Issuespage, you can
create issues to report bugs and request new features. On thePyEnSight Discussionspage or theDiscussionspage on the Ansys Developer portal,
you can post questions, share ideas, and get community feedback.To reach the project support team, emailpyansys.core@ansys.com.InstallationTo use PyEnSight, you must have a locally installed and licensed copy of
Ansys EnSight 2022 R2 or later. Theansys-pyensight-corepackage supports
Python 3.9 through Python 3.12 on Windows and Linux.Two modes of installation are available:User installationDeveloper installationUser installationInstall the latest release fromPyPIwith this command:pip install ansys-pyensight-coreDeveloper installationIf you plan on doing localdevelopmentof PyEnSight with GitHub, consider
using avirtual 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 dependenciesA developer installation allows you to editansys-pyensightfiles 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 testsPre-commit setuppre-commitis a multi-language package manager for pre-commit hooks.To install pre-commit into your git hooks, run this command:pre-commit installpre-committhen runs on every commit. Each time you clone a project,
installingpre-commitshould 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-filesA 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.yamlfile:pre-commit run <hook_id>The first time pre-commit runs on a file, it automatically downloads, installs,
and runs the hook.Local GitHub actionsSimulating GitHub Actions on your local desktop is recommended. After installing theactpackage, you can run a job. For
example, this command runs thedocsjob defined in theci_cd.ymlfile:act -j docsDeploy and upload stepsmust alwaysbe ignored. If they are not ignored, before
running a job, addif: ${{ !env.ACT }}to the workflow step (and commit if required).UsageYou can use this code to start the simplest PyEnSight session:>>>fromansys.pyensight.coreimportLocalLauncher>>>session=LocalLauncher().start()>>>data=session.render(1920,1080,aa=4)>>>withopen("image.png","wb")asf:...f.write(data)Optionally, EnSight can work with an EnSight Docker container using code like this:>>>fromansys.pyensight.coreimportDockerLauncher>>>launcher=DockerLauncher(data_directory="d:/data",use_dev=True)>>>launcher.pull()>>>session=launcher.start()>>>data=session.render(1920,1080,aa=4)>>>withopen("image.png","wb")asf:...f.write(data)In the preceding code, thedata_directoryargument 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 optionaluse_dev=Trueargument
specifies that the latest development version of EnSight should be used.Also, PyEnSight can be launched as other PyAnsys products with thelaunch_ensightmethod:>>>fromansys.pyensight.coreimportlaunch_ensight>>>session=launch_ensight(use_sos=3)>>>data=session.render(1920,1080,aa=4)>>>withopen("image.png","wb")asf:...f.write(data)DependenciesYou will need a locally installed and licensed copy of Ansys to run EnSight, with the
first supported version being Ansys 2022 R2.Documentation and IssuesPlease see the latest releasedocumentationpage for more details.Please feel free to post issues and other questions atPyEnSight Issues. This is the best place
to post questions and code.LicensePyEnSight 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 theAnsys Ensightpage on the Ansys website.