您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 综合/其它 > Abaqus二次开发高级专题(中文版)
©DassaultSystèmes,2008高级专题第4讲IntroductiontoPythonandScriptinginAbaqusL4.2©DassaultSystèmes,2008概要•探究用户数据•Abaqus的体系结构•监控分析作业•定制数据•插件程序•调试脚本•Abaqus中的Python开发环境(PDE)•基于对象编程•Python中的类•实例•习题©DassaultSystèmes,2008探究用户数据IntroductiontoPythonandScriptinginAbaqusL4.4©DassaultSystèmes,2008探究用户数据•查询对象属性查询专门属性。例如:odb=openOdb('cantilever.odb')odb.__members__['analysisTitle','closed','description','diagnosticData','isReadOnly','jobData','name','parts','path','rootAssembly','sectionCategories','sectorDefinition','steps','userData']odb.__methods__['Part','SectionCategory','Step','UserXYData','close','getFrame','save','update']使用print语句。Abaqus的对象状态可以用print语句来打印,例如:printodb({'analysisTitle':Cantileverbeammodel','closed':FALSE,'description':'DDBobject','diagnosticData':'OdbDiagnosticDataobject','isReadOnly':FALSE,'jobData':'JobDataobject','name':'cantilever.odb','parts':'Repositoryobject','path':'d:\temp\cantilever.odb','rootAssembly':'OdbAssemblyobject','sectionCategories':'Repositoryobject','sectorDefinition':None,'steps':'Repositoryobject','userData':'UserDataobject'})IntroductiontoPythonandScriptinginAbaqusL4.5©DassaultSystèmes,2008探究用户数据•prettyPrint函数fromtextReprimport*prettyPrint(odb)({'analysisTitle':'Cantileverbeammodel','closed':FALSE,'description':'DDBobject','diagnosticData':'OdbDiagnosticDataobject','isReadOnly':FALSE,'jobData':'JobDataobject','name':'cantilever.odb','parts':'Repositoryobject','path':'d:\temp\cantilever.odb','rootAssembly':'OdbAssemblyobject','sectionCategories':'Repositoryobject','sectorDefinition':None,'steps':'Repositoryobject','userData':'UserDataobject'})•缺省情况下,只打印1层,第2个变量的含义是深度(prettyPrint.py).prettyPrint(odb,maxRecursionDepth=2)•设置默认深度–影响textRepr函数和打印的Abaqus对象.session.textReprOptions.setValues(maxRecursionDepth=3)IntroductiontoPythonandScriptinginAbaqusL4.6©DassaultSystèmes,2008探究用户数据•更多textRepr函数•textRepr模块中的函数:getIndentedRepr,getPaths,getTypes,prettyPrint,prettyPrintToFile,prettyPrintToFileName,prettyPrintToTerm,printPaths,printPathsToFile,printPathsToFileName,printPathsToTerm,printTypes•函数名:prettyPrint(object,maxRecursionDepth,maxElementsInSequence,significantDigits,_internalMembersMethods)printPaths(object,maxRecursionDepth,maxElementsInSequence,pathRoot,_internalMembersMethods)printTypes(object,maxRecursionDepth,maxElementsInSequence,pathRoot,_internalMembersMethods)printPathsToFileName(fileName,object,maxRecursionDepth,maxElementsInSequence,pathRoot,_internalMembersMethods)•注意:可选参数显示在...中•使用__doc__来检查参数IntroductiontoPythonandScriptinginAbaqusL4.7©DassaultSystèmes,2008探究用户数据•打印路径fromodbAccessimport*fromtextReprimport*odb=openOdb('cantilever.odb')printPaths(odb,pathRoot='odb')odb.analysisTitleodb.closedodb.descriptionodb.diagnosticDataodb.isReadOnlyodb.jobDataodb.nameodb.partsodb.pathodb.rootAssemblyodb.sectionCategoriesodb.sectorDefinitionodb.stepsodb.userData•通过增加深度来显示更多数据printPaths(odb,2,pathRoot='odb')...或选择组分之一printPaths(odb.steps['Step-1'],2,pathRoot='step')IntroductiontoPythonandScriptinginAbaqusL4.8©DassaultSystèmes,2008探究用户数据•getPaths•返回的字符串可以进一步被处理x=getPaths(odb.steps['Step-1'].frames[87].fieldOutputs,pathRoot='fieldOutputs')printxfieldOutputs['S']fieldOutputs['PE']fieldOutputs['RF']fieldOutputs['PEEQ']fieldOutputs['LE']fieldOutputs['PEMAG']fieldOutputs['ACYIELD']fieldOutputs['CF']fieldOutputs['U']y=x.splitlines()printy[3]fieldOutputs['PEEQ']IntroductiontoPythonandScriptinginAbaqusL4.9©DassaultSystèmes,2008探究用户数据•printTypes•返回每个组分(member)的类型stress=odb.steps['Step-1'].frames[87].fieldOutputs['S']printTypes(stress,pathRoot='stress')tuplestress.componentLabelsstringstress.descriptionFieldLocationArraystress.locationsstringstress.nameSymbolicConstantstress.typetuplestress.validInvariantsFieldValueArraystress.values•利用getPaths()和eval(path)打印每个组分值forpathingetPaths(obj).splitlines():print'%-20s%s'%(eval(path),path)©DassaultSystèmes,2008Abaqus的体系结构IntroductiontoPythonandScriptinginAbaqusL4.11©DassaultSystèmes,2008Abaqus的体系结构Abaqus/CAEkernelAbaqus/CAEkernelAbaqusanalysisAbaqusanalysisInputfileWIPmessagesODBfilesPythoninterpreterPythoninterpreterAbaqusGUIAbaqusGUICommandlineinterpreterCommandlineinterpreterPythoninterpreterPythoninterpreterReplayfileReplayfileUpdatemessages•Abaqus包含三块:内核(kernel),GUI和分析过程。KernelscriptKernelscriptGUIscriptGUIscriptCommandsIntroductiontoPythonandScriptinginAbaqusL4.12©DassaultSystèmes,2008Abaqus的体系结构•内核命令•GUI和命令行解释器在不同的命名空间执行内核解释器命令。这样可以避免定义变量时名字过长。•内核脚本与命令行解释器使用相同的命名空间。•Abaqus分析过程中的信息•分析过程中的信息使用作业监控中的API进行处理。•GUI脚本•Abaqus中的GUI使用内部Python语言解释器。用户在使用过程中无法看到,但是可以用来定制GUI。©DassaultSystèmes,2008监控分析作业IntroductiontoPythonandScriptinginAbaqusL4.14©DassaultSystèmes,2008监控分析作业•什么是分析作业监控•执行过程中,可以得到分析过程中的各种信息。•对获得信息作出反应•在有些情况下,用户可能要处理分析过程中的各种信息。例如,当达到某种标准或在分析过程中需要绘制分析结果图而必须中止分析作业的情况。•可以通过在monitorManager对象中写回收(callback)函数来实现。IntroductiontoPythonandScriptinginAbaqusL4.15©DassaultSystèmes,2008监控分析作业•例子•下列语句将打印出分析过程中的所有信息:fromabaqusimport*fromjobMessageimportANY_JOB,ANY_MESSAGE_TYPE#defineacallbackfuncti
本文标题:Abaqus二次开发高级专题(中文版)
链接地址:https://www.777doc.com/doc-6837049 .html