zoukankan      html  css  js  c++  java
  • Python提取Abaqus结果数据

    1. Python提取Abaqus结果数据

    1.1 Python选择节点和单元

    1. getByBoundingBox()
    2. getByBoundingCylinder()
    3. getByBoundingSphere()
      可用tab键查找函数的变量

    通过位置选择节点

    p = mdb.models['Thermal2D-L'].parts['Part-2']
    n = p.nodes
    nlist = n.getByBoundingBox(-100,-100,0,100,100,0)#通过矩形来框选节点
    p.Set(nodes=nlist, name='Set-44')#创建set
    

    通过位置选择单元

    p = mdb.models['Thermal2D-L'].parts['Part-2']
    e = p.elements
    elist = e.getByBoundingBox(-0.2,-12.6,-0.1,0.2,12.6,0.1)
    p.Set(elements=elist,name='Set-5')
    

    注:选中节点的单元都会被选中

    获取节点的label

    p = mdb.models['Thermal2D-L'].parts['Part-2']
    e = p.elements
    elist = e.getByBoundingBox(-0.2,-12.6,-0.1,0.2,12.6,0.1)
    e1 = elist[1]
    elabel1 = e1.label
    

    1.2 Python提取结果

    结构都存储在*.odb文件中,可以采用python直接进行读取

    提取位移

    from odbAccess import*
    from abaqusConstants import*
    import os
    
    myodb=openOdb(path=r'H:AbaqusMultiScaleMeshSizeJob-2D-SubThermal.odb')
    RS=myodb.steps['Step-1'].frames[1].fieldOutputs['U'].values
    cpFile=open('distance.txt','w')
    for i in RS:
        cpFile.write('%d %7.4f %7.4f
    ' % (i.nodeLabel,i.data[0],i.data[1]))
        
    else:
        cpFile.close()
        
    # frames为第几个增量
    # fieldOutputs['U']结果类型,位移
    

    提取mises应力

    RF=myodb.steps['Step-1'].frames[1].fieldOutputs['S'].values
    RF0 = RF[0]
    mises = RF0.mises #mises应力
    data = RF0.data #S11,S22,S33,S12
    eleType = RF0.baseElementType #单元类型
    eleLabel = RF0.elementLabel
    maxPrincipal = RF0.maxInPlanePrincipal #最大平面主应力,可参考具体
    

    获取节点集合上的位移

    from odbAccess import*
    from abaqusConstants import*
    import sys
    import os
    
    odb=openOdb(path=r'H:AbaqusMultiScaleMeshSizeJob-2D-Thermal-Displace.odb')
    
    lastFrame= odb.steps['Step-1'].frames[-1]#创建变量lastFrame,得到载荷步Step-1的最后一帧
    displacement= lastFrame.fieldOutputs['U']#创建变量displacement,得到最后一帧的位移场数据
    
    #创建变量center,得到节点集PUNCH
    #其中PART-2-1为装配体中的几何体,SET-1为创建的集合
    center =odb.rootAssembly.instances['PART-2-1'].nodeSets['SET-1']
    
    #创建变量centerDisplacement,得到region center的位移场数据
    centerDisplacement= displacement.getSubset(region=center)
    
    #输出各种信息,该节点集只有一个节点
    for v in centerDisplacement.values:
        print 'Position = ', v.position,'Type =',v.type
        print 'Node label = ', v.nodeLabel
        print 'X displacement = ', v.data[0]
        print 'Y displacement = ', v.data[1]
        print 'Displacement magnitude =',v.magnitude
    
    odb.close()
    

    获取单元的应力值

    from odbAccess import*
    from abaqusConstants import*
    import sys
    import os
    
    # cpFile=open('artlcF1.txt','w')
    odb=openOdb(path=r'H:AbaqusMultiScaleMeshSizeJob-2D-Thermal-Displace.odb')
    
    # topCenter =odb.rootAssembly.instances['PART-2-1'].nodeSets['SET-1']#创建变量topCenter
    
    topCenter =odb.rootAssembly.instances['PART-2-1'].elementSets['SET-4']
    #创建变量 stressField,得到位移场数据
    stressField= odb.steps['Step-1'].frames[-1].fieldOutputs['S']
    
    field =stressField.getSubset(region=topCenter)
    
    #创建变量 fieldValues,得到field的数值数据
    fieldValues= field.values
    
    #输出label值
    for v in fieldValues:
        print(v.elementLabel)
    
    # 输出应力值
    for v in fieldValues:
        print(v.mises)
    
    # cpFile.write ('%-15.5f' % component)
    # cpFile.close()
    

    获取节点的温度值

    from odbAccess import*
    from abaqusConstants import*
    import sys
    import os
    
    odb=openOdb(path=r'H:AbaqusMultiScaleMeshSizeJob-2D-Thermal-Displace.odb')
    
    lastFrame= odb.steps['Step-1'].frames[-1]#创建变量lastFrame,得到载荷步Step-1的最后一帧
    displacement= lastFrame.fieldOutputs['NT11']#创建变量displacement,得到最后一帧的位移场数据
    
    #创建变量center,得到节点集PUNCH
    #其中PART-2-1为装配体中的几何体,SET-1为创建的集合
    center =odb.rootAssembly.instances['PART-2-1'].nodeSets['SET-1']
    
    #创建变量centerDisplacement,得到region center的位移场数据
    centerDisplacement= displacement.getSubset(region=center)
    
    #输出各种信息,该节点集只有一个节点
    for v in centerDisplacement.values:
        print 'Node label = ', v.nodeLabel
        print 'templabel= ', v.data
      
    

    1.3 Python结果提取方法

    1. 可以直接提取所有的单元或者几何节点的值
    2. 首先获取节点或者单元的label值,然后再读取响应的结果
    3. 在求解先,先建立要提取结果的set集合,然后在结果中按照set进行提取

    1.4 单元面积计算方法

    1. 首先获取组成单元的节点
    2. 然后获取节点的坐标
    3. 通过节点坐标来计算面积
    p = mdb.models['Thermal2D-L'].parts['Part-2']
    n = p.nodes
    e = p.elements
    
    e1 = e[1]
    nodeIndexList = e1.connectivity
    
    # 获取节点的坐标
    PointList = []
    for Index in nodeIndexList:
        temp = n[Index].coordinates
        PointList.append(temp)
        
    # 计算多边形的面积
    

    参考资料

    【1】Abaqus Python getByBoundingBox command
    【2】Python提取Abaqus结果数据
    【3】Abaqus 6.14 帮助文档

  • 相关阅读:
    Atitit attilax要工作研究的要素 纪要 方案 趋势 方向 概念 理论
    Atitit 常见每日流程日程日常工作.docx v7 r8f
    Atitit it 互联网 软件牛人的博客列表
    Atitit 信息链(Information Chain)的概念理解 attilax总结
    Atitit 知识点的体系化 框架与方法 如何了解 看待xxx
    Atitit 聚合搜索多个微博 attilax总结
    Atitit 企业知识管理PKM与PIM
    Atitit 项目沟通管理 Atitit 沟通之道 attilax著.docx
    Atitit 项目管理软件 在线服务 attilax总结 1. 项目管理协作的历史 1 1.1. Worktile 406k 1 1.2. Teambition  584k in baidu
    Atitit.每周末总结 于每周一计划日程表 流程表 v8 import 上周遗漏日志补充 检查话费 检查流量情况 Crm问候 Crm表total and 问候
  • 原文地址:https://www.cnblogs.com/gaozihan/p/12617928.html
Copyright © 2011-2022 走看看