• Stars
    star
    426
  • Rank 101,884 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created about 8 years ago
  • Updated 20 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pythonic interface to MAPDL

PyMAPDL

PyAnsys pypi PyPIact GH-CI codecov zenodo MIT black pre-commit.ci status

Overview

The PyMAPDL project supports Pythonic access to MAPDL to be able to communicate with the MAPDL process directly from Python. The latest ansys-mapdl-core package enables a more comprehensive interface with MAPDL and supports:

  • All the features of the original module (for example, Pythonic commands and interactive sessions).
  • Remote connections to MAPDL from anywhere via gRPC.
  • Direct access to MAPDL arrays, meshes, and geometry as Python objects.
  • Low-level access to the MAPDL solver through APDL math in a SciPy- like interface.

Here's a quick demo of PyMAPDL within Visual Studio Code:

https://github.com/ansys/pymapdl/raw/main/doc/landing_page_demo.gif

PyMAPDL works within Jupyter Notebooks, the standard Python console, or in batch mode on Windows, Linux, and even Mac OS.

Documentation and issues

Documentation for the latest stable release of PyMAPDL is hosted at PyMAPDL 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 also view or download the PyMAPDL cheat sheet. This one-page reference provides syntax rules and commands for using PyMAPDL.

On the PyMAPDL Issues page, you can create issues to report bugs and request new features. On the PyMAPDL Discussions page or the Discussions page on the Ansys Developer portal, you can post questions, share ideas, and get community feedback.

To reach the project support team, email [email protected].

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 at Ansys and is being 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:

For more information on each project, visit their GitHub pages.

Installation

The ansys-mapdl-core package currently supports Python 3.8 through Python 3.11 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/ansys/pymapdl.git

For a local "development" version, install with (requires pip >= 22.0):

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

Offline installation

If you lack an internet connection on your install machine, the recommended way of installing PyMAPDL is downloading the wheelhouse archive from the Releases Page for your corresponding machine architecture.

Each wheelhouse archive contains all the python wheels necessary to install PyMAPDL from scratch on Windows and Linux for Python 3.8 and 3.11. You can install this on an isolated system with a fresh python or on a virtual environment.

For example, on Linux Ubuntu with Python 3.10, unzip it and install it with the following:

  unzip ansys-mapdl-core-v0.65.0-wheelhouse-ubuntu-latest-3.10.zip
wheelhouse
  pip install ansys-mapdl-core -f wheelhouse --no-index --upgrade --ignore-installed

If you're on Windows with Python 3.10, unzip manually to a wheelhouse directory and install using the same command as above.

Consider installing using a virtual environment.

Dependencies

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

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 want 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 that you are launching an instance locally from Windows, but it 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.core import Mapdl
>>> ip = "127.0.0.1"
>>> mapdl = Mapdl(ip=ip, port=50052, start_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 want 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.

For more information, see the full documentation at PyMAPDL Documentation.

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}
}

Because the citation here might not be current, visit the link above to obtain the most recent citation.

License and acknowledgments

PyMAPDL is licensed under the MIT license.

ansys-mapdl-core package 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, visit Ansys.

More Repositories

1

pyfluent

Pythonic interface to Ansys Fluent
Python
268
star
2

pyaedt

AEDT Python Client Package
Python
196
star
3

pydpf-core

Data Processing Framework - Python Core
Python
62
star
4

pyansys

Containing metapackage for the PyAnsys project
Python
50
star
5

pymapdl-reader

Legacy binary interface to MAPDL binary files.
Python
47
star
6

pymechanical

Pythonic interface to Ansys Mechanical â„¢
Python
37
star
7

pydpf-post

Data Processing Framework - Post Processing Module
Python
33
star
8

pyansys-geometry

A Python wrapper for Ansys Geometry Services
Python
29
star
9

optical-automation

Optical Automation Framework
Python
28
star
10

python-installer-qt-gui

Python QT app for installing Python
Python
27
star
11

pyfluent-visualization

Visualize Ansys Fluent simulations using Python
Python
26
star
12

