基于Python的Abaqus二次开发实例讲解

更新时间:2024-05-13 08:29:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

基于Python的Abaqus二次开发实例讲解

(asian58 2013.6.26)

基于Python的Abaqus的二次开发便捷之处在于:

1、所有的代码均可以先在Abaqus\\CAE中操作一遍后再通过rp文件读取,然后再在此基础上进行相应的修改;

2、Python是一种解释性语言,读起来非常清晰,因此在修改程序的过程中,不存在程序难以理解的问题;

3、Python是一种通用性的、功能非常强大的面向对象编程语言,有许多成熟的类似于Matlab函数的程序在网络上流传,为后期进一步的数据处理提供了方便。

为了更加方便地完成Abaqus的二次开发,需进行一些相关约定:

1、所有参数化直接通过点的坐标值进行,直接对几何尺寸的参数化反而更加繁琐; 2、程序参数化已不允许在模型中添加太多的Tie,因此不同零部件的绑定直接通过共节点来进行,这就要求建模方法与常规的建模方法有所区别。思路如下:

将一个整机拆成几个大的Part来建立,一个Part中包含许多零件,这样在划分网格式时就可以自动实现共节点的绑定。不同的零件可通过建立不同的Set来进行区分,不同Part的绑定可以通过Tie来实现。将一个复杂的结构拆成几个恰当的Part来建立,一方面可以将复杂的模型简单化,使建立复杂模型成为可能;另一方面,不同的Part可单独调用,从而又可实现程序的模块化,增加程序的适应范围,延长程序的使用寿命,也方便后期程序的维护和修改。

3、通过py文件建立起的模型要进行参数优化,已不适合采用Isight中Abaqus模块,需要用到Isight的Simcode模块。

下面详细解释一个臂架的py文件。 #此程序用来绘制臂架前段 #导入相关模块

# -*- coding: mbcs -*- from abaqus import *

from abaqusConstants import *

#定义整个臂架的长、宽、高 L0=14300 W0=1650 H0=800

第 1 页 共 11 页

#创建零件P01_12 L1=H0+200 W1=200 T1=12

s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=2000.0)

g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=STANDALONE)

注:通过点的坐标进行参数化s.rectangle(point1=(W0/2, L1/2), point2=(W0/2+W1, -L1/2))

是模型参数化的最好选择。 s.rectangle(point1=(-W0/2, L1/2), point2=(-W0/2-W1, -L1/2))

p = mdb.models['Model-1'].Part(name='Part-1', dimensionality=THREE_D, type=DEFORMABLE_BODY)

p = mdb.models['Model-1'].parts['Part-1'] p.BaseShell(sketch=s)

session.viewports['Viewport: 1'].setValues(displayedObject=p) del mdb.models['Model-1'].sketches['__profile__']

#定义零件的厚度

p = mdb.models['Model-1'].parts['Part-1'] 注:建立一个零件后就立即对f = p.faces 该零件建立一个Set,Set的建pickedFaces01 = f.findAt(((W0/2, L1/2, 0),),((-W0/2, L1/2, 0),), ) 立可以方便后期的相关处理。 p.assignThickness(faces=pickedFaces01, thickness=T1) 需要通过findAt()命令来选取p.Set(faces=pickedFaces01, name='P01_12') 相应的体、面、线或点。

#创建辅助平面和辅助坐标系

p = mdb.models['Model-1'].parts['Part-1']

p.DatumCsysByThreePoints(name='Datum csys-1', coordSysType=CARTESIAN, origin=( 0.0, 0.0, 0.0), line1=(1.0, 0.0, 0.0), line2=(0.0, 1.0, 0.0))

注:所建立的第一个参考可以p = mdb.models['Model-1'].parts['Part-1']

不编号。 p.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=L0)

#创建零件P02_12 L2=L1 W2=W1 T2=12

p = mdb.models['Model-1'].parts['Part-1'] d = p.datums

#将草图原点参数化

t = p.MakeSketchTransform(sketchPlane=d[5], sketchUpEdge=d[4].axis2, sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(0.0, 0.0, L0)) s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=29006.85, gridSpacing=725.17, transform=t) g, v, d1, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) p = mdb.models['Model-1'].parts['Part-1']

第 2 页 共 11 页

注:从第二个草图开始就需要对草图的原点进行参数化。

