MAPDL 梁模态分析示例#

本例演示了如何执行简单的模态分析并将分析结果制作成动画。

Objective#

本示例使用 BEAM188 单元建立了一个简单的三维弹性梁模型。这些梁单元由类似于钢的线弹性材料制成,具有矩形截面。

Procedure#

  • Launch MAPDL instance

  • Material properties

  • Geometry

  • Finite element model

  • Boundary conditions

  • Solving the model

  • Post-processing

  • Stop MAPDL

Launch MAPDL instance#

启动具有交互式绘图功能的 MAPDL

from ansys.mapdl.core import launch_mapdl

nmodes = 10
# start MAPDL
mapdl = launch_mapdl()
print(mapdl)
Product:             Ansys Mechanical Enterprise
MAPDL Version:       23.1
ansys.mapdl Version: 0.67.0

Define material#

定义材料

mapdl.prep7()
mapdl.mp("EX", 1, 2.1e11)
mapdl.mp("PRXY", 1, 0.3)
mapdl.mp("DENS", 1, 7800)
MATERIAL          1     DENS =   7800.000

Create geometry#

创建关键点和线

mapdl.k(1)
mapdl.k(2, 10)
mapdl.l(1, 2)
mapdl.lplot()
modal beam

Define finite element model#

定义单元类型/截面类型 - 矩形梁截面。

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()
modal beam
***** ROUTINE COMPLETED *****  CP =         1.031

Specify boundary conditions#

固定端

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)
modal beam

Solve the model#

Setting modal analysis

mapdl.antype("MODAL")
mapdl.modopt("LANB", nmodes, 0, 200)
mapdl.solve()
mapdl.finish()
FINISH SOLUTION PROCESSING


 ***** ROUTINE COMPLETED *****  CP =         1.047

Postprocess#

Enter the post processor (post1)

mapdl.post1()
output = mapdl.set("LIST")
print(output)

result = mapdl.result
*****  INDEX OF DATA SETS ON RESULTS FILE  *****

   SET   TIME/FREQ    LOAD STEP   SUBSTEP  CUMULATIVE
     1  8.3234             1         1         1
     2  16.275             1         2         2
     3  50.891             1         3         3
     4  60.249             1         4         4
     5  89.208             1         5         5
     6  129.85             1         6         6
     7  138.64             1         7         7
     8  182.23             1         8         8

结果动画

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=False,
    add_text=False,
    n_frames=100,
    displacement_factor=normalizeDisplacement,
    show_axes=False,
    background="w",
    movie_filename="animation.gif",
    off_screen=True,
)
  • modal beam
  • modal beam
Rendering animation:   0%|          | 0/100 [00:00<?, ?it/s]
Rendering animation:   1%|          | 1/100 [00:00<00:12,  7.75it/s]
Rendering animation:   4%|▍         | 4/100 [00:00<00:05, 17.92it/s]
Rendering animation:   7%|▋         | 7/100 [00:00<00:04, 21.18it/s]
Rendering animation:  10%|█         | 10/100 [00:00<00:03, 23.01it/s]
Rendering animation:  13%|█▎        | 13/100 [00:00<00:03, 24.25it/s]
Rendering animation:  16%|█▌        | 16/100 [00:00<00:03, 24.62it/s]
Rendering animation:  19%|█▉        | 19/100 [00:00<00:03, 24.91it/s]
Rendering animation:  22%|██▏       | 22/100 [00:00<00:03, 25.38it/s]
Rendering animation:  25%|██▌       | 25/100 [00:01<00:02, 25.81it/s]
Rendering animation:  28%|██▊       | 28/100 [00:01<00:02, 25.90it/s]
Rendering animation:  31%|███       | 31/100 [00:01<00:02, 26.06it/s]
Rendering animation:  34%|███▍      | 34/100 [00:01<00:02, 26.16it/s]
Rendering animation:  37%|███▋      | 37/100 [00:01<00:02, 26.01it/s]
Rendering animation:  40%|████      | 40/100 [00:01<00:02, 26.10it/s]
Rendering animation:  43%|████▎     | 43/100 [00:01<00:02, 26.19it/s]
Rendering animation:  46%|████▌     | 46/100 [00:01<00:02, 26.23it/s]
Rendering animation:  49%|████▉     | 49/100 [00:01<00:01, 26.17it/s]
Rendering animation:  52%|█████▏    | 52/100 [00:02<00:01, 26.25it/s]
Rendering animation:  55%|█████▌    | 55/100 [00:02<00:01, 26.23it/s]
Rendering animation:  58%|█████▊    | 58/100 [00:02<00:01, 26.02it/s]
Rendering animation:  61%|██████    | 61/100 [00:02<00:01, 24.65it/s]
Rendering animation:  64%|██████▍   | 64/100 [00:02<00:01, 24.54it/s]
Rendering animation:  67%|██████▋   | 67/100 [00:02<00:01, 24.99it/s]
Rendering animation:  70%|███████   | 70/100 [00:02<00:01, 25.37it/s]
Rendering animation:  73%|███████▎  | 73/100 [00:02<00:01, 25.17it/s]
Rendering animation:  76%|███████▌  | 76/100 [00:03<00:00, 25.71it/s]
Rendering animation:  79%|███████▉  | 79/100 [00:03<00:00, 25.98it/s]
Rendering animation:  82%|████████▏ | 82/100 [00:03<00:00, 25.96it/s]
Rendering animation:  85%|████████▌ | 85/100 [00:03<00:00, 26.21it/s]
Rendering animation:  88%|████████▊ | 88/100 [00:03<00:00, 26.67it/s]
Rendering animation:  91%|█████████ | 91/100 [00:03<00:00, 26.85it/s]
Rendering animation:  94%|█████████▍| 94/100 [00:03<00:00, 26.53it/s]
Rendering animation:  97%|█████████▋| 97/100 [00:03<00:00, 26.80it/s]
Rendering animation: 100%|██████████| 100/100 [00:03<00:00, 26.96it/s]
Rendering animation: 100%|██████████| 100/100 [00:03<00:00, 25.17it/s]

[(16.153550716504107, 11.153550716504107, 11.153550716504107),
 (5.0, 0.0, 0.0),
 (0.0, 0.0, 1.0)]

Stop MAPDL#

mapdl.finish()
mapdl.exit()

Total running time of the script: (0 minutes 6.058 seconds)