- 积分
- 5854
- 回帖
- 0
- 西莫币
-
- 贡献
-
- 威望
-
- 存款
-
- 阅读权限
- 120
- 最后登录
- 1970-1-1
该用户从未签到
|
楼主 |
发表于 2008-6-20 16:59
|
显示全部楼层
Complete Macro
The final script is presented below:- Dim oAnsoftApp
- Dim oDesktop
- Dim oProject
- Dim oDesign
- Dim oEditor
- Dim oModule
- 'Define
- Dim u_plate_length
- Dim u_plate_width
- Dim u_plate_thick
- Dim u_plate_high
- Dim armature_length
- Dim armature_width
- Dim armature_thick
- Dim core_radius
- Dim core_height
- Dim coil_1_height
- Dim coil_1_inner_rad
- Dim coil_1_outer_rad
- Dim coil_1_position
- Dim no_current_steps
- Dim no_turns_coil1
- Dim current_min
- Dim current_max
- Dim no_gaps
- Dim gap_min
- Dim gap_max
- u_plate_length = 100
- u_plate_width = 60
- u_plate_thick = 5
- u_plate_high = 75
- armature_length = 120
- armature_width = 80
- armature_thick = 5
- core_radius = 10
- core_height = 70
- coil_1_height = 5
- coil_1_inner_rad = 15
- coil_1_outer_rad = 25
- coil_1_position = 25
- no_current_steps = 2
- no_turns_coil1 = 1000
- current_min = 0.5
- current_max = 1
- no_gaps = 2
- gap_min = 0.01
- gap_max = 1
- Set oAnsoftApp = CreateObject("AnsoftMaxwell.MaxwellScriptInterface.11")
- Set oDesktop = oAnsoftApp.GetAppDesktop()
- oDesktop.RestoreWindow
- Set oProject = oDesktop.NewProject
- oProject.InsertDesign "Maxwell", "MaxwellDesign1", "Magnetostatic", ""
- Set oDesign = oProject.SetActiveDesign("MaxwellDesign1")
- Set oEditor = oDesign.SetActiveEditor("3D Modeler")
- Dim temp,temp1,temp2,temp3,gap,gap_loop_index
- gap_loop_index=0
- temp = gap_max - gap_min
- temp3 = no_gaps - 1
- temp1 = temp/temp3
- temp2 = temp1*gap_loop_index
- gap = gap_min + temp2
- Dim u_plate_x,u_plate_y
- u_plate_x=u_plate_width/2
- u_plate_y=u_plate_length/2
- oEditor.CreateBox Array("NAME:BoxParameters", "CoordinateSystemID:=", -1, "XPosition:=", _
- "0mm", "YPosition:=", "0mm", "ZPosition:=", "0mm", "XSize:=", CStrmm(u_plate_x), "YSize:=", _
- CStrmm(u_plate_y), "ZSize:=", CStrmm(u_plate_thick)), Array("NAME:Attributes", "Name:=", "u_plate", _
- "Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "MaterialName:=", _
- "vacuum", "SolveInside:=", true)
- '
- 'Calculate dimensions for quarter model U Plate
- '
- temp1 = u_plate_x*(-1)
- temp2 = u_plate_thick*(-1)
- oEditor.CreateBox Array("NAME:BoxParameters", "CoordinateSystemID:=", -1, "XPosition:=", _
- CStrmm(u_plate_x), "YPosition:=", CStrmm(u_plate_y), "ZPosition:=", CStrmm(u_plate_thick), "XSize:=", CStrmm(temp1), "YSize:=", _
- CStrmm(temp2), "ZSize:=", CStrmm(u_plate_high)), Array("NAME:Attributes", "Name:=", "u1", _
- "Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "MaterialName:=", _
- "vacuum", "SolveInside:=", true)
- oEditor.Unite Array("NAME:Selections", "Selections:=", "u_plate,u1"), Array("NAME:UniteParameters", "CoordinateSystemID:=", _
- -1, "KeepOriginals:=", false)
- '
- 'Calculate dimensions for armature
- '
- temp = u_plate_thick
- temp = temp + u_plate_high
- temp = temp + gap
- arm_y = armature_length/2
- arm_x = armature_width/2
- oEditor.CreateBox Array("NAME:BoxParameters", "CoordinateSystemID:=", -1, "XPosition:=", _
- "0mm", "YPosition:=", "0mm", "ZPosition:=", CStrmm(temp), "XSize:=", CStrmm(arm_x), "YSize:=", _
- CStrmm(arm_y), "ZSize:=", CStrmm(armature_thick)), Array("NAME:Attributes", "Name:=", "armature", "Flags:=", _
- "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", _
- "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
- '
- 'Calculate dimensions for the core
- '
- temp = u_plate_thick
- oEditor.CreateRectangle Array("NAME:RectangleParameters", "CoordinateSystemID:=", _
- -1, "IsCovered:=", true, "XStart:=", "0mm", "YStart:=", "0mm", "ZStart:=", CStrmm(temp), "Width:=", _
- CStrmm(core_height), "Height:=", CStrmm(core_radius), "WhichAxis:=", "Y"), Array("NAME:Attributes", "Name:=", _
- "core", "Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", _
- "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
- oEditor.SweepAroundAxis Array("NAME:Selections", "Selections:=", "core"), Array("NAME:AxisSweepParameters", "CoordinateSystemID:=", _
- -1, "DraftAngle:=", "0deg", "DraftType:=", "Round", "CheckFaceFaceIntersection:=", _
- false, "SweepAxis:=", "Z", "SweepAngle:=", "90deg", "NumOfSegments:=", "8")
- '
- 'Calculate dimensions for coil_1
- '
- temp = u_plate_thick
- temp = temp + coil_1_position
- temp1 = coil_1_outer_rad - coil_1_inner_rad
- oEditor.CreateRectangle Array("NAME:RectangleParameters", "CoordinateSystemID:=", _
- -1, "IsCovered:=", true, "XStart:=", CStrmm(coil_1_inner_rad), "YStart:=", "0mm", "ZStart:=", _
- CStrmm(temp), "Width:=", CStrmm(temp1), "Height:=", CStrmm(coil_1_height), "WhichAxis:=", "Y"), Array("NAME:Attributes", "Name:=", _
- "coil1", "Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", _
- "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
- oEditor.SweepAroundAxis Array("NAME:Selections", "Selections:=", "coil1"), Array("NAME:AxisSweepParameters", "CoordinateSystemID:=", _
- -1, "DraftAngle:=", "0deg", "DraftType:=", "Round", "CheckFaceFaceIntersection:=", _
- false, "SweepAxis:=", "Z", "SweepAngle:=", "90deg", "NumOfSegments:=", "8")
-
- oEditor.Section Array("NAME:Selections", "Selections:=", "coil1"), Array("NAME:SectionToParameters", "CoordinateSystemID:=", _
- -1, "SectionPlane:=", "ZX")
- oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers", _
- "Section1"), Array("NAME:ChangedProps", Array("NAME:Name", "Value:=", "term1"))))
- oEditor.Section Array("NAME:Selections", "Selections:=", "coil1"), Array("NAME:SectionToParameters", "CoordinateSystemID:=", _
- -1, "SectionPlane:=", "YZ")
- oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers", _
- "Section1"), Array("NAME:ChangedProps", Array("NAME:Name", "Value:=", "term2"))))
- '
- 'the new region defination
- '
- oEditor.CreateRegion Array("NAME:RegionParameters", "CoordinateSystemID:=", -1, "+XPadding:=", _
- "300", "-XPadding:=", "0", "+YPadding:=", "300", "-YPadding:=", "0", "+ZPadding:=", _
- "100", "-ZPadding:=", "50"), Array("NAME:Attributes", "Name:=", "Region", "Flags:=", _
- "Wireframe#", "Color:=", "(255 0 0)", "Transparency:=", 0, "PartCoordinateSystem:=", _
- "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
- oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers", _
- "armature", "u_plate", "core"), Array("NAME:ChangedProps", Array("NAME:Material", "Material:=", _
- "steel_1010"))))
- oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers", _
- "coil1"), Array("NAME:ChangedProps", Array("NAME:Material", "Material:=", "copper"))))
- Set oModule = oDesign.GetModule("BoundarySetup")
- '
- 'Loop for current steps
- '
- loop_index = 0
- loop_limit = no_current_steps
- temp = current_max - current_min
- temp3 =no_current_steps -1
- temp1 = temp/temp3
- temp2 = temp1*loop_index
- curr = current_min + temp2
- curr = curr * no_turns_coil1
- oModule.AssignCurrent Array("NAME:curr1_in", "Current:=", CStrA(curr), "IsSolid:=", _
- true, "Point out of terminal:=", false, "Objects:=", Array("term1"))
- oModule.AssignCurrent Array("NAME:curr1_out", "Current:=", CStrA(curr), "IsSolid:=", _
- true, "Point out of terminal:=", true, "Objects:=", Array("term2"))
-
- Set oModule = oDesign.GetModule("MaxwellParameterSetup")
- oModule.AssignForce Array("NAME:group1", "Is Virtual:=", true, "Reference CS:=", _
- "Global", "Objects:=", Array("armature"))
-
- oModule.AssignMatrix Array("NAME:Matrix1", Array("NAME:MatrixEntry", Array("NAME:MatrixEntry", "Source:=", _
- "curr1_in", "NumberOfTurns:=", "1")), Array("NAME:MatrixGroup"), "Objects:=", Array( _
- "coil1"))
-
- Set oModule = oDesign.GetModule("AnalysisSetup")
- oModule.InsertSetup "Magnetostatic", Array("NAME:SolnOptnSetup", "MaximumPasses:=", 10, "MinimumPasses:=", _
- 2, "MinimumConvergedPasses:=", 1, "PercentRefinement:=", 50, "LinearResidual:=", _
- 1E-006, "ConvergenceDispParamId:=", -1, "SolveFieldOnly:=", false, "PercentError:=", _
- 1, "SolveMatrixAtLast:=", true, "UseOutputVariable:=", false, "PreAdaptMesh:=", _
- false, "NonLinearResidual:=", 0.01, "SolverType:=", 0, "MuNonLinearBH:=", true, "ComputeHc:=", _
- false, "HcNonLinearBH:=", true)
复制代码
[ 本帖最后由 Hottomson 于 2008-6-20 17:12 编辑 ] |
|