许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  Python操作ABAQUS建模教程①

Python操作ABAQUS建模教程①

阅读数 3
点赞 0
article_banner

参考资料

1. pyabaqus库使用指引(官方):GitHub - haiiliin/pyabaqus: Type hints for Abaqus/Python scripting (The repo has been transferred to https://github.com/haiiliin/abqpy).Type hints for Abaqus/Python scripting (The repo has been transferred to https://github.com/haiiliin/abqpy). - GitHub - haiiliin/pyabaqus: Type hints for Abaqus/Python scripting (The repo has been transferred to https://github.com/haiiliin/abqpy).https://github.com/haiiliin/pyabaqus2. abaqus使用指南:Abaqus 6.14 Documentationhttp://wufengyun.com:888/

3. 注意事项:

        1. 安装 python3.9 及以上版本;我使用的是3.9.2。

        2. 安装abaqus;我使用的是abaqus2022。

        3. 安装pyabaqus库,注意这个库需要与自己的abaqus版本对应;例:我安装的是abaqus2022,那么我需要安装pyabaqus==2022这个版本的库。可以使用两种方式安装库:

                ①在命令行窗口输入:pip install pyabaqus==2022

                ②在参考资料1的github 链接 里面找到Source code(tar.gz)(或者直接单击这个链接)下载。完了之后,在文件夹显示,命令行方式打开该文件夹,pip install 全部文件名

                        

                         

                        

         4. 安装完成后,需要设置环境变量。依次点击 右键此电脑-属性-高级系统设置-环境变量-新建系统变量,输入如下:变量值要指向在abaqus安装目录中的abaqus.bat文件。自己找找就好。输入完了,直接一直确定保存就好。

        

         5. 以上完成了,就能在命令行窗口直接调用abaqus的内核进行计算处理了(无需打开abaqus)。调用示例:cmd进入相应的文件夹,使用命令执行如下,前面不变,xuanbiliang.py是文件名,自己可以根据自己的写。

 注意文件夹路径,不要含有 中文 !!!

 

 这个odb结果文件可以直接在abaqus中查看,或者继续用python写一些后处理的逻辑,直接输出csv或者txt等文件都是可以的。

 悬臂梁测试参考代码如下(来源于参考文件2-Abaqus Scripting User's Guide-8.1节):

  1. """
  2. beamExample.py
  3. Reproduce the cantilever beam example from the
  4. Appendix of the Getting Started with
  5. Abaqus: Interactive Edition Manual.
  6. """
  7. from abaqus import *
  8. from abaqusConstants import *
  9. backwardCompatibility.setValues(includeDeprecated=True,
  10. reportDeprecated=False)
  11. # Create a model.
  12. myModel = mdb.Model(name='Beam')
  13. # Create a new viewport in which to display the model
  14. # and the results of the analysis.
  15. myViewport = session.Viewport(name='Cantilever Beam Example',
  16. origin=(20, 20), width=150, height=120)
  17. #-----------------------------------------------------
  18. import part
  19. # Create a sketch for the base feature.
  20. mySketch = myModel.ConstrainedSketch(name='beamProfile',
  21. sheetSize=250.)
  22. # Create the rectangle.
  23. mySketch.rectangle(point1=(-100,10), point2=(100,-10))
  24. # Create a three-dimensional, deformable part.
  25. myBeam = myModel.Part(name='Beam', dimensionality=THREE_D,
  26. type=DEFORMABLE_BODY)
  27. # Create the part's base feature by extruding the sketch
  28. # through a distance of 25.0.
  29. myBeam.BaseSolidExtrude(sketch=mySketch, depth=25.0)
  30. #-----------------------------------------------------
  31. import material
  32. # Create a material.
  33. mySteel = myModel.Material(name='Steel')
  34. # Create the elastic properties: youngsModulus is 209.E3
  35. # and poissonsRatio is 0.3
  36. elasticProperties = (209.E3, 0.3)
  37. mySteel.Elastic(table=(elasticProperties, ) )
  38. #-------------------------------------------------------
  39. import section
  40. # Create the solid section.
  41. mySection = myModel.HomogeneousSolidSection(name='beamSection',
  42. material='Steel', thickness=1.0)
  43. # Assign the section to the region. The region refers
  44. # to the single cell in this model.
  45. region = (myBeam.cells,)
  46. myBeam.SectionAssignment(region=region,
  47. sectionName='beamSection')
  48. #-------------------------------------------------------
  49. import assembly
  50. # Create a part instance.
  51. myAssembly = myModel.rootAssembly
  52. myInstance = myAssembly.Instance(name='beamInstance',
  53. part=myBeam, dependent=OFF)
  54. #-------------------------------------------------------
  55. import step
  56. # Create a step. The time period of the static step is 1.0,
  57. # and the initial incrementation is 0.1; the step is created
  58. # after the initial step.
  59. myModel.StaticStep(name='beamLoad', previous='Initial',
  60. timePeriod=1.0, initialInc=0.1,
  61. description='Load the top of the beam.')
  62. #-------------------------------------------------------
  63. import load
  64. # Find the end face using coordinates.
  65. endFaceCenter = (-100,0,12.5)
  66. endFace = myInstance.faces.findAt((endFaceCenter,) )
  67. # Create a boundary condition that encastres one end
  68. # of the beam.
  69. endRegion = (endFace,)
  70. myModel.EncastreBC(name='Fixed',createStepName='beamLoad',
  71. region=endRegion)
  72. # Find the top face using coordinates.
  73. topFaceCenter = (0,10,12.5)
  74. topFace = myInstance.faces.findAt((topFaceCenter,) )
  75. # Create a pressure load on the top face of the beam.
  76. topSurface = ((topFace, SIDE1), )
  77. myModel.Pressure(name='Pressure', createStepName='beamLoad',
  78. region=topSurface, magnitude=0.5)
  79. #-------------------------------------------------------
  80. import mesh
  81. # Assign an element type to the part instance.
  82. region = (myInstance.cells,)
  83. elemType = mesh.ElemType(elemCode=C3D8I, elemLibrary=STANDARD)
  84. myAssembly.setElementType(regions=region, elemTypes=(elemType,))
  85. # Seed the part instance.
  86. myAssembly.seedPartInstance(regions=(myInstance,), size=10.0)
  87. # Mesh the part instance.
  88. myAssembly.generateMesh(regions=(myInstance,))
  89. # Display the meshed beam.
  90. myViewport.assemblyDisplay.setValues(mesh=ON)
  91. myViewport.assemblyDisplay.meshOptions.setValues(meshTechnique=ON)
  92. myViewport.setValues(displayedObject=myAssembly)
  93. #-------------------------------------------------------
  94. import job
  95. # Create an analysis job for the model and submit it.
  96. jobName = 'beam_tutorial'
  97. myJob = mdb.Job(name=jobName, model='Beam',
  98. description='Cantilever beam tutorial')
  99. # Wait for the job to complete.
  100. myJob.submit()
  101. myJob.waitForCompletion()
  102. #-------------------------------------------------------
  103. import visualization
  104. # Open the output database and display a
  105. # default contour plot.
  106. myOdb = visualization.openOdb(path=jobName + '.odb')
  107. myViewport.setValues(displayedObject=myOdb)
  108. myViewport.odbDisplay.display.setValues(plotState=CONTOURS_ON_DEF)
  109. myViewport.odbDisplay.commonOptions.setValues(renderStyle=FILLED)
python

4. 说说体会:

        pyabaqus库不需要在python文件中import,实际执行python文件的方式是在cmd窗口里面用原始dos命令行的方式,用设置的系统变量 abaqus cae -noGUI 文件名.py 的方式执行,全程无需打开abaqus。这个方式实际上是pyabaqus实现了调用abaqus计算内核模块(像这种大型有限元软件的各个模块是独立开发和工作的。),执行abaqus支持的python语法进而计算。所以实际上计算的python文件只需要满足参考文件2里面的相关规范书写,保证能跑通就行。后期也可以想些方法在python执行中job计算完直接输出需要的图和表格。

        使用python命令建abaqus模型并后处理输出结果,全程无需打开abaqus,只要有代码就能自动计算。为实时计算结构受力提供了接口可能性。


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删
相关文章
QR Code
微信扫一扫,欢迎咨询~
customer

online

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

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空