加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

使用Python从abaqus的ODB数据库中抽取模型和应力

(2013-01-21 22:44:59)
标签:

教育

分类: 编程相关
Utility:通過ABQ得到ODB中變形后的模型數據以及應力數據,作為後續分析的initial conditions。可應用于諸如從drop的結果中某一特定component的變形模型和應力,作為後續分析的initial con-ditions
具体实现代码如下:
首先是核心代码:

from abaqus import *
from abaqusConstants import *
from odbAccess import *

# Output the stress from odb for next more analysis as initial_stress
def initial_stress():
    fields = [("your odb:","(*^__^*)"),("what you want(.inp):","(*^__^*)"),("which step:","(*^__^*)"),("which frame:","(*^__^*)")]
    odbName,outputName,step,frame = getInputs(fields = fields,label = "What you want?")
    f = open(outputName + "_InitialCondition.inp","wb")
    f.write("*INITIAL CONDITIONS, TYPE=STRESS\n** S11, S22, S33, S12, S13, S23\n")
   
    odb = openOdb(path = odbName)
    inst = odb.rootAssembly.instances
    stressField = odb.steps[step].frames[int(frame)].fieldOutputs['S']
    field = stressField.getSubset(region=inst[inst.keys()[0]], position=CENTROID)
    fieldValues = field.values
    for v in fieldValues:
            print 'Element label = ', v.elementLabel
            print
            f.write("            " + str(v.elementLabel)) 
            for component in v.data:
                    print '%-10.5f,' % component,
                    st = str(component)  
                    f.write(",        " + st)
            f.write("\n")   
    # f.close()

   
# output nodes and elements from the specified frame of deformed model
def deformed_model():
    fields = [("your odb:","(*^__^*)"),("what you want(job):","(*^__^*)"),("which frame:","(*^__^*)")]
    odbName,outputName,frame = getInputs(fields = fields,label = "What you want?")
   
    opOdb = openOdb(path = odbName)
    odb = session.odbs[odbName]
    p = mdb.models['Model-1'].PartFromOdb(name='PART-1-1', instance='PART-1-1',
        odb=odb, shape=DEFORMED, step=0, frame=int(frame))
    p = mdb.models['Model-1'].parts['PART-1-1']
    session.viewports['Viewport: 1'].setValues(displayedObject=p)
    odb.close()
    a = mdb.models['Model-1'].rootAssembly
    session.viewports['Viewport: 1'].setValues(displayedObject=a)
    a.DatumCsysByDefault(CARTESIAN)
    a.Instance(name='PART-1-1-1', part=p, dependent=ON)
    jobName = outputName + "_Model"
    mdb.Job(name=jobName, model='Model-1', description='', type=ANALYSIS,
        atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=100,
        memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True,
        explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF,
        modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='',
        scratch='', parallelizationMethodExplicit=DOMAIN, numDomains=1,
        activateLoadBalancing=False)
    mdb.jobs[jobName].writeInput(consistencyChecking=OFF)

主要实现代码写好后,就需要在abaqus中注册插件了,代码如下:
# register the initial_stress_plugin and Deformed_model_plugin
from abaqusGui import getAFXApp
toolset = getAFXApp().getAFXMainWindow().getPluginToolset()

toolset.registerKernelMenuButton(moduleName = 'Extract_model',\
functionName = 'initial_stress()',buttonText = 'Extract the stress(centroid) from odb',\
version = 'version 0.1',author = 'Adam Yu',description = 'Extract the stress from odb for next more analysis as initial_stress')

toolset.registerKernelMenuButton(moduleName = 'Extract_model',\
functionName = 'deformed_model()',buttonText = 'Extract nodes and elements from odb',\
version = 'version 0.1',author = 'Adam Yu',description = 'Extract nodes and elements from odb for next more analysis as deformed model')
ok,插件写好了现在需要测试一下了:

http://s12/mw690/6e39d066gd3cdaef1523b&690

http://s11/mw690/6e39d066gd3cdb0a6fdea&690

http://s2/mw690/6e39d066g7b9491d14891&690

http://s9/mw690/6e39d066gd3cdb2bd17a8&690

未经允许不得转载。

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有