许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  ANSYS SCDM脚本建模,配合FLUENT一体化流程仿真

ANSYS SCDM脚本建模,配合FLUENT一体化流程仿真

阅读数 2
点赞 0
article_banner


视频中的代码:

​# Python Script, API Version = V22

#######变量定义#​#######

#中间立方体的体积

Vmid = 200000000; #单位为mm3

#中间立方体的长

b1 = 1000; #单位为mm

#中间立方体的宽

a1 = 500; #单位为mm

#中间立方体的高

h1 = Vmid / a1 / b1; #单位为mm

#圆柱总体积与中间立方体体积的关系

proportion = 3;

#所有圆柱体的总体积

Vtot = Vmid/proportion; #单位为mm3

#间隙1

gap1 = 100;

#间隙2

gap2 = 150;

#间隙3

gap3 = 20;

#间隙4

gap4 = 100;

#间隙5

gap5 = 100;

#间隙6

gap6 = 10;

#外部立方体的长

b2 = b1+gap2*2;

#外部立方体的宽

a2 = a1+gap1*2;

#外部立方体的高

h2 = h1+gap4+gap5;

#圆柱体直径

d=50.0;

#单个圆柱体体积

Vone =float(math.pi*(d/2)*(d/2) *(h1-gap6*2));

#圆柱体总个数

numbertot =math.ceil(Vtot/Vone);

#中间立方体宽方向上最大可容纳圆柱体的个数

numbera = a1//(d+gap3);

#中间立方体长方向上圆柱体的个数

numberb = math.ceil(numbertot /numbera) ;

#留一组给剩下不够一组的圆柱体

numberremain = numbera - 1;

#补齐最后留的一组

numberlast =numbertot - numberremain * numberb;

#################绘制过程#​###################

# 设置草绘平面

sectionPlane = Plane.PlaneZX

result = ViewHelper.SetSketchPlane(sectionPlane, None)

# EndBlock

# 草绘矩形

point1 = Point2D.Create(MM(-b2/2),MM(-a2/2))

point2 = Point2D.Create(MM(b2/2),MM(-a2/2))

point3 = Point2D.Create(MM(b2/2),MM(a2/2))

result = SketchRectangle.Create(point1, point2, point3)

# EndBlock

# 实体化草绘

mode = InteractionMode.Solid

result = ViewHelper.SetViewMode(mode, None)

# EndBlock

# 拉伸 1 个面

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[0])

options = ExtrudeFaceOptions()

options.ExtrudeType = ExtrudeType.Add

result = ExtrudeFaces.Execute(selection, MM(h2), options)

# EndBlock

# 使抽壳

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[4])

result = Shell.RemoveFaces(selection, MM(-1))

# EndBlock

# 填充

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[10])

secondarySelection = Selection.Empty()

options = FillOptions()

result = Fill.Execute(selection, secondarySelection, options, FillMode.ThreeD, None)

# EndBlock

# 平移 Z 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[9])

direction = Move.GetDirection(selection)

options = MoveOptions()

result = Move.Translate(selection, direction, MM(gap4-1), options)

# EndBlock

# 填充

selection = FaceSelection.Create([GetRootPart().Bodies[0].Faces[1],

GetRootPart().Bodies[0].Faces[6]])

secondarySelection = Selection.Empty()

options = FillOptions()

result = Fill.Execute(selection, secondarySelection, options, FillMode.ThreeD, None)

# EndBlock

# 填充

selection = FaceSelection.Create([GetRootPart().Bodies[0].Faces[1],

GetRootPart().Bodies[0].Faces[5]])

secondarySelection = Selection.Empty()

options = FillOptions()

result = Fill.Execute(selection, secondarySelection, options, FillMode.ThreeD, None)

# EndBlock

# 填充

selection = FaceSelection.Create([GetRootPart().Bodies[0].Faces[1],

GetRootPart().Bodies[0].Faces[4]])

secondarySelection = Selection.Empty()

options = FillOptions()

result = Fill.Execute(selection, secondarySelection, options, FillMode.ThreeD, None)

# EndBlock

# 填充

selection = FaceSelection.Create([GetRootPart().Bodies[0].Faces[0],

GetRootPart().Bodies[0].Faces[2]])

secondarySelection = Selection.Empty()

options = FillOptions()

result = Fill.Execute(selection, secondarySelection, options, FillMode.ThreeD, None)

# EndBlock

# 平移 Z 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[4])

direction = Move.GetDirection(selection)

options = MoveOptions()

