from ansys.mapdl.core import launch_mapdl
from ansys.mapdl.core import Mapdl
import numpy as np
# 启动 ANSYS MAPDL
mapdl = launch_mapdl(run_location='https://www.gofarlic.com\\20Program Files\\ANSYS Inc\\v202\\ansys\\bin\\winx64', override=True)
# 设置 ANSYS MAPDL 参数
mapdl.prep7()
mapdl.units('SI')
# 定义一个四边形
mapdl.block(0, 1, 0, 1, 0, 0.1)
print('1')
# 网格划分
mapdl.et(1, "SOLID186")
mapdl.esize(0.05)
mapdl.vmesh("all")
mapdl.eplot()
mapdl.enorm("all")
mapdl.allsel()
print('2')
# 应用荷载和约束
mapdl.nsel("s", "loc", "z", 0)
mapdl.d("all", "uz")
mapdl.nsel("s", "loc", "z", 1)
mapdl.f("all", "fy", 10)
print('3')
# 求解并输出结果
mapdl.solve(allow_ignore=True)
mapdl.finish()
mapdl.post1()
mapdl.set(1, 1)
# 打印节点数和单元数
print("The number of nodes is: ", mapdl.mesh.n_node)
print("The number of elements is: ", mapdl.mesh.n_elem)
# 打印位移和应力
max_displacement = np.max(mapdl.nodal_displacement(1)[:, 2])
max_stress = np.max(mapdl.principal_stress(1))
max_node_displacement = np.max(np.abs(mapdl.nodal_displacement(1)))
print("The maximum displacement in the z-direction is: ", max_displacement)
print("The maximum stress is: ", max_stress)
print("The maximum nodal displacement is: ", max_node_displacement
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删