工作需要经常在三维软件中建立叶片模型导入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(
p = mdb.models['Blade'].Part(name='blade', dimensionality=THREE_D,
p.ReferencePoint(point=(0.0, 0.0, 0.0))
p = mdb.models['Blade'].parts['blade']
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumPlaneByPrincipalPla
p.DatumAxisByPrincipalAxis
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.projectReferencesOntoSke
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],
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大世界
旨在分享,若侵即删.