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

modal analysis #2310

Closed
mcMunich opened this issue Sep 5, 2023 · 4 comments · Fixed by #2332
Closed

modal analysis #2310

mcMunich opened this issue Sep 5, 2023 · 4 comments · Fixed by #2332
Assignees

Comments

@mcMunich
Copy link
Contributor

mcMunich commented Sep 5, 2023

📝 Description of the example

Modal analysis of a beam.

📁 Files needed for running the example

"""
.. _ref_modal_beam:

MAPDL Modal Beam Analysis Example
---------------------

About as simple as it gets.
"""

###############################################################################
# Launch MAPDL with interactive plotting
from ansys.mapdl.core import launch_mapdl
nmodes = 10
# start MAPDL
mapdl = launch_mapdl()
print(mapdl)

mapdl.prep7()

# Define material
mapdl.mp('EX', 1, 2.1e11)
mapdl.mp('PRXY', 1, 0.3)
mapdl.mp('DENS',1, 7800)

# Define element type/section type - Rectangular beam section 
mapdl.et(1, 'BEAM188')
mapdl.sectype(1,'BEAM','RECT')
mapdl.secoffset('CENT')
mapdl.secdata(2,1)

# Create keypoints and line
mapdl.k(1)
mapdl.k(2,10)
mapdl.l(1,2)
#mapdl.lplot()

# Mesh the line
mapdl.type(1)
mapdl.esize(1)
mapdl.lesize('ALL')
mapdl.lmesh('ALL')
mapdl.eplot()
mapdl.finish()

# Enter the solution processor for boundary conditions
mapdl.run("/SOLU")
# Boundary condition (fixed end )
mapdl.nsel('S,LOC,X,0')
mapdl.d('ALL','ALL')
mapdl.allsel()
mapdl.nplot(plot_bc=True, nnum=True)
mapdl.antype('MODAL')
mapdl.modopt('LANB',nmodes,0,200)
#### Solve
mapdl.solve()
#mapdl.modal_analysis(nmode=nmodes, freqb=1)
mapdl.finish()

# Enter the post processor (post1)
mapdl.post1()
output = mapdl.set('LIST')
print(output)

result = mapdl.result

## animate result
mode2plot = 2
normalizeDisplacement = 1/result.nodal_displacement(mode2plot-1)[1].max()
result.plot_nodal_displacement( mode2plot, show_displacement=True, displacement_factor=normalizeDisplacement, n_colors=10)

result.animate_nodal_displacement(
    mode2plot,
    loop=True,
    add_text=False,
    n_frames=100,
    displacement_factor=normalizeDisplacement,
    show_axes=False,
    background="w",
    movie_filename="plane_vib.gif",
)

mapdl.finish()
mapdl.exit()

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

23.2

🐍 Which Python version are you using?

3.11

📦 Installed packages

