gpt4 book ai didi

python - 在 abaqus python 中使用 Element() 构造函数创建零件元素

转载 作者:太空宇宙 更新时间:2023-11-03 16:42:19 24 4
gpt4 key购买 nike

我无法使用 Abaqus 中零件对象的 Element() 构造函数创建元素。 Node() 构造函数没有问题,但是当您尝试使用之前生成的节点创建元素时,它会显示以下错误警告:

There is no mesh to edit

运行脚本之前,零件网格在 Abaqus CAE 树(Recuadro 部分)中显示为空,运行脚本后不再为空,因此我知道网格已生成。

这是我的脚本:

import sys
import mesh
import part

from abaqus import *
from odbAccess import *
from abaqusConstants import *
from caeModules import *
from driverUtils import executeOnCaeStartup

#
# Función que da el número del nodo en función de las fila y columna de elementos
#
def nnodo(i,j,ne):
n = (2*ne+1)*(i-1)+j
return n

filecae= 'E:\ESI\Fatiga\Cotacto Cilindrico\ABQ\CC-Crack-0.cae'
openMdb(filecae)

# Coordenadas del arranque de la grieta en "Recuadro"

x0 =0.0
y0 = -0.002
z0 = 0.0
delta=[0]

# Dimensiones del recuadro x € [x0-a,x0+a] y € [y0-b, y0]

a=0.2
b=0.2

# Tamaño deseado de los elementos ~ le x le

le = 0.05

# Tamaño inicial de los elementos ~ dx x dy

Nex = 2*int(a/le)
Ney = int(b/le)

Nnx = 2*Nex+1
Nny = 2*Ney+1

dx = 2*a/Nex
dy = b/Ney

Nnodos = Nnx*Nny
Nelems = Nex*Ney

inod = range(Nnodos-1)
ielm = range(Nelems-1)

for i in range(Nny):
delta.append(0)

# Coordenadas de los nodos de la malla inicial

recuadro=mdb.models['P22'].parts['Recuadro']
recuadro1=mdb.models['P22'].rootAssembly.instances['Recuadro-1']
recuadro.generateMesh(regions=(recuadro.faces[0],))

for i in range(1,Nny+1):
dx1 = (Nex*dx/2 - delta[i])/Nex
dx2 = (Nex*dx/2 + delta[i])/Nex

y = y0 - (i-1)*dy/2

for j in range(1,Nnx+1):
if float(i)/2. <> int(float(i)/2. ) or float(j)/2. <>int(float(j)/2. ):
k = (2*Nex+1)*(i-1)+j

if j<=Nex+1:
x = x0 - Nex*dx/2 + (j-1)*dx1

else:
x = x0 - delta[i] + (j-Nex-1)*dx2

recuadro.Node(label = k, coordinates=(x, y, 0.))


# Conectividades de los elementos de la malla inicial

for i in range(1,Ney+1):

for j in range(1,Nex+1):

k = Nex*(i-1)+j

n1 = recuadro.nodes[nnodo(2*i+1, 2*j-1, Nex)]
n2 = recuadro.nodes[nnodo(2*i+1, 2*j , Nex)]
n3 = recuadro.nodes[nnodo(2*i+1, 2*j+1, Nex)]
n4 = recuadro.nodes[nnodo(2*i , 2*j+1, Nex)]
n5 = recuadro.nodes[nnodo(2*i-1, 2*j+1, Nex)]
n6 = recuadro.nodes[nnodo(2*i-1, 2*j , Nex)]
n7 = recuadro.nodes[nnodo(2*i-1, 2*j-1, Nex)]
n8 = recuadro.nodes[nnodo(2*i , 2*j-1, Nex)]

recuadro.Element(label = k, elemShape= QUAD8, nodes=(n1, n2, n3, n4, n5, n6, n7, n8))

最佳答案

我记得我也对这个问题感到困惑。嗯,事情是这样的 - Part 实例实际上尚未分配给您刚刚创建的元素。尝试 mdb.models[MODELNAME].parts[PARTNAME].elements[ELEMENTLABEL].instanceName,您会看到它是 None,因为没有返回值。我不确定这是设计使然,还是一个错误。但基本上,Part 对象有一个方法可以解决这个问题:

p = mdb.models[MODELNAME].parts[PARTNAME].PartFromMesh(name=PARTNAME, copySets=True)

你就完成了。

PS:不过,我可能会补充一点 - 对于中型到大型网格,以这种方式循环创建节点和元素对我来说似乎非常慢。 (提示:还有更快的方法!)

关于python - 在 abaqus python 中使用 Element() 构造函数创建零件元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36689793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com