Skip to content

Commit

Permalink
Merge branch 'main' into ci/links-checker
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 authored Jun 19, 2023
2 parents a8a4537 + 7ce6d7d commit 4caed1e
Show file tree
Hide file tree
Showing 44 changed files with 103 additions and 4,028 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ env:
# You should go up in number, if you go down (or repeat a previous value)
# you might end up reusing a previous cache if it haven't been deleted already.
# It applies 7 days retention policy by default.
RESET_EXAMPLES_CACHE: 0
RESET_DOC_BUILD_CACHE: 0
RESET_AUTOSUMMARY_CACHE: 0
RESET_EXAMPLES_CACHE: 2
RESET_DOC_BUILD_CACHE: 2
RESET_AUTOSUMMARY_CACHE: 2

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ PyMAPDL, see :ref:`ref_mapdl_commands`.
launcher
logging
mapdl
math
mesh
parameters
plotting
pool
post
Pyansys Math <https://math.docs.pyansys.com/version/stable/>
solution
xpl
building_example
Expand Down
1 change: 0 additions & 1 deletion doc/source/api/mapdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ Constants
mapdl_grpc.MapdlGrpc.download
mapdl_grpc.MapdlGrpc.list_error_file
mapdl_grpc.MapdlGrpc.list_files
mapdl_grpc.MapdlGrpc.math
mapdl_grpc.MapdlGrpc.mute
mapdl_grpc.MapdlGrpc.upload

Expand Down
16 changes: 0 additions & 16 deletions doc/source/api/math.rst

This file was deleted.

12 changes: 7 additions & 5 deletions doc/source/api/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,22 @@ It will be executed upstream of each test and not within all tests.
Example
--------

The `test_math.py <pymapdl_test_math_>`_ file contains the unit tests and integration tests of the `ansys.mapdl.core.math module <pymapdl_user_guide_math_>`_. These are just some of the many
.. TO BE MODIFIED
The `test_math.py <pymapdl_test_math_>`_ file contains the unit tests and integration tests of the `ansys.math.core.math module <pymapdl_user_guide_math_>`_. These are just some of the many
tests that you can find in the `test directory <pymapdl_tests_>`_.

Here are some examples of how you use ``pytest``:

.. code:: python
import numpy as np
import ansys.mapdl.core.math as apdl_math
from ansys.math.core.math import AnsMath
@pytest.fixture(scope="module")
def mm(mapdl): # pass the 'mapdl' fixture as an argument.
return mapdl.math
@fixture
def mm():
return AnsMath()
def test_rand(mm): # pass the 'mm' fixture as an argument.
Expand Down
5 changes: 3 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@

# Intersphinx mapping
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"python": ("https://docs.python.org/3/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"pandas": ("https://pandas.pydata.org/docs/", None),
"pyvista": ("https://docs.pyvista.org/version/stable/", None),
"grpc": ("https://grpc.github.io/grpc/python/", None),
"pypim": ("https://pypim.docs.pyansys.com/", None),
"dpf-core": ("https://dpf.docs.pyansys.com/version/stable/", None),
"ansys-dpf-core": ("https://dpf.docs.pyansys.com/version/stable/", None),
"ansys-math-core": ("https://math.docs.pyansys.com/version/stable/", None),
}

