ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
433 stars 121 forks source link

.MAPDL 2D Plane Stress Concentration Analysis #2213

Closed mcMunich closed 1 year ago

mcMunich commented 1 year ago

🤓 Before submitting the issue

🔍 Description of the bug

Example MAPDL 2D Plane Stress Concentration Analysis failes in the post processing block.

🕵️ Steps To Reproduce

# grab the result from the ``mapdl`` instance
result = mapdl.result
result.plot_principal_nodal_stress(
    0,
    "SEQV",
    lighting=False,
    cpos="xy",
    background="w",
    text_color="k",
    add_text=False,
)

nnum, stress = result.principal_nodal_stress(0)
von_mises = stress[:, -1]  # von-Mises stress is the right most column

# Must use nanmax as stress is not computed at mid-side nodes
max_stress = np.nanmax(von_mises)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [11], in <cell line: 3>()
      1 # grab the result from the ``mapdl`` instance
      2 result = mapdl.result
----> 3 result.plot_principal_nodal_stress(
      4     0,
      5     "SEQV",
      6     lighting=False,
      7     cpos="xy",
      8     background="w",
      9     text_color="k",
     10     add_text=False,
     11 )

File /opt/conda/lib/python3.9/site-packages/ansys/mapdl/reader/rst.py:2678, in Result.plot_principal_nodal_stress(self, rnum, comp, show_displacement, displacement_factor, node_components, element_components, sel_type_all, treat_nan_as_zero, **kwargs)
   2676 comp = comp.upper()
   2677 idx = check_comp(PRINCIPAL_STRESS_TYPES, comp)
-> 2678 stress = self.principal_nodal_stress(rnum)[1][:, idx]
   2680 if node_components:
   2681     grid, ind = self._extract_node_components(node_components, sel_type_all)

File /opt/conda/lib/python3.9/site-packages/ansys/mapdl/reader/rst.py:2609, in Result.principal_nodal_stress(self, rnum, nodes)
   2607 # get component stress
   2608 nodenum, stress = self.nodal_stress(rnum, nodes)
-> 2609 pstress, isnan = _binary_reader.compute_principal_stress(stress)
   2610 pstress[isnan] = np.nan
   2611 return nodenum, pstress

File ansys/mapdl/reader/cython/_binary_reader.pyx:1607, in ansys.mapdl.reader._binary_reader.compute_principal_stress()

File /opt/conda/lib/python3.9/site-packages/numpy/__init__.py:313, in __getattr__(attr)
    308     warnings.warn(
    309         f"In the future `np.{attr}` will be defined as the "
    310         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    312 if attr in __former_attrs__:
--> 313     raise AttributeError(__former_attrs__[attr])
    315 if attr == 'testing':
    316     import numpy.testing as testing

AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [11], in <cell line: 3>()
      1 # grab the result from the ``mapdl`` instance
      2 result = mapdl.result
----> 3 result.plot_principal_nodal_stress(
      4     0,
      5     "SEQV",
      6     lighting=False,
      7     cpos="xy",
      8     background="w",
      9     text_color="k",
     10     add_text=False,
     11 )

File /opt/conda/lib/python3.9/site-packages/ansys/mapdl/reader/rst.py:2678, in Result.plot_principal_nodal_stress(self, rnum, comp, show_displacement, displacement_factor, node_components, element_components, sel_type_all, treat_nan_as_zero, **kwargs)
   2676 comp = comp.upper()
   2677 idx = check_comp(PRINCIPAL_STRESS_TYPES, comp)
-> 2678 stress = self.principal_nodal_stress(rnum)[1][:, idx]
   2680 if node_components:
   2681     grid, ind = self._extract_node_components(node_components, sel_type_all)

File /opt/conda/lib/python3.9/site-packages/ansys/mapdl/reader/rst.py:2609, in Result.principal_nodal_stress(self, rnum, nodes)
   2607 # get component stress
   2608 nodenum, stress = self.nodal_stress(rnum, nodes)
-> 2609 pstress, isnan = _binary_reader.compute_principal_stress(stress)
   2610 pstress[isnan] = np.nan
   2611 return nodenum, pstress

File ansys/mapdl/reader/cython/_binary_reader.pyx:1607, in ansys.mapdl.reader._binary_reader.compute_principal_stress()

File /opt/conda/lib/python3.9/site-packages/numpy/__init__.py:313, in __getattr__(attr)
    308     warnings.warn(
    309         f"In the future `np.{attr}` will be defined as the "
    310         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    312 if attr in __former_attrs__:
--> 313     raise AttributeError(__former_attrs__[attr])
    315 if attr == 'testing':
    316     import numpy.testing as testing

AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Apparently something changed in Numpy.

💻 Which Operating System are you using?

Windows

🐍 Which Python version are you using?

3.9

📝 PyMAPDL Report

Show the Report! ```text # PASTE HERE THE OUTPUT OF `python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())"` here ```

📝 Installed packages

Show the installed packages! ```text # PASTE HERE THE OUTPUT OF `python -m pip freeze` here ```

📝 Logger output file

Show the logger output file. ```text # PASTE HERE THE CONTENT OF THE LOGGER OUTPUT FILE. ```
germa89 commented 1 year ago

Which version of PyMAPDL and PyMAPDL reader are you using @mcMunich ?? Because I believe that error was fixed in https://github.com/ansys/pymapdl/pull/1709