result = Move.Translate(selection, direction, MM(gap2-1), options)

# EndBlock

# 平移 Z 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[8])

direction = Move.GetDirection(selection)

options = MoveOptions()

result = Move.Translate(selection, direction, MM(gap2-1), options)

# EndBlock

# 平移 Z 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[6])

direction = Move.GetDirection(selection)

options = MoveOptions()

result = Move.Translate(selection, direction, MM(gap1-1), options)

# EndBlock

# 平移 Z 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[10])

direction = Move.GetDirection(selection)

options = MoveOptions()

result = Move.Translate(selection, direction, MM(gap1-1), options)

# EndBlock

# 平移 Z 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[1])

direction = Move.GetDirection(selection)

options = MoveOptions()

options.Copy = True

result = Move.Translate(selection, direction, MM(104.8), options)

# EndBlock

# 向上移动至所选对象

selection = BodySelection.Create(GetRootPart().Bodies[1])

upToSelection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[1])

moveFrame = Move.CreateFrame(selection)

axis = HandleAxis.Z

options = MoveOptions()

result = Move.UpTo(selection, upToSelection, moveFrame, axis, options)

# EndBlock

# 拉伸 1 个面

selection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[0])

options = ExtrudeFaceOptions()

options.ExtrudeType = ExtrudeType.ForceIndependent

result = ExtrudeFaces.Execute(selection, MM(h1), options)

# EndBlock

# 平移 Z 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[4])

direction = Move.GetDirection(selection)

options = MoveOptions()

options.Copy = True

result = Move.Translate(selection, direction, MM(115.02), options)

# EndBlock

# 向上移动至所选对象

selection = BodySelection.Create(GetRootPart().Bodies[2])

upToSelection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[4])

moveFrame = Move.CreateFrame(selection)

axis = HandleAxis.Z

options = MoveOptions()

result = Move.UpTo(selection, upToSelection, moveFrame, axis, options)

# EndBlock

# 向上拉伸至主体

selection = FaceSelection.Create(GetRootPart().Bodies[2].Faces[0])

upToSelection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[0])

options = ExtrudeFaceOptions()

options.ExtrudeType = ExtrudeType.ForceIndependent

result = ExtrudeFaces.UpTo(selection, Direction.DirY, upToSelection, Point.Create(MM(-115.279496209573), MM(350), MM(21.2707687022301)), options)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[2])

visibility = VisibilityType.Hide

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 设置草绘平面

selection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[4])

result = ViewHelper.SetSketchPlane(selection, None)

# EndBlock

# 草绘圆

origin = Point2D.Create(MM(148), MM(-801))

result = SketchCircle.Create(origin, MM(d/2))

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[1])

visibility = VisibilityType.Hide

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[0])

visibility = VisibilityType.Hide

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 实体化草绘

mode = InteractionMode.Solid

result = ViewHelper.SetViewMode(mode, None)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[2])

visibility = VisibilityType.Show

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[1])

visibility = VisibilityType.Show

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[0])

visibility = VisibilityType.Show

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 拉伸 1 个面

selection = FaceSelection.Create(GetRootPart().Bodies[3].Faces[0])

options = ExtrudeFaceOptions()

options.ExtrudeType = ExtrudeType.Cut

result = ExtrudeFaces.Execute(selection, MM(h1-2*gap6), options)

# EndBlock

# 创建阵列

selection = BodySelection.Create(GetRootPart().Bodies[3])

data = LinearPatternData()

data.LinearDirection = EdgeSelection.Create(GetRootPart().Bodies[0].Edges[19])

data.CountX = (numbera-1)

data.PitchX = MM(gap3+d)

result = Pattern.CreateLinear(selection, data, None)

# EndBlock

# 创建阵列

selection = ComponentSelection.Create(GetRootPart().Components[0])

data = LinearPatternData()

data.LinearDirection = EdgeSelection.Create(GetRootPart().Bodies[0].Edges[16])

data.CountX = numberb

data.PitchX = MM(gap3+d)

result = Pattern.CreateLinear(selection, data, None)

# EndBlock

if numberlast !=0:

# 设置草绘平面

selection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[4])

result = ViewHelper.SetSketchPlane(selection, None)

# EndBlock

# 草绘圆

origin = Point2D.Create(MM(-359), MM(0))

result = SketchCircle.Create(origin, MM(d/2))

baseSel = SelectionPoint.Create(GetRootPart().DatumPlanes[0].Curves[0].GetChildren[ICurvePoint]()[0])

