Skip to main content

Python library for ACP - Ansys Composite PrepPost

Project description

PyAnsys Python PyPI GH-CI Codecov MIT Black

A Python client for Ansys Composite PrepPost (ACP).

Overview

Installation

Install PyACP with:

pip install ansys-acp-core

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_filename = acp.upload_file(local_path="<MODEL_PATH>")
>>> model = acp.import_model(path=remote_filename)
>>> 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:

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

    poetry install --with dev,test

    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

Before generating the documentation, configure the PyACP server via the ansys-launcher, see Launching ACP above. If Ansys is installed the examples can directly built with Sphinx.

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.

Alternatively you can build the documentation by starting a mapdl and pydpf-composites docker container. First ensure that you have accepted the DPF Preview License Agreement by setting the ANSYS_DPF_ACCEPT_LA environment variable to Y (see DPF Preview License Agreement ). In addition the ANSYSLMD_LICENSE_FILE environment variable needs be set to a valid license server (e.g 1055@mylicenseserver.com). Then start the docker containers with:

docker compose -f docker-compose/docker-compose-extras.yaml up -d

Then build the documentation with the Sphinx commands mentioned above.

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.1b1.tar.gz (83.8 kB view hashes)

Uploaded Source

Built Distribution

ansys_acp_core-0.1b1-py3-none-any.whl (184.2 kB view hashes)

Uploaded Python 3

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