旧言虐心 发表于 2016-4-1 09:43

基于Python的SAP2000计算结果转换为ABAQUS

本文基于博文”基于Python的SAP2000模型数据和结果数据读取“继续开发了通过Python语言将SAP2000计算结果导入ABAQUS,如下图所示:                           代码如下所示:<span style="word-wrap: normal; line-height: 22.5px; font-size: 12px;">#-*-coding:mbcs-*-</span>
#***********************************************************************************************************
# <wbr> <wbr> -----------------本程序写入ABAQUS_ODB模型数据和结果数据--------------------------
# <wbr> <wbr> 1.不同单元类型定义成不同的PART、INSTANCE
# <wbr> <wbr> 2.不同的PART中写入了相同的全部节点数据
# <wbr> <wbr> 3.目前只限于矩形截面的截面点,梁、壳单元只限于1个积分点,读入的材料只限于弹性属性
#***********************************************************************************************************
<span style="word-wrap: normal; line-height: 22.5px; font-size: 12px;">def FunWriteOdbData(Material,Section,Node,Frame,Area,LoadCase,ResultsPeriod,ResultsJointDispl,ResultsFrameSectionForce</span><wbr>,
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> ResultsAreaSectionForce,ResultsFrameStress,ResultsAreaStress,FileName):
<wbr> <wbr> <wbr> #-*-coding:UTF-8-*-
<wbr> <wbr> <wbr> #导入相应模块
<wbr> <wbr> <wbr> from odbAccess import *
<wbr> <wbr> <wbr> from odbMaterial import *
<wbr> <wbr> <wbr> from odbSection import *
<wbr> <wbr> <wbr> from abaqusConstants import *
<wbr> <wbr> <wbr> #----------------------------------------------------------------------
<wbr> <wbr> <wbr> #1.创建输出数据ODB,同时将创建根装配rootAssembly
<wbr> <wbr> <wbr> print('4...创建ABAQUS_ODB文件...')
<wbr> <wbr> <wbr> odb=Odb(name='resultModel',analysisTitle='ODB created with Python ODB API',description='',path=FileName)
<wbr> <wbr> <wbr>#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<wbr> <wbr> <wbr>#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<wbr> <wbr> <wbr> print('5...写入ODB模型数据信息...')
<wbr> <wbr> <wbr> #2.创建材料
<wbr> <wbr> <wbr> print('5.1写入材料数据')
<wbr> <wbr> <wbr> for MatName,MatType,E,u,G in Material:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> material_object=odb.Material(name=MatName)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> material_object.Elastic(type=ISOTROPIC,table=((E,u),))
<wbr> <wbr> <wbr>#===========================================================================================================================
<wbr> <wbr> <wbr> <span style="word-wrap: normal; line-height: 22.5px; font-size: 12px;">#3.创建截面</span>
<wbr> <wbr> <wbr> print('5.2写入截面数据')
<wbr> <wbr> <wbr> #a.梁单元截面
<wbr> <wbr> <wbr> beamSection={} <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #储存为字典类型,便于根据截面名字查找属性
<wbr> <wbr> <wbr> for ii in range(len(Section['SectionFrame'])):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> SectName=Section['SectionFrame']
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> SectType=Section['SectionFrame']
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> SectMat =Section['SectionFrame']
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> if SectType==1: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #I形截面
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> h=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面高度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> l=h/2 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面局部坐标系原点距底边距离
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> b1=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #下翼缘宽度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> b2=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #上翼缘宽度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t1=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #下翼缘厚度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t2=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #上翼缘厚度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t3=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #腹板厚度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> odb.IProfile(name=SectName,l=l,h=h,b1=b1,b2=b2,t1=t1,t2=t2,t3=t3)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>beamSection=odb.BeamSection(name=SectName,integration=BEFORE_ANALYSIS,profile=SectName,material=SectMat)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elif SectType==6: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #箱形截面
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> a=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面宽度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> b=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面高度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t1=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #翼缘厚度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t2=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #腹板厚度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t3=t1
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t4=t2
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>odb.BoxProfile(name=SectName,uniformThickness=OFF,a=a,b=b,t1=t1,t2=t2,t3=t3,t4=t4)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>beamSection=odb.BeamSection(name=SectName,integration=BEFORE_ANALYSIS,profile=SectName,material=SectMat)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elif SectType==7: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #圆管形截面
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> r=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面外半径
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> t=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #内壁厚度
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> odb.PipeProfile (name=SectName,r=r,t=t)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>beamSection=odb.BeamSection(name=SectName,integration=BEFORE_ANALYSIS,profile=SectName,material=SectMat)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elif SectType==8: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #矩形截面
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> a=Section['SectionFrame']
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> b=Section['SectionFrame']
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> odb.RectangularProfile(name=SectName,a=a,b=b)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>beamSection=odb.BeamSection(name=SectName,integration=BEFORE_ANALYSIS,profile=SectName,material=SectMat)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elif SectType==9: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #圆形截面
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> r=Section['SectionFrame'] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面半径
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> odb.CircularProfile (name=SectName,r=r)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>beamSection=odb.BeamSection(name=SectName,integration=BEFORE_ANALYSIS,profile=SectName,material=SectMat)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> else:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> print('警告:缺少截面类型')
<wbr> <wbr> <wbr> #定义梁截面分类
<wbr> <wbr> <wbr> sCatRect=odb.SectionCategory(name='Rectangular',description='Space Beam 25 Section Points')
<wbr> <wbr> <wbr> sp1=sCatRect.SectionPoint(number=1,description='SectionPoint-1')
<wbr> <wbr> <wbr> sp2=sCatRect.SectionPoint(number=2,description='SectionPoint-5')
<wbr> <wbr> <wbr> sp3=sCatRect.SectionPoint(number=3,description='SectionPoint-21')
<wbr> <wbr> <wbr> sp4=sCatRect.SectionPoint(number=4,description='SectionPoint-25')
<wbr> <wbr> <wbr> #b.壳单元截面
<wbr> <wbr> <wbr> shellSection={}
<wbr> <wbr> <wbr> for SectName,SectMat,Thickness in Section['SectionShell']: <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>shellSection=odb.HomogeneousShellSection(name=SectName,material=SectMat,thickness=Thickness)
<wbr> <wbr> <wbr> #定义壳截面分类
<wbr> <wbr> <wbr> sCatShell=odb.SectionCategory(name='Shell',description='Five-Layered Shell')
<wbr> <wbr> <wbr> spBot=sCatShell.SectionPoint(number=1,description='Bottom')
<wbr> <wbr> <wbr> spMid=sCatShell.SectionPoint(number=3,description='Middle')
<wbr> <wbr> <wbr> spTop=sCatShell.SectionPoint(number=5,description='Top')
<wbr> <wbr> <wbr>#===========================================================================================================================