s.rectangle(point1=(W0/2, L2/2), point2=(W0/2+W2, -L2/2)) s.rectangle(point1=(-W0/2, L2/2), point2=(-W0/2-W2, -L2/2)) p = mdb.models['Model-1'].parts['Part-1'] d2 = p.datums

p.Shell(sketchPlane=d2[5], sketchUpEdge=d2[4].axis2, sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, sketch=s) s.unsetPrimaryObject()

del mdb.models['Model-1'].sketches['__profile__']

#定义零件的厚度

p = mdb.models['Model-1'].parts['Part-1']

注:给几何面赋厚度,可以在f = p.faces

后期赋壳单元属性时直接选取pickedFaces02 = f.findAt(((W0/2, L1/2, L0),),((-W0/2, L1/2, L0),), )

几何面的厚度; p.assignThickness(faces=pickedFaces02, thickness=T2)

也可以通过壳单元属性给建立p.Set(faces=pickedFaces02, name='P02_12')

的Set赋予厚度。两种方法适

用于不同的情况。 #创建零件P03_12和零件P04_08 T3=12 T4=8

p = mdb.models['Model-1'].parts['Part-1'] d = p.datums

t = p.MakeSketchTransform(sketchPlane=d[5], sketchUpEdge=d[4].axis2, sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(0.0, 0.0, L0)) s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=29006.85, gridSpacing=725.17, transform=t) g, v, d1, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) #创建草图

p = mdb.models['Model-1'].parts['Part-1']

s.Line(point1=(-W0/2-W1, H0/2), point2=(-W0/2, H0/2)) s.Line(point1=(W0/2, H0/2), point2=(W0/2+W1, H0/2)) s.Line(point1=(-W0/2-W1, -H0/2), point2=(-W0/2, -H0/2)) s.Line(point1=(W0/2, -H0/2), point2=(W0/2+W1, -H0/2)) p = mdb.models['Model-1'].parts['Part-1'] d2 = p.datums

p.ShellExtrude(sketchPlane=d2[5], sketchUpEdge=d2[4].axis2,

sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, sketch=s, depth=L0, flipExtrudeDirection=ON) s.unsetPrimaryObject()

del mdb.models['Model-1'].sketches['__profile__'] #定义零件P03_12的厚度

p = mdb.models['Model-1'].parts['Part-1'] f = p.faces

pickedFaces03 = f.findAt(((-W0/2, H0/2, L0/2),),((W0/2, H0/2, L0/2),),) p.assignThickness(faces=pickedFaces03, thickness=T3)

第 3 页 共 11 页

p.Set(faces=pickedFaces03, name='P03_12')

#定义零件P04_12的厚度

p = mdb.models['Model-1'].parts['Part-1'] f = p.faces

pickedFaces04 = f.findAt(((-W0/2, -H0/2, L0/2),),((W0/2, -H0/2, L0/2),),) p.assignThickness(faces=pickedFaces04, thickness=T4) p.Set(faces=pickedFaces04, name='P04_12')

#创建零件P05_08 T5=8

p = mdb.models['Model-1'].parts['Part-1'] d = p.datums

t = p.MakeSketchTransform(sketchPlane=d[5], sketchUpEdge=d[4].axis2, sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(0.0, 0.0, L0)) s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=29006.85, gridSpacing=725.17, transform=t) g, v, d1, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) p = mdb.models['Model-1'].parts['Part-1']

s.Line(point1=(-W0/2-W1/2, H0/2), point2=(-W0/2-W1/2, -H0/2)) s.Line(point1=(W0/2+W1/2, H0/2), point2=(W0/2+W1/2, -H0/2)) p = mdb.models['Model-1'].parts['Part-1'] d2 = p.datums

p.ShellExtrude(sketchPlane=d2[5], sketchUpEdge=d2[4].axis2,

sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, sketch=s, depth=L0, flipExtrudeDirection=ON) s.unsetPrimaryObject()

del mdb.models['Model-1'].sketches['__profile__'] #定义零件P05_8的厚度

p = mdb.models['Model-1'].parts['Part-1'] f = p.faces

pickedFaces05 = f.findAt(((-W0/2-W1/2, 0, L0/2),),((W0/2+W1/2, 0, L0/2),),) p.assignThickness(faces=pickedFaces05, thickness=T5) p.Set(faces=pickedFaces05, name='P05_08')

#创建零件P06_08 L6=W0+W1 n=L0//2520+1 T6=8

p = mdb.models['Model-1'].parts['Part-1'] f, d = p.faces, p.datums

