Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAPDL 2D Beam Example is not working #2428

Closed
4 tasks done
iazehaf opened this issue Oct 17, 2023 · 2 comments
Closed
4 tasks done

MAPDL 2D Beam Example is not working #2428

iazehaf opened this issue Oct 17, 2023 · 2 comments

Comments

@iazehaf
Copy link

iazehaf commented Oct 17, 2023

🤓 Before submitting the issue

🔍 Description of the bug

I downloaded the MAPDL 2D Beam Example from the gallery examples here. When I run the script I get this error message:

CRITICAL - pymapdl_global -  logging - handle_exception - Uncaught exception
Traceback (most recent call last):
  File "D:\Sandbox\mapdl_beam.py", line 15, in <module>
    from ansys.mapdl.core import launch_mapdl
  File "D:\Sandbox\.venv\lib\site-packages\ansys\mapdl\core\__init__.py", line 62, in <module>
    import pyvista
  File "D:\Sandbox\.venv\lib\site-packages\pyvista\__init__.py", line 9, in <module>
    from pyvista.core import *
  File "D:\Sandbox\.venv\lib\site-packages\pyvista\core\__init__.py", line 4, in <module>
    from . import _vtk_core
  File "D:\Sandbox\.venv\lib\site-packages\pyvista\core\_vtk_core.py", line 28, in <module>
    from vtkmodules.numpy_interface.dataset_adapter import (
  File "D:\Sandbox\.venv\lib\site-packages\vtkmodules\numpy_interface\dataset_adapter.py", line 388, in <module>
    class VTKNoneArray(object):
  File "D:\Sandbox\.venv\lib\site-packages\vtkmodules\numpy_interface\dataset_adapter.py", line 170, in decorator
    return mcs(cls.__name__, cls.__bases__, body)
  File "D:\Sandbox\.venv\lib\site-packages\vtkmodules\numpy_interface\dataset_adapter.py", line 385, in __new__
    return type.__new__(mcs, name, parent, attr)
TypeError: 'VTKArrayMetaClass' object is not iterable

🕵️ Steps To Reproduce

"""
.. _ref_mapdl_beam:

MAPDL 2D Beam Example
---------------------

This is an example from the book *"Finite element analysis using ansys 11.0"*
by Paletikrishna Chaitanya, Sambanarajesh Kumar, and Datti Srinivas.
PHI Learning Pvt. Ltd., 1 Jan 2010.

"""

###############################################################################
# Launch MAPDL with interactive plotting
from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl()

###############################################################################
# Define an I-beam
mapdl.prep7()
mapdl.et(1, "BEAM188")
mapdl.keyopt(1, 4, 1)  # transverse shear stress output

# material properties
mapdl.mp("EX", 1, 2e7)  # N/cm2
mapdl.mp("PRXY", 1, 0.27)  #  Poisson's ratio

# beam properties in centimeters
sec_num = 1
mapdl.sectype(sec_num, "BEAM", "I", "ISection", 3)
mapdl.secoffset("CENT")
beam_info = mapdl.secdata(15, 15, 29, 2, 2, 1)  # dimensions are in centimeters

###############################################################################
# Create nodes within MAPDL
mapdl.n(1, 0, 0, 0)
mapdl.n(12, 110, 0, 0)
mapdl.n(23, 220, 0, 0)
mapdl.fill(1, 12, 10)
mapdl.fill(12, 23, 10)

# list the node coordinates
print(mapdl.mesh.nodes)

# list the node numbers
print(mapdl.mesh.nnum)

# plot the nodes using VTK
mapdl.nplot(vtk=True, nnum=True, cpos="xy", show_bounds=True, point_size=10)

###############################################################################
# create elements between the nodes
# we can just manually create elements since we know that the elements
# are sequential
for node in mapdl.mesh.nnum[:-1]:
    mapdl.e(node, node + 1)

# print the elements from MAPDL
print(mapdl.elist())

###############################################################################
# Access them as a list of arrays
# See the documentation on ``mapdl.mesh.elem`` for interpreting the
# individual elements
for elem in mapdl.mesh.elem:
    print(elem)

###############################################################################
# Define the boundary conditions

# Allow movement only in the X and Z direction
for const in ["UX", "UY", "ROTX", "ROTZ"]:
    mapdl.d("all", const)

# constrain just nodes 1 and 23 in the Z direction
mapdl.d(1, "UZ")
mapdl.d(23, "UZ")

# apply a -Z force at node 12
mapdl.f(12, "FZ", -22840)


###############################################################################
# run the static analysis
mapdl.run("/solu")
mapdl.antype("static")
print(mapdl.solve())

###############################################################################
# Stop mapdl
# ~~~~~~~~~~
#
mapdl.exit()

💻 Which Operating System are you using?

Windows

🐍 Which Python version are you using?

3.8

📝 PyMAPDL Report

Show the Report!

CRITICAL - pymapdl_global -  logging - handle_exception - Uncaught exception
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Sandbox\.venv\lib\site-packages\ansys\mapdl\core\__init__.py", line 62, in <module>
    import pyvista
  File "D:\Sandbox\.venv\lib\site-packages\pyvista\__init__.py", line 9, in <module>
    from pyvista.core import *
  File "D:\Sandbox\.venv\lib\site-packages\pyvista\core\__init__.py", line 4, in <module>
    from . import _vtk_core
  File "D:\Sandbox\.venv\lib\site-packages\pyvista\core\_vtk_core.py", line 28, in <module>
    from vtkmodules.numpy_interface.dataset_adapter import (
  File "D:\Sandbox\.venv\lib\site-packages\vtkmodules\numpy_interface\dataset_adapter.py", line 388, in <module>
    class VTKNoneArray(object):
  File "D:\Sandbox\.venv\lib\site-packages\vtkmodules\numpy_interface\dataset_adapter.py", line 170, in decorator
    return mcs(cls.__name__, cls.__bases__, body)
  File "D:\Sandbox\.venv\lib\site-packages\vtkmodules\numpy_interface\dataset_adapter.py", line 385, in __new__
    return type.__new__(mcs, name, parent, attr)
TypeError: 'VTKArrayMetaClass' object is not iterable

📝 Installed packages

Show the installed packages!

ansys-api-mapdl==0.5.1
ansys-api-platform-instancemanagement==1.0.0
ansys-mapdl-core==0.67.0
ansys-mapdl-reader==0.52.20
ansys-math-core==0.1.3
ansys-platform-instancemanagement==1.1.2
ansys-tools-path==0.3.1
appdirs==1.4.4
certifi==2023.7.22
charset-normalizer==3.3.0
click==8.1.7
colorama==0.4.6
contourpy==1.1.1
cycler==0.12.1
fonttools==4.43.1
geomdl==5.3.1
grpcio==1.59.0
idna==3.4
importlib-metadata==6.8.0
kiwisolver==1.4.5
matplotlib==3.8.0
numpy==1.26.1
packaging==23.2
Pillow==10.1.0
platformdirs==3.11.0
pooch==1.7.0
protobuf==3.20.3
psutil==5.9.6
pyansys-tools-versioning==0.5.0
pyiges==0.3.1
pyparsing==3.1.1
python-dateutil==2.8.2
pyvista==0.42.3
requests==2.31.0
scipy==1.11.3
scooby==0.7.4
six==1.16.0
tqdm==4.66.1
urllib3==2.0.6
vtk==9.2.6
zipp==3.17.0

📝 Logger output file

Show the logger output file.

# PASTE HERE THE CONTENT OF THE LOGGER OUTPUT FILE.

@germa89
Copy link
Collaborator

germa89 commented Oct 17, 2023

Hello @iazehaf

It does work for me.

It seems an issue with pyvista. Can you try with a brand new venv?

@iazehaf
Copy link
Author

iazehaf commented Oct 17, 2023

It worked with a new venv. Thank you. It's weird because there was no error message after running pip install ansys-mapdl-core.

@iazehaf iazehaf closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants