Skip to main content

Python interface to MAPDL Service

Project description

https://img.shields.io/pypi/v/ansys-mapdl-core.svg https://dev.azure.com/pyansys/pyansys/_apis/build/status/pyansys.pymapdl?branchName=master https://zenodo.org/badge/70696039.svg

Documentation and Issues

See the Documentation page for more details, and the Examples gallery for some examples.

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

Project Transition - Legacy Support

This project was formerly known as pyansys, and we’d like to thank all the early adopters, contributors, and users who submitted issues, gave feedback, and contributed code through the years. The pyansys project has been taken up Ansys and will be leveraged in creating new Pythonic, cross-platform, and multi-language service based interfaces for Ansys’s products. Your contributions to pyansys has shaped it into a better solution.

The pyansys project is expanding beyond just MAPDL, and while there are many new features and changes to the original Python module, many steps have been taken to ensure compatibility with legacy code while supporting new features. The original python module has been split up into the following projects and modules:

Please visit the GitHub pages for further details regarding each project.

Installation

The ansys-mapdl-core package currently supports Python 3.6 through Python 3.8 on Windows, Mac OS, and Linux.

Install the latest release from PyPi with:

pip install ansys-mapdl-core

Alternatively, install the latest from PyMAPDL GitHub via:

pip install git+https://github.com/pyansys/pymapdl.git

For a local “development” version, install with:

git clone https://github.com/pyansys/pymapdl.git
cd mapdl
pip install -e .

Dependencies

You will need a local licenced copy of ANSYS to run MAPDL prior and including 2021R1. If you have the latest version of 2021R1, you can connect to a remote instance of MAPDL and do not need MAPDL installed locally and can connect to a remote instance via gRPC.

Getting Started

Launch MAPDL Locally

You can launch MAPDL locally directly from Python using launch_mapdl:

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()

This automatically searches for the latest local version of MAPDL, launches it as a background process, and immediately connects to it. You can then start sending python commands to MAPDL.

Launching Manually or Connecting to a Remote Instance

If you wish to connect to a session of MAPDL on a remote computer (either locally the LAN or through the internet), first ensure you have MAPDL started in gRPC server mode. This example assumes you will be launching an instance locally from Windows, but can be easily adapted to run from Linux, or the LAN provided the necessary ports are open. This example specifies the port with -port 50052, but this option can be left out if you plan on using the default port 50052.

start "MAPDL" "%ANSYS211_DIR%\bin\winx64\ANSYS211.exe" -port 50052 -grpc

Next, connect to the instance of MAPDL from python with:

>>> from ansys.mapdl import Mapdl
>>> ip = '127.0.0.1'
>>> mapdl = Mapdl(ip=ip, port=50052, request_instance=False)
>>> print(mapdl)

A successful connection returns:

Product:             ANSYS Mechanical Enterprise
MAPDL Version:       RELEASE  2020 R2           BUILD 20.2TEST  UPDATE 20200601
ansys.mapdl.core Version: 0.57.0

Should you wish to connect to this instance of MAPDL from a remote computer, you substitute ip= with the LAN or WAN address of the computer you wish to connect to. Depending on your network settings, you may have to open local ports or enable port redirection across the WAN.

Basic Usage

You run MAPDL commands via:

mapdl.run('/PREP7')

Nearly all the built-in MAPDL commands have an associated pythonic method mapped to it. For example, /PREP7 is:

mapdl.prep7()

There are also non-mapdl commands such as mapdl.eplot which plot elements using vtk and pyvista rather than relying on MAPDL’s graphics server. Another is mapdl.vget, which leverages gRPC to rapidly exchange binary arrays from MAPDL to Python rather than relying on file IO to exchange data.

Additionally, there are the post_processing, geometry, and mesh properties, which you can use to perform remote (or local) post processing without result file exchange, display geometry properties, or view mesh statistics. Additionally, there’s the parameters property which shows the active MAPDL parameters, and you can use to send or receive arrays between MAPDL and Python.

See the full documentation at PyMAPDL Documentation for more details.

Run on Docker

Run MAPDL within a container on any OS with docker!

See MAPDL on Docker README for details regarding using MAPDL within a container.

Citing this Module

If you use PyMAPDL for research and would like to cite the module and source, you can visit pyansys Zenodo and generate the correct citation. For example, the BibTex citation is:

@software{alexander_kaszynski_2020_4009467,
  author       = {Alexander Kaszynski},
  title        = {{pyansys: Python Interface to MAPDL and Associated
                   Binary and ASCII Files}},
  month        = aug,
  year         = 2020,
  publisher    = {Zenodo},
  version      = {0.43.2},
  doi          = {10.5281/zenodo.4009467},
  url          = {https://doi.org/10.5281/zenodo.4009467}
}

Please visit the link above for the most recent citation as the citation here may not be current.

License and Acknowledgments

PyMAPDL is licensed under the MIT license.

This module, ansys-mapdl-core makes no commercial claim over ANSYS whatsoever. This tool extends the functionality of MAPDL by adding a Python interface to the MAPDL service without changing the core behavior or license of the original software. The use of the interactive APDL control of PyMAPDL requires a legally licensed local copy of ANSYS.

To get a copy of ANSYS, please visit ANSYS.

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-mapdl-core-0.58.2.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

ansys_mapdl_core-0.58.2-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file ansys-mapdl-core-0.58.2.tar.gz.

File metadata

  • Download URL: ansys-mapdl-core-0.58.2.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for ansys-mapdl-core-0.58.2.tar.gz
Algorithm Hash digest
SHA256 79e9ad08d950b3d7ab3ee977abc64c8b27f5c2458ab9eab1ccf5b0e01fe2a831
MD5 62c2c1d285c9d69d515a3b06e3ed9443
BLAKE2b-256 32e4360ce22f6027ba9aadd11c24f12f330cec75dc9ff29b0c2e29b707f94f44

See more details on using hashes here.

File details

Details for the file ansys_mapdl_core-0.58.2-py3-none-any.whl.

File metadata

  • Download URL: ansys_mapdl_core-0.58.2-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for ansys_mapdl_core-0.58.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a03a22468fd8f78df740dcf73848196e3d03551e049d43c83db5a74a0f7e4a2f
MD5 6fb6d750f08db4bf4a17c9ac8b360798
BLAKE2b-256 dcaf2b1ba79a007eea22ac6bd8085e4a4c202f8163e422777ec58dd9cf0cac34

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