targetSel = SelectionPoint.Create(GetRootPart().DatumPlanes[0].GetChildren[IDatumLine]()[0])

result = Constraint.CreateCoincident(baseSel, targetSel)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create([GetRootPart().Bodies[2],

GetRootPart().Bodies[0],

GetRootPart().Bodies[1]])

visibility = VisibilityType.Hide

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 实体化草绘

mode = InteractionMode.Solid

result = ViewHelper.SetViewMode(mode, None)

# EndBlock

# 拉伸 1 个面

selection = FaceSelection.Create(GetRootPart().Bodies[3].Faces[0])

options = ExtrudeFaceOptions()

options.ExtrudeType = ExtrudeType.Cut

result = ExtrudeFaces.Execute(selection, MM(h1-2*gap6), options)

# EndBlock

# 平移 X 手柄

selection = FaceSelection.Create(GetRootPart().Bodies[3].Faces[0])

reference = Selection.Create(GetRootPart().Components[0].Components[6].Components[0].Content.Bodies[0].Edges[0].GetChildren[ICurvePoint]()[0])

direction = -Direction.DirX

options = MoveOptions()

result = Move.SetDimension(selection, direction, MM(d+gap3), reference, options)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[2])

visibility = VisibilityType.Show

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[1])

visibility = VisibilityType.Show

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[0])

visibility = VisibilityType.Show

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 创建阵列

selection = BodySelection.Create(GetRootPart().Bodies[3])

data = LinearPatternData()

data.LinearDirection = EdgeSelection.Create(GetRootPart().Bodies[0].Edges[16])

data.CountX = numberlast

data.PitchX = MM(gap3+d)

result = Pattern.CreateLinear(selection, data, None)

# EndBlock

# 向上移动至所选对象

selection = ComponentSelection.Create([GetRootPart().Components[0],

GetRootPart().Components[1]])

upToSelection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[1])

anchorPoint = Move.GetAnchorPoint(selection)

moveFrame = Frame.Create(anchorPoint, Direction.DirX, Direction.DirY)

axis = HandleAxis.Y

options = MoveOptions()

result = Move.UpTo(selection, upToSelection, moveFrame, axis, options)

# EndBlock

# 向上移动至所选对象

selection = ComponentSelection.Create([GetRootPart().Components[0],

GetRootPart().Components[1]])

upToSelection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[2])

anchorPoint = Move.GetAnchorPoint(selection)

moveFrame = Frame.Create(anchorPoint, Direction.DirX, Direction.DirY)

axis = HandleAxis.X

options = MoveOptions()

result = Move.UpTo(selection, upToSelection, moveFrame, axis, options)

# EndBlock

# 向上移动至所选对象

selection = ComponentSelection.Create(GetRootPart().Components[0])

upToSelection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[1])

moveFrame = Move.CreateFrame(selection)

axis = HandleAxis.Z

options = MoveOptions()

result = Move.UpTo(selection, upToSelection, moveFrame, axis, options)

# EndBlock

# 向上移动至所选对象

selection = ComponentSelection.Create(GetRootPart().Components[1])

upToSelection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[3])

moveFrame = Move.CreateFrame(selection)

axis = HandleAxis.Z

options = MoveOptions()

result = Move.UpTo(selection, upToSelection, moveFrame, axis, options)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[2])

visibility = VisibilityType.Hide

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 更改对象可见性

selection = BodySelection.Create(GetRootPart().Bodies[2])

visibility = VisibilityType.Show

inSelectedView = False

faceLevel = False

ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)

# EndBlock

# 相交主体

targets = BodySelection.Create(GetRootPart().Bodies[1])

tools = PowerSelection.Bodies.ByVolume(MM(Vone/10e5),

PowerSelectOptions(True),

SearchCriteria.SizeComparison.SmallerOrEqual)

options = MakeSolidsOptions()

result = Combine.Intersect(targets, tools, options)

# EndBlock

# 删除对象

selection = ComponentSelection.Create([GetRootPart().Components[0],

GetRootPart().Components[1]])

result = Delete.Execute(selection)

# EndBlock

#输出另存文件并重新命名

b2 = b2*1e-3;

a2 = a2*1e-3;

h2 = h2*1e-3;

options = ExportOptions.Create()

name = 'C:\Users\Tle\Desktop\x%.3f-y%.3f-z%.3f.scdoc' %(b2,a2,h2)

DocumentSave.Execute(name, options)

# EndBlock


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

相关文章
技术文档
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
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空