利用Python实现Abaqus二维/三维围线积分快速建模


首先运行python代码的方式最简单的是复制代码,然后粘贴至下图红色方框处

>>>   此处粘贴



三维

130.149.89.49:2080/v6.14/books/eif/SymmConeCrack_model.py

二维

130.149.89.49:2080/v6.14/books/eif/AxisymmConeCrack_model.py


二维代码如下:


'''

-----------------------------------------------------------------------------

Axisymmetric model of a conical crack in a block modeled using

axisymmetric reduced integration elements (CAX8R).

-----------------------------------------------------------------------------

'''


from abaqus import *

import testUtils

testUtils.setBackwardCompatibility()

from abaqusConstants import *


import part, material, section, assembly, step, interaction

import regionToolset, displayGroupMdbToolset as dgm, mesh, load, job


#----------------------------------------------------------------------------


# Create a model


Mdb()

modelName = 'AxisymmConeCrack'

myModel = mdb.Model(name=modelName)

   

# Create a new viewport in which to display the model

# and the results of the analysis.


myViewport = session.Viewport(name=modelName)

myViewport.makeCurrent()

myViewport.maximize()

   

#---------------------------------------------------------------------------


# Create a part


# Create a sketch for the base feature


mySketch = myModel.Sketch(name='blockProfile', sheetSize=500.0)

mySketch.sketchOptions.setValues(viewStyle=AXISYM)

mySketch.setPrimaryObject(option=STANDALONE)


mySketch.ObliqueConstructionLine(point1=(0.0, -250.0),

   point2=(0.0, 250.0))

mySketch.rectangle(point1=(0.0, 0.0),

   point2=(300.0, -300.0))

myBlock = myModel.Part(name='Block', dimensionality=AXISYMMETRIC,

   type=DEFORMABLE_BODY)

myBlock.BaseShell(sketch=mySketch)

mySketch.unsetPrimaryObject()

del myModel.sketches['blockProfile']


myViewport.setValues(displayedObject=myBlock)


# Create the conical crack on the block


f = myBlock.faces.findAt((150,-150,0))

t = myBlock.MakeSketchTransform(sketchPlane=f, sketchPlaneSide=SIDE1,

   origin=(150.0, -150.0, 0.0))

mySketch = myModel.Sketch(name='coneCrackProfile', sheetSize=848.52,

   gridSpacing=21.21, transform=t)

mySketch.setPrimaryObject(option=SUPERIMPOSE)

myBlock.projectReferencesOntoSketch(sketch=mySketch,

   filter=COPLANAR_EDGES)

mySketch.sketchOptions.setValues(gridOrigin=(-150.0, 150.0))

mySketch.AngularConstructionLine(point=(-140.0, 150.0), angle=135.0)

mySketch.Line(point1=(-140.0, 150.0),

   point2=(-129.393398282202, 139.393398282202))

mySketch.Line(point1=(-129.393398282202, 139.393398282202), point2=(-150.0,

   139.393398282202))

pickedFaces = myBlock.faces.findAt(((150,-150,0),))

myBlock.PartitionFaceBySketch(faces=pickedFaces, sketch=mySketch)

mySketch.unsetPrimaryObject()

del myModel.sketches['coneCrackProfile']


#---------------------------------------------------------------------------


# Partition the model for meshing


f = myBlock.faces.findAt((150,-150,0))

t = myBlock.MakeSketchTransform(sketchPlane=f,

   sketchPlaneSide=SIDE1, origin=(150.256637, -150.260327, 0.0))

mySketch = myModel.Sketch(name='profile', sheetSize=848.52,

   gridSpacing=21.21, transform=t)

mySketch.setPrimaryObject(option=SUPERIMPOSE)

myBlock.projectReferencesOntoSketch(sketch=mySketch,

   filter=COPLANAR_EDGES)

mySketch.sketchOptions.setValues(gridOrigin=(-150.256637,150.260327))

mySketch.Line(point1=(-129.650035282202,139.653725282202),

   point2=(149.743362999999,139.653725282202))

mySketch.CircleByCenterPerimeter(center=(-129.650035282202,139.653725282202),

   point1=(-134.650035282202,139.653725282202))

mySketch.AngularConstructionLine(point=(-124.650035282202,139.653725282202),

   angle=45.0)

mySketch.AngularConstructionLine(point=(-134.650035282202,139.653725282202),

   angle=240.0)

mySketch.AngularConstructionLine(point=(-124.650035282202,139.653725282202),

   angle=135.0)

mySketch.Line(point1=(-150.256637,131.650327),

   point2=(149.743362999999,131.650327))

mySketch.Line(point1=(-124.650035282202,139.653725282202),

   point2=(-114.043433564404,150.260327))

mySketch.Line(point1=(-124.650035282202,139.653725282202),

   point2=(-116.646637000001,131.650327))