t = p.MakeSketchTransform(sketchPlane=f[0], sketchUpEdge=d[4].axis2,

sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(W0/2+W1/2, -H0/2, 0))

第 4 页 共 11 页

s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=28684, gridSpacing=717, transform=t)

g, v, d1, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) p = mdb.models['Model-1'].parts['Part-1']

#循环命令绘制平行隔板 for i in range(0,n):

注:也可以将range(0,n)改成自 s.Line(point1=(-500-(i*2520), H0), point2=(-500-(i*2520), 0.0))

定义数组,这样就可以实现不p = mdb.models['Model-1'].parts['Part-1']

等间距的参数化控制。 f1, d2 = p.faces, p.datums

p.ShellExtrude(sketchPlane=f1[0], sketchUpEdge=d2[4].axis2,

sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, sketch=s, depth=L6, flipExtrudeDirection=ON) s.unsetPrimaryObject()

del mdb.models['Model-1'].sketches['__profile__'] #定义零件P06_08的厚度

p = mdb.models['Model-1'].parts['Part-1'] f = p.faces

for i in range(0,n):

注:将循环绘制的零件通过循 pickedFaces = f.findAt(((0, H0/4, 500+i*2520),))

环命令分别建立各自的Set并 p.assignThickness(faces=pickedFaces, thickness=T6)

分别命名。也可以将循环绘制 p.Set(faces=pickedFaces, name='P06_08_'+str(1+i))

的零件建立成一个Set,视具体

情况而定。 #创建零件P07_12,P08_12 W7=200 L7=W0+W1 T7=12 T8=12

p = mdb.models['Model-1'].parts['Part-1'] f, e = p.faces, p.edges

t = p.MakeSketchTransform(

sketchPlane=f.findAt(coordinates=(W0/2+W1/2, 0.0, 100.0)), sketchUpEdge=e.findAt(coordinates=(W0/2+W1/2, 0.0, 0.0)), sketchOrientation=RIGHT,sketchPlaneSide=SIDE1, origin=(W0/2+W1/2, -H0/2, 0.0))

s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=53678, gridSpacing=1341, transform=t)

g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) p = mdb.models['Model-1'].parts['Part-1'] #循环命令绘制平行隔板 for i in range(0,n):

s.Line(point1=(400+i*2520, -H0), point2=(600+i*2520, -H0)) s.Line(point1=(400+i*2520, 0), point2=(600+i*2520, 0))

第 5 页 共 11 页

p = mdb.models['Model-1'].parts['Part-1'] f1, e1 = p.faces, p.edges p.ShellExtrude(

sketchPlane=f.findAt(coordinates=(W0/2+W1/2, 0.0, 100.0)), sketchUpEdge=e.findAt(coordinates=(W0/2+W1/2, 0.0, 0.0)), sketchPlaneSide=SIDE1,

sketchOrientation=RIGHT, sketch=s, depth=W0+W1, flipExtrudeDirection=ON, keepInternalBoundaries=ON) s.unsetPrimaryObject()

del mdb.models['Model-1'].sketches['__profile__']

#定义零件P07_12的厚度

p = mdb.models['Model-1'].parts['Part-1'] f = p.faces

for i in range(0,n):

pickedFaces07 = f.findAt(((0, H0/2, 400+i*2520),),((0, H0/2, 600+i*2520),),) p.assignThickness(faces=pickedFaces07, thickness=T7) p.Set(faces=pickedFaces07, name='P07_12_'+str(1+i))

#定义耦合set fp=[]

for i in range(0,2):

fp.append(f.findAt(((0, H0/2, 400+i*2520),),((0, H0/2, 600+i*2520),),)) p.Set(faces=fp, name='P07_fp')

注:为了后期边界条件施加的方便,在此次将一系列面定义成一个Set。必须通过append()命令将所有通过循环命令查找的faces添加到一个数值中,这样才能将所有的faces建立到一个Set中去 #定义零件P08_12的厚度

p = mdb.models['Model-1'].parts['Part-1'] f = p.faces

for i in range(0,n):

pickedFaces08 = f.findAt(((0, -H0/2, 400+i*2520),),((0, -H0/2, 600+i*2520),),) p.assignThickness(faces=pickedFaces08, thickness=T7) p.Set(faces=pickedFaces08, name='P08_12_'+str(1+i))

#为中间隔板创建空腔

#定义相关参数边界距离、圆角 d0=100 r0=100

