Giter VIP home page Giter VIP logo

pymechanical's Introduction

PyMechanical logo

PyAnsys PyPI Python GH-CI Codecov MIT Black

Overview

PyMechanical brings Ansys Mechanical to Python. It enables your Python programs to use Mechanical within Python's ecosystem. It includes the ability to:

  • Connect to a remote Mechanical session
  • Embed an instance of Mechanical directly as a Python object

Install the package

Install PyMechanical using pip with:

pip install ansys-mechanical-core

For more information, see Install the package in the PyMechanical documentation.

Dependencies

You must have a licensed copy of Ansys Mechanical installed. When using an embedded instance, that installation must be runnable from the same computer as your Python program. When using a remote session, a connection to that session must be reachable from your Python program.

Getting started

PyMechanical uses the built-in scripting capabilities of Mechanical. For information on the scripting APIs available, see the Scripting in Mechanical Guide in the Ansys Help.

Configuring the mechanical installation

On a Windows system, the environment variable AWP_ROOT<ver> is configured when Mechanical is installed, where <ver> is the Mechanical release number, such as 231 for release 2023 R1. PyMechanical automatically uses this environment variable (or variables if there are multiple installations of different versions) to locate the latest Mechanical installation. On a Linux system, you must configure the AWP_ROOT<ver> environment variable to point to the absolute path of a Mechanical installation.

Starting a remote session

To start a remote session of Mechanical on your computer from Python, use the launch_mechanical() method. This methods returns an object representing the connection to the session:

import ansys.mechanical.core as pymechanical

mechanical = pymechanical.launch_mechanical()

Running commands on the remote session

Given a connection to a remote session, you can send an IronPython script. This uses the built-in scripting capabilities of Mechanical. Here is an example:

result = mechanical.run_python_script("2+3")
result = mechanical.run_python_script("ExtAPI.DataModel.Project.ProjectDirectory")

Using an embedded instance of Mechanical as a Python object

PyMechanical also supports directly embedding an instance of Mechanical as a Python object. In this mode, there is no externally running instance of Mechanical. This feature is supported on Windows for version 2023 R1 and later, and on Linux for version 2023 R2 and later. Here is an example:

import ansys.mechanical.core as pymechanical

app = pymechanical.App()
project_dir = app.ExtAPI.DataModel.Project.ProjectDirectory

Documentation and issues

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

On the PyMechanical Issues page, you can create issues to report bugs and request new features. On the PyMechanical 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].

Testing and development

If you would like to test or contribute to the development of PyMechanical, see Contribute in the PyMechanical documentation.

pymechanical's People

Contributors

dependabot[bot] avatar koubaa avatar klmcadams avatar robpasmue avatar samigithub2022 avatar dipinknair avatar pre-commit-ci[bot] avatar pipkat avatar akaszynski avatar maxjprey avatar rajesh1359 avatar revathyvenugopal162 avatar eric-clevenger avatar germa89 avatar jorgepiloto avatar raph-luc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.