旧言虐心 发表于 2016-4-1 09:43

<wbr> <wbr> #4.创建部件
<wbr> <wbr> <wbr> print('5.3创建部件PART')
<wbr> <wbr> <wbr> beamPart=odb.Part(name='beamPart', embeddedSpace=THREE_D,type=DEFORMABLE_BODY)
<wbr> <wbr> <wbr> shellPart=odb.Part(name='shellPart', embeddedSpace=THREE_D,type=DEFORMABLE_BODY)
<wbr> <wbr> <wbr> #a.创建节点
<wbr> <wbr> <wbr> print(' <wbr> <wbr> a.写入节点数据')
<wbr> <wbr> <wbr> Node=sorted(Node,key=lambda x:x,reverse=False) <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #排序,节点号从小到大
<wbr> <wbr> <wbr> beamPart.addNodes(nodeData=tuple(Node),nodeSetName='ALL')
<wbr> <wbr> <wbr> shellPart.addNodes(nodeData=tuple(Node),nodeSetName='ALL')
<wbr> <wbr> <wbr> #为便于后面查找节点坐标,把节点数据储存为字典格式
<wbr> <wbr> <wbr> nodeData={}
<wbr> <wbr> <wbr> for NodeNum,x,y,z in Node:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> nodeData=(x,y,z)
<wbr> <wbr> <wbr> #----------------------------------------------------------------------------------
<wbr> <wbr> <wbr> print(' <wbr> <wbr> b.写入单元数据')
<wbr> <wbr> <wbr> #b.创建梁单元
<wbr> <wbr> <wbr> Frame=sorted(Frame,key=lambda x:x,reverse=False)
<wbr> <wbr> <wbr> beamData=[]
<wbr> <wbr> <wbr> for ii in range(len(Frame)):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> beam_el_num=Frame
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> node1=Frame
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> node2=Frame
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> beamData.append((beam_el_num,node1,node2))
<wbr> <wbr> <wbr> beamData=tuple(beamData)
<wbr> <wbr> <wbr> beamPart.addElements(elementData=beamData, type='B31',elementSetName='BEAM',sectionCategory=sCatRect) <wbr> #单积分点
<wbr> <wbr> <wbr> #----------------------------------------------------------------------------------
<wbr> <wbr> <wbr> #c.创建壳单元
<wbr> <wbr> <wbr> Area=sorted(Area,key=lambda x:x,reverse=False)
<wbr> <wbr> <wbr> shellData=[]
<wbr> <wbr> <wbr> for ii in range(len(Area)):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> shell=Area
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> nodes=Area
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> shellData.append((shell,nodes,nodes,nodes,nodes))
<wbr> <wbr> <wbr> shellData=tuple(shellData)
<wbr> <wbr> <wbr> shellPart.addElements(elementData=shellData, type='S4R',elementSetName='SHELL',sectionCategory=sCatShell)#单积分点
<wbr> <wbr> <wbr>#===========================================================================================================================
<wbr> <wbr> <wbr> #5.创建装配件
<wbr> <wbr> <wbr> print('5.4创建装配件Assembly')
<wbr> <wbr> <wbr> beamInstance=odb.rootAssembly.Instance(name='BeamInstance',object=beamPart)
<wbr> <wbr> <wbr> shellInstance=odb.rootAssembly.Instance(name='ShellInstance',object=shellPart)
<wbr> <wbr> <wbr> #指定截面
<wbr> <wbr> <wbr> #a.梁单元截面
<wbr> <wbr> <wbr> print(' <wbr> <wbr> a.指定梁截面')
<wbr> <wbr> <wbr> for ii in range(len(Frame)):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> beam_el_num=Frame <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #单元编号
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> beam_el_sect=Frame <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面名字
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #计算截面方向余弦
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> x1=nodeData]
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> y1=nodeData]
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> x2=nodeData]
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> y2=nodeData]
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> if abs(x2-x1)<1E-5:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> cos1=-1
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> cos2=0
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> else:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> cos1=-(y2-y1)/(x2-x1)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> cos2=1
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> TEMPBEAMLEN=(cos1**2+cos2**2)**0.5
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> cos1=cos1/TEMPBEAMLEN
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> cos2=1/TEMPBEAMLEN
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elset=beamInstance.ElementSetFromElementLab<wbr>els(name='BEAM_'+str(beam_el_num),elementLabels=(beam_el_num,)) #定义集合
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> beamInstance.assignSection(region=elset,section=beamSection) <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #赋予截面
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> beamInstance.assignBeamOrientation(region=elset,method=N1_COSINES,vector=(cos1,cos2,0)) <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #截面方向
<wbr> <wbr> <wbr> #----------------------------------------------------------------------------------
<wbr> <wbr> <wbr> #b.壳单元截面
<wbr> <wbr> <wbr> print(' <wbr> <wbr> b.指定壳截面')
<wbr> <wbr> <wbr> for ii in range(len(Area)):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> shell_el_num =Area <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #单元编号
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> shell_el_sect=Area <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #单元截面
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elset=shellInstance.ElementSetFromElementLab<wbr>els(name='SHELL_'+str(shell_el_num),elementLabels=(shell_el_num,)) #定义集合
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> shellInstance.assignSection(region=elset,section=shellSection) <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #赋予截面
<wbr> <wbr> <wbr>#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<wbr> <wbr> <wbr>#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<wbr> <wbr> <wbr> print('6...写入ODB结果数据信息...')
<wbr> <wbr> <wbr> print('6.1创建分析步STEP')
<wbr> <wbr> <wbr> stepsObject={}
<wbr> <wbr> <wbr> for ii in range(len(LoadCase)):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> CaseName=LoadCase
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> CaseType=LoadCase
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> if CaseType==1: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #静力分析
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>stepsObject=odb.Step(name=CaseName,description='LINEAR_STATIC_ANALYSIS',domain=TIME,timePeriod=1.0)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elif CaseType==3: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #模态分析
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>stepsObject=odb.Step(name=CaseName,description='MODAL_EIGEN_ANALYSIS',domain=MODAL)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> elif CaseType==7: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #时程分析
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> TimePeriod=LoadCase*LoadCase
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>stepsObject=odb.Step(name=CaseName,description='Time_HISTORY_ANALYSIS',domain=TIME,timePeriod=TimePeriod)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> else:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> print('警告:缺少分析工况')
<wbr> <wbr> <wbr>#===========================================================================================================================
<wbr> <wbr> <wbr> print('6.2写入场数据')
<wbr> <wbr> <wbr> for kk in range(len(LoadCase)):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> CaseName=LoadCase
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> CaseType=LoadCase
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> JointDispl=ResultsJointDispl
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> JointDispl=sorted(JointDispl,key=lambda x:x,reverse=False) <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #按单元号从小到大排序 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> if CaseType==7: <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #%%%%%时程分析步%%%%%%
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> FrameSectionForce=ResultsFrameSectionForce<wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> AreaSectionForce=ResultsAreaSectionForce
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> FrameStress=ResultsFrameStress
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> AreaStress=ResultsAreaStress
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> FrameSectionForce=sorted(FrameSectionForce,key=lambda x:x,reverse=False)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> AreaSectionForce=sorted(AreaSectionForce,key=lambda x:x,reverse=False)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> FrameStress=sorted(FrameStress,key=lambda x:x,reverse=False)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> AreaStress=sorted(AreaStress,key=lambda x:x,reverse=False)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> if FrameSectionForce>1:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> print('警告:梁单元内力输出位置数目大于1')
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> if AreaStress>1:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> print('警告:壳单元内力输出位置数目大于1')
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> IncNum=LoadCase <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #增量步总数
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> DT=LoadCase <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #增量步时间间隔
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> for ii in range(IncNum):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #创建帧
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>frameHistory=stepsObject.Frame(incrementNumber=ii+1,frameValue=ii*DT,description='Increment <wbr> '+
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> str(ii+1)+':'+'Step Time = <wbr> '+str(ii*DT))
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #---------------------------------------------------------------------------------------------------------
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #节点位移
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> nodeLabelData=[] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #节点
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> dispUData=[] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #位移
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> dispURData=[] <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> #转角
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> for jj in range(len(JointDispl)):
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> nodeLabelData.append(JointDispl)
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> U1=JointDispl
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> U2=JointDispl
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> U3=JointDispl
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> R1=JointDispl
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> R2=JointDispl
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> R3=JointDispl
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> dispUData.append((U1,U2,U3))
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> dispURData.append((R1,R2,R3))
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> uField = frameHistory.FieldOutput(name='U',description='U',type=VECTOR,validInvariants=(MAGNITUDE,))#创建位移场
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>uField.addData(position=NODAL,instance=beamInstance,labels=tuple(nodeLabelData),data=tuple(dispUData)) #写入位移
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>uField.addData(position=NODAL,instance=shellInstance,labels=tuple(nodeLabelData),data=tuple(dispUData))
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> urField = frameHistory.FieldOutput(name='UR',description='UR',type=VECTOR,validInvariants=(MAGNITUDE,))
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>urField.addData(position=NODAL,instance=beamInstance,labels=tuple(nodeLabelData),data=tuple(dispURData))
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>urField.addData(position=NODAL,instance=shellInstance,labels=tuple(nodeLabelData),data=tuple(dispURData))
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> stepsObject.setDefaultField(uField) <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> else:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> print('警告:缺少输出工况')
<wbr> <wbr> <wbr> #----------------------------------------------------------------------------------------------------------------
<wbr> <wbr> <wbr> #保存数据
<wbr> <wbr> <wbr> print('6.3...........完成................')
<wbr> <wbr> <wbr> odb.save()
<wbr> <wbr> <wbr> odb.close()参考文献:ABAQUS帮助文档
页: [1]
查看完整版本: 基于Python的SAP2000计算结果转换为ABAQUS