您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > abaqus-python-2
#-*-coding:cp936-*-#filename:abaqus_1.py####################################设定参数percent=0.3#纤维体积比n=8#纤维束的个数####################################调用模块fromrandomimport*fromabaqusimport*fromabaqusConstantsimport*fromcaeModulesimport*fromdriverUtilsimportexecuteOnCaeStartupexecuteOnCaeStartup()##############################随机生成纤维束的圆心坐标xyr0=(percent/(n*3.14))**0.5r=r0+0.001x=(1-2*r)*random()+ry=(1-2*r)*random()+rxy=[(x,y)]foriinrange(n-1):flag=1whileflag==1:x=(1-2*r)*random()+ry=(1-2*r)*random()+rflag=0forjinrange(len(xy)):dis=(x-xy[j][0])**2+(y-xy[j][1])**2ifdis((2*r)**2+0.001):flag=1xy.append((x,y))##############################开始建模frompartimport*#第一步,建立建模s=mdb.models['Model-1'].Sketch(name='__profile__',sheetSize=10.0)#定义模型的草图ss.rectangle(point1=(0.0,0.0),point2=(1.0,1.0))#指定两顶点画矩形p=mdb.models['Model-1'].Part(name='Part-1',dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)#定义模型的部件part-1p.BaseShell(sketch=s)#将s赋给pdelmdb.models['Model-1'].sketches['__profile__']#收回建模所占的环境内存s1=mdb.models['Model-1'].Sketch(name='__profile__',sheetSize=100.0)foriinrange(n):s1.CircleByCenterPerimeter(center=xy[i],point1=(xy[i][0]+r0,xy[i][1]))#指定圆心和圆上一点画圆n个p1=mdb.models['Model-1'].parts['Part-1']pickedFaces=p1.faces[0:1]p1.PartitionFaceBySketch(faces=pickedFaces,sketch=s1)frommaterialimport*#第二步,材料定义fromsectionimport*mdb.models['Model-1'].Material(name='Material-1')#定义材料名称1mdb.models['Model-1'].materials['Material-1'].Elastic(table=((80.0,0.3),))#定义材料1的刚度mdb.models['Model-1'].HomogeneousSolidSection(name='Section-1',material='Material-1',thickness=1.0)#定义截面2mdb.models['Model-1'].Material(name='Material-2')#定义材料名称2mdb.models['Model-1'].materials['Material-2'].Elastic(table=((200.0,0.3),))#定义材料2的刚度mdb.models['Model-1'].HomogeneousSolidSection(name='Section-2',material='Material-2',thickness=1.0)#定义截面2faces=mdb.models['Model-1'].parts['Part-1'].faces.findAt(((0.0,0.0,0.0),))region=(faces,)#以上两行找到包含点(0,0,0)的面,保存到regionmdb.models['Model-1'].parts['Part-1'].SectionAssignment(region=region,sectionName='Section-1')#截面属性附给选中的面regionf2=mdb.models['Model-1'].parts['Part-1'].facesforiinrange(n+1):iff2[i:i+1]==faces:j=ifaces2=f2[0:j]+f2[j+1:n+1]region2=(faces2,)#以上找到除faces以外的面,保存到region2mdb.models['Model-1'].parts['Part-1'].SectionAssignment(region=region2,sectionName='Section-2')#截面属性2附给选中的面region2fromassemblyimport*#第三步,装配mdb.models['Model-1'].rootAssembly.DatumCsysByDefault(CARTESIAN)#参考直角坐标系p=mdb.models['Model-1'].parts['Part-1']#指定part-1mdb.models['Model-1'].rootAssembly.Instance(name='Part-1-1',part=p,dependent=ON)#生成part-1对象的实体Part-1-1,dependent网格在part上面fromstepimport*#第四步,定义分析步mdb.models['Model-1'].StaticStep(name='Step-1',previous='Initial',timeIncrementationMethod=FIXED,initialInc=0.01,noStop=OFF)#定义一个固定增量的静态分析步mdb.models['Model-1'].fieldOutputRequests['F-Output-1'].setValuesInStep(stepName='Step-1',variables=('S','U'))#定义输出到ODB文件的数据(应力、位移)frominteractionimport*#第五步,定义接触fromloadimport*#第六步,荷载边界定义edges1=mdb.models['Model-1'].rootAssembly.instances['Part-1-1'].edges.findAt(((0.0,0.5,0.0),))#选中两条边0,保存到regionregion=(edges1,)mdb.models['Model-1'].DisplacementBC(name='BC-1',createStepName='Initial',region=region,u1=SET,u2=UNSET,ur3=UNSET,amplitude=UNSET,distribution=UNIFORM,localCsys=None)#定义为0的位移边界edges2=mdb.models['Model-1'].rootAssembly.instances['Part-1-1'].edges.findAt(((0.5,0.0,0.0),))#选中两条边1,保存到regionregion=(edges2,)mdb.models['Model-1'].DisplacementBC(name='BC-2',createStepName='Initial',region=region,u1=UNSET,u2=SET,ur3=UNSET,amplitude=UNSET,distribution=UNIFORM,localCsys=None)#定义为0的位移边界edges3=mdb.models['Model-1'].rootAssembly.instances['Part-1-1'].edges.findAt(((1.0,0.5,0.0),))#选中两条边2,保存到regionregion=(edges3,)mdb.models['Model-1'].DisplacementBC(name='BC-3',createStepName='Step-1',region=region,u1=1.0,u2=UNSET,ur3=UNSET,amplitude=UNSET,fixed=OFF,distribution=UNIFORM,localCsys=None)#定义非0的位移边界frommeshimport*#第七步,网格划分控制elemType1=mesh.ElemType(elemCode=CPS8R,elemLibrary=STANDARD)elemType2=mesh.ElemType(elemCode=CPS6M,elemLibrary=STANDARD)faces=mdb.models['Model-1'].parts['Part-1'].faces[0:n+1]pickedRegions=(faces,)mdb.models['Model-1'].parts['Part-1'].setElementType(regions=pickedRegions,elemTypes=(elemType1,elemType2))#定义两种网格类型pickedEdges=mdb.models['Model-1'].parts['Part-1'].edges[0:n+4]mdb.models['Model-1'].parts['Part-1'].seedEdgeBySize(edges=pickedEdges,size=0.01)#定义网格划分全局单元大小mdb.models['Model-1'].parts['Part-1'].generateMesh()#给part划分网格session.viewports['Viewport:1'].setValues(displayedObject=p)#显示session.viewports['Viewport:1'].assemblyDisplay.setValues(mesh=ON)#####################第八步,生成任务以及其他杂项功能#mdb.models.changeKey(fromName='Model-1',toName='abaqus—001')#修改模型名称#mdb.models['Model-1'].materials['Material-1'].elastic.setValues(table=((514.3,0.15),))#修改模型中的材料属性mdb.Job(name='Job-001',model='Model-1',type=ANALYSIS,explicitPrecision=SINGLE,nodalOutputPrecision=SINGLE,description='',parallelizationMethodExplicit=DOMAIN,multiprocessingMode=DEFAULT,numDomains=1,userSubroutine='',numCpus=1,preMemory=512.0,standardMemory=512.0,standardM
本文标题:abaqus-python-2
链接地址:https://www.777doc.com/doc-5431275 .html