Show the Report! ```shell aiohttp==3.8.4 aiosignal==1.3.1 alabaster==0.7.13 ansi2html==1.8.0 ansys-api-mapdl==0.5.1 ansys-api-mechanical==0.1.0 ansys-api-meshing-prime==0.1.1 ansys-api-platform-instancemanagement==1.0.0b3 ansys-dpf-core==0.9.0 ansys-dpf-gate==0.4.1 ansys-dpf-gatebin==0.3.1 ansys-dpf-post==0.5.0 ansys-grpc-dpf==0.7.1 ansys-mapdl-core==0.65.2 ansys-mapdl-reader==0.52.20 ansys-mechanical-core==0.10.1 ansys-meshing-prime==0.4.0 ansys-platform-instancemanagement==1.1.1 ansys-pythonnet==3.1.0rc1 ansys-tools-path==0.3.1 anyio==3.7.1 appdirs==1.4.4 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 astroid==2.15.6 asttokens==2.2.1 async-lru==2.0.4 async-timeout==4.0.2 atomicwrites==1.4.1 attrs==23.1.0 autopep8==2.0.2 Babel==2.12.1 backcall==0.2.0 bcrypt==4.0.1 beautifulsoup4==4.12.2 binaryornot==0.4.4 black==23.7.0 bleach==6.0.0 cachetools==5.3.1 certifi==2023.5.7 cffi==1.15.1 chardet==5.1.0 charset-normalizer==3.2.0 click==8.1.4 cloudpickle==2.2.1 clr-loader==0.2.6 colorama==0.4.6 comm==0.1.3 contourpy==1.1.0 cookiecutter==2.2.3 cryptography==41.0.2 cycler==0.11.0 dash==2.13.0 dash-core-components==2.0.0 dash-html-components==2.0.0 dash-table==5.0.0 debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 diff-match-patch==20230430 dill==0.3.6 docstring-to-markdown==0.12 docutils==0.20.1 executing==1.2.0 fastjsonschema==2.17.1 flake8==6.0.0 Flask==2.2.5 fonttools==4.41.0 fqdn==1.5.1 frozenlist==1.4.0 geomdl==5.3.1 google-api-core==2.11.1 google-api-python-client==2.93.0 google-auth==2.22.0 google-auth-httplib2==0.1.0 googleapis-common-protos==1.59.1 grpcio==1.56.0 httplib2==0.22.0 idna==3.4 imagesize==1.4.1 importlib-metadata==6.8.0 inflection==0.5.1 intervaltree==3.1.0 ipykernel==6.24.0 ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.0.7 isoduration==20.11.0 isort==5.12.0 itsdangerous==2.1.2 jaraco.classes==3.3.0 jedi==0.18.2 jellyfish==1.0.0 Jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 jsonschema==4.18.2 jsonschema-specifications==2023.6.1 jupyter-events==0.7.0 jupyter-lsp==2.2.0 jupyter_client==8.3.0 jupyter_core==5.3.1 jupyter_server==2.7.0 jupyter_server_terminals==0.4.4 jupyterlab==4.0.3 jupyterlab-pygments==0.2.2 jupyterlab-widgets==3.0.8 jupyterlab_server==2.24.0 keyring==24.2.0 kiwisolver==1.4.4 lazy-object-proxy==1.9.0 MarkupSafe==2.1.3 matplotlib==3.7.2 matplotlib-inline==0.1.6 mccabe==0.7.0 mistune==3.0.1 more-itertools==9.1.0 multidict==6.0.4 mypy-extensions==1.0.0 nbclient==0.8.0 nbconvert==7.6.0 nbformat==5.9.1 nest-asyncio==1.5.6 notebook_shim==0.2.3 numpy==1.25.1 numpydoc==1.5.0 overrides==7.3.1 packaging==23.1 pandocfilters==1.5.0 paramiko==3.2.0 parso==0.8.3 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 Pillow==10.0.0 platformdirs==3.8.1 plotly==5.15.0 pluggy==1.2.0 pooch==1.7.0 prometheus-client==0.17.1 prompt-toolkit==3.0.39 protobuf==3.20.3 protoc-gen-swagger==0.1.0 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 pyansys-tools-versioning==0.4.0 pyasn1==0.5.0 pyasn1-modules==0.3.0 pycodestyle==2.10.0 pycparser==2.21 pydocstyle==6.3.0 pyflakes==3.0.1 Pygments==2.15.1 pyiges==0.3.1 pylint==2.17.4 pylint-venv==3.0.2 pyls-spyder==0.4.0 PyNaCl==1.5.0 pyparsing==3.0.9 PyQt5==5.15.9 PyQt5-Qt5==5.15.2 PyQt5-sip==12.12.1 PyQtWebEngine==5.15.6 PyQtWebEngine-Qt5==5.15.2 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-black==1.3.0 python-lsp-jsonrpc==1.0.0 python-lsp-server==1.7.4 python-slugify==8.0.1 pytoolconfig==1.2.5 pyvista==0.40.1 pywin32==306 pywin32-ctypes==0.2.2 pywinpty==2.0.11 PyYAML==6.0 pyzmq==25.1.0 QDarkStyle==3.1 qstylizer==0.2.2 QtAwesome==1.2.3 qtconsole==5.4.3 QtPy==2.3.1 referencing==0.29.1 requests==2.31.0 retrying==1.3.4 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.9.0 rpds-py==0.8.10 rsa==4.9 Rtree==1.0.1 scipy==1.11.1 scooby==0.7.2 Send2Trash==1.8.2 six==1.16.0 sniffio==1.3.0 snowballstemmer==2.2.0 sortedcontainers==2.4.0 soupsieve==2.4.1 Sphinx==7.0.1 sphinxcontrib-applehelp==1.0.4 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 spyder==5.4.5 spyder-kernels==2.4.4 stack-data==0.6.2 tenacity==8.2.2 terminado==0.17.1 text-unidecode==1.3 textdistance==4.5.0 three-merge==0.1.1 tinycss2==1.2.1 tomli==2.0.1 tomlkit==0.11.8 tornado==6.3.2 tqdm==4.65.0 traitlets==5.9.0 trame==3.2.4 trame-client==2.10.0 trame-components==2.1.1 trame-deckgl==2.0.2 trame-markdown==2.0.2 trame-matplotlib==2.0.2 trame-plotly==2.1.1 trame-rca==0.3.1 trame-router==2.0.2 trame-server==2.11.7 trame-simput==2.3.2 trame-vega==2.0.3 trame-vtk==2.5.4 trame-vuetify==2.2.4 typing_extensions==4.7.1 ujson==5.8.0 uri-template==1.3.0 uritemplate==4.1.1 urllib3==1.26.16 vtk==9.2.6 watchdog==3.0.0 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.1 Werkzeug==2.2.3 whatthepatch==1.0.5 widgetsnbextension==4.0.8 wrapt==1.15.0 wslink==1.11.1 yapf==0.40.1 yarl==1.9.2 zipp==3.16.1 ```
@germa89
Copy link
Collaborator

germa89 commented Sep 5, 2023

Thank you a lot @mcMunich !

@germa89
Copy link
Collaborator

germa89 commented Sep 5, 2023

Suggestions for the future implementation:

  • Use mapdl.solution() instead of mapdl.slashsolu()
  • Implement animations?

@mcMunich
Copy link
Contributor Author

mcMunich commented Sep 6, 2023

@germa89 Animations should be included. I just didn't have time and there are exactly 0 modal analyses on the examples page. I see that as an oversight. Also @mikerife had some preliminary ideas how to plot the secdata which is/not? currently possible. Maybe that can also be added?

@mcMunich
Copy link
Contributor Author

mcMunich commented Sep 12, 2023

@germa89 animation added above but couldn't get mapdl.solution() to work in place of mapdl.run()

@germa89 germa89 self-assigned this Sep 15, 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

Successfully merging a pull request may close this issue.

3 participants