分享
分销 收藏 举报 申诉 / 11
播放页_导航下方通栏广告

类型在abaqus中利用python语言建模例子.pdf

  • 上传人:曲****
  • 文档编号:226687
  • 上传时间:2023-03-11
  • 格式:PDF
  • 页数:11
  • 大小:358.92KB
  • 下载积分:15 金币
  • 播放页_非在线预览资源立即下载上方广告
    配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    abaqus 利用 python 语言 建模 例子
    资源描述:
    3.1 Creating a partThe first example shows how you can use an Abaqus/CAE script to replicate the functionality of Abaqus/CAE.The script does the following:Creates a new model in the model database.Creates a two-dimensional sketch.Creates a three-dimensional,deformable part.Extrudes the two-dimensional sketch to create the first geometric feature of the part.Creates a new viewport.Displays a shaded image of the new part in the new viewport.The new viewport and the shaded part are shown in Figure 3 7.Figure 3-1 The example creates a new viewport and a part.YQ Viewport for Model A Model:Model A Part:Part A B QThe example scripts from this manual can be copied to the user5 s working directory by using the Abaqus fetch utility:abaqus fetch job=scriptNamewhere scriptName.py is the name of the script(see“Execution procedure for fetching sample input files,“Section 3.2.12 of the Abaqus Analysis Users Manual).Use the following command to retrieve the script for this example:xyCoordsOuter 二(TO,30),(10,30),(40,-30),(30,-30),(20,-10),(-20,-10),(-30,-30),(-40,-30),(-10,30)for i in range(len(xyCoordsInner)-l):mySketch.Line(pointl=xyCoordsInneri,point2=xyCoordsInneri+1)for i in range(len(xyCoordsOuter)-1):mySketch.Line(point 1=xyCoordsOuteri,point2=xyCoords0uteri+1)myPart=myModel.Part(name=,Part A,,dimensionality=THREE_D,type=DEFORMABLE_BODY)myPart.BaseSolidExtrude(sketch=mySketch,depth=20.0)myViewport=session.Viewport(name=,Viewport for Model A,origin=(10,10),width=150,height=100)myViewport.setValues(displayedObject=myPart)myViewport.partDisplay.setValues(renderStyle=SHADED)3.1.2 How does the script work?This section explains each portion of the example script.from abaqus import*This statement makes the basic Abaqus objects accessible to the script.It also provides access to a default model database using the variable named mdb.The statement,from abaqusConstants import*,makes the Symbolic Constants defined by the Abaqus Scripting Interface available to the script,import sketch import partThese statements provide access to the objects related to sketches and parts,sketch and part are cal led Python modules.The next statement in the script is shown in Figure 3-2.You can read this statement from right to left as follows:1.Create a new model named Model A.2.Store the new model in the model database mdb.3.Assign the new model to a variable called myModel.Figure 3-2 Creating a new model.3.Assign a variable to the new model1.Create a new model named Model AmyModel=mdb.Model(name=1 Model A)2.Store the new model in the model database mdbmySketch=myModel.ConstrainedSketch(name=,Sketch A,sheetSize=200.0)This statement creates a new sketch object named Sketch A in myModel.The variable mySketch is assigned to the new sketch.The sketch will be placed on a sheet 200 units square.Note the following:A command that creates something(an“object“in object-oriented programming terms)is called a constructor and starts with an uppercase character.You have seen the Model and Sketch commands that create Model objects and Sketch objects,respectively.The command uses the variable myModel that we created in the previous statement.Using variables with meaningful names in a script makes the script easier to read and understand.xyCoordsInner=(-5,20),(5,20),(15,0),(-15,0),(-5,20)xyCoordsOuter=(-10,30),(10,30),(40,-30),(30,-30),(20,-10),(-20,-10),(-30,-30),(-40,-30),(-10,30)These two statements define the X-andcoordinates of the vertices that form the inner and outer profile of the letter A.The variable xyCoordsInner refers to the vertices of the inner profile,and the variable xyCoordsOuter refers to the vertices of the outer profile,for i in range(len(xyCoordsInner)-1):mySketch.Line(pointl=xyCoordsInneri,point2=xyCoordsInneri+1)This loop creates the inner profile of the letter A in mySketch.Four lines are created using the 产 and coordinates of the vertices in xyCoordsInner to define the beginning point and the end point of each line.Note the following:Python uses only indentation to signify the start and the end of a loop.Python does not use the brackets of C and C+.The len()function returns the number of coordinate pairs in xyCoordsInnerfive in our example.The range()function returns a sequence of integers.In Python,as in C and C+,the index of an array starts at zero.In our example range(4)returns 0,1,2,3.For each iteration of the loop in the example the variable i is assigned to the next value in the sequence of integers.Similarly,a second loop creates the outer profile of the A character.myPart=myModel.Part(name=,Part A,dimensionality=THREE_D,type=DEFORMABLE_BODY)This statement creates a three-dimensional,deformable part named Part A in myModel.The new part is assigned to the variable myPart.myPart.BaseSolidExtrude(sketch=mySketch,depth=20.0)This statement creates a base solid extrude feature in myPart by extruding mySketch through a depth of 20.0.myViewport=session.Viewport(name=,Viewport for Model A,origin=(20,20),width=150,height=100)This statement creates a new viewport named Viewport for Model A in session.The new viewport is assigned to the variable myViewport.The origin of the viewport is at(20,20),and it has a width of 150 and a height of 100.myViewport.setValues(displayedObject=myPart)This statement tells Abaqus to display the new part,myPart,in the new viewport,myViewport.myViewport.partDisplayOptions.setValues(renderStyle=SHADED)This statement sets the render style of the part display options in myViewport to shaded.As a result,myPart appears in the shaded render style.3.2 Reading from an output databaseThe second example shows how you can use the Abaqus Scripting Interface to read an output database,manipulate the data,and display the results using the Visualization module in Abaqus/CAE.The Abaqus Scripting Interface allows you to display the data even though you have not written it back to an output database.The script does the following:Opens the tutorial output database.Creates variables that refer to the first and second steps in the output database.Creates variables that refer to the last frame of the first and second steps.Creates vari ables that refer to the di splacement fi eld output i n the last frame of the first and second steps.Creates variables that refer to the stress field output in the last frame of the first and second steps.Subtracts the displacement field output from the two steps and puts the result in a variable called deltaDisplacement.Subtracts the stress field output from the two steps and puts the result in a variable called deltaStress.Selects deltaDisplacement as the default deformed variable.Selects the von Mises invariant of deltaStress as the default field output variable.Plots a contour plot of the result.The resulting contour plot is shown in Figure 3-3.Figure 3-3 The resulting contour plot.S-S/Mises(Aug:75%)+4.012e-02+3.678e-02+3.344e-02+3.01 le-02+2.677e-02+2.343e-02+2.010e-02+1.676e-02+1.342e-02+1.009e-02+6.750e-03+3.414e-03+7.711e-05XStep:Session Step,Step for Viewer non-persistent fields Session FramePrimary Var:S-S?MisesDeformed Var:U-U Deformation Scale Factor:+1.000e+00Use the following commands to retrieve the script and the output databasethat is readby the script:abaqus fetch abaqus fetchjob=odbExample job=viewer_tutorial3.2.1 The example script odbExample.pyScript to open an output database,superimpose variables from the last frame of different steps,and display a contour plot of the result.from abaqus import*from abaqusConstants import*import visualizationmyViewport=session.Viewport(name=,Superposition example,origin=(10,10),width=150,height=100)#Open the tutorial output database.myOdb=visualization.openOdb(path=viewer_tutorial.odb,)#Associate the output database with the viewport.myViewport.setValues(displayedObject=myOdb)#Create variables that refer to the first two steps.f irstStep=myOdb.stepsStep-1secondStep=myOdb.steps Step-2#Read displacement and stress data from the last frame#of the first two steps.frame1=firstStep.frames-1frame2=secondStep.frames-1displacement!=framel.fieldOutputsU,displacement2=frame2.fieldOutputsU,stressl=framel.fieldOutputsS5stress2=frame2.fieldOutputsS#Find the added displacement and stress caused by the loading in the second step.deltaDisplacement=displacement2-displacement1deltaStress=stress2-stressl#Create a Mises stress contour plot of the result.myViewport.odbDisplay.setDeformedVariable(deltaDisplacement)myViewport.odbDisplay.setPrimaryVariable(field=deltaStress,outputPosit ion=INTEGRATION_POINT,refinement=(INVARIANT,Mises)myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,)3.2.2 How does the script work?This section explains each portion of the example script.from abaqus import*from abaqusConstants import*These statements make the basic Abaqus objects accessible to the script as well as all the Symbolic Constants defined in the Abaqus Scripting Interface.import visualizationThis statement provides access to the commands that replicate the functionality of the Visualization module in Abaqus/CAE(Abaqus/Viewer).myViewport=session.Viewport(name=,Superposition example)This statement creates a new viewport named Superposition example in the session.The new viewport is assigned to the variable myViewport.The origin and the size of the viewport assume the default values.odbPath=viewer_tutorial.odbThis statement creates a path to the tutorial output database.myOdb=session.openOdb(path=odbPath)This statement uses the path variable odbPath to open the output database and to assign it to the variable myOdb.myViewport.setValues(displayedObject=myOdb)This statement displays the default plot of the output database in the viewport.firstStep=myOdb.stepsStep-1secondStep=myOdb.steps5 Step-25These statements assign the first and second steps in the output database to the variables firstStep and secondStep.frame1=firstStep.frames-1frame2=secondStep.frames-1These statements assign the last frame of the first and second steps to the variables frame1 and frame2.In Python an index of 0 refers to the first item in a sequence.An index of-1 refers to the last item in a sequence.displacement!=framel.fieldOutputsUdisplacement?二 frame2.fieldOutputsU,These statements assign the displacement field output in the last frame of the first and second steps to the variables displacement!and displacement2.stressl=framel.fieldOutputsSstress2=frame2.fieldOutputsSSimilarly,these statements assign the stress field output in the last frame of the first and second steps to the variables stressl and stress2.deltaDisplacement=displacement2-displacement1This statement subtracts the displacement field output from the last frame of the two steps and puts the resulting field output into a new variable deltaDisplacement.deltaStress=stress2-stresslSimilarly,this statement subtracts the stress field output and puts the result in the variable deltaStress.myViewport.odbDisplay.setDeformedVariable(deltaDisplacement)This statement uses deltaDisplacement,the displacement field output variable that we created earlier,to set the deformed variable.This is the variable that Abaqus will use to display the shape of the deformed model.myViewport.odbDisplay.setPrimaryVariable(field=deltaStress,outputPosition=INTEGRATION_POINT,refinement=(INVARIANT,Mises)This statement uses deltaStress,our stress field output variable,to set the primary variable.This is the variable that Abaqus will display in a contour or symbol plot.myViewport.odbDisplay.display.setValues(plotState=(C0NT0URS_0N_DEF,)The final statement sets the plot state to display a contour plot on the deformed model shape.3.3 SummaryThe examples illustrate how a script can operate on a model in a model database or on the data stored in an output database.The details of the commands in the examples are described in later sections;however,you should note the following:You can run a script from the Abaqus/CAE startup screen when you start a session.After a session has started,you can run a script from the FileRun Script menu or from the command line interface.A script is a sequence of commands stored in ASCII format and can be edited with a standard text editor.A set of example scripts are provided with Abaqus.Use the abaqus fetch command to retrieve a script and any associated files.You must use the import statement to make the required set of Abaqus Scripting Interface commands available.For example,the statement import part provides the commands that create and operate on parts.A command that creates something(an“object”in object-oriented programming terms)is called a constructor and starts with an uppercase character.For example,the fol lowing statement uses the Model constructor to create a model object.myModel=mdb.Model(name=Model A)The model object created ismdb.models 5 Model A You can use a variable to refer to an object.Variables make your scripts easier to read and understand.myModel refers to a model object in the previous example.A Python script can include a loop.The start and end of a loop is controlled by indentation in the script.Python includes a set of built-in functions.For example,the len()function returns the length of a sequence.You can use commands to replicate any operation that can be performed interactively when you are working with Abaqus/CAE;for example,creating a viewport,displaying a contour plot,and setting the step and the frame to display.
    展开阅读全文
    提示  咨信网温馨提示:
    1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
    2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
    3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
    4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
    5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
    6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

    开通VIP折扣优惠下载文档

    自信AI创作助手
    关于本文
    本文标题:在abaqus中利用python语言建模例子.pdf
    链接地址:https://www.zixin.com.cn/doc/226687.html
    页脚通栏广告

    Copyright ©2010-2026   All Rights Reserved  宁波自信网络信息技术有限公司 版权所有   |  客服电话:0574-28810668    微信客服:咨信网客服    投诉电话:18658249818   

    违法和不良信息举报邮箱:help@zixin.com.cn    文档合作和网站合作邮箱:fuwu@zixin.com.cn    意见反馈和侵权处理邮箱:1219186828@qq.com   | 证照中心

    12321jubao.png12321网络举报中心 电话:010-12321  jubao.png中国互联网举报中心 电话:12377   gongan.png浙公网安备33021202000488号  icp.png浙ICP备2021020529号-1 浙B2-20240490   


    关注我们 :微信公众号  抖音  微博  LOFTER               

    自信网络  |  ZixinNetwork