Suddenly reported an error and the program cannot run? #3045
-
May I ask why I used it normally a few days ago, but today I suddenly reported an error and the program cannot run?
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Here is all my code. from ansys.mapdl.core import launch_mapdl
def daoru():
f = open("C://Software//Qt_Project//demo6//ansys_module//shangyuanzhu.txt", "r", encoding='utf-8')
str_0 = f.read()
f.close()
return str_0
def daoru1():
f = open("C://Software//Qt_Project//demo6//ansys_module//xiayuanzhu.txt", "r", encoding='utf-8')
str_1 = f.read()
f.close()
return str_1
def daoru2():
f = open("C://Software//Qt_Project//demo6//ansys_module//changfangti.txt", "r", encoding='utf-8')
str_2 = f.read()
f.close()
return str_2
# 初始化 ANSYS Mapdl
mapdl = launch_mapdl()
mapdl.clear()
mapdl.prep7()
# 创建几何体
b1 = mapdl.block(daoru2()) # 创建中间长方体1
mapdl.block(70, 130, -30, 30, -30, -20) # 创建一边的长方体2
mapdl.block(-130, -70, -30, 30, 20, 30) # 另一边的长方体3
c_top = mapdl.cylind(daoru()) # 创建上圆柱体
c_bottom = mapdl.cylind(daoru1()) # 创建下圆柱体
mapdl.wprota(0, -90) # 设置工作平面旋转角度(xy ,yz ,zx)
mapdl.wpoffs(40, 0, 30) # 设置工作平面偏移量
c_lft = mapdl.cyl4(0, 0, 17.5, "", "", "", -60) # 创建左圆柱体
mapdl.wpoffs(-80, 0, 0)
c_rgt = mapdl.cyl4(0, 0, 17.5, "", "", "", -60) # 创建右圆柱体
mapdl.wpoffs(40, 0, -30)
mapdl.wprota(0, 90)
b_sub = mapdl.block(-40, 40, -30, 30, -7.5, 7.5) # 创建子长方体
mapdl.finish()
mapdl.prep7() # 访问前处理器
# 添加节点和体元素
mapdl.vlist()
mapdl.vadd(6, 7, 8)
mapdl.vsbv(1, 9)
mapdl.vadd(2, 3, 4, 5, 6)
# 定义属性
mapdl.et(1, "SOLID186") # 定义单元类型
mapdl.mp("EX", "1", "2E11") # 定义弹性模量
mapdl.mp("NUXY", "1", "0.3") # 定义泊松比
# 网格划分
mapdl.type("1") # 激活单元类型号1
mapdl.mat("1") # 激活材料号1
mapdl.smrtsize("3") # 智能分网,大小为3。1-10中数字越小划分越精细
mapdl.mshape(1) # 四面体网格
mapdl.vmesh("ALL") # 执行分网
mapdl.finish() # 退出当前处理器
# 绘制模型
mapdl.eplot(off_screen=True)
pl = mapdl.vplot(quality=5, return_plotter=True, off_screen=True)
# 访问求解器
mapdl.slashsolu()
# 设置边界条件
mapdl.nsel("S", "LOC", "Z", "-45") # 选择z坐标值为-45的全部结点
mapdl.d("ALL", "ALL", "0") # 指定边界条件为固定约束
mapdl.allsel("ALL") # 全选
# 施加加载荷
mapdl.f("ALL", "FZ", "198") # 施加荷载
mapdl.allsel("ALL") # 全选
# 求解
mapdl.antype("STATIC") # 设置分析类型为静力分析
mapdl.solve() # 提交求解器进行求解
mapdl.finish() # 退出当前处理器
# 后处理
mapdl.post1()
mapdl.set("last")
mapdl.prnsol("EPTO", "COMP")
mapdl.post_processing.plot_nodal_total_eqv_strain()
mapdl.post_processing.plot_nodal_elastic_component_strain('X', 'XZ')
# 应变
mapdl.set("LAST")
cmd = mapdl.prnsol("EPTO", "PRIN")
# 保存结果
with open("Result_EPTO.txt", "w") as fo:
fo.write(cmd)
# 选择左上角节点并输出应变结果
leftup = mapdl.nsel('s', 'loc', -80, 0, 18.5)
cmd1 = mapdl.prnsol("leftup", "PRIN")
with open("Result_1.txt", "w") as fo:
fo.write(cmd1)
allow_ignore = True
mapdl.finish() |
Beta Was this translation helpful? Give feedback.
-
Hi @COOLEST-GET In the last weeks, no new PyMAPDL release has been published, nor new MAPDL release. Hence I doubt it is a library error (I'm assuming you are not using PyMAPDL from a cloned repo). Now, it seems you might have changed something in the model because you get:
As the message explains, it seems your model is not constrained enough so it is moving freely in space. Check you have applied forces and/or displacements in all three directions. |
Beta Was this translation helpful? Give feedback.
-
I used this approach as a solution in the previous version of this code, but it was not resolved in the version I released. Why do I have to make changes to the code when my SB teammate wrote something |
Beta Was this translation helpful? Give feedback.
Hi @COOLEST-GET
In the last weeks, no new PyMAPDL release has been published, nor new MAPDL release.
Hence I doubt it is a library error (I'm assuming you are not using PyMAPDL from a cloned repo).
Now, it seems you might have changed something in the model because you get: