Metadata-Version: 2.4
Name: ansys-optislang-core
Version: 1.4.1
Summary: A Python wrapper for Ansys optiSLang application.
Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
Requires-Python: >=3.9,<4
Description-Content-Type: text/x-rst
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
License-File: LICENSE
Requires-Dist: psutil>=5.9
Requires-Dist: Deprecated>=1.2.14
Requires-Dist: pywin32>=304; sys_platform == 'win32'
Requires-Dist: build>=0.8.0 ; extra == "build"
Requires-Dist: twine>=4.0.1 ; extra == "build"
Requires-Dist: ansys-sphinx-theme==1.6.4 ; extra == "doc"
Requires-Dist: matplotlib==3.10.1 ; extra == "doc"
Requires-Dist: numpydoc==1.9.0 ; extra == "doc"
Requires-Dist: pypandoc==1.16.2 ; extra == "doc"
Requires-Dist: quarto-cli==1.8.25 ; extra == "doc"
Requires-Dist: Sphinx==8.2.3 ; extra == "doc"
Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
Requires-Dist: sphinx-gallery==0.19.0 ; extra == "doc"
Requires-Dist: pytest==8.4.2 ; extra == "tests"
Requires-Dist: pytest-cov==7.0.0 ; extra == "tests"
Requires-Dist: matplotlib>=3.5.3 ; extra == "tests"
Requires-Dist: mypy==1.19.0 ; extra == "typing"
Requires-Dist: types-Deprecated ; extra == "typing"
Requires-Dist: types-psutil ; extra == "typing"
Project-URL: Documentation, https://optislang.docs.pyansys.com
Project-URL: Homepage, https://optislang.docs.pyansys.com
Project-URL: Source, https://github.com/ansys/pyoptislang
Project-URL: Tracker, https://github.com/ansys/pyoptislang/issues
Provides-Extra: build
Provides-Extra: doc
Provides-Extra: tests
Provides-Extra: typing

PyOptiSLang
===========
|pyansys| |python| |pypi| |PyPIact| |GH-CI| |codecov| |MIT| |black|

.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
   :target: https://docs.pyansys.com/
   :alt: PyAnsys

.. |python| image:: https://img.shields.io/pypi/pyversions/ansys-optislang-core?logo=pypi
   :target: https://pypi.org/project/ansys-optislang-core/
   :alt: Python

.. |pypi| image:: https://img.shields.io/pypi/v/ansys-optislang-core.svg?logo=python&logoColor=white
   :target: https://pypi.org/project/ansys-optislang-core/

.. |PyPIact| image:: https://img.shields.io/pypi/dm/ansys-optislang-core.svg?label=PyPI%20downloads
   :target: https://pypi.org/project/ansys-optislang-core/

.. |codecov| image:: https://codecov.io/gh/ansys/pyoptislang/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/ansys/pyoptislang
   :alt: Codecov

.. |GH-CI| image:: https://github.com/ansys/pyoptislang/actions/workflows/ci_cd.yml/badge.svg
   :target: https://github.com/ansys/pyoptislang/actions/workflows/ci_cd.yml
   :alt: GH-CI

.. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
   :target: https://opensource.org/licenses/MIT
   :alt: MIT

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
   :target: https://github.com/psf/black
   :alt: 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:

- Start and manage local instances of Ansys optiSLang
- Remote connections to Ansys optiSLang instances via TCP/IP
- Create new Ansys optiSLang projects
- Open existing Ansys optiSLang projects
- Control Ansys optiSLang project execution
- Save Ansys optiSLang projects
- Execute Ansys optiSLang Python API scripts on backend side
- Evaluate designs on root project level
- Create and connect nodes


Documentation and issues
------------------------
For comprehensive information on PyOptiSLang, see the latest release
`documentation <https://optislang.docs.pyansys.com>`_. On the
`PyOptiSLang Issues <https://github.com/ansys/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.9 through 3.13 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
<https://docs.python.org/3/library/venv.html>`_.

User installation
~~~~~~~~~~~~~~~~~
Install the latest release from `PyPi
<https://pypi.org/project/ansys-optislang-core/>`_ with this command:

.. code::

   pip install ansys-optislang-core


Alternatively, install the latest `PyOptiSLang GitHub
<https://github.com/ansys/pyoptislang/issues>`_ package with this command:

.. code::

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


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

.. code::

   git clone https://github.com/ansys/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 <https://github.com/ansys/pyoptislang/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.9, unzip the wheelhouse and install PyOptiSLang with code
like this:

.. code:: bash

    unzip PyOptiSLang-v0.1.0-wheelhouse-Linux-3.9.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 an
already running optiSLang instance. By default, PyOptiSLang uses local domain communication
(Named Pipes on Windows and Unix Domain Sockets on Linux) in user scope. For remote connections,
TCP/IP communication can be used optionally.

Launch optiSLang locally
~~~~~~~~~~~~~~~~~~~~~~~~

For launching optiSLang locally, use the ``Optislang`` class without specifying either of the
``local_server_id`` or ``host`` and ``port`` arguments. This launches optiSLang locally and
establishes a local domain communication channel. The ``communication_channel`` argument can be specified
to use remote TCP/IP communication if desired. Other parameters can optionally be specified.

.. code:: python

    from ansys.optislang.core import Optislang

    osl = Optislang()
    osl.dispose()


Connect to an already running optiSLang instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For connection to an already running optiSLang instance, you must specify either of the
``local_server_id`` or ``host`` and ``port`` arguments.
Arguments related to the execution of a new optiSLang instance are ignored in this case.

.. code:: python

    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:

.. code:: python

    from ansys.optislang.core import Optislang

    osl = Optislang()
    file_path = r"C:\Users\Username\my_scripts\myscript.py"
    osl.application.project.run_python_file(path=file_path)
    osl.application.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 <https://www.ansys.com/products/connect/ansys-optislang>`_
page on the Ansys website.