mySketch.Line(point1=(-134.650035282202,139.653725282202),

   point2=(-139.270799434863,131.650327))

mySketch.Line(point1=(-139.270799434863,131.650327),

   point2=(-139.270799434863,-149.739672999999))

mySketch.Line(point1=(-116.646637000001,131.650327),

   point2=(-116.646637000001,-149.739672999999))


pickedFaces = myBlock.faces.findAt((150,-150,0))

f = myBlock.faces


myBlock.PartitionFaceBySketch(faces=f, sketch=mySketch)

mySketch.unsetPrimaryObject()

del myModel.sketches['profile']


#---------------------------------------------------------------------------


# Assign material properties


import material

import section


# Create linear elastic material


myModel.Material(name='ElasticMaterial')

myModel.Material(name='LinearElastic')

myModel.materials['LinearElastic'].Elastic(table=((30000000.0,

   0.3), ))

myModel.HomogeneousSolidSection(name='SolidHomogeneous',

   material='LinearElastic', thickness=1.0)


# Create a set for the entire part


allFaces = myBlock.faces

myBlock.Set(faces=allFaces, name='All')


# Assign the above section properties to the part


region = myBlock.sets['All']

myBlock.SectionAssignment(region=region, sectionName='SolidHomogeneous')


#---------------------------------------------------------------------------


# Create an assembly


myAssembly = myModel.rootAssembly

myViewport.setValues(displayedObject=myAssembly)

myAssembly.DatumCsysByThreePoints(coordSysType=CYLINDRICAL,

   origin=(0.0, 0.0, 0.0), point1=(1.0, 0.0, 0.0),

   point2=(0.0, 0.0, -1.0))


myBlockInstance = myAssembly.Instance(name='Block-1', part=myBlock,

   dependent=OFF)



#---------------------------------------------------------------------------


# Create a step for Applying a load


myModel.StaticStep(name='ApplyLoad', previous='Initial',

   description='Apply the load')


#---------------------------------------------------------------------------


# Create interaction properties


# Create a set for the crack tip


v1 = myAssembly.instances['Block-1'].vertices

v = myBlockInstance.vertices.findAt((20.606602,-10.606602,0.))

verts1 = v1[v.index:(v.index+1)]

myAssembly.Set(vertices=verts1, name='crackTip')


# Create a set for the seam crack edges


edges1 = myBlockInstance.edges.findAt(((13.535534,-3.535534,0.),),

   ((18.838835,-8.838835,0.),),)

myAssembly.Set(edges=edges1, name='seamCrackEdge')


# Assign seam crack properties


pickedRegions = myAssembly.sets['seamCrackEdge']

myAssembly.engineeringFeatures.assignSeam(regions=pickedRegions)


crackFront = crackTip = myAssembly.sets['crackTip']


v1 = myBlockInstance.vertices.findAt((10.,0.,0.))

v2 = myBlockInstance.vertices.findAt((20.606602,-10.606602,0.))

myAssembly.engineeringFeatures.ContourIntegral(name='Crack', symmetric=OFF,

   crackFront=crackFront, crackTip=crackTip,

   extensionDirectionMethod=Q_VECTORS, qVectors=((v1,v2), ),

   midNodePosition=0.27, collapsedElementAtTip=SINGLE_NODE)


#---------------------------------------------------------------------------


# Create loads and boundary conditions


# Create sets for assigning boundary conditions and loads


# Create a set for the base


e = myBlockInstance.edges

edges1 = myBlockInstance.edges.findAt(((150.,-300.,0.),),

   ((22.297919,-300.,0.),), ((5.492919,-300.,0.),))

myAssembly.Set(edges=edges1, name='base')


# Create a set for the axisymmetric edge


edges1 = myBlockInstance.edges.findAt(((0.,-5.303301,0.),),

   ((0.,-159.305,0.),), ((0.,-14.608301,0.),))

myAssembly.Set(edges=edges1, name='axisymmEdge')


# Create a set for the top surface of the cone


s1 = myBlockInstance.edges.findAt((5,0,0))

side1Edges1 = e[s1.index:(s1.index+1)]

myAssembly.Surface(side1Edges=side1Edges1, name='topCrackSurf')


# Assign boundary conditions


baseFixed = myAssembly.sets['base']

myModel.DisplacementBC(name='baseFixed', createStepName='Initial',

   region=baseFixed, u2=0.0, fixed=OFF, distributionType=UNIFORM,

   localCsys=None)


axiEdge = myAssembly.sets['axisymmEdge']

myModel.DisplacementBC(name='axisymmEdge', createStepName='Initial',

   region=axiEdge, u1=0.0, fixed=OFF, distributionType=UNIFORM,

   localCsys=None)



# Assign load conditions


topSurf = myAssembly.surfaces['topCrackSurf']

