一個Abaqus建模腳本

工作需要經常在三維軟件中建立葉片模型導入abaqus計算,不勝其煩,于是嘗試用Python編寫一個腳本。

#!/usr/bin/python

#-*-coding:UTF-8-*-

from abaqus import *

from abaqusConstants import *

from caeModules import *

from driverUtils import executeOnCaeStartup

executeOnCaeStartup()

Mdb()

mdb.models.changeKey(fromName='Model-1', toName='Blade')

profileName=('profileT-T','profileA-A','profileB-B','profileC-C','profileD-D','profileE-E','profileF-F',

'profileG-G','profileH-H','profileJ-J','profileK-K')

sectionName=('sectionT-T','sectionA-A','sectionB-B','sectionC-C','sectionD-D','sectionE-E','sectionF-F',

'sectionG-G','sectionH-H','sectionJ-J','sectionK-K')

sectionHeight=(523.75,530,542.48,587.48,632.48,677.48,722.48,767.48,812.48,857.48,902.48)

setingAngle=30

sectionAngle=(-0.4269,0,0.8386,2.9231,5.8331,8.7544,11.7169,14.6364,17.4819,20.3272,22.6569)

transformVector=((-54.687,-7.691),(-54.712,-7.595),(-54.761,-7.403),(-54.891,-6.902),(-54.992,-6.248),

(-55.093,-5.749),(-55.241,-5.374),(-55.448,-5.028),(-55.613,-4.679),(-55.783,-4.330),(-55.953,-3.981))

pp=( ( 0.000, 2.561),( 0.500, 1.691),( 1.000, 1.341),( 1.500, 1.101),( 2.000, 0.913),( 2.500, 0.789),此處省略數據)

bladeLength=(125.131,125.231,125.219,125.225,125.215,125.213,125.213,125.213,125.200,125.177,125.230)

for i in range(len(profileName)):

s = mdb.models['Blade'].ConstrainedSketch(name=profileName[i], sheetSize=400.0)

g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints

s.setPrimaryObject(option=STANDALONE)

yj=pp[72*2*i:72*2*i+72]

yr=pp[72*2*i+72:72*2*i+144]

s.Spline(points=(yj))

s.Spline(points=(yr))

s.ConstructionLine(point1=(0.0, 0.0), point2=(0.0,1.0))

s.ConstructionLine(point1=(bladeLength[i], 0.0), point2=(bladeLength[i],1.0))

s.FixedConstraint(entity=g[2])

s.FixedConstraint(entity=g[3])

s.FixedConstraint(entity=g[4])

s.FixedConstraint(entity=g[5])

#circleCenter=((yj[len(yj)-1][0]+yr[len(yr)-1][0])/2,(yj[len(yj)-1][1]+yr[len(yr)-1][1])/2)

s.ArcByCenterEnds(center=(124.66325378418, 0.564650535583496), point1=yj[len(yj)-1], point2=yr[len(yr)-1], direction=COUNTERCLOCKWISE)

s.CoincidentConstraint(entity1=v[143], entity2=g[3], addUndoState=False)

s.TangentConstraint(entity1=g[6], entity2=g[5])

print profileName[i],'has been created'

session.viewports['Viewport: 1'].partDisplay.geometryOptions.setValues(

    referenceRepresentation=ON)

p = mdb.models['Blade'].Part(name='blade', dimensionality=THREE_D, 

    type=DEFORMABLE_BODY)

p.ReferencePoint(point=(0.0, 0.0, 0.0))

p = mdb.models['Blade'].parts['blade']

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=523.75)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=530.0)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=542.8)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=587.48)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=632.48)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=677.48)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=722.48)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=767.48)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=812.48)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=857.48)

p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=902.48)

p.DatumAxisByPrincipalAxis(principalAxis=YAXIS)

for i in range(len(sectionName)):

p = mdb.models['Blade'].parts['blade']

e1, d2 = p.edges, p.datums

t = p.MakeSketchTransform(sketchPlane=d2[i+2], sketchUpEdge=d2[13], 

sketchPlaneSide=SIDE1, sketchOrientation=LEFT, origin=(0.0, 0.0, sectionHeight[i]))

s = mdb.models['Blade'].ConstrainedSketch(name='__profile__', 

sheetSize=400, gridSpacing=10, transform=t)

g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints

s.setPrimaryObject(option=SUPERIMPOSE)

p = mdb.models['Blade'].parts['blade']

p.projectReferencesOntoSketch(sketch=s, filter=COPLANAR_EDGES)

s.retrieveSketch(sketch=mdb.models['Blade'].sketches[profileName[i]])

session.viewports['Viewport: 1'].view.fitView()

s.move(vector=transformVector[i], objectList=(g[5], g[6], g[7], g[8], g[9]))

s.rotate(centerPoint=(0.0, 0.0), angle=sectionAngle[i]+setingAngle, objectList=(g[5], g[6], g[7], g[8], g[9]))

p = mdb.models['Blade'].parts['blade']

e, d1 = p.edges, p.datums

p.Wire(sketchPlane=d1[i+2], sketchUpEdge=d1[13], sketchPlaneSide=SIDE1, 

sketchOrientation=LEFT, sketch=s)

s.unsetPrimaryObject()

del mdb.models['Blade'].sketches['__profile__']

print sectionName[i],'has been created.'

p = mdb.models['Blade'].parts['blade']

e = p.edges

p.SolidLoft(loftsections=((e[15], e[16], e[17]), (e[12], e[13], e[14]), (e[18], 

    e[19], e[20]), (e[9], e[10], e[11]), (e[21], e[22], e[23]), (e[6], e[7], 

    e[8]), (e[24], e[25], e[26]), (e[3], e[4], e[5]), (e[27], e[28], e[29]), (

    e[0], e[1], e[2]), (e[30], e[31], e[32])), startCondition=NONE, 

    endCondition=NONE)

session.viewports['Viewport: 1'].setValues(displayedObject=p)

print('''Three-dimensional model of blade has been created.

Check your model please!

Copyright: WXS''')

這個程序還不完善,還有很多改進的地方,最終建立的模型如下


整個建模的思路類似在UG中的操作,最后形成體采用loft命令。個人感覺Abaqus沒有像APDL中的Select功能是一項遺憾,findAt函數不太好使。

abaqus不能像ANSYS直接建三維點,建模過程需要要建很多基準面,感覺對待有的三維模型會比較麻煩。



轉自公眾號——ABAQUS大世界

旨在分享,若侵即刪.

登錄后免費查看全文
立即登錄
App下載
技術鄰APP
工程師必備
  • 項目客服
  • 培訓客服
  • 平臺客服

TOP

1