HFSS的近场仿真
1、软件安装和破解
1)Hfss13只能安装在C盘。
2)破解时先在控制面板里关闭Windows defender并且退出360杀毒软件。否则Ansoft2008fix.exe会被当病毒杀掉。
3)将Ansoft2008fix.exe和hfss12fix.exe和license.lic拷贝到HFSS13.0目录下。
4)以管理员身份运行Ansoft2008fix.exe。
5)以管理员身份运行hfss12fix.exe,连续patch六个dll。
6)打开hfss,弹出框框,无视继续。依次点击TOOls-options-general options-webupdate options-never
2、模型的建立
2.1设计变量
2.2画模型
2.3 边界条件
、
2.4激励源
2.5加运算器
2.6 画近场线
近场线要一一对应。
3、数据的导出
用Add Trace添加曲线到同一页面,用Apply Trace改变频点。
导出为csv格式。
将横坐标反归一化。
画出三维曲面图。
4、用脚本画近场线
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set oProject = oDesktop.GetActiveProject()
Set oDesign = oProject.GetActiveDesign()
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
' 声明变量与常数.
Dim zpos, Xnum, Ynum, xspan, yspan, dx, dy,pos
Dim Units, index
Dim y()
Dim x()
Units = "mm"
pos=6000
'-----------------------------3米x面----------------------------------------
Units = InputBox("Select the units:"&Chr(13)& _
"(cm,mm,um,in,mil)", "Nearfield","mm",pos,pos)
zpos = InputBox("Input the Z plane position:","Nearfield", 3200,pos,pos)
xspan = InputBox("Input X sampling span:","Nearfield", 4000,pos,pos)
yspan = InputBox("Input Y sampling span:","Nearfield", 2100,pos,pos)
Xnum = InputBox("Input sampling number in X direction:","Nearfield", 100,pos,pos) Ynum = InputBox("Input sampling number in Y direction:","Nearfield", 15,pos,pos)
Redim y(Ynum)
dx=xspan/(Xnum-1)
dy=yspan/(Ynum-1)
y(0)="Position of y"
For n=1 To Ynum
y(n)=-yspan/2 + (n-1)*dy
'将X向点坐标存入数组
ZV alue=cstr(zpos) & Units
YV alue=cstr(y(n)) & Units
XV aluemin=cstr(-xspan/2) & Units
XV aluemmax=cstr(xspan/2) & Units
index="lin3mx" & cstr(n)
oEditor.CreatePolyline Array("NAME:PolylineParameters", "IsPolylineCovered:=", true, "IsPolylineClosed:=", _
false, Array("NAME:PolylinePoints", Array("NAME:PLPoint", "X:=", XV aluemin, "Y:=", YV alue, "Z:=", _
ZV alue), Array("NAME:PLPoint", "X:=", XV aluemmax, "Y:=", YV alue, "Z:=", ZV alue)), _
Array("NAME:PolylineSegments", Array("NAME:P LSegment", "SegmentType:=", _ "Line", "StartIndex:=", 0, "NoOfPoints:=", 2)), Array("NAME:PolylineXSection", "XSectionType:=", _
"None", "XSectionOrient:=", "Auto", "XSectionWidth:=", "0mm", "XSectionTopWidth:=", _
"0mm", "XSectionHeight:=", "0mm", "XSectionNumSegments:=", "0", "XSectionBendType:=", _
"Corner")), Array("NAME:Attributes", "Name:=", index, "Flags:=", "", "Color:=", _ "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "UDMId:=", _
"", "MaterialV alue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", _ true)
namepara="NAME:" & index
Set oModule = oDesign.GetModule("RadField")
oModule.InsertNearFieldLineSetup Array(namepara, "UseCustomRadiationSurface:=", _ false, "Line:=", index, "NumPts:=", cstr(Xnum))
Next
'------------------------------3米y面---------------------------------------
Units = InputBox("Select the units:"&Chr(13)& _
"(cm,mm,um,in,mil)", "Nearfield","mm",pos,pos)
zpos = InputBox("Input the Z plane position:","Nearfield", 3200,pos,pos)
xspan = InputBox("Input X sampling span:","Nearfield", 2100,pos,pos)
yspan = InputBox("Input Y sampling span:","Nearfield", 4000,pos,pos)
Xnum = InputBox("Input sampling number in X direction:","Nearfield", 15,pos,pos) Ynum = InputBox("Input sampling number in Y direction:","Nearfield", 100,pos,pos)
Redim x(Xnum)
dx=xspan/(Xnum-1)
dy=yspan/(Ynum-1)
x(0)="Position of x"
For n=1 To Xnum
x(n)=-xspan/2 + (n-1)*dx
'将X向点坐标存入数组
ZV alue=cstr(zpos) & Units
XV alue=cstr(x(n)) & Units
YV aluemin=cstr(-yspan/2) & Units
YV aluemmax=cstr(yspan/2) & Units
index="lin3my" & cstr(n)
oEditor.CreatePolyline Array("NAME:PolylineParameters", "IsPolylineCovered:=", true, "IsPolylineClosed:=", _
false, Array("NAME:PolylinePoints", Array("NAME:PLPoint", "Y:=", YV aluemin, "X:=", XV alue, "Z:=", _
ZV alue), Array("NAME:PLPoint", "Y:=", YV aluemmax, "X:=", XV alue, "Z:=", ZV alue)), _
Array("NAME:PolylineSegments", Array("NAME:P LSegment", "SegmentType:=", _
"Line", "StartIndex:=", 0, "NoOfPoints:=", 2)), Array("NAME:PolylineYSection",
"YSectionType:=", _
"None", "YSectionOrient:=", "Auto", "YSectionWidth:=", "0mm", "YSectionTopWidth:=", _
"0mm", "YSectionHeight:=", "0mm", "YSectionNumSegments:=", "0",
"YSectionBendType:=", _
"Corner")), Array("NAME:Attributes", "Name:=", index, "Flags:=", "", "Color:=", _
"(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "UDMId:=", _
"", "MaterialV alue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", _
true)
namepara="NAME:" & index
Set oModule = oDesign.GetModule("RadField")
oModule.InsertNearFieldLineSetup Array(namepara, "UseCustomRadiationSurface:=", _ false, "Line:=", index, "NumPts:=", cstr(Ynum))
Next
5、用脚本导出近场数据
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("Project6")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("ReportSetup")
'---------------------------------------3mx-0.8G--------------------------------------------------------
oModule.CreateReport "XY Plot 27", "Near Fields", "Rectangular Plot", _
"Setup1 : Sweep", Array("Context:=", "lin3mx1"), Array("NormalizedDistance:=", Array( _ "All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx2"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx3"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx4"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx5"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx6"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx7"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx8"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx9"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx10"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx11"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx12"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx13"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx14"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3mx15"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.ExportToFile "XY Plot 27", "C:/Users/xiaoen/Documents/3mx-0.8G.csv" oModule.DeleteReports Array("XY Plot 27")
'---------------------------------------3my-0.8G--------------------------------------------------------
oModule.CreateReport "XY Plot 27", "Near Fields", "Rectangular Plot", _
"Setup1 : Sweep", Array("Context:=", "lin3my1"), Array("NormalizedDistance:=", Array( _ "All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my2"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my3"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my4"),
Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=",
_
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my5"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my6"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my7"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my8"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my9"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my10"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my11"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my12"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my13"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my14"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.AddTraces "XY Plot 27", "Setup1 : Sweep", Array("Context:=", "lin3my15"), Array("NormalizedDistance:=", Array( _
"All"), Array("NAME:V ariableV alues", "Freq:=", "0.8GHz")), Array("X Component:=", _
"NormalizedDistance", "Y Component:=", Array("NearETotal")), Array()
oModule.ExportToFile "XY Plot 27", "C:/Users/xiaoen/Documents/3my-0.8G.csv" oModule.DeleteReports Array("XY Plot 27")