myModel.Pressure(name='Load', createStepName='ApplyLoad',

   region=topSurf, distributionType=UNIFORM, magnitude=10.0)


#---------------------------------------------------------------------------


# Create a mesh


# Seed all the edges


pickedEdges = myBlockInstance.edges.findAt(((5,0,0),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=3, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((7.803301,-10.606602,0.),),

   ((5.492919,-18.61,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=5, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((0.,-5.303301,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=3, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((29.608301,-14.608301,0),),

   ((300.,-14.608301,0.),), ((13.29622,-14.608301,0.),),

   ((0.,-14.608301,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=2, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((13.535534,-3.535534,0.),),

   ((30.909903,-5.303301,0.),), ((300.,-5.303301,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=2, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((23.106602,0.,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=6, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((22.297919,-18.61,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=8, constraint=FIXED)


pickedEdges1 = myBlockInstance.edges.findAt(((19.5,-10.606602,0.),),

   ((21.837944,-10.606602,0.),))

pickedEdges2 = myBlockInstance.edges.findAt(((19.73591,-9.735911,0.),))

myAssembly.seedEdgeByBias(end1Edges=pickedEdges1, end2Edges=pickedEdges2,

   ratio=3.7, number=8, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((15.987204,-8.693185,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=3, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((22.520019,-5.987204,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=6, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((20.606602,-15.606602,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=8, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((54.017143,0.,0.),))

myAssembly.seedEdgeByBias(end2Edges=pickedEdges, ratio=1.5,

   number=12, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((45.593697,-10.606602,0.),))

myAssembly.seedEdgeByBias(end1Edges=pickedEdges, ratio=1.3,

   number=12, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((40,-18.61,0.),))

myAssembly.seedEdgeByBias(end1Edges=pickedEdges, ratio=1.5,

   number=12, constraint=FIXED)


pickedEdges1 = myBlockInstance.edges.findAt(((33.61,-39,0.),),

   ((10.985838,-39.106735,0.),), ((0.,-39.106735,0.),))

pickedEdges2 = myBlockInstance.edges.findAt(((300.,-39.106735,0.),))

myAssembly.seedEdgeByBias(end1Edges=pickedEdges1, end2Edges=pickedEdges2,

   ratio=5, number=8, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((40,-300,0.),))

myAssembly.seedEdgeByBias(end1Edges=pickedEdges, ratio=1.5,

   number=12, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((22.297919,-300.,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=8, constraint=FIXED)


pickedEdges = myBlockInstance.edges.findAt(((5.492919,-300.,0.),))

myAssembly.seedEdgeByNumber(edges=pickedEdges, number=5, constraint=FIXED)


# Assign meshing controls to the respective regions


pickedRegions = myBlockInstance.faces.findAt(((162,-5,0),),

   ((162,-15,0),), ((5,-5,0),), ((5,-15,0),), ((23.10,-2,0),),

   ((20.606602,-17,0),), ((5.4929,-150,0),), ((22.2979,-150,0),),

   ((166.805,-150,0),))

myAssembly.setMeshControls(regions=pickedRegions, elemShape=QUAD,

   technique=STRUCTURED)


pickedRegions = myBlockInstance.faces.findAt(((18.5,-9,0.),),

   ((22.52,-8,0),), ((20.60,-12,0.),))

myAssembly.setMeshControls(regions=pickedRegions, elemShape=QUAD_DOMINATED,

   technique=SWEEP)


elemType1 = mesh.ElemType(elemCode=CAX8R, elemLibrary=STANDARD,

   secondOrderAccuracy=OFF, hourglassControl=STIFFNESS,

   distortionControl=OFF)

elemType2 = mesh.ElemType(elemCode=CAX6M, elemLibrary=STANDARD)


faces1 = myBlockInstance.faces

pickedRegions = (faces1, )

myAssembly.setElementType(regions=pickedRegions,

   elemTypes=(elemType1, elemType2))


partInstances = (myBlockInstance, )

myAssembly.generateMesh(regions=partInstances)


#---------------------------------------------------------------------------


# Request history output for the crack


myModel.historyOutputRequests.changeKey(fromName='H-Output-1',

   toName='JInt')

myModel.historyOutputRequests['JInt'].setValues(

   contourIntegral='Crack', numberOfContours=5)

myModel.HistoryOutputRequest(name='StrInt', createStepName='ApplyLoad',

   contourIntegral='Crack', numberOfContours=5,

   contourType=K_FACTORS)

myModel.HistoryOutputRequest(name='TStr', createStepName='ApplyLoad',

   contourIntegral='Crack', numberOfContours=5,

   contourType=T_STRESS)


#---------------------------------------------------------------------------


# Create the job


myJob = mdb.Job(name=modelName, model=modelName,

   description='Contour integral analysis')

mdb.saveAs(pathName=modelName)


#---------------------------------------------------------------------------


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空