A Python client for Ansys Composite PrepPost (ACP).
Install PyACP with:
pip install ansys-acp-core[all]
For installing PyACP in development mode, see the Development Setup instructions below.
The PyACP documentation can be viewed online at https://acp.docs.pyansys.com.
The ACP server can be started with launch_acp
:
import ansys.acp.core as pyacp
acp = pyacp.launch_acp()
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'
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:
Start by cloning this repository, and entering the newly created directory:
git clone https://github.com/ansys/pyacp cd pyacp
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
Note
At this point, you may need to restart your shell or editor to ensure that the new
poetry
command is available.
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).
Activate your development virtual environment with:
poetry shell
The PyACP test suite uses pytest. You can run it with
pytest --license-server=<YOUR_LICENSE_SERVER> tests/unittests
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.
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
.
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.
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:
Set the following additional environment variables in your shell:
ANSYSLMD_LICENSE_FILE
: To a valid license server (e.g[email protected]
).PYMAPDL_PORT
: Choose any free port.PYMAPDL_START_INSTANCE=FALSE
PYDPF_COMPOSITES_DOCKER_CONTAINER_PORT
: Choose any free port.
Start the docker containers with:
docker compose -f docker-compose/docker-compose-extras.yaml up -d
Build the documentation with the Sphinx commands mentioned above:
On Linux & MacOS:
make -C doc html
On Windows:
cd doc; .\make.bat html
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.
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
PyACP
is licensed under the MIT license. Please see the LICENSE for more details.