pyansys-dev-guide

PyAnsys Project Developer's Guide
26
star
13

ansys-sphinx-theme

PyData-based Sphinx theme from the PyAnsys community
Python
21
star
14

example-data

This repository contains example datasets for PyAnsys projects.
Python
20
star
15

pytwin

Ansys Digital Twin repository
Python
19
star
16

pyfluent-parametric

Pythonic interface to Ansys Fluent parametric
Python
18
star
17

pyprimemesh

Pythonic Meshing Client for Ansys Prime Server
Python
15
star
18

pyoptislang

Pythonic interface to optiSLang
Python
14
star
19

ansys-templates

A tool for creating new projects according to Ansys guidelines
Python
11
star
20

pymapdl-corba

Python interface to ANSYS APDL CORBA server.
Python
10
star
21

pymotorcad

Python
9
star
22

actions

A collection of reusable workflows
Python
8
star
23

PyAEDT-docs

Host documentation for PyAEDT
HTML
8
star
24

ansys-tools-visualization-interface

A common visualizer for PyAnsys libraries.
Python
8
star
25

pysimai

A Python wrapper for Ansys SimAI
Python
8
star
26

api-eigen-example

Ansys API example repository for demonstrating the use of REST and gRPC in different SW languages (Python, C++...)
C++
7
star
27

create-python-project

This repository holds a wizard that provides commands to auto-generate a python project based on different template structures. The created project will be as per Ansys recommendations.
Python
7
star
28

pydynamicreporting

Pyansys project for Ansys Dynamic Reporting, a report generator tool.
Python
7
star
29

pydpf-composites

A Python wrapper for Ansys DPF for the post-processing of composite structures.
Python
7
star
30

ansys-tools-protoc-helper

Utility for compiling .proto files to Python source
Python
7
star
31

ansys-tools-repo-sync

Tool to synchronize the content of different repositories.
Python
7
star
32

pyensight

Python API for EnSight
Python
6
star
33

ml-rl-cartpole

Reinforced Machine Learning Example: Cartpole
Jupyter Notebook
6
star
34

pyaedt-dev-docs

Host development documentation for PyAEDT
HTML
6
star
35

pyconverter-xml2py

A Python wrapper to convert XML documentation into Python source code with its Sphinx documentation.
Python
6
star
36

pyaedt-toolkits-common

Common library to all PyAEDT toolkits
Python
6
star
37

pyedb

pyedb is a Python library to use the EDB client library.
Python
6
star
38

review-bot

GitHub PR reviewer bot using OpenAI
Python
5
star
39

pyaedt-qt-ui

Simple Pyaedt Qt5 Hfss3dLayout dashboard for Board management
Python
5
star
40

pyansys-cheat-sheet

This repository contains the cheat-sheets for PyAnsys
TeX
5
star
41

pysystem-coupling

Python API to System Coupling
Python
5
star
42

aedt-testing

Testing Framework for Ansys Electronics Desktop
Python
5
star
43

pyaedt-toolkits-antenna

AEDT Antenna Toolkit
Python
5
star
44

ansys-api-geometry

Auto-generated gRPC Python interface files for the Ansys Geometry Service
Python
5
star
45

pymapdl-examples

Repository holding examples for PyMAPDL
Shell
5
star
46

lsdyna-spotless

A toolkit for running LS-DYNA simulations on AWS spot instances while encapsulating away the interruptible behavior by checkpointing on-interruption and greedy job restart.
Shell
5
star
47

DevRelDocs

Documentation staging area for the DevRel site
HTML
4
star
48

grpc_chunk_stream_demo

Demonstrate Large Array Serialization using gRPC
C++
4
star
49

grantami-bomanalytics

Pythonic interface for Ansys Granta Compliance reporting API
Python
4
star
50

5G-Wizard

Tool to calculate Power Density and Cumulative Distribution Function for 5G devices
Python
4
star
51

pyrocky

A Python API for Ansys Rocky
Python
4
star
52

pysherlock

Pythonic interface to Sherlock
Python
4
star
53