p = mdb.models['Model-1'].parts['Part-1'] f1, e1 = p.faces, p.edges t = p.MakeSketchTransform(

f.findAt(coordinates=(0, 0.0, 500.0)),

sketchUpEdge=e.findAt(coordinates=(W0/2+W1/2, 0.0, 500.0)), sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(0.0, 0.0, 500.0))

s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=5910.0, gridSpacing=147.0, transform=t)

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

第 6 页 共 11 页

s.setPrimaryObject(option=SUPERIMPOSE) p = mdb.models['Model-1'].parts['Part-1']

p.projectReferencesOntoSketch(sketch=s, filter=COPLANAR_EDGES) #创建矩形

s.rectangle(point1=(-W0/2-W1/2+d0, H0/2-d0), point2=(W0/2+W1/2-d0, -H0/2+d0)) #创建圆角

s.FilletByRadius(radius=r0, curve1=g[29], nearPoint1=(-W0/2-W1/2+d0, H0/2-d0), curve2=g[26], nearPoint2=(-W0/2-W1/2+d0, H0/2-d0)) s.FilletByRadius(radius=r0, curve1=g[26], nearPoint1=(-W0/2-W1/2+d0, -H0/2+d0), curve2=g[27], nearPoint2=(-W0/2-W1/2+d0, -H0/2+d0)) s.FilletByRadius(radius=r0, curve1=g[27], nearPoint1=(W0/2+W1/2-d0, -H0/2+d0), curve2=g[28], nearPoint2=(W0/2+W1/2-d0, -H0/2+d0)) s.FilletByRadius(radius=r0, curve1=g[28], nearPoint1=(W0/2+W1/2-d0, H0/2-d0), curve2=g[29], nearPoint2=(W0/2+W1/2-d0, H0/2-d0)) p = mdb.models['Model-1'].parts['Part-1'] f1, d2 = p.faces, p.datums p.CutExtrude(

f.findAt(coordinates=(0, 0.0, 500.0)),

sketchUpEdge=e.findAt(coordinates=(W0/2+W1/2, 0.0, 500.0)),

sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, sketch=s, depth=L0, flipExtrudeDirection=OFF) s.unsetPrimaryObject()

del mdb.models['Model-1'].sketches['__profile__']

#开始建立梁Beam_1

p = mdb.models['Model-1'].parts['Part-1'] f, d = p.faces, p.datums

注:圆角有方向性,因此在绘制圆角时需要将nearpoint也进行参数化,可直接选择草图的原点。另外,此处的curve最好通过findAt查找得出。 #绘制参考面

p.DatumPlaneByOffset(plane=f.findAt(coordinates= (W0/2, -H0/2, 100.0)),flip=SIDE2, offset=8.0) dp1 = d.keys()[-1]

p = mdb.models['Model-1'].parts['Part-1'] d = p.datums

t = p.MakeSketchTransform(sketchPlane=d[dp1], sketchUpEdge=d[4].axis1, 注:通过参考面的编号[dp1]来 sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(0.0, 0.0,

引用参考面。 0.0))

s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=31857.0, gridSpacing=796.0, transform=t) g, v, d1, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) p = mdb.models['Model-1'].parts['Part-1']

#计算中间加强梁的数量 if n%2==1:

第 7 页 共 11 页

注:此处建立参考面后,立即给该参考面进行了编号(dp1),否则后面的程序中无法引用该参考面。实际上,每建立一个参考后,都应该给该参考进行编号,这样的操作才比较规范。

n1=n//2 n2=n//2 else:

n1=n//2 n2=n//2-1 for i in range(0,n1):

s.Line(point1=(-500-i*2520*2, W0/2+W1/2), point2=(-500-2520-i*2520*2,-W0/2-W1/2 )) for i in range(0,n2):

s.Line(point1=(-500-2520-i*2520*2,-W0/2-W1/2), point2=(-500-2*2520-i*2520*2,W0/2+W1/2 ))

#在基准平面dp1上面绘制梁

p = mdb.models['Model-1'].parts['Part-1'] d2 = p.datums e = p.edges

p.Wire(sketchPlane=d2[dp1], sketchUpEdge=d2[4].axis1, sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, sketch=s) s.unsetPrimaryObject()

del mdb.models['Model-1'].sketches['__profile__'] edges1=[] 注:必须通过append()命令将所for i in range(0,n-1): 有通过循环命令查找的edges添 edges1.append(e.findAt(((0, -H0/2-8, 500+2520/2+i*2520),),)) 加到一个数组中,这样才能将所 p.Set(edges=edges1, name='Beam_1') 有的edges建立到一个Set中去, 以方便后期建立tie。 ###########################

