Skip to main content

A Python wrapper for Ansys optiSLang application.

Project description

PyAnsys Python pypi PyPIact GH-CI Codecov MIT Black

Overview

PyOptiSLang is a Python wrapper for Ansys optiSLang. It supports Pythonic access to Ansys optiSLang to be able to communicate with Ansys optiSLang directly from Python. The latest ansys-optislang package provides these capabilities:

  • Starting and managing local instances of Ansys optiSLang

  • Remote connections to Ansys optiSLang instances via TCP/IP

  • Create new Ansys optiSLang project

  • Open existing Ansys optiSLang project

  • Control Ansys optiSLang project execution

  • Save Ansys optiSLang project

  • Execute classic Ansys optiSLang Python API script on backend side

  • Evaluate designs on root project level

Documentation and issues

For comprehensive information on PyOptiSLang, see the latest release documentation. On the PyOptiSLang Issues page, you can create issues to submit questions, report bugs, and request new features. This is the best place to post questions and code.

Installation

The ansys-optislang-core package supports Python 3.7 through 3.10 on Windows and Linux. Three modes of installation are available:

  • User installation

  • Developer installation

  • Offline installation

For either a developer or offline installation, consider using a virtual environment.

User installation

Install the latest release from PyPi with this command:

pip install ansys-optislang-core

Alternatively, install the latest PyOptiSLang GitHub package with this command:

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

Developer installation

If you plan on doing local development with GitHub, clone and install PyOptiSLang with this code:

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

A developer installation allows you to edit ansys-optislang-core files locally. Any changes that you make are reflected in your setup after restarting the Python kernel.

Offline installation

Using a wheelhouse can be helpful if you work for a company that restricts access to external networks. From the Releases page in the PyOptiSLang repository, you can find the wheelhouses for a particular release in its assets and download the wheelhouse corresponding to your setup.

You can then install PyOptiSLang and all of its dependencies from one single entry point that can be shared internally, which eases the security review of the PyOptiSLang package content.

For example, on Linux with Python 3.7, unzip the wheelhouse and install PyOptiSLang with code like this:

unzip PyOptiSLang-v0.1.0-wheelhouse-Linux-3.7.zip wheelhouse
pip install ansys-optislang-core -f wheelhouse --no-index --upgrade --ignore-installed

If you’re on Windows with Python 3.9, unzip the wheelhouse to a wheelhouse directory and then install using the same pip command as in the preceding Linux code example.

Dependencies

You must have a local licensed copy or a remote instance of optiSLang installed. The first supported version is 2023 R1.

Getting started

Using the Optislang class, you can either launch optiSLang locally or connect to a remote optiSLang instance.

Launch optiSLang locally

For launching optiSLang locally, both the host and port parameters in the Optislang class must be set to None, which are their defaults. Other parameters can optionally be specified.

from ansys.optislang.core import Optislang

osl = Optislang()
osl.dispose()

Connect to a remote optiSLang instance

For remote connection, it is assumed that an optiSLang instance is already running on a remote (or local) host as a server. In this case, you must specify the host and port parameters. Parameters related to the execution of a new optiSLang instance are ignored.

from ansys.optislang.core import Optislang

host = "127.0.0.1"
port = 5310
osl = Optislang(host=host, port=port)
osl.dispose()

Basic usage

This code shows how to launch optiSLang locally, open and run a Python script file, save the results to a new project, and then close the connection:

from ansys.optislang.core import Optislang

osl = Optislang()
file_path = r"C:\Users\Username\my_scripts\myscript.py"
osl.run_python_file(path=file_path)
osl.save_copy("MyNewProject.opf")
osl.dispose()

License and acknowledgments

PyOptiSLang is licensed under the MIT license.

PyOptiSLang makes no commercial claim over Ansys whatsoever. This library extends the functionality of Ansys optiSLang by adding a Python interface to optiSLang without changing the core behavior or license of the original software. The use of the interactive control of PyOptiSLang requires a legally licensed local copy of optiSLang.

For more information on optiSLang, see the Ansys optiSLang page on the Ansys website.

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_optislang_core-0.3.0.tar.gz (527.9 kB view details)

Uploaded Source

Built Distribution

ansys_optislang_core-0.3.0-py3-none-any.whl (548.8 kB view details)

Uploaded Python 3

File details

Details for the file ansys_optislang_core-0.3.0.tar.gz.

File metadata

  • Download URL: ansys_optislang_core-0.3.0.tar.gz
  • Upload date:
  • Size: 527.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for ansys_optislang_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 034d63f2fb62c767da7bb562a88578ceb1a472f1d5ce42925b7992f08379eeb6
MD5 c5e3fe89ee23ac6860c113c969bfe8e2
BLAKE2b-256 0c712ab3b1d48dfd56e7fd322e275432fecc1a77590dd258809eebe5162dd6e1

See more details on using hashes here.

File details

Details for the file ansys_optislang_core-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ansys_optislang_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 449eb5084463093bd6e6f7bdbe68c14a4013119c863b2659e9a7f0c289055556
MD5 2551ccfd46760450a9c274de15dbec36
BLAKE2b-256 4193b5d77605fb9ee3b081f604aa3ad2cc8f302d6bbbc56c5407eaea3fd17ea0

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