Skip to main content

Python library for ACP - Ansys Composite PrepPost

Project description

PyACP Logo

PyAnsys Python PyPI GH-CI Codecov MIT Black

A Python client for Ansys Composite PrepPost (ACP).

Installation

Install PyACP with:

pip install ansys-acp-core[all]

For installing PyACP in development mode, see the Development Setup instructions below.

Documentation

The PyACP documentation can be viewed online at https://acp.docs.pyansys.com.

Getting Started

Launching ACP

The ACP server can be started with launch_acp:

import ansys.acp.core as pyacp

acp = pyacp.launch_acp()

Basic Usage

Once the server is running, we can start working with PyACP. For example, to load an ACP Model from an existing file:

>>> remote_path = acp.upload_file(local_path="<MODEL_PATH>")
>>> model = acp.import_model(path=remote_path)
>>> model.name
'ACP Model'

Development Setup

Installation

Installing PyACP in developer mode allows you to modify the source and enhance it. Before contributing to the project, please refer to the PyAnsys Developer’s guide.

You will need to follow these steps:

  1. Start by cloning this repository, and entering the newly created directory:

    git clone https://github.com/ansys/pyacp
    cd pyacp
  2. Make sure you have the latest version of poetry and its shell plugin:

    python -m pip install pipx
    pipx ensurepath
    pipx install poetry
    pipx inject poetry poetry-plugin-shell
  1. Install the project and all its development dependencies using poetry. This also takes care of creating a new virtual environment:

    poetry install --all-groups --all-extras

    This step installs PyACP in an editable mode (no build step is needed, no re-install when changing the code).

  2. Activate your development virtual environment with:

    poetry shell

Testing

The PyACP test suite uses pytest. You can run it with

pytest --license-server=<YOUR_LICENSE_SERVER> tests/unittests

Benchmarking

As part of the test suite, we run some performance benchmarks. These can be run with

pytest --license-server=<YOUR_LICENSE_SERVER> tests/benchmarks

Additional options can be found in the pytest-benchmark documentation.

NOTE: The benchmarks use the tc-netem Linux kernel module to simulate a slow network connection within a Docker container. This is available only on Linux, not on Docker for MacOS or Windows.

The benchmark results from the main branch are uploaded to https://acp.docs.pyansys.com/benchmarks.

Pre-commit hooks

Style and linter checks are run through the pre-commit tool. You can run these checks with

pre-commit run --all-files

We also recommend installing pre-commit into your repository:

pre-commit install

This will run the pre-commit hooks on the changed files before every git commit. If you ever need to create a commit without running the hooks, you can skip them with git commit -n.

Documentation

Basic documentation build

To build the documentation, run the following commands:

On Linux & MacOS:

make -C doc html

On Windows:

cd doc; .\make.bat html

The generated HTML files can be viewed with the browser of your choice.

This method of building the documentation will run the examples with the default or currently configured launch options for the ACP, MAPDL, and DPF servers. Make sure to have these installed and configured correctly, or alternatively follow the Docker-based instructions below.

Alternative: start services with docker

Alternatively, you can use the provided docker-compose file to start the MAPDL and DPF servers.

First, review the DPF preview license agreement, and if you agree, set the ANSYS_DPF_ACCEPT_LA environment variable to Y. See the PyDPF documentation for details.

On Windows, you can then use the shipped shell script:

.\doc\create_doc_windows.ps1

The following manual steps can be used on any platform:

  1. Set the following additional environment variables in your shell:

    • ANSYSLMD_LICENSE_FILE: To a valid license server (e.g 1055@mylicenseserver.com).

    • PYMAPDL_PORT: Choose any free port.

    • PYMAPDL_START_INSTANCE=FALSE

    • PYDPF_COMPOSITES_DOCKER_CONTAINER_PORT: Choose any free port.

  2. Start the docker containers with:

    docker compose -f docker-compose/docker-compose-extras.yaml up -d
  3. Build the documentation with the Sphinx commands mentioned above:

    On Linux & MacOS:

    make -C doc html

    On Windows:

    cd doc; .\make.bat html

Partial builds

Two environment variables can be used to run a quicker partial documentation build:

  • PYACP_DOC_SKIP_API=1: Skip the API reference build.

  • PYACP_DOC_SKIP_GALLERY=1: Skip running the examples.

Distribution

The following commands can be used to build and check the PyACP package:

poetry build
twine check dist/*

This creates both a source distribution, and a wheel file. An alternative is

pip install build
python -m build --wheel

License

PyACP is licensed under the MIT license. Please see the LICENSE for more details.

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_acp_core-0.2.1.tar.gz (123.4 kB view details)

Uploaded Source

Built Distribution

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

ansys_acp_core-0.2.1-py3-none-any.whl (262.8 kB view details)

Uploaded Python 3

File details

Details for the file ansys_acp_core-0.2.1.tar.gz.

File metadata

  • Download URL: ansys_acp_core-0.2.1.tar.gz
  • Upload date:
  • Size: 123.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for ansys_acp_core-0.2.1.tar.gz
Algorithm Hash digest
SHA256 84f4449b7bccc14b5a07f59d7b0613ca2d2bdf9347a23eeb4e6ef28d08f44439
MD5 6467070d0b2df8bfe5b5ddd7c7b76e48
BLAKE2b-256 de27af8108d0c73d241e6234dc6ac1ae70b60dfb38f8d815944d220eff8f1613

See more details on using hashes here.

File details

Details for the file ansys_acp_core-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ansys_acp_core-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 262.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for ansys_acp_core-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 daa53aca80b360e91c472edf6fede7a24c2db1ad05dab3532fbff8e908359a4f
MD5 4391e35f69c06910fe9e000abe36ae42
BLAKE2b-256 22d62d60b85160d3d4d7300f79ae05ff7a9fbab23ba99da0b21764a3f868922e

See more details on using hashes here.

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