#开始定义有限元分析的相关参数 #定义材料

mdb.models['Model-1'].Material(name='steel')

mdb.models['Model-1'].materials['steel'].Elastic(table=((210000.0, 0.3), )) mdb.models['Model-1'].materials['steel'].Density(table=((7.8e-06, ), ))

#定义壳单元属性

mdb.models['Model-1'].HomogeneousShellSection(name='shell', preIntegrate=OFF, material='steel', thicknessType=UNIFORM, thickness=10.0, thicknessField='', idealization=NO_IDEALIZATION, poissonDefinition=DEFAULT,

thicknessModulus=None, temperature=GRADIENT, useDensity=OFF, integrationRule=SIMPSON, numIntPts=5) #赋所有壳单元属性

p = mdb.models['Model-1'].parts['Part-1']

注:此处选择厚度属性来源于for i in range(1,5):

几何。如果需要做厚度优化的 region1 = p.sets['P0'+str(i)+'_12']

p.SectionAssignment(region=region1, sectionName='shell', offset=0.0, 话,也可以选择来源于壳单元属性,但需要建立与之匹配的 offsetType=FROM_GEOMETRY, offsetField='',

壳单元属性,并且一个零件对 thicknessAssignment=FROM_GEOMETRY)

应于一个壳单元熟悉。 第 8 页 共 11 页

region2 = p.sets['P05_08']

p.SectionAssignment(region=region2, sectionName='shell', offset=0.0, offsetType=FROM_GEOMETRY, offsetField='', thicknessAssignment=FROM_GEOMETRY) for i in range(1,n+1):

注:全部通过前期建立的Set region3 = p.sets['P06_08_'+str(i)]

p.SectionAssignment(region=region3, sectionName='shell', offset=0.0, 来赋壳单元属性,省掉了再次findAt的麻烦。 offsetType=FROM_GEOMETRY, offsetField='',

thicknessAssignment=FROM_GEOMETRY) for i in range(1,n+1):

region4 = p.sets['P07_12_'+str(i)]

p.SectionAssignment(region=region4, sectionName='shell', offset=0.0, offsetType=FROM_GEOMETRY, offsetField='', thicknessAssignment=FROM_GEOMETRY) for i in range(1,n+1):

region5 = p.sets['P08_12_'+str(i)]

p.SectionAssignment(region=region5, sectionName='shell', offset=0.0, offsetType=FROM_GEOMETRY, offsetField='',

thicknessAssignment=FROM_GEOMETRY) #定义梁单元属性

mdb.models['Model-1'].LProfile(name='L_65', a=65.0, b=65.0, t1=7.0, t2=7.0)

mdb.models['Model-1'].BeamSection(name='B_65', integration=DURING_ANALYSIS, poissonRatio=0.0, profile='L_65', material='steel', temperatureVar=LINEAR, consistentMassMatrix=False)

#赋所有梁单元属性

p = mdb.models['Model-1'].parts['Part-1'] region = p.sets['Beam_1']

p.SectionAssignment(region=region, sectionName='B_65', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION)

p.assignBeamSectionOrientation(region=region, method=N1_COSINES, n1=(0.0, 0.0, -1.0))

#定义装配体 import assembly

a = mdb.models['Model-1'].rootAssembly a.DatumCsysByDefault(CARTESIAN)

p = mdb.models['Model-1'].parts['Part-1']

a.Instance(name='Part-1-1', part=p, dependent=ON)

#定义分析步 import step

mdb.models['Model-1'].StaticStep(name='Step-1', previous='Initial')

第 9 页 共 11 页

#定义底面与梁的tied import interaction

a = mdb.models['Model-1'].rootAssembly region1=a.instances['Part-1-1'].sets['P04_12'] region2=a.instances['Part-1-1'].sets['Beam_1']

mdb.models['Model-1'].Tie(name='Constraint-1', master=region1, slave=region2,

positionToleranceMethod=COMPUTED, adjust=OFF, tieRotations=ON, thickness=ON)

#开始定义耦合 #导入相关模块 import regionToolset

a = mdb.models['Model-1'].rootAssembly d, r = a.datums, a.referencePoints

#定义参考点

