您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > abaqus-python-random-mpc-3
#-*-coding:cp936-*-#filename:abaqus_1.py####################################É趨²ÎÊýfields=(('fibervolumefraction:','0.3'),('numberoffiber:','12'),('dispersion:','0.001'))percent,n,Dispersion=getInputs(fields=fields,label=Inputtheparameters)percent=float(percent)#ÏËάÌå»ý±Èn=int(n)#ÏËάµÄ¸öÊýDispersion=float(Dispersion)#·ÖɢϵÊý####################################µ÷ÓÃÄ£¿éfromrandomimport*fromabaqusimport*fromabaqusConstantsimport*fromcaeModulesimport*fromdriverUtilsimportexecuteOnCaeStartupexecuteOnCaeStartup()##############################Ëæ»úÉú³ÉÏËάÊøµÄÔ²ÐÄ×ø±êxyr0=(percent/(n*3.14))**0.5r=r0+Dispersionx=(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+Dispersion):flag=1xy.append((x,y))##############################¿ªÊ¼½¨Ä£frompartimport*#µÚÒ»²½,½¨Á¢½¨Ä£s=mdb.models['Model-1'].Sketch(name='__profile__',sheetSize=10.0)#¶¨ÒåÄ£Ð͵IJÝͼ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)#¶¨ÒåÄ£Ð͵IJ¿¼þ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*#µÚÈý²½£¬×°Åäa1=mdb.models['Model-1'].rootAssemblyp=mdb.models['Model-1'].parts['Part-1']#Ö¸¶¨part-1a1.Instance(name='Part-1-1',part=p,dependent=OFF)#Éú³Épart-1¶ÔÏóµÄʵÌåPart-1-1£¬independentÍø¸ñÔÚInstanceÉÏÃæfromstepimport*#µÚËIJ½,¶¨Òå·ÖÎö²½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ÎļþµÄÊý¾Ý(Ó¦Á¦¡¢Î»ÒÆ)frommeshimport*#µÚÎå²½,Íø¸ñ»®·Ö¿ØÖÆelemType1=mesh.ElemType(elemCode=CPS4R,elemLibrary=STANDARD)elemType2=mesh.ElemType(elemCode=CPS3,elemLibrary=STANDARD)faces=mdb.models['Model-1'].rootAssembly.instances['Part-1-1'].faces[0:n+1]pickedRegions=(faces,)mdb.models['Model-1'].rootAssembly.setElementType(regions=pickedRegions,elemTypes=(elemType1,elemType2))#¶¨ÒåÁ½ÖÖÍø¸ñÀàÐÍsize0=float(getInput(Inputthemeshsize:,0.02))pickedEdges=a1.instances['Part-1-1'].edges[0:n+4]a1.seedEdgeBySize(edges=pickedEdges,size=size0,constraint=FIXED)#ÈöÍø¸ñÖÖ×ÓpartInstances=(a1.instances['Part-1-1'],)a1.generateMesh(regions=partInstances)#¸øpartInstances»®·ÖÍø¸ñfrominteractionimport*#µÚÁù²½,¶¨Òå¶àµãÔ¼ÊøÌõ¼þ-----MPCm=mdb.models['Model-1']r=m.rootAssemblynode=r.instances['Part-1-1'].nodesne=[]#ne´æ´¢ËùÓб߽çÉϵĵ¥Ôª½ÚµãµÄ±àºÅforiinrange(len(node)):x=node[i].coordinates[0]y=node[i].coordinates[1]flag=(x-1)*(x-0)*(y-1)*(y-0)*10000ifabs(flag)0.0001:ne.append(i)printne0=,len(ne)foriinrange(len(ne)):#ÕÒ³öËĸö¶¥µãx=node[ne[i]].coordinates[0]y=node[ne[i]].coordinates[1]if(abs(x-0)0.0001)and(abs(y-0)0.0001):r.Set(nodes=node[ne[i]:ne[i]+1],name='set-01')aa1=ielif(abs(x-1)0.0001)and(abs(y-0)0.0001):r.Set(nodes=node[ne[i]:ne[i]+1],name='set-02')aa2=ielif(abs(x-0)0.0001)and(abs(y-1)0.0001):r.Set(nodes=node[ne[i]:ne[i]+1],name='set-03')aa3=ielif(abs(x-1)0.0001)and(abs(y-1)0.0001):r.Set(nodes=node[ne[i]:ne[i]+1],name='set-04')aa4=iaa=[aa1,aa2,aa3,aa4]aa.sort()delne[aa[3]];delne[aa[2]];delne[aa[1]];delne[aa[0]]#printa1,a2,a3,a4printne1=,len(ne)m.Equation(name='eq-00',terms=((1,'set-04',1),(-1,'set-02',1),(-1,'set-03',1)))#¶¨Òå½ÇµãµÄMPCm.Equation(name='eq-01',terms=((1,'set-04',2),(-1,'set-02',2),(-1,'set-03',2)))#-----------------------------¶¨Ò
本文标题:abaqus-python-random-mpc-3
链接地址:https://www.777doc.com/doc-5431268 .html