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

Add modal example #2332

Merged
merged 10 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/00-mapdl-examples/3d_notch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
----------------------------------------------------

This tutorial is the 3D corollary to the 2D plane example
:ref:`ref_plane_stress_concentration`, but This example verifies the
:ref:`ref_plane_stress_concentration`.
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved
However, this example verifies the
stress concentration factor :math:`K-t` when modeling opposite single
germa89 marked this conversation as resolved.
Show resolved Hide resolved
notches in a finite width thin plate
notches in a finite width thin plate.
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved

First, start MAPDL as a service and disable all but error messages.
"""
Expand Down
143 changes: 143 additions & 0 deletions examples/00-mapdl-examples/modal_beam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
"""
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved
.. _ref_modal_beam:

=================================
MAPDL modal beam analysis example
=================================

This example demonstrate how to performa a simple modal analysis
germa89 marked this conversation as resolved.
Show resolved Hide resolved
and animate its results.


Objective
~~~~~~~~~
This example models a simple 3D elastic beam made of BEAM188 elements.
These beams elements are made of a linear elastic material similar to steel,
and have a rectangular section.


Procedure
~~~~~~~~~

* Launch MAPDL instance
* Material properties
* Geometry
* Finite element model
* Boundary conditions
* Solving the model
germa89 marked this conversation as resolved.
Show resolved Hide resolved
* Post-processing
* Stop MAPDL

"""

###############################################################################
# Launch MAPDL instance
# =====================
germa89 marked this conversation as resolved.
Show resolved Hide resolved
#
# Launch MAPDL with interactive plotting
from ansys.mapdl.core import launch_mapdl

nmodes = 10
# start MAPDL
mapdl = launch_mapdl()
print(mapdl)


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

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

###############################################################################
# Define finite element model
# ===========================
#
# Define element type/section type - Rectangular beam section
germa89 marked this conversation as resolved.
Show resolved Hide resolved
mapdl.et(1, "BEAM188")
mapdl.sectype(1, "BEAM", "RECT")
mapdl.secoffset("CENT")
mapdl.secdata(2, 1)

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

###############################################################################
# Specify boundary conditions
# ===========================
#
# Fully fixed (clamped) end.
mapdl.solution() # Entering the solution processor.
mapdl.nsel("S", "LOC", "X", "0")
mapdl.d("ALL", "ALL")
mapdl.allsel()
mapdl.nplot(plot_bc=True, nnum=True)

###############################################################################
# Solve the model
# ===============
#
# Setting modal analysis
mapdl.antype("MODAL")
mapdl.modopt("LANB", nmodes, 0, 200)
mapdl.solve()
mapdl.finish()

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

result = mapdl.result

###############################################################################
# Animate results
germa89 marked this conversation as resolved.
Show resolved Hide resolved

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",
)

###############################################################################
# Stop MAPDL
# ==========
#
mapdl.finish()
mapdl.exit()
Loading