a.ReferencePoint(point=(0.0, H0/2, 500+2520/2)) r1 = a.referencePoints 注:对建立的参考点编号,以rp1 = r.keys()[-1] 方便后期调用。 refPoints1=(r1[rp1], )

region1=regionToolset.Region(referencePoints=refPoints1) s1 = a.instances['Part-1-1'].faces

region2 = a.instances['Part-1-1'].sets['P07_fp']

mdb.models['Model-1'].Coupling(name='Constraint-2', controlPoint=region1,

surface=region2, influenceRadius=WHOLE_SURFACE, couplingType=DISTRIBUTING, localCsys=None, u1=ON, u2=ON, u3=ON, ur1=ON, ur2=ON, ur3=ON)

########################

#定义边界条件 import load

a = mdb.models['Model-1'].rootAssembly d, r = a.datums, a.referencePoints

region = a.instances['Part-1-1'].sets['P02_12']

mdb.models['Model-1'].DisplacementBC(name='SPC', createStepName='Initial', region=region, u1=SET, u2=SET, u3=SET, ur1=SET, ur2=SET, ur3=SET,

amplitude=UNSET, distributionType=UNIFORM, fieldName='', localCsys=None) a = mdb.models['Model-1'].rootAssembly

region = a.instances['Part-1-1'].sets['P08_12_'+str(n-1)]

mdb.models['Model-1'].DisplacementBC(name='SPC2', createStepName='Initial', region=region, u1=SET, u2=SET, u3=SET, ur1=SET, ur2=SET, ur3=SET,

amplitude=UNSET, distributionType=UNIFORM, fieldName='', localCsys=None) r1 = a.referencePoints refPoints1=(r1[rp1], )

region = regionToolset.Region(referencePoints=refPoints1)

mdb.models['Model-1'].ConcentratedForce(name='force', createStepName='Step-1',

第 10 页 共 11 页

region=region, cf2=-10000.0, distributionType=UNIFORM, field='', localCsys=None)

mdb.models['Model-1'].Gravity(name='G', createStepName='Step-1', comp2=-9.8, distributionType=UNIFORM, field='') ################

#划分网格 import mesh

p = mdb.models['Model-1'].parts['Part-1']

p.seedPart(size=20.0, deviationFactor=0.1, minSizeFactor=0.1) p.generateMesh()

a = mdb.models['Model-1'].rootAssembly

##############

#创建作业并提交分析 import job

mdb.Job(name='006', model='Model-1', description='', type=ANALYSIS,

atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=90, memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True,

explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF, modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='', scratch='', multiprocessingMode=DEFAULT, numCpus=4, numDomains=4) mdb.jobs['006'].submit(consistencyChecking=ON) mdb.jobs['006'].waitForCompletion()

############## #进入后处理模块 import visualization

o3 = session.openOdb(name='F:/ABAQUS/006.odb')

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

session.viewports['Viewport: 1'].odbDisplay.display.setValues(plotState=( CONTOURS_ON_DEF, ))

session.viewports['Viewport: 1'].view.setValues(session.views['Iso']) mdb.saveAs(pathName='F:/ABAQUS/006.cae')

第 11 页 共 11 页

region=region, cf2=-10000.0, distributionType=UNIFORM, field='', localCsys=None)

mdb.models['Model-1'].Gravity(name='G', createStepName='Step-1', comp2=-9.8, distributionType=UNIFORM, field='') ################

#划分网格 import mesh

p = mdb.models['Model-1'].parts['Part-1']

p.seedPart(size=20.0, deviationFactor=0.1, minSizeFactor=0.1) p.generateMesh()

a = mdb.models['Model-1'].rootAssembly

##############

#创建作业并提交分析 import job

mdb.Job(name='006', model='Model-1', description='', type=ANALYSIS,

atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=90, memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True,

explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF, modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='', scratch='', multiprocessingMode=DEFAULT, numCpus=4, numDomains=4) mdb.jobs['006'].submit(consistencyChecking=ON) mdb.jobs['006'].waitForCompletion()

############## #进入后处理模块 import visualization

o3 = session.openOdb(name='F:/ABAQUS/006.odb')

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

session.viewports['Viewport: 1'].odbDisplay.display.setValues(plotState=( CONTOURS_ON_DEF, ))

session.viewports['Viewport: 1'].view.setValues(session.views['Iso']) mdb.saveAs(pathName='F:/ABAQUS/006.cae')

第 11 页 共 11 页

本文来源:https://www.bwwdw.com/article/1qy7.html

Top