pypim

Product Instance Management python client package
Python
4
star
54

pyansys-sound

Pythonic interface to Ansys Sound
Python
4
star
55

pyansys-tools-report

Ansys tool for reporting your Python environment's package versions and hardware resources in a standardized way
Python
3
star
56

example-coverage

Report on example coverage
Python
3
star
57

pyansys-tools-variableinterop

Optional variable specifications for interoperability between languages and capabilities
Python
3
star
58

hollerith

Fixed width formatting library
C++
3
star
59

ansys-api-meshing-prime

Ansys Prime Server Meshing gRPC APIs
Python
3
star
60

pyseascape

Pythonic interface to Ansys RedHawk-SC, Totem-SC and other seascape tools
Python
3
star
61

pyansys-math

A Python repository for mathematical libraries
Python
3
star
62

pyansys-protos-generator

Automatically generate a python package from protofiles stored according to gRPC protofile conventions
Python
3
star
63

ansys-tools-path

Library to detect Ansys products installation path
Python
3
star
64

ansys-engineeringworkflow-api

Common Python API for running and monitoring an Engineering Workflow
Python
3
star
65

template

Template repository
Python
3
star
66

pyaedt-toolkit-template

PyAEDT Toolkit Template
Python
3
star
67

pyansys-helloworld

Demonstrate how to create a basic pyansys service package
Python
2
star
68

pymapdl-dev-docs

Nightly development documentation for pymapdl
HTML
2
star
69

pyadditive

Pythonic interface client to Ansys additive simulation service
Python
2
star
70

ansys-api-modelcenter

Python
2
star
71

.github

Ansys GitHub organization landing page
2
star
72

ansys-tools-local-product-launcher

A utility for launching Ansys products on the local machine
Python
2
star
73

pymechanical-embedding-examples

Examples for the embedding capabilities of pymechanical
2
star
74

DPF-Core-docs

Host built documentation for DPF-Core
2
star
75

py-mel-logging

Library that defines a Python logger that can be used in the Microsoft.Extensions.Logging framework.
Python
2
star
76

DPF-Post-docs

Host built documentation for DPF-Post
HTML
2
star
77

pyansys-tools-versioning

Utilities for backwards and forward server support.
Python
2
star
78

ansys-api-mechanical

Python
2
star
79

ansys-pyensight-vscode

A VSCode extension to empower the PyEnSight Python module
TypeScript
2
star
80

pymodelcenter

Rich Pythonic APIs for Ansys ModelCenter
Python
2
star
81

pymechanical-stubs

Project to generate mechanical api stubs
Python
2
star
82

pyworkbench

PyWorkbench
Python
2
star
83

pyedb-core

Ansys Electronics Database Python Client Package
Python
2
star
84

pyaedt-docs-redirect

Simple redirect from aedtdocs.pyansys.com to aedt.docs.pyansys.com
HTML
1
star
85

grantami-recordlists

A Python wrapper for GRANTA MI RecordLists API
Python
1
star
86

pyansys-sanjose-workshop

PyAnsys Examples for Demos
HTML
1
star
87

ansys-all-members

Repository for updating the ansys/all-members team automatically
Python
1
star
88

openapi-common

Common authentication components for OpenAPI client libraries
Python
1
star
89

c-extension-demo

Simple CPython c-extension demo
C
1
star
90

techcon-2022-pytest

Slides for the TechCon 2022 talk "PyAnsys tools for unit testing"
TeX
1
star
91

ansys-api-discovery

This repository provides the auto-generated gRPC Python interface files for Discovery/SpaceClaim.
Python
1
star
92

magnet-segmentation-toolkit

Magnet segmentation toolkit
Python
1
star
93

pymechanical-examples

Repository holding PyMechanical remote examples
1
star
94

landing-page

PyAnsys documentation landing page
1
star
95

ansys-api-pyensight

Python
1
star
96

techcon-2022-pyvista

TeX
1
star
97

pymechanical-env

Repository for loading environment variables when using PyMechanical embedding instances in Linux
Python
1
star