weixin_45842816
2021-05-17 00:15
采纳率: 0%
浏览 245

Abaqus二次开发生成的odb文件打不开

我用abaqus进行磨损的计算,最后需要将每一步的磨损显示出来,于是我建立了新的odb来显示,但是打开新生成的odb文件时会报错,软件直接退出。代码和报错如下,请问是为什么呀。

path = OdbName + '_Wear_Distribution.odb'  # odb文件名
                if not os.path.exists(path):
                        # show wear region
                        log.pri_show()

                        odb = Odb(name=OdbName + '_WearDistri', analysisTitle='wear_distribution',
                                  description='', path=OdbName + '_Wear_Distribution.odb')

                        part1 = odb.Part(name=instance, embeddedSpace=THREE_D, type=DEFORMABLE_BODY)

                        partdata = open(Name1_Inp, 'r')
                        nodedata = partdata.readlines()[start_line:end_line]  

                        node_group = [0, 0, 0, 0]
                        Node_Data = []
                        nodeLabelData = []  # 存储节点编号

                        for nl in nodedata:
                                nodeline = sub(',', ' ', nl)
                                nodeline = split(' +', nodeline)
                                nodelabel = int(nodeline[1])
                                nodeLabelData.append(nodelabel)
                                node_x = float(nodeline[2])
                                node_y = float(nodeline[3])
                                node_z = float(nodeline[4])
                                node_group[0] = nodelabel
                                node_group[1] = node_x
                                node_group[2] = node_y
                                node_group[3] = node_z
                                node_group_tuple = tuple(node_group)
                                Node_Data.append(node_group_tuple)

                        Node_Data = tuple(Node_Data)  # 存储节点信息
                        partdata.close()

                        part1.addNodes(nodeData=Node_Data, nodeSetName='nset-1')  

                        partdata = open(Name1_Inp, 'r')

                        elementdata = partdata.readlines()[start_ele_line:end_ele_line]  # element line number is not found
                        Element_Data = []
                        ele_group = [0, 0, 0, 0, 0, 0, 0, 0, 0]

                        for el in elementdata:  # 获取单元信息
                                elementline = split(',', el)
                                ele_group[0] = int(elementline[0])
                                ele_group[1] = int(elementline[1])
                                ele_group[2] = int(elementline[2])
                                ele_group[3] = int(elementline[3])
                                ele_group[4] = int(elementline[4])
                                ele_group[5] = int(elementline[5])
                                ele_group[6] = int(elementline[6])
                                ele_group[7] = int(elementline[7])
                                ele_group[8] = int(elementline[8])

                                ele_group_tuple = tuple(ele_group)
                                Element_Data.append(ele_group_tuple)

                        Element_Data = tuple(Element_Data)
                        partdata.close()
                        # 添加单元信息
                        part1.addElements(elementData=Element_Data, type='C3D8R', elementSetName='eset-1')

                        # 创建实例对象
                        instance1 = odb.rootAssembly.Instance(name=instance, object=part1)

                        # 创建分析步
                        step1 = odb.Step(name='Step-start-1', description='wear region',
                                         domain=TIME, timePeriod=1.0)
                        analysisTime = 0.1
                        frame1 = step1.Frame(incrementNumber=1, frameValue=analysisTime,
                                             description='results frame for time ' + str(analysisTime))

                        # 创建磨损区域信息,显示法向磨损
                        WearRegion = frame1.FieldOutput(name='U', description='Displacements', type=VECTOR,
                                                        componentLabels=('U1', 'U2', 'U3'),
                                                        validInvariants=(MAGNITUDE,))

                        dis_x = []
                        dis_y = []
                        dis_z = []

                        flag = 0
                        # 为表面结点添加目标信息
                        # Total_Wear_Depth = range(lenNode)
                        # wear_depth = open("wear_txt",'r')
                        # for i, d in enumerate(wear_depth):
                        #         depth = split(" ", d)
                        #         Total_Wear_Depth[i] = depth[1]

                        for node in nodeLabelData:
                                wear_node_cycle = 0
                                for wearLabel in NodeNum:
                                        if wearLabel == node:
                                                flag = 1
                                                break
                                        else:
                                                flag = 0
                                        wear_node_cycle += 1

                                if flag == 1:
                                        dis_x.append(Total_Wear_Depth[wear_node_cycle]
                                                     * list_vector[i][1])
                                        dis_y.append(Total_Wear_Depth[wear_node_cycle]
                                                     * list_vector[i][2])
                                        dis_z.append(Total_Wear_Depth[wear_node_cycle]
                                                     * list_vector[i][3])

                                else:
                                        dis_x.append(0)
                                        dis_y.append(0)
                                        dis_z.append(0)

                        disdata = zip(dis_x, dis_y, dis_z)
                        # 输出磨损深度
                        # for dep in Total_Wear_Depth:  # Êä³ö×ܵıíÃæÄ¥ËðÉî¶È
                        #         worklog.writelines(str(dep))
                        #         worklog.writelines(str('\n'))
                        # output.close()

                        WearRegion.addData(position=NODAL, instance=instance1,
                                           labels=nodeLabelData, data=disdata)

                        step1.setDefaultDeformedField(WearRegion)
                        odb.save()
                        odb.close()

1条回答 默认 最新

相关推荐 更多相似问题