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

2024-04-28 15:57:05 发布

您现在位置:Python中文网/ 问答频道 /正文

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

There is no mesh to edit

在运行脚本之前,部件网格在Abaqus CAE树(part 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))

Tags: infromimportleforrangedenodes
1条回答
网友
1楼 · 发布于 2024-04-28 15:57:05

我记得我也被这个问题搞糊涂了。好吧,事情是这样的-一个零件实例并没有实际分配给你刚刚创建的元素。尝试mdb.models[MODELNAME].parts[PARTNAME].elements[ELEMENTLABEL].instanceName,您将看到它是None,因为没有返回值。我不确定这是设计的还是错误的。但基本上,Part对象有一个方法来解决这个问题:

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

你就完蛋了。在

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

相关问题 更多 >