




免费预览已结束,剩余12页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Python Scripting in ABAQUSPython Scripting in ABAQUSKevin MaxwellTexas A&M UniversityAugust 30, 2006IntroductionABAQUS CAE provides a graphical user interface that allows the user to create finite element models that can then be analyzed in ABAQUS Standard. For every feature in CAE, there is a corresponding Python script command that the program uses when creating the model. If the language is understood well enough, an entire model can be created simply by running a script file. While one could write an entire script from scratch, ABAQUS provides several easier methods that autogenerate Python commands. When a model is created in CAE, two files are automatically created in the work directory. The replay file records every action that is performed in CAE including camera zoom/panning commands and also any mistakes that were made and then corrected. This file can be run to “replay” all the work that has been done on the model. The recover file records only the minimum necessary commands to recreate the model. If an error occurs and CAE closes without saving, the recover file can be run to recreate the model. When a model is saved, CAE uses the recover file to write a journal file. The journal file is a comprehensive script that shows all work saved on the model. Note that the recover file is deleted whenever the model is saved and all of its commands are transferred to the journal file. The recover and journal files provide an easy alternative to writing Python scripts from scratch. One can simply define a model in CAE and then save the Python commands from the recover or journal files as a separate script file.There are several valuable sources of information pertaining to scripting in ABAQUS. The ABAQUS Scripting Users Manual and ABAQUS Scripting Reference Manual are invaluable resources that are included in the ABAQUS documentation. The users manual gives an overview to scripting while the reference manual provides in-depth coverage of every scripting command used in ABAQUS. Another source of information can be found at . This website contains numerous resources dealing with the Python language in general.ExampleTo illustrate the procedure for auto-generating Python scripts, the cruciform specimen used for interfacial normal strength testing will be modeled. This specimen is shown in Figure 1. As can be seen from the figure, symmetry planes were exploited so that only of the specimen was modeled. The entire 2D model was first created in CAE and the necessary commands were copied from the recover file. The easiest way to do this is by splitting the modeling process into smaller segments and copying commands from the recover or journal file at the end of each segment. The resulting script can then be run in CAE so that the next segment can be created. Figure 1: of Cruciform SpecimenBefore starting the model type the following command into the Python editor box in CAE:session.journalOptions.setValues(recoverGeometry=COORDINATE)This sets the recover and journal files to record geometry commands in the form of coordinates instead of geometric indices. This step is very helpful if any type of parameterization will be used with the script.Next, the part will be sketched and created in CAE. The commands used to sketch the part in Figure 1 are then copied from the recover or journal file. These commands are shown below. mdb.modelsModel-1.ConstrainedSketch(name=_profile_, sheetSize=0.1)mdb.modelsModel-1.sketches_profile_.sketchOptions.setValues( decimalPlaces=3)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.0, 0.0), point2=( 0.015, 0.0065)del mdb.modelsModel-1.sketches_profile_mdb.modelsModel-1.ConstrainedSketch(name=_profile_, sheetSize=0.1)mdb.modelsModel-1.sketches_profile_.sketchOptions.setValues( decimalPlaces=3)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.0, 0.0), point2=( 0.015, 0.0)mdb.modelsModel-1.sketches_profile_.HorizontalConstraint(entity= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0075, 0.0), )mdb.modelsModel-1.sketches_profile_.Line(point1=(0.015, 0.0), point2= (0.015, 0.0065)mdb.modelsModel-1.sketches_profile_.VerticalConstraint(entity= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.015, 0.00325), )mdb.modelsModel-1.sketches_profile_.PerpendicularConstraint(entity1= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0075, 0.0), ), entity2= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.015, 0.00325), )mdb.modelsModel-1.sketches_profile_.Line(point1=(0.015, 0.0065), point2=(0.004, 0.0065)mdb.modelsModel-1.sketches_profile_.HorizontalConstraint(entity= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0095, 0.0065), )mdb.modelsModel-1.sketches_profile_.PerpendicularConstraint(entity1= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.015, 0.00325), ), entity2= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0095, 0.0065), )mdb.modelsModel-1.sketches_profile_.Line(point1=(0.004, 0.0065), point2=(0.004, 0.03)mdb.modelsModel-1.sketches_profile_.VerticalConstraint(entity= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.004, 0.01825), )mdb.modelsModel-1.sketches_profile_.PerpendicularConstraint(entity1= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0095, 0.0065), ), entity2= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.004, 0.01825), )mdb.modelsModel-1.sketches_profile_.Line(point1=(0.004, 0.03), point2=(0.0, 0.03)mdb.modelsModel-1.sketches_profile_.HorizontalConstraint(entity= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.002, 0.03), )mdb.modelsModel-1.sketches_profile_.PerpendicularConstraint(entity1= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.004, 0.01825), ), entity2= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.002, 0.03), )mdb.modelsModel-1.sketches_profile_.Line(point1=(0.0, 0.03), point2=( 0.0, 0.0)mdb.modelsModel-1.sketches_profile_.VerticalConstraint(entity= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0, 0.015), )mdb.modelsModel-1.sketches_profile_.PerpendicularConstraint(entity1= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.002, 0.03), ), entity2= mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0, 0.015), )mdb.modelsModel-1.sketches_ profile _.FilletByRadius(curve1= mdb.modelsModel-1.sketches_ profile _.geometry.findAt(0.004, 0.01825), ), curve2= mdb.modelsModel-1.sketches_ profile_.geometry.findAt(0.0095, 0.0065), ), nearPoint1=(0.0040139821358, 0.00947074592113), nearPoint2=( 0.00570417288691, 0.0064547881484), radius=0.006)Once the commands are copied, they may need to be modified so that the part is more robustly defined. For instance, instead of using (0, 2.439999) to define a vertex point, it may need to be changed to (0, 2.44) or even (0, r), where r is a variable that can be defined and used to parameterize the model. Also, some of the commands generated can be completely abandoned. The horizontal, vertical, perpendicular, etc. constraint commands sometimes cause problems with scripting, so deleting them is usually a good idea. The modified version of the generated sketch commands are given below.mdb.modelsModel-1.ConstrainedSketch(name=_profile_, sheetSize=0.1)mdb.modelsModel-1.sketches_profile_.sketchOptions.setValues(decimalPlaces=3)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.0, 0.0), point2=(0.015, 0.0)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.015, 0.0), point2=(0.015, h)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.015, h), point2=(w, h)mdb.modelsModel-1.sketches_profile_.Line(point1=(w, h), point2=(w, 0.03)mdb.modelsModel-1.sketches_profile_.Line(point1=(w, 0.03), point2=(0.0, 0.03)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.0, 0.03), point2=(0.0, 0.0)mdb.modelsModel-1.sketches_profile_.FilletByRadius(curve1=mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.004, 0.01825), ), curve2=mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0095, 0.0065), ), nearPoint1=(w+r, h), nearPoint2=(w, h+r), radius=r)The rest of the model and script are then created in CAE using the same steps as above. Special care must be taken when seeding and meshing the part. This is usually the most involved part of the process since anything other than trivial geometries requires a moderate to large amount of modification of the mesh seeds. Once the entire model has been created it is usually a good idea to run a simple analysis just to check for errors. The script can then be modified to achieve the task at hand (i.e. parameterization). The full, parameterized cruciform script is given below. Note that comments in Python are preceded by # and are also highlighted in this document. Also note the part, material, section, etc import module commands that precede the script. The recover and journal files generate these commands and they must be included in the final script. from part import *from material import *from section import *from assembly import *from step import *from interaction import *from load import *from mesh import *from job import *from sketch import *from visualization import *from connectorBehavior import *#TO VARY A PARAMETER, UNCOMMENT THE LIST VECTOR FOR THE SPECIFIC PARAMETER (WIDTHS, HEIGHTS, OR RADII) AND COMMENT #OUT THE CORRESPONDING DUMMY LETTER (W, H, OR R). THEN UNCOMMENT THE RESPECTIVE FOR LOOP COMMAND.#THE CURRENT SETUP WILL VARY THE WING HEIGHT FROM 0.003 - 0.009 WHILE#KEEPING THE LOADING ARM WIDTH AND FILLET RADIUS CONSTANT AT 0.008 AND 0.006 RESPECTIVELY.w = .008#widths = .001,.002,.003,.004,.005,.006,.008#h = .002heights = .003,.004,.005,.006,.007,.008,.009r = .006#radii = .003,.004,.005,.006,.007i=1#for w in widths:#for h in heights:for r in radii:#CREATE THE PART SKETCHmdb.modelsModel-1.ConstrainedSketch(name=_profile_, sheetSize=0.1)mdb.modelsModel-1.sketches_profile_.sketchOptions.setValues(decimalPlaces=3)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.0, 0.0), point2=(0.015, 0.0)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.015, 0.0), point2=(0.015, h)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.015, h), point2=(w, h)mdb.modelsModel-1.sketches_profile_.Line(point1=(w, h), point2=(w, 0.03)mdb.modelsModel-1.sketches_profile_.Line(point1=(w, 0.03), point2=(0.0, 0.03)mdb.modelsModel-1.sketches_profile_.Line(point1=(0.0, 0.03), point2=(0.0, 0.0)mdb.modelsModel-1.sketches_profile_.FilletByRadius(curve2=mdb.modelsModel-1.sketches_profile_.geometry.findAt(w, h*2), ), curve1=mdb.modelsModel-1.sketches_profile_.geometry.findAt(0.0095, h), ), nearPoint1=(w+r, h), nearPoint2=(w, h+r), radius=r)#CREATE THE ACTUAL PART FROM THE PART SKETCHmdb.modelsModel-1.Part(dimensionality=TWO_D_PLANAR, name=Part-1, type=DEFORMABLE_BODY)mdb.modelsModel-1.partsPart-1.BaseShell(sketch=mdb.modelsModel-1.sketches_profile_)del mdb.modelsModel-1.sketches_profile_#CREATE THE EPOXY MATERIAL AND THE MATRIX SECTIONmdb.modelsModel-1.Material(name=Epoxy)mdb.modelsModel-1.materialsEpoxy.Elastic(table=(3440000000.0, 0.35), )mdb.modelsModel-1.HomogeneousSolidSection(material=Epoxy, name=Matrix, thickness=1.0)#INSTANCE THE PARTmdb.modelsModel-1.rootAssembly.DatumCsysByDefault(CARTESIAN)mdb.modelsModel-1.rootAssembly.Instance(dependent=OFF, name=Part-1, part=mdb.modelsModel-1.partsPart-1)#CREATE A NEW STEPmdb.modelsModel-1.StaticStep(description=Apply load to specimen, name=Apply Load Step, previous=Initial)mdb.modelsModel-1.rootAssembly.regenerate()#ASSIGN THE MATRIX SECTIONmdb.modelsModel-1.partsPart-1.SectionAssignment(offset=0.0, region=Region(faces=mdb.modelsModel-1.partsPart-1.faces.findAt(0.001, 0.001, 0.0), (0.0, 0.0, 1.0), ), sectionName=Matrix)mdb.modelsModel-1.rootAssembly.regenerate()#CREATE THE SURFACE TRACTION LOADmdb.modelsModel-1.SurfaceTraction(createStepName=Apply Load Step, directionVector=(0.0, 0.0, 0.0), (0.0, 1.0, 0.0), distributionType=UNIFORM, field=, localCsys=None, magnitude=100.0, name=Load-1, region=Region(side1Edges=mdb.modelsModel1.rootAssembly.instancesPart- 1.edges.findAt(0.0005, 0.03, 0.0), ), ), traction=GENERAL)#CREATE THE SYMMETRY BOUNDARY CONDITIONSmdb.modelsModel-1.XsymmBC(createStepName=Apply Load Step, name=BC-1, region=Region(edges=mdb.modelsModel1.rootAssembly.instancesPart-1.edges.findAt(0.0, 0.0225, 0.0), ), )mdb.modelsModel-1.YsymmBC(createStepName=Apply Load Step, name=BC-2, region=Region(edges=mdb.modelsModel-1.rootAssembly.instancesPart-1.edges.findAt(0.00375, 0.0, 0.0), ), )#SEED AND MESH THE PARTmdb.modelsModel-1.rootAssembly.seedPartInstance(deviationFactor=0.1, regions=(mdb.modelsModel-1.rootAssembly.instancesPart-1, ), size=0.0005)mdb.modelsModel-1.rootAssembly.generateMesh(regions=(mdb.modelsModel-1.rootAssembly.instancesPart-1, )#CREATE A JOB AND SUBMIT ITjobname = Job-%s %imdb.Job(contactPrint=OFF, description=, echoPrint=OFF, explicitPrecision=SINGLE, historyPrint=OFF, model=Model-1, modelPrint=OFF, multiprocessingMode=DEFAULT, name=jobname, nodalOutputPrecision=SINGLE, numCpus=1, numDomains=1, parallelizationMethodExplicit=DOMAIN, preMemory=256.0, scratch=, standardMemory=256.0, standardMemoryPolicy=MODERATE, type=ANALYSIS, userSubroutine=)job = jobnamejob.submit()job.waitForCompletion()i=i+1#END OF FOR LOOPMicromechanics TemplatesTemplates for square and hexagonal composite fiber orientations were created using Python scripts and ABAQUS. The respective scripts create a model in ABAQUS CAE and assign a mesh to this model. The fiber volume fraction as well as the global element size can be specified. Sample meshes for both templates are given in Figure 1 and Figure 2. Note that symmetry planes were exploited in order to model of the square or hexagon.Figure 2: Square MeshThe python scripts used to create these models are included below. Some of the commands were autogenerated using ABAQUS CAE and the associated recover/journal files. However, most of the commands were written from scratch in Notepad+, an open source text editor with multi-language support (/uk/site.htm). It can be seen that the commands in the scripts given below are somewhat simpler than the example above. This is because repositories were used to store repetitive object paths. For example, the commandsketch1 = mdb.modelsModel-1.sketches_profile_allows the object pathmdb.modelsModel-1.sketches_profile_to be replaced with the variable sketch1. This greatly reduces the amount of typing needed and also makes the script more readable. Overall, the use of scripting made the definition of the model geometry much easier to define as well as allowing the parameterization of the fiber size and mesh. Figure 3: Hexagonal MeshThe mesh was developed so that the elements are most uniform along the fiber matrix interface. To accomplish this, a small square partition in the lower left of the model and a circular partition with radius greater than the fiber radius were added to the mesh. These partitions can be seen in Figure 3 and Figure 4. It should be noted that time constraints did not allow the meshes for either template to be completely refined. For the square model, the user can input global element size and the number of seeds along the fiber matrix interface. For the hexagonal model, the user can input global element size, interface seed number, and number of seeds along the top edge (this number has to be specified in order to make this mesh edge symmetric). Options such as biasing the element size along different directions could be added to the script at a later date. A method to decrease the element size in the lower left corner of the models would help to refine the mesh. The mesh might also need to be altered so that all elements have a reasonable aspect ratio.Figure 4: Square Model PartitionsFigure 5: Hexagonal Model partitionsSquare Script:from part import *from material import *from section import *from assembly import *from step import *from interaction import *from load import *from mesh import *from job import *from sketch import *from visualization import *#Geometry definitions#Choose values of fiber radius and matrixwVf = .4element_size = .015interface_seeds = 40w = 1.0pi=3.14159
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 邮政理赔协议书范本
- 劝退赔付协议书范本
- 机车出售转让协议书范本
- 心理健康课件结语大全
- 2025年度建筑劳务分包合同
- 2025年度文化旅游项目简易工程劳务分包协议
- 二零二五版驾校学员实习基地合作协议
- 2025年生物科技产品定向采购协议书促进生命科学进步
- 二零二五年水电梯级电站运营维护承包协议
- 二零二五年度智能仓储物流服务合作协议
- 2025年消毒供应室专科理论考试题库及答案
- 专利转让许可培训课件
- 张力性气胸个案护理
- 铁路客运安全与应急处理
- 煲仔饭外卖活动方案
- 工厂三级安全教育培训考核试卷(含答案)
- (2025)特种设备安全管理人员安全考核考试题库及答案
- 危化品经营安全生产规章制度
- 2025至2030再加工一次性设备行业产业运行态势及投资规划深度研究报告
- 护理专业组长竞聘
- 学堂在线 管理沟通的艺术 期末考试答案
评论
0/150
提交评论