我使用这两个函数在一个矩形样本上生成一组已知坐标为 X 的节点(您可以根据节点的坐标更改 if 条件):
def Functions_Set_Face_AC(Face, Name_Face):
modelName1='Model-1'
mdb.models[modelName1].rootAssembly.Set(faces=Face, name=Name_Face)
mdb.models[modelName1].rootAssembly.Set(name=Name_Face, nodes=mdb.models[modelName1].rootAssembly.sets[Name_Face].nodes)
def Node_Set_X(X, modelName, instanceName):
"""ABAQUS_Fucntion: Set
defines a set of nodes at the front surface of the specimen
input:
X: Level of the surface
(Depending of your coordinate system, it may change. But it should be
in direction of the thichness).
modelName: name of the model
instanceName: name of the instance
"""
X=round(X,6);
FRONT=[];
for i in mdb.models[modelName].rootAssembly.instances[instanceName].faces:
a=i.pointOn[0]
if a[0]== X:
FRONT=FRONT+[mdb.models[modelName].rootAssembly.instances[instanceName].faces.findAt(((a[0],a[1],a[2]),))]
#Assign set
Functions_Set_Face_AC(FRONT, 'FRONT_X')
然后,在 odb 文件中,您可以使用以下两个函数提取这些节点的坐标以及位移(或任何其他输出):
第二个函数将结果保存到 csv 文件中。 (请记住,您应该在步骤中激活 COORD 以提取 odb 中点的坐标)
# =============================================================================
# Matrix form
# =============================================================================
def Give_FieldVariable_matrixform(COORD1, COORD2, COORD3, U1, U2, U3):
"""Give the field varialbe in the form of [[c1, c2, c3, u1,u2,u3],...]
input:
COORD1, COORD2, COORD3: nodal coordinates
U1, U2, U3: the interested field variable at nodes
Output:
U: a matrix includes coordinate and field variable
Note:
this function helps to save this nodal information into a csv file."""
U=[]
for i in range(0,len(COORD1)):
# coordinate
c1 = COORD1[i][1][1]
c2 = COORD2[i][1][1]
c3 = COORD3[i][1][1]
# Field variable
u1 = U1[i][1][1]
u2 = U2[i][1][1]
u3 = U3[i][1][1]
U.append([c1, c2, c3, u1, u2, u3])
return U
# =============================================================================
# Save to a csv file
# =============================================================================
def Extract_FieldVariable_odb(OdbFile, SetName, csvFile):
"""
This function saves the nodal displacement field of a given set.
Input:
OdbFile: The odb file (string) eg.: 'Job-1.odb'
SetName: the name of your set (string)
csvFile: csv file name (string).
Output:
A csv file including nodal coordinate and dispalcement in a form of:
x, y, z, U1, U2, U3
will be saved in your Work directory
Note:
*** You should first open the visualization ***
*** You should active CCORD in step ***
"""
myOdb = openOdb(path = OdbFile)
nodes=myOdb.rootAssembly.nodeSets[SetName]
framelen=len(myOdb.steps['Step-1'].frames)
U1_Fr=session.xyDataListFromField(odb=myOdb, outputPosition=NODAL, variable=(('U',NODAL, ((COMPONENT, 'U1'), )), ), nodeSets=(SetName, ))
U2_Fr=session.xyDataListFromField(odb=myOdb, outputPosition=NODAL, variable=(('U',NODAL, ((COMPONENT, 'U2'), )), ), nodeSets=(SetName, ))
U3_Fr=session.xyDataListFromField(odb=myOdb, outputPosition=NODAL, variable=(('U',NODAL, ((COMPONENT, 'U3'), )), ), nodeSets=(SetName, ))
COORD1_Fr=session.xyDataListFromField(odb=myOdb, outputPosition=NODAL, variable=(('COORD',NODAL, ((COMPONENT, 'COOR1'), )), ), nodeSets=(SetName, ))
COORD2_Fr=session.xyDataListFromField(odb=myOdb, outputPosition=NODAL, variable=(('COORD',NODAL, ((COMPONENT, 'COOR2'), )), ), nodeSets=(SetName, ))
COORD3_Fr=session.xyDataListFromField(odb=myOdb, outputPosition=NODAL, variable=(('COORD',NODAL, ((COMPONENT, 'COOR3'), )), ), nodeSets=(SetName, ))
Total = Give_FieldVariable_matrixform(COORD1_Fr, COORD2_Fr, COORD3_Fr,
U1_Fr, U2_Fr, U3_Fr)
np.savetxt(csvFile, Total, delimiter=",")
希望对你有帮助。