suppress_warnings = ["label.*"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ Perform required imports
import math
import matplotlib.pyplot as plt
from ansys.mapdl.core import launch_mapdl
from ansys.math.core.math import AnsMath
mapdl = launch_mapdl(nproc=4)
mapdl.clear()
mm = mapdl.math
# Importing and connecting PyAnsys Math with PyMAPDL
mm = AnsMath(mapdl)
Define parameters
Expand Down
4 changes: 2 additions & 2 deletions doc/source/getting_started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ on Windows and with Ansys 13.0 on Linux.
.. note::

The latest versions of Ansys provide significantly better support
and features. Certain features, such as APDL Math, are not supported
on earlier Ansys versions.
and features. Certain features are not supported on earlier
Ansys versions.

For more information, see :ref:`install_mapdl`.

Expand Down
10 changes: 6 additions & 4 deletions doc/source/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
.. _legacy_reader_docs: https://reader.docs.pyansys.com/
.. _example_data_repo: https://github.com/pyansys/example-data
.. _ansys_tools_path: http://path.tools.docs.pyansys.com/
.. _pyansys_math: https://math.docs.pyansys.com/version/stable/
.. _pyansys_math_api: https://math.docs.pyansys.com/version/stable/api/index.html

.. #PyAnsys Developer Guide
.. _dev_guide_pyansys: https://dev.docs.pyansys.com
.. _dev_guide_contributing: https://dev.docs.pyansys.com/how-to/contributing.html
.. _dev_guide_coding_style: https://dev.docs.pyansys.com/coding-style/index.html

.. #Other libraries
.. _pyvista_docs: https://docs.pyvista.org
.. _pyvista_docs: https://docs.pyvista.org/version/stable/
.. _jupyter: https://jupyter.org/
.. _grpc: https://grpc.io/
.. _pandas_org: https://pandas.pydata.org
.. _numpy_org: https://numpy.org
.. _pandas_org: https://pandas.pydata.org/
.. _numpy_org: https://numpy.org/
.. _numpy_docs: https://numpy.org/doc/stable/
.. _matplotlib_docs: https://matplotlib.org/stable/contents.html
.. _matplotlib_main: https://matplotlib.org
.. _matplotlib_main: https://matplotlib.org/
.. _precommit: https://pre-commit.com/
.. _gmsh: https://gmsh.info/
.. _scipy_docs: https://docs.scipy.org/doc/scipy/reference/
Expand Down
98 changes: 38 additions & 60 deletions doc/source/user_guide/math.rst
Original file line number Diff line number Diff line change
@@ -1,62 +1,30 @@
.. _mapdl_math_class_ref:

APDL Math overview
==================
APDL Math provides the ability to access and manipulate the large
sparse matrices and solve a variety of eigenproblems. PyMAPDL classes
and bindings present APDL Math in a similar manner to the popular
`numpy <numpy_docs_>`_ and `scipy <scipy_docs_>`_ libraries.
The APDL Math command set is based on tools for manipulating large mathematical
matrices and vectors that provide access to standard linear algebra
operations, access to the powerful sparse linear solvers of ANSYS
Mechanical APDL (MAPDL), and the ability to solve eigenproblems.

Python and MATLAB eigensolvers are based on the publicly available
LAPACK libraries and provides reasonable solve time for relatively
small degrees of freedom (dof) eigenproblems of perhaps 100,000.
However, Ansys solvers are designed for the scale of 100 s of
millions of dof, providing a variety of situations where you can
directly leverage Ansys high-performance solvers on a variety of
eigenproblems. Fortunately, you can leverage this without relearning
an entirely new language because APDL Math has been written in a similar manner
as the ``numpy`` and ``scipy`` libraries. For example, here is a comparison between
the NumPy and SciPy linear algebra solvers and the Ansys MAPDL Math solver:

.. table:: ``numpy`` vs PyMAPDL Math Implementation

+--------------------------------------------+-----------------------------------+
| ``numpy`` and ``scipy`` | ``ansys.mapdl.math`` |
+============================================+===================================+
| .. code:: python | .. code:: python |
| | |
| k_py = k + sparse.triu(k, 1).T | k = mm.matrix(k_py, triu=True) |
| m_py = m + sparse.triu(m, 1).T | m = mm.matrix(m_py, triu=True) |
| n = 10 | n = 10 |
| ev = linalg.eigsh(k_py, k=neqv, M=m_py) | ev = mm.eigs(n, k, m) |
| | |
+--------------------------------------------+-----------------------------------+

What follows is a basic example and a detailed description of the
PyMAPDL Math API. For additional PyMAPDL Math examples, see
:ref:`ref_apdl_math_examples`.


MAPDL matrix example
~~~~~~~~~~~~~~~~~~~~
This example demonstrates how to send an MAPDL Math matrix from MAPDL
to Python and then send it back to be solved. While this example runs the
:func:`MapdlMath.eigs() <ansys.mapdl.core.math.MapdlMath.eigs>` method on mass
and stiffness matrices generated from MAPDL, you could instead use
mass and stiffness matrices generated from an external FEM tool or
even modify the mass and stiffness matrices within Python.
PyAnsys Math overview
=====================
`PyAnsys Math <pyansys_math_>`_ provides the ability to access and manipulate
large sparse matrices and solve a variety of eigenproblems in a similar
manner to the popular `numpy <numpy_docs_>`_ and `scipy <scipy_docs_>`_ libraries.


PyMAPDL and PyAnsys Math
~~~~~~~~~~~~~~~~~~~~~~~~
This example demonstrates how to take advantage of the `ansys-math-core` package
with PyMAPDL.

It illustrates how to send an MAPDL Math matrix from MAPDL to Python and then send
it back to be solved. While this example runs the
:func:`mm.eigs() <ansys.math.core.math.AnsMath.eigs>` method on mass and stiffness
matrices generated from MAPDL, you could instead use mass and stiffness matrices
generated from an external FEM tool or even modify the mass and stiffness matrices
within Python.

First, solve the first 10 modes of a ``1 x 1 x 1`` steel meter cube
in MAPDL.

.. code:: python
import re
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()
Expand Down Expand Up @@ -90,11 +58,14 @@ You now have solved for the first 10 modes of the cube:
Next, load the mass and stiffness matrices that are stored by default
in the ``<jobname>.full`` file. First, create an instance of the :class:`MapdlMath
<ansys.mapdl.core.math.MapdlMath>` class as ``mm``:
<ansys.math.core.math.AnsMath>` class as ``mm``:

.. code:: python
mm = mapdl.math
from ansys.math.core.math import AnsMath
# Importing and connecting PyAnsys Math to PyMAPDL
mm = AnsMath(mapdl)
# load by default from file.full
k = mm.stiff()
Expand All @@ -106,7 +77,7 @@ in the ``<jobname>.full`` file. First, create an instance of the :class:`MapdlM
mapdl.clear()
print(k_py)
After running the :func:`Mapdl.clear() <ansys.mapdl.core.Mapdl.clear>` method,
After running the :func:`mapdl.clear() <ansys.mapdl.core.Mapdl.clear>` method,
these matrices are stored solely within Python.

.. code:: output
Expand All @@ -119,6 +90,13 @@ these matrices are stored solely within Python.
(241, 241) 50854700854.68495
(242, 242) 95726495726.47179
To call PyAnsys Math directly from PyMAPDL, you can run this command:

.. code:: python
# Launching PyAnsys Math directly with PyMAPDL
mm = mapdl.math
The final step is to send these matrices back to MAPDL to be solved.
While you have cleared MAPDL, you could have shut down MAPDL or even
Expand All @@ -136,8 +114,8 @@ transferred the matrices to a different MAPDL session to be solved:
print(eigval)
As expected, the natural frequencies obtained from the
:func:`MapdlMath.eigs() <ansys.mapdl.core.math.MapdlMath.eigs>` method is
identical to the result from the :func:`Mapdl.solve() <ansys.mapdl.core.Mapdl.solve>`
:func:`mm.eigs() <ansys.math.core.math.AnsMath.eigs>` method is
identical to the result from the :func:`mapdl.solve() <ansys.mapdl.core.Mapdl.solve>`
method within MAPDL.

.. code:: output
Expand All @@ -147,17 +125,17 @@ method within MAPDL.
If you want to obtain the eigenvectors as well as the eigenvalues,
initialize a matrix ``eigvec`` and send that to the
:func:`MapdlMath.eigs() <ansys.mapdl.core.math.MapdlMath.eigs>` method:
:func:`mm.eigs() <ansys.math.core.math.AnsMath.eigs>` method:

.. code:: pycon
>>> nmode = 10
>>> eigvec = mm.zeros(my_stiff.nrow, nmode) # for eigenvectors
>>> val = mm.eigs(nmode, my_stiff, my_mass, fmin=1)
The MAPDL Math matrix ``eigvec`` now contains the eigenvectors for the
The AnsMath matrix ``eigvec`` now contains the eigenvectors for the
solution.

APDL Math reference
~~~~~~~~~~~~~~~~~~~
For more information, see :ref:`ref_math_api`.
PyAnsys Math reference
~~~~~~~~~~~~~~~~~~~~~~
For more information, see the `PyAnsys Math API reference <pyansys_math_api_>`_.
1 change: 1 addition & 0 deletions doc/styles/Vocab/ANSYS/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Pseudotime
Puri
py
PyAnsys
PyAnsys Math
PyDPF-Core
PyDPF-Post
PyMAPDL
Expand Down
5 changes: 2 additions & 3 deletions examples/00-mapdl-examples/lathe_cutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,8 @@
# Generate a single horizontal slice along the XY plane.
#
# .. note::
# We're using ``eye_dome_lighting`` here to enhance the plots of our slices.
# Read more about it at `Eye Dome Lighting
# <pyvista_eye_dome_lighting_>`_
# PyVista's ``eye_dome_lighting`` method is used here to enhance the plots of the slices.
# For more information, see`Eye Dome Lighting <pyvista_eye_dome_lighting_>`_.

single_slice = grid.slice(normal=[0, 0, 1], origin=[0, 0, 0])
single_slice.plot(
Expand Down
5 changes: 0 additions & 5 deletions examples/01-apdlmath-examples/README.txt

This file was deleted.

Loading

0 comments on commit 4caed1e

Please sign in to comment.