HFSS 计算面上的电磁场
录入:edatop.com 点击:
要导出如图所示这个面上的电磁场,可以生成这个面上的一系列点,计算出这些点的场值,然后保存到文件。
' ----------------------------------------------
' Script Recorded by Ansoft HFSS Version 15.0.0
' 2:01:46 下午 11月 15, 2017
' ----------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("cavity-waveguide-for-MAGY")
'The field on the coupled plane is correct by checking.
'=================================================================
dim Bs
'=======================@output file=====================================
Set oFS = CreateObject("Scripting.FileSystemObject")
path_Bs_E="Bs_E.txt"
Set ofile_Bs_E = oFS.CreateTextFile (path_Bs_E)
' ==========腔体的结构数据==================================================
Mode_porperties_Cavity=Array("L:=", "20mm", "Phase:=", "0deg", "W:=", _
"26mm", "b:=", "10mm", "d:=", "8mm")
Model_porperties_resonator= Array("Freq:=", "9.17GHz", "L:=", _
"20mm", "Phase:=", "0deg", "W:=", "26mm", "b:=", "10mm", "d:=", "8mm", "t:=", _
"1mm", "wl:=", "32.62mm")
'===========get module pointers of two model ================================
Set oDesign_cw = oProject.SetActiveDesign("cavity-waveguide(final Model)")
Set oEditor_cw = oDesign_cw.SetActiveEditor("3D Modeler")
Set oModule_cw = oDesign_cw.GetModule("FieldsReporter")
Set oDesign_cv = oProject.SetActiveDesign("cavity-eigenModel")
Set oEditor_cv = oDesign_cv.SetActiveEditor("3D Modeler")
Set oModule_cv = oDesign_cv.GetModule("FieldsReporter")
'=================model variables ==========================================
L= 20 'Unit : mm
d= 8
b= 10
'=============================================================================
dx =d/20
dy =b/20
z=L
i =-1
j =-1
for x = -d/2 to d/2 step dx
i=i+1
j =-1
for y= -b/2 to b/2 step dy
j=j+1
px = Cstr(x)+"mm"
py = CStr(y)+"mm"
Pz = CStr(z)+"mm"
pName="Point_"+CStr(i)+"_"+CStr(j)
oEditor_cv.CreatePoint Array("NAME:PointParameters", "PointX:=", px, "PointY:=", _
py, "PointZ:=", pz), Array("NAME:Attributes", "Name:=", pName, "Color:=", _
"(132 132 193)")
oModule_cv.CalcStack "clear"
oModule_cv.EnterQty "H"
oModule_cv.EnterPoint pName
oModule_cv.CalcOp "Value"
oModule_cv.CalcOp "Real"
oModule_cv.ClcEval "Setup1 : LastAdaptive", Mode_porperties_Cavity
Bs_Real_xyz = oModule_cv.GetTopEntryValue("Setup1 : LastAdaptive", Mode_porperties_Cavity )
Real_x = CStr(Bs_Real_xyz(0))
oModule_cv.CalcStack "pop"
oModule_cv.CalcStack "undo"
oModule_cv.CalcOp "Imag"
oModule_cv.ClcEval "Setup1 : LastAdaptive", Mode_porperties_Cavity
Bs_Imag_xyz = oModule_cv.GetTopEntryValue("Setup1 : LastAdaptive", Mode_porperties_Cavity )
Imag_x = CStr(Bs_Imag_xyz(0))
if i<> j Then
oEditor_cv.Delete Array("NAME:Selections", "Selections:=", pName)
end if
'===============================耦合孔处波导场=================================================
oEditor_cw.CreatePoint Array("NAME:PointParameters", "PointX:=", px, "PointY:=", _
py, "PointZ:=", pz), Array("NAME:Attributes", "Name:=", pName, "Color:=", _
"(132 132 193)")
oModule_cw.CalcStack "clear"
oModule_cw.EnterQty "E"
oModule_cw.EnterPoint pName
oModule_cw.CalcOp "Value"
oModule_cw.CalcOp "Real"
oModule_cw.ClcEval "Setup1 : LastAdaptive", Model_porperties_resonator
E_Real_xyz = oModule_cw.GetTopEntryValue("Setup1 : LastAdaptive", Model_porperties_resonator )
Real_x = CStr(E_Real_xyz(0))
oModule_cw.CalcStack "pop"
oModule_cw.CalcStack "undo"
oModule_cw.CalcOp "Imag"
oModule_cw.ClcEval "Setup1 : LastAdaptive", Model_porperties_resonator
E_Imag_xyz = oModule_cw.GetTopEntryValue("Setup1 : LastAdaptive", Model_porperties_resonator )
Imag_x = CStr(E_Imag_xyz(0))
if i <> j Then
oEditor_cw.Delete Array("NAME:Selections", "Selections:=", pName)
End if
'================save to file ===============
dilimt=Space(10)
line=CStr(x)+dilimt+ CStr(y) +dilimt+CStr(z) +dilimt+_
CStr(Bs_Real_xyz(0))+dilimt + CStr(Bs_Real_xyz(1)) +dilimt+CStr(Bs_Real_xyz(2))+dilimt+_
CStr(Bs_Imag_xyz(0))+dilimt + CStr(Bs_Imag_xyz(1)) +dilimt+CStr(Bs_Imag_xyz(2))+dilimt+_
CStr(E_Real_xyz(0))+dilimt + CStr(E_Real_xyz(1)) +dilimt+CStr(E_Real_xyz(2))+dilimt+_
CStr(E_Imag_xyz(0))+dilimt + CStr(E_Imag_xyz(1)) +dilimt+CStr(E_Imag_xyz(2))+dilimt
ofile_Bs_E.WriteLine line
next
next
ofile_Bs_E.close
HFSS 学习培训课程套装,专家讲解,视频教学,帮助您全面系统地学习掌握HFSS
上一篇:利用C#在hfss中绘制像素画
下一篇:HFSS报错解决方法:Simulation completed with execution error on server: Local Machine.