├── 3dmodeler ├── DuplicateAroundAxis.m ├── SweepAroundAxis.m ├── hfssAddMaterial.m ├── hfssAddproperty.m ├── hfssAssignMaterial.m ├── hfssBox.asv ├── hfssBox.m ├── hfssChangeProperty.m ├── hfssChangeProperty_line.m ├── hfssCircle.m ├── hfssCoaxialCable.m ├── hfssCone.m ├── hfssConicalHorn.asv ├── hfssConicalHorn.m ├── hfssConnect.m ├── hfssCopy.m ├── hfssCoverLines.m ├── hfssCreateRegion.asv ├── hfssCreateRegion.m ├── hfssCreateRegularPolygon.m ├── hfssCylinder.asv ├── hfssCylinder.m ├── hfssDetachFaces.m ├── hfssDipole.m ├── hfssDuplicateAlongLine.m ├── hfssDuplicateAroundAxis.asv ├── hfssDuplicateAroundAxis.m ├── hfssDuplicateMirror.m ├── hfssEllipse.m ├── hfssHelix.asv ├── hfssHelix.m ├── hfssHollowCylinder.m ├── hfssIntersect.m ├── hfssMove.m ├── hfssPLObject.m ├── hfssPolygon.m ├── hfssRectangle.asv ├── hfssRectangle.m ├── hfssRegion.m ├── hfssRename.m ├── hfssRotate.m ├── hfssSetTransparency.m ├── hfssSphere.m ├── hfssSplit.m ├── hfssSubtract.m ├── hfssSweepAlongPath.m ├── hfssSweepAlongVector.m ├── hfssSweepAroundAxis.m ├── hfssUnite.m ├── hfssUnite2.m ├── hfssWireConnection.m ├── hfssdrawline.m ├── hfssdrawline1.m ├── hfssdrawline2.m ├── hfssdrawline3.m ├── hs_err_pid4540.log └── html │ └── hfssBox.html ├── COPYING ├── README ├── README.asv ├── README.md ├── Untitled.m ├── analysis ├── hfssAddOptVar.asv ├── hfssAddOptVar.m ├── hfssCreateReport.m ├── hfssExportGain.m ├── hfssExportNetworkData.m ├── hfssExportRadiationParameters.m ├── hfssExportReport.m ├── hfssExportToFile.m ├── hfssFarField.m ├── hfssFarFieldSphere.asv ├── hfssFarFieldSphere.m ├── hfssInsertSolution.m ├── hfssInterpolatingSweep.m └── hfssSolveSetup.m ├── batch.log ├── boundary ├── hfssAssignLumpedPort.asv ├── hfssAssignLumpedPort.m ├── hfssAssignPE.m ├── hfssAssignPE_face.m ├── hfssAssignPH.m ├── hfssAssignRadiation.m ├── hfssAssignRadiation_face.asv ├── hfssAssignRadiation_face.m ├── hfssAssignWavePort.m ├── hfssAssignWavePort_face2.m ├── hfssAssignWaveport_face.m ├── hfssCircularPort.m ├── hfssEditSources.m ├── hfssPE.m └── hfssPH.m ├── doc ├── dipole_balun.jpg ├── hfss-matlab-api.html ├── hfssclose.m └── style.css ├── examples ├── dipole_example.m └── folded_dipole.m ├── function_w ├── 3DArray1516exportResult.vbs ├── fclose_w.m ├── hfssAssignLumpedPort_w.asv ├── hfssAssignLumpedPort_w.m ├── hfssAssignPE_unknowfaceID.m ├── hfssChangeMarkerProperty.m ├── hfssChangeOptVar.m ├── hfssChangeOptVarRange.m ├── hfssChangeVar.m ├── hfssCreate3DGainReport.m ├── hfssCreateEHGainReport.m ├── hfssCreateEHGainReport2.m ├── hfssCreateEquationCurve.m ├── hfssCreatePolyline.m ├── hfssCreateRelativeCS.asv ├── hfssCreateRelativeCS.m ├── hfssCreateReportFF.m ├── hfssCreateS11Report.m ├── hfssExportImageToFile.m ├── hfssFaceID.m ├── hfssModel.m ├── hfssSetWCS.m ├── hfssaddVar.asv └── hfssaddVar.m ├── general ├── hfssAddMaterial.m ├── hfssCloseActiveProject.m ├── hfssExecuteScript.m ├── hfssInsertDesign.m ├── hfssNewProject.m ├── hfssOpenProject.m ├── hfssSaveProject.m └── hfssSetActiveProject.m ├── hfssapi.rar ├── my_polar.m └── yueliang └── example ├── my_cone.m ├── my_conicalhorn.m └── my_cylinder.m /3dmodeler/DuplicateAroundAxis.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssUnite(fid, varargin) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary for unite a given set of objects already 7 | % present in the HFSS 3D Modeler. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % varargin - names of the objects that need to be united. It can be specified 13 | % either as a single cell array of strings, or several individual 14 | % cell strings containing a single object name (see example ...) 15 | % 16 | % Note : 17 | % ------ 18 | % 19 | % Example : 20 | % --------- 21 | % fid = fopen('myantenna.vbs', 'wt'); 22 | % ... 23 | % % Method 1. 24 | % hfssUnite(fid, {'Object1', 'Object2', Object3'}); 25 | % % ... or Method 2. 26 | % hfssUnite(fid, {'Object1'}, {'Object2'}, {'Object3'}); 27 | % 28 | % ---------------------------------------------------------------------------- 29 | 30 | % ---------------------------------------------------------------------------- 31 | % This file is part of HFSS-MATLAB-API. 32 | % 33 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 34 | % under the terms of the GNU General Public License as published by the Free 35 | % Software Foundation; either version 2 of the License, or (at your option) 36 | % any later version. 37 | % 38 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 39 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 40 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41 | % for more details. 42 | % 43 | % You should have received a copy of the GNU General Public License along with 44 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 45 | % Place, Suite 330, Boston, MA 02111-1307 USA 46 | % 47 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 48 | % ---------------------------------------------------------------------------- 49 | 50 | function DuplicateAroundAxis(fid,name,Axis,deg,num) 51 | 52 | % Preamble. 53 | fprintf(fid, '\n'); 54 | fprintf(fid, 'oEditor.DuplicateAroundAxis Array("NAME:Selections", "Selections:=", "%s", "NewPartsModelFlag:=", _\n',name); 55 | fprintf(fid, '"Model"), Array("NAME:DuplicateAroundAxisParameters", "CreateNewObjects:=", true, "WhichAxis:=", _\n'); 56 | fprintf(fid, ' "%s", "AngleStr:=", "%fdeg", "NumClones:=", "%f"), Array("NAME:Options", "DuplicateAssignments:=", _\n',Axis,deg,num); 57 | fprintf(fid,'false) \n'); 58 | 59 | 60 | -------------------------------------------------------------------------------- /3dmodeler/SweepAroundAxis.m: -------------------------------------------------------------------------------- 1 | function SweepAroundAxis(fid,name,Axis,deg) 2 | 3 | fprintf(fid, '\n'); 4 | fprintf(fid, 'oEditor.SweepAroundAxis Array("NAME:Selections", "Selections:=", "%s", "NewPartsModelFlag:=", _\n',name); 5 | 6 | % Rectangle Parameters. 7 | fprintf(fid, ' "Model"), Array("NAME:AxisSweepParameters", "DraftAngle:=", "0deg", "DraftType:=", _\n'); 8 | fprintf(fid, '"Round", "CheckFaceFaceIntersection:=", false, "SweepAxis:=", "%s", "SweepAngle:=", _\n',Axis); 9 | fprintf(fid, ' "%fdeg", "NumOfSegments:=", "0") _\n',deg); 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /3dmodeler/hfssAddMaterial.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignMaterial(fid, Object, Material) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to assign a material selection to an 7 | % existing HFSS object. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Object - name of the object to which the material is to assigned. 13 | % Material - the material to be assigned to the Object. This is a string that 14 | % should either be predefined in HFSS or defined using 15 | % hfssAddMaterial(...) 16 | % 17 | % Note : 18 | % ------ 19 | % 20 | % Example : 21 | % --------- 22 | % fid = fopen('myantenna.vbs', 'wt'); 23 | % ... 24 | % hfssAssignMaterial(fid, 'FR4Mount', 'FR4epoxy'); 25 | % ---------------------------------------------------------------------------- 26 | 27 | % ---------------------------------------------------------------------------- 28 | % This file is part of HFSS-MATLAB-API. 29 | % 30 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 31 | % under the terms of the GNU General Public License as published by the Free 32 | % Software Foundation; either version 2 of the License, or (at your option) 33 | % any later version. 34 | % 35 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 36 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38 | % for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License along with 41 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 42 | % Place, Suite 330, Boston, MA 02111-1307 USA 43 | % 44 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 45 | % ---------------------------------------------------------------------------- 46 | function hfssAddMaterial(fid, Name, num) 47 | 48 | fprintf(fid, '\n'); 49 | fprintf(fid, 'Set oDefinitionManager = oProject.GetDefinitionManager()\n'); 50 | fprintf(fid, 'oDefinitionManager.AddMaterial _\n'); 51 | fprintf(fid, 'Array("NAME:%s", _\n',Name); 52 | fprintf(fid, '"CoordinateSystemType:=", _\n'); 53 | fprintf(fid, '"Cartesian", _\n'); 54 | fprintf(fid, 'Array("NAME:AttachedData"), _\n'); 55 | fprintf(fid, 'Array("NAME:ModifierData"), _\n'); 56 | fprintf(fid, '"permittivity:=","%f")\n',num); 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /3dmodeler/hfssAddproperty.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssChangeProperty(fid, num, name) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to change object's property. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % num - the number of objects. 12 | % name - the name of objects. 13 | % 14 | % Note : 15 | % ------ 16 | % 17 | % Example : 18 | % --------- 19 | % fid = fopen('myantenna.vbs', 'wt'); 20 | % ... 21 | % ---------------------------------------------------------------------------- 22 | 23 | % ---------------------------------------------------------------------------- 24 | % This file is part of HFSS-MATLAB-API. 25 | % 26 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 27 | % under the terms of the GNU General Public License as published by the Free 28 | % Software Foundation; either version 2 of the License, or (at your option) 29 | % any later version. 30 | % 31 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 32 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 33 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34 | % for more details. 35 | % 36 | % You should have received a copy of the GNU General Public License along with 37 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 38 | % Place, Suite 330, Boston, MA 02111-1307 USA 39 | % 40 | % Copyright 2008, Vijay Ramasami (yue_liang423@163.com) 41 | % ------------------------------------------------------------------------- 42 | % --- 43 | 44 | function hfssAddproperty(fid, num, name,Value) 45 | 46 | % preamble 47 | fprintf(fid, '\n'); 48 | fprintf(fid, 'oDesign.ChangeProperty _\n'); 49 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 50 | fprintf(fid, 'Array("NAME:LocalVariableTab", _\n'); 51 | fprintf(fid, 'Array("NAME:PropServers", _\n'); 52 | fprintf(fid,'"LocalVariables"), Array("Name:NewProps",'); 53 | for i = 1:num-1 54 | fprintf(fid, 'Array("NAME:%s", _\n',name{i}); 55 | fprintf(fid,'"PropType:=", "VariableProp", "UserDef:=",true, "Value:=", "%f%s"), _\n',Value{1}(i),Value{2}(i)); 56 | end -------------------------------------------------------------------------------- /3dmodeler/hfssAssignMaterial.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignMaterial(fid, Object, Material) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to assign a material selection to an 7 | % existing HFSS object. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Object - name of the object to which the material is to assigned. 13 | % Material - the material to be assigned to the Object. This is a string that 14 | % should either be predefined in HFSS or defined using 15 | % hfssAddMaterial(...) 16 | % 17 | % Note : 18 | % ------ 19 | % 20 | % Example : 21 | % --------- 22 | % fid = fopen('myantenna.vbs', 'wt'); 23 | % ... 24 | % hfssAssignMaterial(fid, 'FR4Mount', 'FR4epoxy'); 25 | % ---------------------------------------------------------------------------- 26 | 27 | % ---------------------------------------------------------------------------- 28 | % This file is part of HFSS-MATLAB-API. 29 | % 30 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 31 | % under the terms of the GNU General Public License as published by the Free 32 | % Software Foundation; either version 2 of the License, or (at your option) 33 | % any later version. 34 | % 35 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 36 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38 | % for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License along with 41 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 42 | % Place, Suite 330, Boston, MA 02111-1307 USA 43 | % 44 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 45 | % ---------------------------------------------------------------------------- 46 | function hfssAssignMaterial(fid, Name, Material) 47 | 48 | fprintf(fid, '\n'); 49 | fprintf(fid, 'oEditor.AssignMaterial _\n'); 50 | fprintf(fid, '\tArray("NAME:Selections", _\n'); 51 | fprintf(fid, '\t\t"Selections:=", "%s"), _\n', Name); 52 | fprintf(fid, '\tArray("NAME:Attributes", _\n'); 53 | fprintf(fid, '\t\t"MaterialName:=", "%s", _\n', Material); 54 | 55 | % if the material is copper or pec, we should set solve inside to be false and for 56 | % other materials (in general) is should be true. 57 | if (strcmp(Material, 'copper')) 58 | fprintf(fid, '\t\t"SolveInside:=", false)\n'); 59 | elseif (strcmp(Material, 'pec')) 60 | fprintf(fid, '\t\t"SolveInside:=", false)\n'); % added by yueliang 61 | else 62 | fprintf(fid, '\t\t"SolveInside:=", true)\n'); 63 | end; 64 | -------------------------------------------------------------------------------- /3dmodeler/hfssChangeProperty.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssChangeProperty(fid, num, name) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to change object's property. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % num - the number of objects. 12 | % name - the name of objects. 13 | % 14 | % Note : 15 | % ------ 16 | % 17 | % Example : 18 | % --------- 19 | % fid = fopen('myantenna.vbs', 'wt'); 20 | % ... 21 | % ---------------------------------------------------------------------------- 22 | 23 | % ---------------------------------------------------------------------------- 24 | % This file is part of HFSS-MATLAB-API. 25 | % 26 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 27 | % under the terms of the GNU General Public License as published by the Free 28 | % Software Foundation; either version 2 of the License, or (at your option) 29 | % any later version. 30 | % 31 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 32 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 33 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34 | % for more details. 35 | % 36 | % You should have received a copy of the GNU General Public License along with 37 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 38 | % Place, Suite 330, Boston, MA 02111-1307 USA 39 | % 40 | % Copyright 2008, Vijay Ramasami (yue_liang423@163.com) 41 | % ------------------------------------------------------------------------- 42 | % --- 43 | 44 | function hfssChangeProperty(fid, num, name) 45 | 46 | % preamble 47 | fprintf(fid, '\n'); 48 | fprintf(fid, 'oEditor.ChangeProperty _\n'); 49 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 50 | fprintf(fid, 'Array("NAME:Geometry3DAttributeTab", _\n'); 51 | fprintf(fid, 'Array("NAME:PropServers", _\n'); 52 | for i = 1:num-1 53 | fprintf(fid, '"%s", _\n',name{i}); 54 | end 55 | fprintf(fid, '"%s"), _\n',name{num}); 56 | fprintf(fid, 'Array("NAME:ChangedProps", _\n'); 57 | fprintf(fid, 'Array("NAME:Color", _\n'); 58 | % change color 59 | fprintf(fid, '"R:=", 255, "G:=", 128, "B:=", 128)))) _\n'); -------------------------------------------------------------------------------- /3dmodeler/hfssChangeProperty_line.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssChangeProperty(fid, num,first,pro) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to change line's property. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % num - the number of points. 12 | % first - the first point first(x,y,z). include the units char 13 | % pro - 2tonum point pro{num}(x,y,z). include the units char 14 | % Note : 15 | % ------ 16 | % 17 | % This file is part of HFSS-MATLAB-API. 18 | % 19 | % Copyright 2016, ZZM 20 | % ------------------------------------------------------------------------- 21 | % --- 22 | 23 | function hfssChangeProperty_line(fid, num,first,pro) 24 | 25 | % preamble 26 | fprintf(fid, '\n'); 27 | 28 | fprintf(fid, 'oEditor.ChangeProperty _\n'); 29 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 30 | fprintf(fid, 'Array("NAME:Geometry3DPolylineTab", _\n'); 31 | fprintf(fid, 'Array("NAME:PropServers", _\n'); 32 | fprintf(fid,'"Polyline1:CreatePolyline:2:Segment0"), Array("Name:NewProps",'); 33 | fprintf(fid, 'Array("NAME:ChangedProps", Array("Name:Point1", "X:=","%s","Y:=", "%s","Z:=", "%s"), _\n',first(1),first(2),first(3)); 34 | fprintf(fid, 'Array("NAME:ChangedProps", Array("Name:Point2", "X:=","%s","Y:=", "%s","Z:=", "%s")))), _\n',pro{1}(1),pro{1}(2),pro{1}(3)); 35 | for i = 2:num-1 36 | fprintf(fid, 'oEditor.ChangeProperty _\n'); 37 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 38 | fprintf(fid, 'Array("NAME:Geometry3DPolylineTab", _\n'); 39 | fprintf(fid, 'Array("NAME:PropServers", _\n'); 40 | fprintf(fid,'"Polyline1:CreatePolyline:2:Segment%d"), Array("Name:NewProps",',i-1); 41 | fprintf(fid, 'Array("NAME:ChangedProps", Array("Name:Point2", "X:=","%s","Y:=", "%s","Z:=", "%s")))), _\n',pro{1}(1),pro{1}(2),pro{1}(3)); 42 | fprintf(fid,'"PropType:=", "VariableProp", "UserDef:=",true, "Value:=", "%f%s")))), _\n',Value(i),Units); 43 | end -------------------------------------------------------------------------------- /3dmodeler/hfssCoaxialCable.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % hfssCoaxialCable(fid, Names, Axis, Center, Radii, Height, Units) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VBScript necessary to draw a Coaxial Cable in 7 | % HFSS. The "Coaxial Cable" can have as many cylinders as you specify. This 8 | % function only creates the geometric structure and does not set any material 9 | % properties. 10 | % 11 | % Parameters : 12 | % ------------ 13 | % fid - file identifier of the HFSS VBScript File. 14 | % Name - a cell of strings that contains the names of each cylinder that is a 15 | % part of the co-axial cable (see example). 16 | % Axis - axis of the Coaxial Cable (choose between 'X', 'Y' or 'Z'). 17 | % Center - Coordinates of the Center of the Coaxial Cable ([x, y, z]). 18 | % Radii - an array of Radii of the Cylinders present in the Coaxial cable. 19 | % each radius corresponds to the respective name specfied in the 20 | % 'Name' parameter. 21 | % Height - length of the coaxial cable. 22 | % Units - can be either 'in' or 'mm' or 'meter' or anything defined in HFSS. 23 | % 24 | % Example: 25 | % --------- 26 | % ... 27 | % hfssCoaxialCable(fid, {'Cyl1_In', 'Cyl1_Er', 'Cyl1_Out'}, 'Z', [0, 0, 0], 28 | % 0.02, 0.03, 0.04], 10, 'in') 29 | % ... 30 | % -------------------------------------------------------------------------- % 31 | 32 | % ---------------------------------------------------------------------------- 33 | % This file is part of HFSS-MATLAB-API. 34 | % 35 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 36 | % under the terms of the GNU General Public License as published by the Free 37 | % Software Foundation; either version 2 of the License, or (at your option) 38 | % any later version. 39 | % 40 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 41 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 42 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43 | % for more details. 44 | % 45 | % You should have received a copy of the GNU General Public License along with 46 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 47 | % Place, Suite 330, Boston, MA 02111-1307 USA 48 | % 49 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 50 | % ---------------------------------------------------------------------------- 51 | function hfssCoaxialCable(fid, Names, Axis, Center, Radii, Height, Units) 52 | 53 | % Sort the Radii first in Ascending order. 54 | [Radii, iR] = sort(Radii); 55 | Names = cellstr(char(Names{iR})); 56 | 57 | % Get the # of Cylinders. 58 | nCylinders = length(Radii); 59 | 60 | % First create the N-1 hollow cylinders. 61 | for iR = nCylinders:-1:2, 62 | hfssHollowCylinder(fid, Names{iR}, Axis, Center, Radii(iR-1), ... 63 | Radii(iR), Height, Units); 64 | end; 65 | 66 | % Finally create the inner cylinder. 67 | hfssCylinder(fid, Names{1}, Axis, Center, Radii(1), Height, Units); 68 | -------------------------------------------------------------------------------- /3dmodeler/hfssCone.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssCone(fid, Name, Axis, Center, BottomRadius, TopRadius, Height, Units) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB script necessary to model a cone in HFSS. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % Name - name of the cone (in HFSS). 12 | % Center - center of the cone (specify as [x, y, z]). This is also the 13 | % starting point of the cone. 14 | % Axis - axis of the cone (specify as 'X', 'Y', or 'Z'). 15 | % BottomRadius - radius of the cone (scalar). 16 | % TopRadius - radius of the cone (scalar). 17 | % Height - height of the cone (from the point specified by Center). 18 | % Units - specify as 'in', 'mm', 'meter' or anything else defined in HFSS. 19 | % 20 | % Note : 21 | % ------ 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('myantenna.vbs', 'wt'); 26 | % ... 27 | % hfssCone(fid, 'Cone1', 'Z', [0, 0, 0], 0.1, 0.2, 10, 'in'); 28 | % ---------------------------------------------------------------------------- 29 | 30 | % ---------------------------------------------------------------------------- 31 | % This file is part of HFSS-MATLAB-API. 32 | % 33 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 34 | % under the terms of the GNU General Public License as published by the Free 35 | % Software Foundation; either version 2 of the License, or (at your option) 36 | % any later version. 37 | % 38 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 39 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 40 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41 | % for more details. 42 | % 43 | % You should have received a copy of the GNU General Public License along with 44 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 45 | % Place, Suite 330, Boston, MA 02111-1307 USA 46 | % 47 | % Copyright 2007, YueLiang (yue_liang423@163.com) 48 | % ---------------------------------------------------------------------------- 49 | function hfssCone(fid, Name, Axis, Center, BottomRadius, TopRadius, Height, Units) 50 | 51 | % Preamble. 52 | fprintf(fid, 'oEditor.CreateCone _\n'); 53 | fprintf(fid, 'Array("NAME:ConeParameters", _\n'); 54 | 55 | % Parameters. 56 | fprintf(fid, '"XCenter:=", "%f%s", _\n', Center(1), Units); 57 | fprintf(fid, '"YCenter:=", "%f%s", _\n', Center(2), Units); 58 | fprintf(fid, '"ZCenter:=", "%f%s", _\n', Center(3), Units); 59 | fprintf(fid, '"WhichAxis:=", "%s", _\n', upper(Axis)); 60 | fprintf(fid, '"Height:=", "%f%s", _\n', Height, Units); 61 | fprintf(fid, '"BottomRadius:=", "%f%s", _\n', BottomRadius, Units); 62 | fprintf(fid, '"TopRadius:=", "%f%s"), _\n', TopRadius, Units); 63 | 64 | % Attributes. 65 | fprintf(fid, 'Array("NAME:Attributes", _\n'); 66 | fprintf(fid, '"Name:=", "%s", _\n', Name); 67 | fprintf(fid, '"Flags:=", "", _\n'); 68 | fprintf(fid, '"Color:=", "(132 132 193)", _\n'); 69 | fprintf(fid, '"Transparency:=", 0, _\n'); 70 | fprintf(fid, '"PartCoordinateSystem:=", "Global", _\n'); 71 | fprintf(fid, '"MaterialName:=", "vacuum", _\n'); 72 | fprintf(fid, '"SolveInside:=", true)\n'); -------------------------------------------------------------------------------- /3dmodeler/hfssConicalHorn.asv: -------------------------------------------------------------------------------- 1 | function hfssConicalHorn(fid, Name, Center, Waveguide, Horn, Wall_T, Units) 2 | % Creates the VB Script necessary to create a Conical Horn wiht Circle Waveguide in HFSS. 3 | %Waveguide=[Waveguide_Radius, 4 | %Waveguide_length];Horn=[Horn_R,Horn_L];Wall_T is Wall_Thickness 5 | Waveguide_R = Waveguide(1); 6 | Waveguide_L = Waveguide(2); 7 | Horn_R = Horn(1); 8 | Horn_L = Horn(2); 9 | 10 | hfssaddVar(fid,'Waveguide_R',Waveguide_R,Units) 11 | hfssaddVar(fid,'Waveguide_L',Waveguide_L,Units) 12 | hfssaddVar(fid,'Horn_R',Horn_R,Units) 13 | hfssaddVar(fid,'Horn_L',Horn_L,Units) 14 | hfssaddVar(fid,'Wall_T',Wall_T,Units) 15 | %% Waveguide 16 | 17 | Name_1 = 'Waveguide_in'; 18 | 19 | Axis = 'Z'; 20 | Radius = 'Waveguide_R'; 21 | Height = 'Waveguide_L'; 22 | hfssCylinder(fid, Name_1, Axis, Center, Radius, Height, Units) 23 | 24 | Name_2 = 'Waveguide'; 25 | Radius = 'Waveguide_R + Wall_T'; 26 | hfssCylinder(fid, Name_2, Axis, Center, Radius, Height, Units) 27 | 28 | hfssSubtract(fid, Name_2, Name_1) 29 | %% Horn 30 | % 31 | Name_1 = 'Horn_in'; 32 | 33 | Center = reshape(Center, length(Center), 1); 34 | if iscell(Center) 35 | 1; 36 | else 37 | Center = mat2cell(Center,[1,1,1],1); 38 | end 39 | 40 | Center_Horn = Center; 41 | Center_Horn{3,1} = strcat(num2str(Center{3,1}),Units,'+Waveguide_L'); 42 | Axis = 'Z'; 43 | Radius = 'Waveguide_R'; 44 | hfssCircle(fid, Name_1, Axis, Center_Horn, Radius, Units) 45 | 46 | Name_2 = 'Horn_In_up'; 47 | Center_Horn_up = Center; 48 | Center_Horn_up{3,1} = strcat(num2str(Center{3,1}),Units,'+Waveguide_L+Horn_L'); 49 | Axis = 'Z'; 50 | Radius = 'Horn_R'; 51 | hfssCircle(fid, Name_2, Axis, Center_Horn_up, Radius, Units) 52 | 53 | hfssConnect(fid, {Name_1, Name_2}) 54 | 55 | % 56 | Name_1 = Name; 57 | Axis = 'Z'; 58 | Radius = 'Waveguide_R + Wall_T'; 59 | hfssCircle(fid, Name_1, Axis, Center, Radius, Units) 60 | 61 | Name_2 = 'Horn_up'; 62 | Center = [0 0 Waveguide_L + Horn_L]; 63 | Axis = 'Z'; 64 | Radius = 'Horn_R + Wall_T'; 65 | hfssCircle(fid, Name_2, Axis, Center, Radius, Units) 66 | 67 | hfssConnect(fid, {Name_1, Name_2}) 68 | 69 | hfssSubtract(fid, Name, 'Horn_in') 70 | %% Unit waveguide and horn 71 | hfssUnite(fid, Name, 'Waveguide') 72 | hfssAssignMaterial(fid, Name, 'pec') 73 | -------------------------------------------------------------------------------- /3dmodeler/hfssConicalHorn.m: -------------------------------------------------------------------------------- 1 | function hfssConicalHorn(fid, Name, Center, Waveguide, Horn, Wall_T, Units) 2 | % Creates the VB Script necessary to create a Conical Horn wiht Circle Waveguide in HFSS. 3 | %Waveguide=[Waveguide_Radius, 4 | %Waveguide_length];Horn=[Horn_R,Horn_L];Wall_T is Wall_Thickness 5 | Waveguide_R = Waveguide(1); 6 | Waveguide_L = Waveguide(2); 7 | Horn_R = Horn(1); 8 | Horn_L = Horn(2); 9 | 10 | hfssaddVar(fid,'Waveguide_R',Waveguide_R,Units) 11 | hfssaddVar(fid,'Waveguide_L',Waveguide_L,Units) 12 | hfssaddVar(fid,'Horn_R',Horn_R,Units) 13 | hfssaddVar(fid,'Horn_L',Horn_L,Units) 14 | hfssaddVar(fid,'Wall_T',Wall_T,Units) 15 | %% Waveguide 16 | 17 | Name_1 = 'Waveguide_in'; 18 | 19 | Axis = 'Z'; 20 | Radius = 'Waveguide_R'; 21 | Height = 'Waveguide_L'; 22 | hfssCylinder(fid, Name_1, Axis, Center, Radius, Height, Units) 23 | 24 | Name_2 = 'Waveguide'; 25 | Radius = 'Waveguide_R + Wall_T'; 26 | hfssCylinder(fid, Name_2, Axis, Center, Radius, Height, Units) 27 | 28 | hfssSubtract(fid, Name_2, Name_1) 29 | %% Horn 30 | % 31 | Name_1 = 'Horn_in'; 32 | 33 | Center = reshape(Center, length(Center), 1); 34 | if iscell(Center) 35 | 1; 36 | else 37 | Center = mat2cell(Center,[1,1,1],1); 38 | end 39 | 40 | Center_Horn = Center; 41 | Center_Horn{3,1} = strcat(num2str(Center{3,1}),Units,'+Waveguide_L'); 42 | Axis = 'Z'; 43 | Radius = 'Waveguide_R'; 44 | hfssCircle(fid, Name_1, Axis, Center_Horn, Radius, Units) 45 | 46 | Name_2 = 'Horn_In_up'; 47 | Center_Horn_up = Center; 48 | Center_Horn_up{3,1} = strcat(num2str(Center{3,1}),Units,'+Waveguide_L+Horn_L'); 49 | Axis = 'Z'; 50 | Radius = 'Horn_R'; 51 | hfssCircle(fid, Name_2, Axis, Center_Horn_up, Radius, Units) 52 | 53 | hfssConnect(fid, {Name_1, Name_2}) 54 | 55 | % 56 | Name_1 = Name; 57 | Axis = 'Z'; 58 | Radius = 'Waveguide_R + Wall_T'; 59 | hfssCircle(fid, Name_1, Axis, Center_Horn, Radius, Units) 60 | 61 | Name_2 = 'Horn_up'; 62 | Axis = 'Z'; 63 | Radius = 'Horn_R + Wall_T'; 64 | hfssCircle(fid, Name_2, Axis, Center_Horn_up, Radius, Units) 65 | 66 | hfssConnect(fid, {Name_1, Name_2}) 67 | 68 | hfssSubtract(fid, Name, 'Horn_in') 69 | %% Unit waveguide and horn 70 | hfssUnite(fid, Name, 'Waveguide') 71 | hfssAssignMaterial(fid, Name, 'pec') 72 | -------------------------------------------------------------------------------- /3dmodeler/hfssConnect.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssConnect(fid, Names) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates VB Script necessary to connect two HFSS objects using a surface. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % Names - a cell array of strings that represent the surface-like objects that 12 | % need to be connected to form a solid structure. 13 | % 14 | % Note : 15 | % ------ 16 | % 17 | % Example : 18 | % --------- 19 | % fid = fopen('myantenna.vbs', 'wt'); 20 | % ... 21 | % hfssConnect(fid, {'topLayer', 'bottomLayer'}); 22 | % ---------------------------------------------------------------------------- 23 | 24 | % ---------------------------------------------------------------------------- 25 | % This file is part of HFSS-MATLAB-API. 26 | % 27 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 28 | % under the terms of the GNU General Public License as published by the Free 29 | % Software Foundation; either version 2 of the License, or (at your option) 30 | % any later version. 31 | % 32 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 33 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 34 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 35 | % for more details. 36 | % 37 | % You should have received a copy of the GNU General Public License along with 38 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 39 | % Place, Suite 330, Boston, MA 02111-1307 USA 40 | % 41 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 42 | % ---------------------------------------------------------------------------- 43 | function hfssConnect(fid, Names) 44 | 45 | fprintf(fid, '\n'); 46 | fprintf(fid, 'oEditor.Connect _\n'); 47 | fprintf(fid, 'Array("NAME:Selections", _\n'); 48 | fprintf(fid, '"Selections:=", _\n'); 49 | 50 | nObjects = length(Names); 51 | fprintf(fid, '"'); 52 | for iO = 1:nObjects-1, 53 | fprintf(fid, '%s,', Names{iO}); 54 | end; 55 | fprintf(fid, '%s")\n', Names{nObjects}); 56 | -------------------------------------------------------------------------------- /3dmodeler/hfssCopy.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssCopy(fid, Name) 3 | % 4 | % Description : 5 | % ------------- 6 | % Create the VB Script necessary to construct a rectangle using the HFSS 7 | % 3D Modeler. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of which you want to copy 13 | % 14 | % Note : 15 | % ------ 16 | % Todo: a feature to add automatic holes in the rectangle object. 17 | % 18 | % Example : 19 | % --------- 20 | % fid = fopen('myantenna.vbs', 'wt'); 21 | % ... 22 | % % in this example, Y-axis size is 10in and Z-axis size is 20in. 23 | % hfssRectangle(fid, 'Rect1', 'X', [0,0,0], 10, 20, 'in'); 24 | % 25 | % ---------------------------------------------------------------------------- 26 | 27 | % ---------------------------------------------------------------------------- 28 | % This file is part of HFSS-MATLAB-API. 29 | % 30 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 31 | % under the terms of the GNU General Public License as published by the Free 32 | % Software Foundation; either version 2 of the License, or (at your option) 33 | % any later version. 34 | % 35 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 36 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38 | % for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License along with 41 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 42 | % Place, Suite 330, Boston, MA 02111-1307 USA 43 | % 44 | % Copyright 2008, Yueliang (yue_liang423@163.com) 45 | % ------------------------------------------------------------------------- 46 | function hfssCopy(fid, Name) 47 | 48 | % Preamble. 49 | fprintf(fid, '\n'); 50 | fprintf(fid, 'oEditor.Copy _\n'); 51 | 52 | fprintf(fid, 'Array("NAME:Selections", "Selections:=", "%s") \n',Name); 53 | fprintf(fid, 'oEditor.Paste'); -------------------------------------------------------------------------------- /3dmodeler/hfssCoverLines.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssCopy(fid, Name) 3 | % 4 | % Description : 5 | % ------------- 6 | % Create the VB Script necessary to construct a rectangle using the HFSS 7 | % 3D Modeler. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of which you want to copy 13 | % 14 | % Note : 15 | % ------ 16 | % Todo: a feature to add automatic holes in the rectangle object. 17 | % 18 | % Example : 19 | % --------- 20 | % fid = fopen('myantenna.vbs', 'wt'); 21 | % ... 22 | % % in this example, Y-axis size is 10in and Z-axis size is 20in. 23 | % hfssRectangle(fid, 'Rect1', 'X', [0,0,0], 10, 20, 'in'); 24 | % 25 | % ---------------------------------------------------------------------------- 26 | 27 | % ---------------------------------------------------------------------------- 28 | % This file is part of HFSS-MATLAB-API. 29 | % 30 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 31 | % under the terms of the GNU General Public License as published by the Free 32 | % Software Foundation; either version 2 of the License, or (at your option) 33 | % any later version. 34 | % 35 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 36 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38 | % for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License along with 41 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 42 | % Place, Suite 330, Boston, MA 02111-1307 USA 43 | % 44 | % Copyright 2008, Yueliang (yue_liang423@163.com) 45 | % ------------------------------------------------------------------------- 46 | function hfssCoverLines(fid, Name) 47 | 48 | % Preamble. 49 | fprintf(fid, '\n'); 50 | fprintf(fid, 'oEditor.CoverLines _\n'); 51 | 52 | fprintf(fid, 'Array("NAME:Selections", "Selections:=", "%s", "NewPartsModelFlag:=", _ \n',Name); 53 | fprintf(fid, '"Model")'); -------------------------------------------------------------------------------- /3dmodeler/hfssCreateRegion.asv: -------------------------------------------------------------------------------- 1 | function hfssCreateRegion(PaddingType,XPad,YPad,ZPad,Units) 2 | %PaddingType = 1,Absolute Offset; XPad = [+XPadding 3 | 4 | if PaddingType = 1 5 | Type = 'Absolute Offset'; 6 | else 7 | Type = '?' 8 | end 9 | fprintf(fid, '\n'); 10 | fprintf(fid, 'oEditor.CreateRegion _\n'); 11 | fpirntf(fid, 'Array("NAME:RegionParameters", _\n'); 12 | fprintf(fid, '"+XPaddingType:=", "%s","+XPadding:=", "%f%s", _\n',Tpye, XPad(1), Units); 13 | fprintf(fid, '"-XPaddingType:=", "%s","-XPadding:=", "%f%s", _\n',Tpye, XPad(2), Units); 14 | fprintf(fid, '"+YPaddingType:=", "%s","+YPadding:=", "%f%s", _\n',Tpye, YPad(1), Units); 15 | fprintf(fid, '"-YPaddingType:=", "%s","-YPadding:=", "%f%s", _\n',Tpye, YPad(2), Units); 16 | fprintf(fid, '"+ZPaddingType:=", "%s","+ZPadding:=", "%f%s", _\n',Tpye, ZPad(1), Units); 17 | fprintf(fid, '"-ZPaddingType:=", "%s","-ZPadding:=", "%f%s", _\n',Tpye, ZPad(2), Units); 18 | fpinntf(fid, 'Array("NAME:Attributes", "Name:=", "Region", _\n'); 19 | fprintf(fid, '"Flags:=", "Wireframe#", "Color:=", "(255 0 0)", "Transparency:=", 0, _\n'); 20 | fprint(fid, '"PartCoordinateSystem:=", "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", _\n'); 21 | fprintf(fid, '"SolveInside:=", true) \n'); 22 | end 23 | 24 | 25 | %oEditor.CreateRegion Array("NAME:RegionParameters", 26 | %"+XPaddingType:=", "Absolute Offset", "+XPadding:=", "25mm", 27 | %"-XPaddingType:=", "Absolute Offset", "-XPadding:=", "25mm", 28 | %"+YPaddingType:=", "Absolute Offset", "+YPadding:=", "25mm", 29 | %"-YPaddingType:=", "Absolute Offset", "-YPadding:=", "25mm", 30 | % "+ZPaddingType:=", "Absolute Offset", "+ZPadding:=", "25mm", 31 | %"-ZPaddingType:=", "Absolute Offset", "-ZPadding:=", "25mm"), 32 | %Array("NAME:Attributes", "Name:=", "Region", 33 | % "Flags:=", "Wireframe#", "Color:=", "(255 0 0)", "Transparency:=", 0, "PartCoordinateSystem:=", _ 34 | % "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", _ 35 | % true) 36 | 37 | -------------------------------------------------------------------------------- /3dmodeler/hfssCreateRegion.m: -------------------------------------------------------------------------------- 1 | function hfssCreateRegion(fid,PaddingType,XPad,YPad,ZPad,Units) 2 | %PaddingType = 1,Absolute Offset; XPad = [+XPadding,-XPadding] 3 | 4 | if PaddingType == 1 5 | Type = 'Absolute Offset'; 6 | else 7 | Type = '?' 8 | end 9 | fprintf(fid, '\n'); 10 | fprintf(fid, 'oEditor.CreateRegion _\n'); 11 | fprintf(fid, 'Array("NAME:RegionParameters", _\n'); 12 | fprintf(fid, '"+XPaddingType:=", "%s","+XPadding:=", "%f%s", _\n',Type, XPad(1), Units); 13 | fprintf(fid, '"-XPaddingType:=", "%s","-XPadding:=", "%f%s", _\n',Type, XPad(2), Units); 14 | fprintf(fid, '"+YPaddingType:=", "%s","+YPadding:=", "%f%s", _\n',Type, YPad(1), Units); 15 | fprintf(fid, '"-YPaddingType:=", "%s","-YPadding:=", "%f%s", _\n',Type, YPad(2), Units); 16 | fprintf(fid, '"+ZPaddingType:=", "%s","+ZPadding:=", "%f%s", _\n',Type, ZPad(1), Units); 17 | fprintf(fid, '"-ZPaddingType:=", "%s","-ZPadding:=", "%f%s"), _\n',Type, ZPad(2), Units); 18 | fprintf(fid, 'Array("NAME:Attributes", "Name:=", "Region", _\n'); 19 | fprintf(fid, '"Flags:=", "Wireframe#", "Color:=", "(255 0 0)", "Transparency:=", 0, _\n'); 20 | fprintf(fid, '"PartCoordinateSystem:=", "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", _\n'); 21 | fprintf(fid, '"SolveInside:=", true) \n'); 22 | end 23 | 24 | 25 | %oEditor.CreateRegion Array("NAME:RegionParameters", 26 | %"+XPaddingType:=", "Absolute Offset", "+XPadding:=", "25mm", 27 | %"-XPaddingType:=", "Absolute Offset", "-XPadding:=", "25mm", 28 | %"+YPaddingType:=", "Absolute Offset", "+YPadding:=", "25mm", 29 | %"-YPaddingType:=", "Absolute Offset", "-YPadding:=", "25mm", 30 | % "+ZPaddingType:=", "Absolute Offset", "+ZPadding:=", "25mm", 31 | %"-ZPaddingType:=", "Absolute Offset", "-ZPadding:=", "25mm"), 32 | %Array("NAME:Attributes", "Name:=", "Region", 33 | % "Flags:=", "Wireframe#", "Color:=", "(255 0 0)", "Transparency:=", 0, "PartCoordinateSystem:=", _ 34 | % "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", _ 35 | % true) 36 | 37 | -------------------------------------------------------------------------------- /3dmodeler/hfssDetachFaces.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/3dmodeler/hfssDetachFaces.m -------------------------------------------------------------------------------- /3dmodeler/hfssDuplicateAroundAxis.asv: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssDuplicateAroundAxis(fid, ObjectList, Axis, DupAngle,... 3 | % [dupBoundaries = true]) 4 | % 5 | % Description : 6 | % ------------- 7 | % Creates the VB Script necessary to duplicate specified parts according to 8 | % a mirror plane. 9 | % 10 | % Parameters : 11 | % ------------ 12 | % fid - file identifier of the HFSS script file. 13 | % ObjectList - a cell-array of strings that represent the objects to be 14 | % cloned. 15 | % Axis - axis around which Object is to be duplicate. 16 | % DupAngle - angle (in *deg*) over which the object is to be duplicate. 17 | % [dupBoundaries] - (optional, boolean) set to false if you wish NOT to 18 | % duplicate boundaries along with the geometry. 19 | % 20 | % Note : 21 | % ------ 22 | % If you have used this 3D modeler feature before, then you will probably 23 | % realize that if the original object (to be cloned) has the name 'Name', 24 | % then the cloned objects will have names 'Name1', 'Name2', ... This applies 25 | % to the cloned boundaries and excitations also. 26 | % 27 | % Example : 28 | % --------- 29 | % fid = fopen('myantenna.vbs', 'wt'); 30 | % ... 31 | % 32 | % ---------------------------------------------------------------------------- 33 | 34 | % ---------------------------------------------------------------------------- 35 | % This file is part of HFSS-MATLAB-API. 36 | % 37 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 38 | % under the terms of the GNU General Public License as published by the Free 39 | % Software Foundation; either version 2 of the License, or (at your option) 40 | % any later version. 41 | % 42 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 43 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 44 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45 | % for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License along with 48 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 49 | % Place, Suite 330, Boston, MA 02111-1307 USA 50 | % 51 | % Copyright 2008, Yueliang (yue_liang423@163.com) 52 | % ------------------------------------------------------------------------- 53 | % --- 54 | function hfssDuplicateAroundAxis(fid, ObjectList, Axis, DupAngle,NumClones,... 55 | dupBoundaries) 56 | 57 | % arguments processor. 58 | if (nargin < 5) 59 | error('Insufficient number of arguments !'); 60 | elseif (nargin < 6) 61 | dupBoundaries = []; 62 | end; 63 | 64 | % default arguments. 65 | %if isempty(dupBoundaries) 66 | % dupBoundaries = false; 67 | %end; 68 | 69 | nObjects = length(ObjectList); 70 | 71 | % Preamble. 72 | fprintf(fid, '\n'); 73 | fprintf(fid, 'oEditor.DuplicateAroundAxis _\n'); 74 | fprintf(fid, 'Array("NAME:Selections", _\n'); 75 | 76 | % Object Selections. 77 | fprintf(fid, '"Selections:=", "'); 78 | for iObj = 1:nObjects, 79 | fprintf(fid, '%s', ObjectList{iObj}); 80 | if (iObj ~= nObjects) 81 | fprintf(fid, ','); 82 | end; 83 | end; 84 | fprintf(fid, '"), _\n'); 85 | 86 | % Duplication Around Axis. 87 | fprintf(fid, 'Array("NAME:DuplicateAroundAxisParameters", _\n'); 88 | fprintf(fid, '"WhichAxis:=", "%s", _\n', Axis); 89 | %fprintf(fid, '"AngleStr:=", "%fdeg", _\n', DupAngle); 90 | if isnumeric(NumClones) 91 | %fprintf(fid, '"NumClones:=", %f), _\n', NumClones); 92 | if isnumeric(NumClones) 93 | fprintf(fid, '"NumClones:=", %f), _\n', NumClones); 94 | else 95 | fprintf(fid, '"NumClones:=", "%s"), _\n', NumClones); 96 | end 97 | 98 | % Duplicate Boundaries with Geometry or not. 99 | fprintf(fid, 'Array("NAME:Options", _\n'); 100 | if 1 == isempty(dupBoundaries) 101 | fprintf(fid, '"DuplicateBoundaries:=", false)\n'); 102 | else 103 | fprintf(fid, '"DuplicateBoundaries:=", true)\n'); 104 | end -------------------------------------------------------------------------------- /3dmodeler/hfssDuplicateMirror.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssDuplicateMirror(fid, ObjectList, dVector, Units, ... 3 | % [dupBoundaries = true]) 4 | % 5 | % Description : 6 | % ------------- 7 | % Creates the VB Script necessary to duplicate specified parts according to 8 | % a mirror plane. 9 | % 10 | % Parameters : 11 | % ------------ 12 | % fid - file identifier of the HFSS script file. 13 | % ObjectList - a cell-array of strings that represent the objects to be 14 | % cloned. 15 | % dVector - (vector) the translation vector for the duplication process 16 | % (specified as [dx, dy, dz]). 17 | % Units - specified as either 'mm', 'meter', 'in' or anything else 18 | % defined in HFSS. 19 | % [dupBoundaries] - (optional, boolean) set to false if you wish NOT to 20 | % duplicate boundaries along with the geometry. 21 | % 22 | % Note : 23 | % ------ 24 | % If you have used this 3D modeler feature before, then you will probably 25 | % realize that if the original object (to be cloned) has the name 'Name', 26 | % then the cloned objects will have names 'Name1', 'Name2', ... This applies 27 | % to the cloned boundaries and excitations also. 28 | % 29 | % Example : 30 | % --------- 31 | % fid = fopen('myantenna.vbs', 'wt'); 32 | % ... 33 | % 34 | % ---------------------------------------------------------------------------- 35 | 36 | % ---------------------------------------------------------------------------- 37 | % This file is part of HFSS-MATLAB-API. 38 | % 39 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 40 | % under the terms of the GNU General Public License as published by the Free 41 | % Software Foundation; either version 2 of the License, or (at your option) 42 | % any later version. 43 | % 44 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 45 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 46 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47 | % for more details. 48 | % 49 | % You should have received a copy of the GNU General Public License along with 50 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 51 | % Place, Suite 330, Boston, MA 02111-1307 USA 52 | % 53 | % Copyright 2008, Yueliang (yue_liang423@163.com) 54 | % ---------------------------------------------------------------------------- 55 | 56 | function hfssDuplicateMirror(fid, ObjectList, dVector, Units, ... 57 | dupBoundaries) 58 | 59 | 60 | % arguments processor. 61 | if (nargin < 4) 62 | error('Insufficient number of arguments !'); 63 | elseif (nargin < 5) 64 | dupBoundaries = []; 65 | end; 66 | 67 | % default arguments. 68 | if isempty(dupBoundaries) 69 | dupBoundaries = false; 70 | end; 71 | 72 | nObjects = length(ObjectList); 73 | 74 | % Preamble. 75 | fprintf(fid, '\n'); 76 | fprintf(fid, 'oEditor.DuplicateMirror _\n'); 77 | fprintf(fid, 'Array("NAME:Selections", _\n'); 78 | 79 | % Object Selections. 80 | fprintf(fid, '"Selections:=", "'); 81 | for iObj = 1:nObjects, 82 | fprintf(fid, '%s', ObjectList{iObj}); 83 | if (iObj ~= nObjects) 84 | fprintf(fid, ','); 85 | end; 86 | end; 87 | fprintf(fid, '"), _\n'); 88 | 89 | % Duplication Vectors. 90 | fprintf(fid, 'Array("NAME:DuplicateToMirrorParameters", _\n'); 91 | fprintf(fid, '"DuplicateMirrorBaseX:=", "%f%s", _\n', 0, Units); 92 | fprintf(fid, '"DuplicateMirrorBaseY:=", "%f%s", _\n', 0, Units); 93 | fprintf(fid, '"DuplicateMirrorBaseZ:=", "%f%s", _\n', 0, Units); 94 | fprintf(fid, '"DuplicateMirrorNormalX:=", "%f%s", _\n', dVector(1), Units); 95 | fprintf(fid, '"DuplicateMirrorNormalY:=", "%f%s", _\n', dVector(2), Units); 96 | fprintf(fid, '"DuplicateMirrorNormalZ:=", "%f%s"), _\n', dVector(3), Units); 97 | 98 | 99 | % Duplicate Boundaries with Geometry or not. 100 | fprintf(fid, 'Array("NAME:Options", _\n'); 101 | if (dupBoundaries) 102 | fprintf(fid, '"DuplicateBoundaries:=", true)\n'); 103 | else 104 | fprintf(fid, '"DuplicateBoundaries:=", false)\n'); 105 | end; -------------------------------------------------------------------------------- /3dmodeler/hfssEllipse.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssEllipse(fid, Name, Axis, Center, MajRadius, Ratio, Units) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to create an ellipse primitive in HFSS. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % Name - name of the circle object (in HFSS). 12 | % Axis - choose between 'X', 'Y', or 'Z' to represent the circle axis. 13 | % Center - center of the circle (use the [x, y, z] format). 14 | % MajRadius - majradius of the ellipse. 15 | % Ration - ration of the ellipse. 16 | % Units - units for all the above quantities (use either 'in', 'mm', 'meter' 17 | % or anything else defined in HFSS). 18 | % 19 | % Note : 20 | % ------ 21 | % 22 | % Example : 23 | % --------- 24 | % fid = fopen('myantenna.vbs', 'wt'); 25 | % ... 26 | % hfssCircle(fid, 'C_Patch', 'Z', [10, 11, 12], 13, 0.8, 'mm'); 27 | % ---------------------------------------------------------------------------- 28 | 29 | % ---------------------------------------------------------------------------- 30 | % This file is part of HFSS-MATLAB-API. 31 | % 32 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 33 | % under the terms of the GNU General Public License as published by the Free 34 | % Software Foundation; either version 2 of the License, or (at your option) 35 | % any later version. 36 | % 37 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 38 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 39 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40 | % for more details. 41 | % 42 | % You should have received a copy of the GNU General Public License along with 43 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 44 | % Place, Suite 330, Boston, MA 02111-1307 USA 45 | % 46 | % Copyright 2008, Yueliang (yue_liang423@163.com) 47 | % ------------------------------------------------------------------------- 48 | % --- 49 | function hfssEllipse(fid, Name, Axis, Center, MajRadius, Ratio, Units) 50 | 51 | fprintf(fid, '\n'); 52 | % Preamble. 53 | fprintf(fid, 'oEditor.CreateEllipse _\n'); 54 | fprintf(fid, 'Array("NAME:EllipseParameters", _\n'); 55 | 56 | % Parameters. 57 | fprintf(fid, '"CoordinateSystemID:=", -1, _\n'); 58 | fprintf(fid, '"IsCovered:=", true, _\n'); 59 | fprintf(fid, '"XCenter:=", "%f%s", _\n', Center(1), Units); 60 | fprintf(fid, '"YCenter:=", "%f%s", _\n', Center(2), Units); 61 | fprintf(fid, '"ZCenter:=", "%f%s", _\n', Center(3), Units); 62 | fprintf(fid, '"MajRadius:=", "%f%s", _\n', MajRadius, Units); 63 | fprintf(fid, '"Ratio:=", "%f%s", _\n', Ratio, Units); 64 | fprintf(fid, '"WhichAxis:=", "%s"), _\n', upper(Axis)); 65 | 66 | % Attributes. 67 | fprintf(fid, 'Array("NAME:Attributes", _\n'); 68 | fprintf(fid, '"Name:=", "%s", _\n', Name); 69 | fprintf(fid, '"Flags:=", "", _\n'); 70 | fprintf(fid, '"Color:=", "(132 132 193)", _\n'); 71 | fprintf(fid, '"Transparency:=", 0, _\n'); 72 | fprintf(fid, '"PartCoordinateSystem:=", "Global", _\n'); 73 | fprintf(fid, '"MaterialName:=", "vacuum", _\n'); 74 | fprintf(fid, '"SolveInside:=", true)\n'); -------------------------------------------------------------------------------- /3dmodeler/hfssHelix.asv: -------------------------------------------------------------------------------- 1 | 2 | %oEditor.CreateHelix 3 | %Array("NAME:Selections", "Selections:=", "Circle1", "NewPartsModelFlag:=", _ 4 | %"Model"), Array("NAME:HelixParameters", "XCenter:=", "0mm", "YCenter:=", "0mm", "ZCenter:=", _ 5 | %"0mm", "XStartDir:=", "0mm", "YStartDir:=", "0mm", "ZStartDir:=", "1mm", "NumThread:=", _ 6 | %"2", "RightHand:=", true, "RadiusIncrement:=", "0mm", "Thread:=", "50mm") 7 | %% 8 | function hfssHelix(fid, Name, Center, StartDir, Turns,RightHand, RadiusIncrement, Thread, Units) 9 | Center = reshape(Center, length(Center), 1); 10 | 11 | if iscell(Center) 12 | 1; 13 | else 14 | Center = mat2cell(Center,[1,1,1],1); 15 | end 16 | 17 | StartDir = reshape( StartDir, length( StartDir), 1); 18 | 19 | if iscell(StartDir) 20 | 1; 21 | else 22 | StartDir = mat2cell(StartDir,[1,1,1],1); 23 | end 24 | 25 | fprintf(fid, '\n'); 26 | fprintf(fid, 'oEditor.CreateHelix _\n'); 27 | fprintf(fid, 'Array("NAME:Selections", _\n'); 28 | fprintf(fid, '"Selections:=", "%s",_\n',Name); 29 | fprintf(fid, '"NewPartsModelFlag:=","Model"),_\n '); 30 | fprintf(fid, 'Array("NAME:HelixParameters", _\n '); 31 | %Center 32 | if isnumeric(Center{1,1}) 33 | fprintf(fid, '"XCenter:=", "%f%s", _\n', Center{1,1}, Units); 34 | else 35 | fprintf(fid, '"XCenter:=", "%s", _\n', Center{1,1}); 36 | end 37 | 38 | if isnumeric(Center{2,1}) 39 | fprintf(fid, '"YCenter:=", "%f%s", _\n', Center{2,1}, Units); 40 | else 41 | fprintf(fid, '"YCenter:=", "%s", _\n', Center{2,1}); 42 | end 43 | 44 | if isnumeric(Center{3,1}) 45 | fprintf(fid, '"ZCenter:=", "%f%s", _\n', Center{3,1}, Units); 46 | else 47 | fprintf(fid, '"ZCenter:=", "%s", _\n', Center{3,1}); 48 | end 49 | %StartDir 50 | if isnumeric(Center{1,1}) 51 | fprintf(fid, '"XCenter:=", "%f%s", _\n', Center{1,1}, Units); 52 | else 53 | fprintf(fid, '"XCenter:=", "%s", _\n', Center{1,1}); 54 | end 55 | 56 | if isnumeric(Center{2,1}) 57 | fprintf(fid, '"YCenter:=", "%f%s", _\n', Center{2,1}, Units); 58 | else 59 | fprintf(fid, '"YCenter:=", "%s", _\n', Center{2,1}); 60 | end 61 | 62 | if isnumeric(Center{3,1}) 63 | fprintf(fid, '"ZCenter:=", "%f%s", _\n', Center{3,1}, Units); 64 | else 65 | fprintf(fid, '"ZCenter:=", "%s", _\n', Center{3,1}); 66 | end 67 | %NumThread 68 | fprintf(fid, '"NumThread:=", "%f", _\n', Turns); 69 | %If RightHand 70 | if RightHand == 1 71 | fprintf(fid, '"RightHand:=", true, _\n '); 72 | else 73 | fprintf(fid, '"RightHand:=", false, _\n '); 74 | end 75 | %RadiusIncrement 76 | fprintf(fid, '"RadiusIncrement:=", "%f%s", _\n', RadiusIncrement, Units); 77 | %Thread 78 | fprintf(fid, '"Thread:=", "%f%s")', Thread, Units); 79 | %% 80 | %fprintf(fid, '\n'); 81 | %fprintf(fid, 'oEditor.CreateHelix _\n'); 82 | %fprintf(fid, 'Array("NAME:Selections", _\n'); 83 | %fprintf(fid, '"Selections:=", "%s",_\n',Name); 84 | %fprintf(fid, '"NewPartsModelFlag:=","Model"),_\n '); 85 | %fprintf(fid, 'Array("NAME:HelixParameters", _\n '); 86 | %Center 87 | %fprintf(fid, '"XCenter:=", "%f%s", _\n', Center(1), Units); 88 | %fprintf(fid, '"YCenter:=", "%f%s", _\n', Center(2), Units); 89 | %fprintf(fid, '"ZCenter:=", "%f%s", _\n', Center(3), Units); 90 | %StartDir 91 | %fprintf(fid, '"XStartDir:=", "%f%s", _\n', StartDir(1), Units); 92 | %fprintf(fid, '"YStartDir:=", "%f%s", _\n', StartDir(2), Units); 93 | %fprintf(fid, '"ZStartDir:=", "%f%s", _\n', StartDir(3), Units); 94 | %NumThread 95 | %fprintf(fid, '"NumThread:=", "%f", _\n', Turns); 96 | %If RightHand 97 | %if RightHand == 1 98 | % fprintf(fid, '"RightHand:=", true, _\n '); 99 | %else 100 | % fprintf(fid, '"RightHand:=", false, _\n '); 101 | %end 102 | %RadiusIncrement 103 | %fprintf(fid, '"RadiusIncrement:=", "%f%s", _\n', RadiusIncrement, Units); 104 | %Thread 105 | %fprintf(fid, '"Thread:=", "%f%s")', Thread, Units); -------------------------------------------------------------------------------- /3dmodeler/hfssHelix.m: -------------------------------------------------------------------------------- 1 | 2 | %oEditor.CreateHelix 3 | %Array("NAME:Selections", "Selections:=", "Circle1", "NewPartsModelFlag:=", _ 4 | %"Model"), Array("NAME:HelixParameters", "XCenter:=", "0mm", "YCenter:=", "0mm", "ZCenter:=", _ 5 | %"0mm", "XStartDir:=", "0mm", "YStartDir:=", "0mm", "ZStartDir:=", "1mm", "NumThread:=", _ 6 | %"2", "RightHand:=", true, "RadiusIncrement:=", "0mm", "Thread:=", "50mm") 7 | %% 8 | function hfssHelix(fid, Name, Center, StartDir, Turns,RightHand, RadiusIncrement, Thread, Units) 9 | Center = reshape(Center, length(Center), 1); 10 | 11 | if iscell(Center) 12 | 1; 13 | else 14 | Center = mat2cell(Center,[1,1,1],1); 15 | end 16 | 17 | StartDir = reshape( StartDir, length( StartDir), 1); 18 | 19 | if iscell(StartDir) 20 | 1; 21 | else 22 | StartDir = mat2cell(StartDir,[1,1,1],1); 23 | end 24 | 25 | fprintf(fid, '\n'); 26 | fprintf(fid, 'oEditor.CreateHelix _\n'); 27 | fprintf(fid, 'Array("NAME:Selections", _\n'); 28 | fprintf(fid, '"Selections:=", "%s",_\n',Name); 29 | fprintf(fid, '"NewPartsModelFlag:=","Model"),_\n '); 30 | fprintf(fid, 'Array("NAME:HelixParameters", _\n '); 31 | %Center 32 | if isnumeric(Center{1,1}) 33 | fprintf(fid, '"XCenter:=", "%f%s", _\n', Center{1,1}, Units); 34 | else 35 | fprintf(fid, '"XCenter:=", "%s", _\n', Center{1,1}); 36 | end 37 | 38 | if isnumeric(Center{2,1}) 39 | fprintf(fid, '"YCenter:=", "%f%s", _\n', Center{2,1}, Units); 40 | else 41 | fprintf(fid, '"YCenter:=", "%s", _\n', Center{2,1}); 42 | end 43 | 44 | if isnumeric(Center{3,1}) 45 | fprintf(fid, '"ZCenter:=", "%f%s", _\n', Center{3,1}, Units); 46 | else 47 | fprintf(fid, '"ZCenter:=", "%s", _\n', Center{3,1}); 48 | end 49 | %StartDir 50 | if isnumeric(StartDir{1,1}) 51 | fprintf(fid, '"XStartDir:=", "%f%s", _\n', StartDir{1,1}, Units); 52 | else 53 | fprintf(fid, '"XStartDir:=", "%s", _\n', StartDir{1,1}); 54 | end 55 | 56 | if isnumeric(StartDir{2,1}) 57 | fprintf(fid, '"YStartDir:=", "%f%s", _\n', StartDir{2,1}, Units); 58 | else 59 | fprintf(fid, '"YStartDir:=", "%s", _\n', StartDir{2,1}); 60 | end 61 | 62 | if isnumeric(StartDir{3,1}) 63 | fprintf(fid, '"ZStartDir:=", "%f%s", _\n', StartDir{3,1}, Units); 64 | else 65 | fprintf(fid, '"ZStartDir:=", "%s", _\n', StartDir{3,1}); 66 | end 67 | %NumThread 68 | fprintf(fid, '"NumThread:=", "%f", _\n', Turns); 69 | %If RightHand 70 | if RightHand == 1 71 | fprintf(fid, '"RightHand:=", true, _\n '); 72 | else 73 | fprintf(fid, '"RightHand:=", false, _\n '); 74 | end 75 | %RadiusIncrement 76 | fprintf(fid, '"RadiusIncrement:=", "%f%s", _\n', RadiusIncrement, Units); 77 | %Thread 78 | if isnumeric(Thread) 79 | fprintf(fid, '"Thread:=", "%f%s")', Thread, Units); 80 | else 81 | fprintf(fid, '"Thread:=", "%s")', Thread); 82 | end 83 | %% 84 | %fprintf(fid, '\n'); 85 | %fprintf(fid, 'oEditor.CreateHelix _\n'); 86 | %fprintf(fid, 'Array("NAME:Selections", _\n'); 87 | %fprintf(fid, '"Selections:=", "%s",_\n',Name); 88 | %fprintf(fid, '"NewPartsModelFlag:=","Model"),_\n '); 89 | %fprintf(fid, 'Array("NAME:HelixParameters", _\n '); 90 | %Center 91 | %fprintf(fid, '"XCenter:=", "%f%s", _\n', Center(1), Units); 92 | %fprintf(fid, '"YCenter:=", "%f%s", _\n', Center(2), Units); 93 | %fprintf(fid, '"ZCenter:=", "%f%s", _\n', Center(3), Units); 94 | %StartDir 95 | %fprintf(fid, '"XStartDir:=", "%f%s", _\n', StartDir(1), Units); 96 | %fprintf(fid, '"YStartDir:=", "%f%s", _\n', StartDir(2), Units); 97 | %fprintf(fid, '"ZStartDir:=", "%f%s", _\n', StartDir(3), Units); 98 | %NumThread 99 | %fprintf(fid, '"NumThread:=", "%f", _\n', Turns); 100 | %If RightHand 101 | %if RightHand == 1 102 | % fprintf(fid, '"RightHand:=", true, _\n '); 103 | %else 104 | % fprintf(fid, '"RightHand:=", false, _\n '); 105 | %end 106 | %RadiusIncrement 107 | %fprintf(fid, '"RadiusIncrement:=", "%f%s", _\n', RadiusIncrement, Units); 108 | %Thread 109 | %fprintf(fid, '"Thread:=", "%f%s")', Thread, Units); -------------------------------------------------------------------------------- /3dmodeler/hfssHollowCylinder.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssHollowCylinder(fid, Name, Axis, Center, inRadius, outRadius, 3 | % Height, Units) 4 | % 5 | % Description : 6 | % ------------- 7 | % Creates VB Script necessary to generate a hollow cylinder in HFSS. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the hollow cylinder (in HFSS). 13 | % Axis - choose between 'X', 'Y' or 'Z' for the cylinder axis. 14 | % Center - center of the cylinder (express as [x, y, z]). 15 | % inRadius - inner radius of the cylinder. 16 | % outRadius - outer radius of the cylinder. 17 | % Height - cylinder height. 18 | % Units - units for all the quantities (use either 'in', 'mm', 'meter' or 19 | % anything else that is defined in HFSS). 20 | % 21 | % Note : 22 | % ------ 23 | % This function creates an extra object that is a contatenation of the Name 24 | % with '_sub' that gets subtracted from the outer cylinder to get the hollow 25 | % structure. 26 | % 27 | % Example : 28 | % --------- 29 | % fid = fopen('myantenna.vbs', 'wt'); 30 | % ... 31 | % hfssHollowCylinder(fid, 'Dipole', 'X', [-G/2, 0, 0], 0.95*R, R, L, 'in'); 32 | % ---------------------------------------------------------------------------- 33 | 34 | % ---------------------------------------------------------------------------- 35 | % This file is part of HFSS-MATLAB-API. 36 | % 37 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 38 | % under the terms of the GNU General Public License as published by the Free 39 | % Software Foundation; either version 2 of the License, or (at your option) 40 | % any later version. 41 | % 42 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 43 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 44 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45 | % for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License along with 48 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 49 | % Place, Suite 330, Boston, MA 02111-1307 USA 50 | % 51 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 52 | % ---------------------------------------------------------------------------- 53 | function hfssHollowCylinder(fid, Name, Axis, Center, inRadius, outRadius, ... 54 | Height, Units) 55 | 56 | hfssCylinder(fid, Name, Axis, Center, outRadius, Height, Units) 57 | hfssCylinder(fid, strcat(Name, '_sub'), Axis, Center, inRadius, Height, ... 58 | Units); 59 | hfssSubtract(fid, Name, strcat(Name, '_sub')); 60 | -------------------------------------------------------------------------------- /3dmodeler/hfssIntersect.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssIntersect(fid, varargin) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary for intersect a given set of objects already 7 | % present in the HFSS 3D Modeler. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % varargin - names of the objects that need to be united. It can be specified 13 | % either as a single cell array of strings, or several individual 14 | % cell strings containing a single object name (see example ...) 15 | % 16 | % Note : 17 | % ------ 18 | % 19 | % Example : 20 | % --------- 21 | % fid = fopen('myantenna.vbs', 'wt'); 22 | % ... 23 | % % Method 1. 24 | % hfssUnite(fid, {'Object1', 'Object2', Object3'}); 25 | % % ... or Method 2. 26 | % hfssUnite(fid, {'Object1'}, {'Object2'}, {'Object3'}); 27 | % 28 | % ---------------------------------------------------------------------------- 29 | 30 | % ---------------------------------------------------------------------------- 31 | % This file is part of HFSS-MATLAB-API. 32 | % 33 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 34 | % under the terms of the GNU General Public License as published by the Free 35 | % Software Foundation; either version 2 of the License, or (at your option) 36 | % any later version. 37 | % 38 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 39 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 40 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41 | % for more details. 42 | % 43 | % You should have received a copy of the GNU General Public License along with 44 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 45 | % Place, Suite 330, Boston, MA 02111-1307 USA 46 | % 47 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 48 | % ------------------------------------------------------------------------- 49 | % --- 50 | 51 | function hfssIntersect(fid, varargin) 52 | 53 | % Preamble. 54 | fprintf(fid, '\n'); 55 | fprintf(fid, 'oEditor.Intersect _\n'); 56 | fprintf(fid, 'Array("NAME:Selections", _\n'); 57 | fprintf(fid, '"Selections:=", '); 58 | 59 | % If the first argument is a cell then it contains a cell of strings that must 60 | % be united, else each argument is a cell. 61 | if (iscell(varargin{1})) 62 | Objects = varargin{1}; 63 | else 64 | Objects = varargin; 65 | end; 66 | 67 | % Total # of Objects. 68 | nObjects = length(Objects); 69 | 70 | % Add the Objects. 71 | fprintf(fid, '"'); 72 | for iP = 1:nObjects-1, 73 | fprintf(fid, '%s,', Objects{iP}); 74 | end; 75 | fprintf(fid, '%s"), _\n', Objects{nObjects}); 76 | 77 | % Postamble. 78 | fprintf(fid, 'Array("NAME:IntersectParameters", "KeepOriginals:=", false)\n'); -------------------------------------------------------------------------------- /3dmodeler/hfssMove.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssMove(fid, ObjList, tVector, Units) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to move a given set of objects. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % ObjList - a cell array of objects that need to be moved. 12 | % tVector - a translation vector that defines the motion (specify as 13 | % [tx, ty, tz]). 14 | % Units - units for the transalation vector (use 'in', 'mm', 'meter' or 15 | % anything else defined in HFSS). 16 | % 17 | % Note : 18 | % ------ 19 | % 20 | % Example : 21 | % --------- 22 | % fid = fopen('myantenna.vbs', 'wt'); 23 | % ... create some objects here ... 24 | % hfssMove(fid, {'Dipole1', 'Dipole2'}, [0, d, 0], 'in'); 25 | % ---------------------------------------------------------------------------- 26 | 27 | % ---------------------------------------------------------------------------- 28 | % This file is part of HFSS-MATLAB-API. 29 | % 30 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 31 | % under the terms of the GNU General Public License as published by the Free 32 | % Software Foundation; either version 2 of the License, or (at your option) 33 | % any later version. 34 | % 35 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 36 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38 | % for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License along with 41 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 42 | % Place, Suite 330, Boston, MA 02111-1307 USA 43 | % 44 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 45 | % ---------------------------------------------------------------------------- 46 | function hfssMove(fid, ObjectList, tVector, Units) 47 | 48 | nObjects = length(ObjectList); 49 | 50 | tVector = reshape(tVector, length(tVector), 1); 51 | if iscell(tVector) 52 | 1; 53 | else 54 | tVector = mat2cell(tVector,[1,1,1],1); 55 | end 56 | % Preamble. 57 | fprintf(fid, '\n'); 58 | fprintf(fid, 'oEditor.Move _\n'); 59 | fprintf(fid, 'Array("NAME:Selections", _\n'); 60 | 61 | % Object Selections. 62 | fprintf(fid, '"Selections:=", "'); 63 | for iObj = 1:nObjects, 64 | fprintf(fid, '%s', ObjectList{iObj}); 65 | if (iObj ~= nObjects) 66 | fprintf(fid, ','); 67 | end; 68 | end; 69 | fprintf(fid, '"), _\n'); 70 | 71 | % Transalation Vector. 72 | fprintf(fid, 'Array("NAME:TranslateParameters", _\n'); 73 | 74 | if isnumeric(tVector{1,1}) 75 | fprintf(fid, '"TranslateVectorX:=", "%f%s", _\n', tVector{1,1}, Units); 76 | else 77 | fprintf(fid, '"TranslateVectorX:=", "%s", _\n', tVector{1,1}); 78 | end 79 | 80 | if isnumeric(tVector{2,1}) 81 | fprintf(fid, '"TranslateVectorY:=", "%f%s", _\n', tVector{2,1}, Units); 82 | else 83 | fprintf(fid, '"TranslateVectorY:=", "%s", _\n', tVector{2,1}); 84 | end 85 | 86 | if isnumeric(tVector{3,1}) 87 | fprintf(fid, '"TranslateVectorZ:=", "%f%s") _\n', tVector{3,1}, Units); 88 | else 89 | fprintf(fid, '"TranslateVectorZ:=", "%s") _\n', tVector{3,1}); 90 | end 91 | %fprintf(fid, '"TranslateVectorX:=", "%f%s", _\n', tVector(1), Units); 92 | %fprintf(fid, '"TranslateVectorY:=", "%f%s", _\n', tVector(2), Units); 93 | %fprintf(fid, '"TranslateVectorZ:=", "%f%s")\n', tVector(3), Units); 94 | -------------------------------------------------------------------------------- /3dmodeler/hfssRectangle.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/3dmodeler/hfssRectangle.asv -------------------------------------------------------------------------------- /3dmodeler/hfssRectangle.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/3dmodeler/hfssRectangle.m -------------------------------------------------------------------------------- /3dmodeler/hfssRegion.m: -------------------------------------------------------------------------------- 1 | 2 | % zzm---------------------------------------------------------------------------- 3 | function hfssRegion(fid, Name, x_d,fx_d, y_d,fy_d, z_d,fz_d) 4 | 5 | % Cylinder Parameters. 6 | fprintf(fid, '\n'); 7 | fprintf(fid, 'oEditor.CreateRegion _\n'); 8 | fprintf(fid, 'Array("NAME:RegionParameters", _\n'); 9 | fprintf(fid, '"+XPaddingType:=", _\n'); 10 | fprintf(fid, '"Percentage Offset", _\n'); 11 | fprintf(fid, '"+XPadding:=", "%f", _\n',x_d); 12 | 13 | fprintf(fid, '"-XPaddingType:=", _\n'); 14 | fprintf(fid, '"Percentage Offset", _\n'); 15 | fprintf(fid, '"-XPadding:=", "%f", _\n',fx_d); 16 | 17 | fprintf(fid, '"+YPaddingType:=", _\n'); 18 | fprintf(fid, '"Percentage Offset", _\n'); 19 | fprintf(fid, '"+YPadding:=", "%f", _\n',y_d); 20 | 21 | fprintf(fid, '"-YPaddingType:=", _\n'); 22 | fprintf(fid, '"Percentage Offset", _\n'); 23 | fprintf(fid, '"-YPadding:=", "%f", _\n',fy_d); 24 | 25 | fprintf(fid, '"+ZPaddingType:=", _\n'); 26 | fprintf(fid, '"Percentage Offset", _\n'); 27 | fprintf(fid, '"+ZPadding:=", "%f", _\n',z_d); 28 | 29 | fprintf(fid, '"-ZPaddingType:=", _\n'); 30 | fprintf(fid, '"Percentage Offset", _\n'); 31 | fprintf(fid, '"-ZPadding:=", "%f"), _\n',fz_d); 32 | 33 | % Region Properties. 34 | fprintf(fid, 'Array("NAME:Attributes", _\n'); 35 | fprintf(fid, '"Name:=", "%s", _\n', Name); 36 | fprintf(fid, '"Flags:=", "Wireframe#", _\n'); 37 | fprintf(fid, '"Color:=", "(255 0 0)", _\n'); 38 | fprintf(fid, '"Transparency:=", 0, _\n'); 39 | fprintf(fid, '"PartCoordinateSystem:=", "Global", _\n'); 40 | fprintf(fid, '"MaterialName:=", "vacuum" , _\n'); 41 | fprintf(fid, '"SolveInside:=", true)\n'); 42 | fprintf(fid, '\n'); 43 | -------------------------------------------------------------------------------- /3dmodeler/hfssRename.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssRename(fid, oldName, newName) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to rename a HFSS Object. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % oldName - the object's previous name. 12 | % newName - the object's new name. 13 | % 14 | % Note : 15 | % ------ 16 | % 17 | % Example : 18 | % --------- 19 | % fid = fopen('myantenna.vbs', 'wt'); 20 | % ... 21 | % hfssRename(fid, 'dipole1', 'dipole_one'); 22 | % 23 | % ---------------------------------------------------------------------------- 24 | 25 | % ---------------------------------------------------------------------------- 26 | % This file is part of HFSS-MATLAB-API. 27 | % 28 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 29 | % under the terms of the GNU General Public License as published by the Free 30 | % Software Foundation; either version 2 of the License, or (at your option) 31 | % any later version. 32 | % 33 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 34 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 35 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 36 | % for more details. 37 | % 38 | % You should have received a copy of the GNU General Public License along with 39 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 40 | % Place, Suite 330, Boston, MA 02111-1307 USA 41 | % 42 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 43 | % ---------------------------------------------------------------------------- 44 | function hfssRename(fid, oldName, newName) 45 | 46 | fprintf(fid, '\n'); 47 | fprintf(fid, 'oEditor.ChangeProperty _\n'); 48 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 49 | fprintf(fid, 'Array("NAME:Geometry3DAttributeTab", _\n'); 50 | fprintf(fid, 'Array("NAME:PropServers", "%s"), _\n', oldName); 51 | fprintf(fid, 'Array("NAME:ChangedProps", _\n'); 52 | fprintf(fid, 'Array("NAME:Name", _\n'); 53 | fprintf(fid, '"Value:=", "%s"))))\n', newName); 54 | -------------------------------------------------------------------------------- /3dmodeler/hfssRotate.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssRotate(fid, ObjectList, Axis, RotAngle) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to duplicate specified parts according to 7 | % a mirror plane. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % ObjectList - a cell-array of strings that represent the objects to be 13 | % cloned. 14 | % Axis - axis around which Object is to be rotate. 15 | % RotAngle - angle (in *deg*) over which the object is to be rotate. 16 | % 17 | % Note : 18 | % ------ 19 | % If you have used this 3D modeler feature before, then you will probably 20 | % realize that if the original object (to be cloned) has the name 'Name', 21 | % then the cloned objects will have names 'Name1', 'Name2', ... This applies 22 | % to the cloned boundaries and excitations also. 23 | % 24 | % Example : 25 | % --------- 26 | % fid = fopen('myantenna.vbs', 'wt'); 27 | % ... 28 | % 29 | % ---------------------------------------------------------------------------- 30 | 31 | % ---------------------------------------------------------------------------- 32 | % This file is part of HFSS-MATLAB-API. 33 | % 34 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 35 | % under the terms of the GNU General Public License as published by the Free 36 | % Software Foundation; either version 2 of the License, or (at your option) 37 | % any later version. 38 | % 39 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 40 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 41 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42 | % for more details. 43 | % 44 | % You should have received a copy of the GNU General Public License along with 45 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 46 | % Place, Suite 330, Boston, MA 02111-1307 USA 47 | % 48 | % Copyright 2008, Yueliang (yue_liang423@163.com) 49 | % ------------------------------------------------------------------------- 50 | % --- 51 | 52 | function hfssRotate(fid, ObjectList, Axis, RotAngle) 53 | 54 | nObjects = length(ObjectList); 55 | 56 | % Preamble. 57 | fprintf(fid, '\n'); 58 | fprintf(fid, 'oEditor.Rotate _\n'); 59 | fprintf(fid, 'Array("NAME:Selections", _\n'); 60 | 61 | % Object Selections. 62 | fprintf(fid, '"Selections:=", "'); 63 | for iObj = 1:nObjects, 64 | fprintf(fid, '%s', ObjectList{iObj}); 65 | if (iObj ~= nObjects) 66 | fprintf(fid, ','); 67 | end; 68 | end; 69 | fprintf(fid, '"), _\n'); 70 | 71 | % Duplication Around Axis. 72 | fprintf(fid, 'Array("NAME:RotateParameters", _\n'); 73 | fprintf(fid, '"RotateAxis:=", "%s", _\n', Axis); 74 | fprintf(fid, '"RotateAngle:=", "%fdeg") \n', RotAngle); -------------------------------------------------------------------------------- /3dmodeler/hfssSetTransparency.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssSetTransparency(fid, ObjectList, Value) 3 | % 4 | % Description 5 | % ----------- 6 | % Creates the VB Script necessary to set the transparency of the given set of 7 | % objects to a given value. 8 | % 9 | % Parameters 10 | % ---------- 11 | % fid - file identifier of the HFSS script file. 12 | % ObjectList - a cell-array of objects whose transparency needs to be set. 13 | % Value - the value of the objects transparency (can be between 0 and 1). 14 | % 15 | % Example 16 | % ------- 17 | % hfssSetTransparency(fid, {'AirBox'}, 0.95); 18 | % ---------------------------------------------------------------------------- 19 | 20 | % ---------------------------------------------------------------------------- 21 | % This file is part of HFSS-MATLAB-API. 22 | % 23 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 24 | % under the terms of the GNU General Public License as published by the Free 25 | % Software Foundation; either version 2 of the License, or (at your option) 26 | % any later version. 27 | % 28 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 29 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 30 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31 | % for more details. 32 | % 33 | % You should have received a copy of the GNU General Public License along with 34 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 35 | % Place, Suite 330, Boston, MA 02111-1307 USA 36 | % 37 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 38 | % ---------------------------------------------------------------------------- 39 | 40 | function hfssSetTransparency(fid, ObjectList, Value) 41 | 42 | % arguments processing. 43 | if (nargin < 3) 44 | erro('non-enough arguments !'); 45 | end; 46 | 47 | if ((Value < 0) | (Value > 1)) 48 | error('transparency must be between 0 and 1!'); 49 | end; 50 | 51 | if (~iscell(ObjectList)) 52 | error('ObjectList must be a cell-array of objects !'); 53 | end; 54 | 55 | nObj = length(ObjectList); 56 | 57 | fprintf(fid, '\n'); 58 | fprintf(fid, 'oEditor.ChangeProperty _\n'); 59 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 60 | fprintf(fid, '\tArray("NAME:Geometry3DAttributeTab", _\n'); 61 | fprintf(fid, '\t\tArray("NAME:PropServers",'); 62 | for iO = 1:nObj-1, 63 | fprintf(fid, '"%s", ', ObjectList{i}); 64 | end; 65 | fprintf(fid, '"%s"), _\n', ObjectList{nObj}); 66 | fprintf(fid, '\t\tArray("NAME:ChangedProps", _\n'); 67 | fprintf(fid, '\t\t\tArray("NAME:Transparent", "Value:=", %f) _\n', Value); 68 | fprintf(fid, '\t\t\t) _\n'); 69 | fprintf(fid, '\t\t) _\n'); 70 | fprintf(fid, '\t)\n'); 71 | -------------------------------------------------------------------------------- /3dmodeler/hfssSphere.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssSphere(fid, Name, Center, Radius, Units) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to create a sphere in HFSS. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % Name - name of the sphere (appears in HFSS). 12 | % Center - center of the sphere (specify as [cx, cy, cz]) 13 | % Radius - radius of the sphere (scalar) 14 | % Units - specify as 'in', 'm', 'meter' or anything defined in HFSS. 15 | % 16 | % Note : 17 | % ------ 18 | % 19 | % Example : 20 | % --------- 21 | % fid = fopen('myantenna.vbs', 'wt'); 22 | % ... 23 | % hfssSphere(fid, 'Sphere1', [0,0,0], 1, 'meter'); 24 | % 25 | % ---------------------------------------------------------------------------- 26 | 27 | % ---------------------------------------------------------------------------- 28 | % This file is part of HFSS-MATLAB-API. 29 | % 30 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 31 | % under the terms of the GNU General Public License as published by the Free 32 | % Software Foundation; either version 2 of the License, or (at your option) 33 | % any later version. 34 | % 35 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 36 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38 | % for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License along with 41 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 42 | % Place, Suite 330, Boston, MA 02111-1307 USA 43 | % 44 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 45 | % ---------------------------------------------------------------------------- 46 | function hfssSphere(fid, Name, Center, Radius, Units) 47 | 48 | % Preamble 49 | fprintf(fid, '\n'); 50 | fprintf(fid, 'oEditor.CreateSphere _\n'); 51 | fprintf(fid, 'Array("NAME:SphereParameters", _\n'); 52 | 53 | % Center and Radius. 54 | fprintf(fid, '"XCenter:=", "%f%s", _\n' , Center(1), Units); 55 | fprintf(fid, '"YCenter:=", "%f%s", _\n' , Center(2), Units); 56 | fprintf(fid, '"ZCenter:=", "%f%s", _\n' , Center(3), Units); 57 | fprintf(fid, '"Radius:=" , "%f%s"), _\n', Radius, Units); 58 | 59 | % Attributes. 60 | fprintf(fid, 'Array("NAME:Attributes", _\n'); 61 | fprintf(fid, '"Name:=", "%s", _\n', Name); 62 | fprintf(fid, '"Flags:=", "", _\n'); 63 | fprintf(fid, '"Color:=", "(132 132 193)", _\n'); 64 | fprintf(fid, '"Transparency:=", 0, _\n'); 65 | fprintf(fid, '"PartCoordinateSystem:=", "Global", _\n'); 66 | fprintf(fid, '"MaterialName:=", "vacuum", _\n'); 67 | fprintf(fid, '"SolveInside:=", true)\n'); 68 | -------------------------------------------------------------------------------- /3dmodeler/hfssSplit.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % hfssSplit(fid, splitplane, side, varargin) 3 | % 4 | % Description: 5 | % ------------ 6 | % Creates the necessary VB script to split specified objects along a palne. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % varargin - names of the objects that need to be splited. It can be specified 12 | % either as a single cell array of strings, or several individual 13 | % cell strings containing a single object name (see example ...) 14 | % splitplane - the specified plane such as 'XY','YZ' and 'ZX'. 15 | % side - the part you want to remain. Possible values are 'Both', 16 | % 'PositiveOnly','NegativeOnly'. 17 | % 18 | % Example : 19 | % --------- 20 | % fid = fopen('myantenna.vbs', 'wt'); 21 | % ... 22 | % hfssSplit(fid, 'XY', 'PositiveOnly', {'one','two',...}); 23 | % 24 | % ---------------------------------------------------------------------------- 25 | 26 | % ---------------------------------------------------------------------------- 27 | % This file is part of HFSS-MATLAB-API. 28 | % 29 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 30 | % under the terms of the GNU General Public License as published by the Free 31 | % Software Foundation; either version 2 of the License, or (at your option) 32 | % any later version. 33 | % 34 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 35 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 36 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 37 | % for more details. 38 | % 39 | % You should have received a copy of the GNU General Public License along with 40 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 41 | % Place, Suite 330, Boston, MA 02111-1307 USA 42 | % 43 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 44 | % ------------------------------------------------------------------------- 45 | 46 | function hfssSplit(fid, splitplane, side, varargin) 47 | 48 | % Preamble. 49 | fprintf(fid, '\n'); 50 | fprintf(fid, 'oEditor.Split _\n'); 51 | fprintf(fid, 'Array("NAME:Selections", _\n'); 52 | fprintf(fid, '"Selections:=", '); 53 | 54 | % If the first argument is a cell then it contains a cell of strings that must 55 | % be united, else each argument is a cell. 56 | if (iscell(varargin{1})) 57 | Objects = varargin{1}; 58 | else 59 | Objects = varargin; 60 | end; 61 | 62 | % Total # of Objects. 63 | nObjects = length(Objects); 64 | 65 | % Add the Objects. 66 | fprintf(fid, '"'); 67 | for iP = 1:nObjects-1, 68 | fprintf(fid, '%s,', Objects{iP}); 69 | end; 70 | fprintf(fid, '%s"), _\n', Objects{nObjects}); 71 | 72 | % Postamble. 73 | fprintf(fid, 'Array("NAME:SplitToParameters", "CoordinateSystemID:=", -1, _\n'); 74 | fprintf(fid, '"SplitPlane:=", "%s", _\n', splitplane); 75 | fprintf(fid, '"WhichSide:=", "%s", _\n', side); 76 | fprintf(fid, '"SplitCrossingObjectsOnly:=", false) \n'); 77 | -------------------------------------------------------------------------------- /3dmodeler/hfssSubtract.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % hfssSubtract(fid, blankParts, toolParts) 3 | % 4 | % Description: 5 | % ------------ 6 | % Creates the necessary VB script to subtract a set of tool parts from a set 7 | % of blank parts, a.k.a., will produce blank parts - tool parts. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % blankParts - a cell array of strings that contain the blank parts. 13 | % toolParts - a cell array of strings that contain the tool parts. 14 | % 15 | % Example : 16 | % --------- 17 | % fid = fopen('myantenna.vbs', 'wt'); 18 | % ... 19 | % hfssSubtract(fid, {'BigPlate'}, {'SmallPlate'}); 20 | % 21 | % ---------------------------------------------------------------------------- 22 | 23 | % ---------------------------------------------------------------------------- 24 | % This file is part of HFSS-MATLAB-API. 25 | % 26 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 27 | % under the terms of the GNU General Public License as published by the Free 28 | % Software Foundation; either version 2 of the License, or (at your option) 29 | % any later version. 30 | % 31 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 32 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 33 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34 | % for more details. 35 | % 36 | % You should have received a copy of the GNU General Public License along with 37 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 38 | % Place, Suite 330, Boston, MA 02111-1307 USA 39 | % 40 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 41 | % ---------------------------------------------------------------------------- 42 | % Will result in blankParts - toolParts. 43 | function hfssSubtract(fid, blankParts, toolParts) 44 | 45 | % Preamble. 46 | fprintf(fid, '\n'); 47 | fprintf(fid, 'oEditor.Subtract _\n'); 48 | fprintf(fid, 'Array("NAME:Selections", _\n'); 49 | 50 | % Add the Blank Parts. 51 | fprintf(fid, '"Blank Parts:=", _\n'); 52 | if (iscell(blankParts)) 53 | nBlank = length(blankParts); 54 | fprintf(fid, '"'); 55 | for iB = 1:nBlank-1, 56 | fprintf(fid, '%s,', blankParts{iB}); 57 | end; 58 | fprintf(fid, '%s", _\n', blankParts{nBlank}); 59 | else 60 | fprintf(fid, '"%s", _\n', blankParts); 61 | end; 62 | 63 | % Add the Tool Parts. 64 | fprintf(fid, '"Tool Parts:=", _\n'); 65 | if (iscell(toolParts)) 66 | nTool = length(toolParts); 67 | fprintf(fid, '"'); 68 | for iB = 1:nTool-1, 69 | fprintf(fid, '%s,', toolParts{iB}); 70 | end; 71 | fprintf(fid, '%s"), _\n', toolParts{nTool}); 72 | else 73 | fprintf(fid, '"%s"), _\n', toolParts); 74 | end; 75 | 76 | % Post-Amble. 77 | fprintf(fid, 'Array("NAME:SubtractParameters", _\n'); 78 | fprintf(fid, '"KeepOriginals:=", false) \n'); 79 | -------------------------------------------------------------------------------- /3dmodeler/hfssSweepAlongPath.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssSweepAlongPath(fid, Object) 3 | % 4 | % Description: 5 | % ------------ 6 | % Creates the VB Script necessary to sweep a 2D object around the given axis 7 | % to create a 3D object. 8 | % 9 | % Parameters: 10 | % ----------- 11 | % fid - file identifier of the HFSS script file. 12 | % Object - name of the Object to be sweeped. 13 | % 14 | % ---------------------------------------------------------------------------- 15 | % ---------------------------------------------------------------------------- 16 | % This file is part of HFSS-MATLAB-API. 17 | % 18 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 19 | % under the terms of the GNU General Public License as published by the Free 20 | % Software Foundation; either version 2 of the License, or (at your option) 21 | % any later version. 22 | % 23 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 24 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 25 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26 | % for more details. 27 | % 28 | % You should have received a copy of the GNU General Public License along with 29 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 30 | % Place, Suite 330, Boston, MA 02111-1307 USA 31 | % 32 | % Copyright 2008, Yueliang (yue_liang423@163.com) 33 | % ------------------------------------------------------------------------- 34 | function hfssSweepAlongPath(fid, Object) 35 | 36 | fprintf(fid, '\n'); 37 | fprintf(fid, 'oEditor.SweepAlongPath _\n'); 38 | fprintf(fid, ' Array("NAME:Selections", "Selections:=", "%s,%s"), _\n', Object{1},Object{2}); 39 | fprintf(fid, ' Array("NAME:PathSweepParameters", _\n'); 40 | fprintf(fid, ' "CoordinateSystemID:=", -1, _\n'); 41 | fprintf(fid, ' "DraftAngle:=", "0deg", _\n'); 42 | fprintf(fid, ' "DraftType:=", "Round", _\n'); 43 | fprintf(fid, ' "CheckFaceFaceIntersection:=", false, _\n'); 44 | fprintf(fid, ' "TwistAngle:=", "0deg") \n'); 45 | -------------------------------------------------------------------------------- /3dmodeler/hfssSweepAlongVector.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssSweepAlongVector(fid, Object2D, SweepVector, Units,... 3 | % [DraftAngle = 0 deg], [DraftType = 'Round']) 4 | % 5 | % Description: 6 | % ------------ 7 | % Creates the VB Script necessary to sweep the specified 1D or 2D parts 8 | % along a vector. 9 | % 10 | % Parameters: 11 | % ----------- 12 | % fid - file identifier of the HFSS script file. 13 | % Object2D - name of the 2D Object to be sweeped. 14 | % SweepVector - the vector of the object sweep along. 15 | % DraftAngle - angle (in *deg*) to which the object's profile, or shape is 16 | % expanded (or contracted) as it is swept. 17 | % DraftType - set it to either 'Round' (default), 'Extended' or 'Natural' 18 | % (consult the HFSS Help for more info). 19 | % 20 | % ---------------------------------------------------------------------------- 21 | % ---------------------------------------------------------------------------- 22 | % This file is part of HFSS-MATLAB-API. 23 | % 24 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 25 | % under the terms of the GNU General Public License as published by the Free 26 | % Software Foundation; either version 2 of the License, or (at your option) 27 | % any later version. 28 | % 29 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 30 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 31 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32 | % for more details. 33 | % 34 | % You should have received a copy of the GNU General Public License along with 35 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 36 | % Place, Suite 330, Boston, MA 02111-1307 USA 37 | % 38 | % Copyright 2008, Yueliang (yue_liang423@163.com) 39 | % ---------------------------------------------------------------------------- 40 | function hfssSweepAlongVector(fid, Object2D, SweepVector, Units,... 41 | DraftAngle, DraftType) 42 | 43 | % arguments processor. 44 | if (nargin < 4) 45 | error('Not enough arguments !'); 46 | elseif (nargin < 5) 47 | DraftAngle = 0; 48 | DraftType = 'Round'; 49 | elseif (nargin < 6) 50 | DraftType = 'Round'; 51 | end; 52 | 53 | % default arguments. 54 | if isempty(DraftAngle) 55 | DraftAngle = 0; 56 | end; 57 | if isempty(DraftType) 58 | DraftType = 'Round'; 59 | end; 60 | 61 | fprintf(fid, '\n'); 62 | 63 | fprintf(fid, 'oEditor.SweepAlongVector _\n'); 64 | fprintf(fid, '\tArray("NAME:Selections", "Selections:=", "%s"), _\n', Object2D); 65 | fprintf(fid, '\tArray("NAME:VectorSweepParameters", _\n'); 66 | fprintf(fid, '\t\t"CoordinateSystemID:=", -1, _\n'); 67 | fprintf(fid, '\t\t"DraftAngle:=", "%fdeg", _\n', DraftAngle); 68 | fprintf(fid, '\t\t"DraftType:=", "%s", _\n', DraftType); 69 | fprintf(fid, '\t\t"CheckFaceFaceIntersection:=", false, _\n'); 70 | fprintf(fid, '\t\t"SweepVectorX:=", "%f%s", _\n', SweepVector(1), Units); 71 | fprintf(fid, '\t\t"SweepVectorY:=", "%f%s", _\n', SweepVector(2), Units); 72 | fprintf(fid, '\t\t"SweepVectorZ:=", "%f%s") \n', SweepVector(3), Units); -------------------------------------------------------------------------------- /3dmodeler/hfssSweepAroundAxis.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssSweepAroundAxis(fid, Object2D, Axis, SweepAngle, ... 3 | % [DraftAngle = 0 deg], [DraftType = 'Round']) 4 | % 5 | % Description: 6 | % ------------ 7 | % Creates the VB Script necessary to sweep a 2D object around the given axis 8 | % to create a 3D object. 9 | % 10 | % Parameters: 11 | % ----------- 12 | % fid - file identifier of the HFSS script file. 13 | % Object2D - name of the 2D Object to be sweeped. 14 | % Axis - axis around which Object2D is to be sweeped. 15 | % SweepAngle - angle (in *deg*) over which the object is to be sweeped. 16 | % DraftAngle - angle (in *deg*) to which the object's profile, or shape is 17 | % expanded (or contracted) as it is swept. 18 | % DraftType - set it to either 'Round' (default), 'Extended' or 'Natural' 19 | % (consult the HFSS Help for more info). 20 | % 21 | % ---------------------------------------------------------------------------- 22 | % ---------------------------------------------------------------------------- 23 | % This file is part of HFSS-MATLAB-API. 24 | % 25 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 26 | % under the terms of the GNU General Public License as published by the Free 27 | % Software Foundation; either version 2 of the License, or (at your option) 28 | % any later version. 29 | % 30 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 31 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 32 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 33 | % for more details. 34 | % 35 | % You should have received a copy of the GNU General Public License along with 36 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 37 | % Place, Suite 330, Boston, MA 02111-1307 USA 38 | % 39 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 40 | % ---------------------------------------------------------------------------- 41 | function hfssSweepAroundAxis(fid, Object, Axis, SweepAngle, ... 42 | DraftAngle, DraftType) 43 | 44 | % arguments processor. 45 | if (nargin < 4) 46 | error('Not enough arguments !'); 47 | elseif (nargin < 5) 48 | DraftAngle = 0; 49 | DraftType = 'Round'; 50 | elseif (nargin < 6) 51 | DraftType = 'Round'; 52 | end; 53 | 54 | % default arguments. 55 | if isempty(DraftAngle) 56 | DraftAngle = 0; 57 | end; 58 | if isempty(DraftType) 59 | DraftType = 'Round'; 60 | end; 61 | 62 | fprintf(fid, '\n'); 63 | 64 | fprintf(fid, 'oEditor.SweepAroundAxis _\n'); 65 | fprintf(fid, '\tArray("NAME:Selections", "Selections:=", "%s"), _\n', Object); 66 | fprintf(fid, '\tArray("NAME:AxisSweepParameters", _\n'); 67 | fprintf(fid, '\t\t"DraftAngle:=", "%fdeg", _\n', DraftAngle); 68 | fprintf(fid, '\t\t"DraftType:=", "%s", _\n', DraftType); 69 | fprintf(fid, '\t\t"SweepAxis:=", "%s", _\n', Axis); 70 | fprintf(fid, '\t\t"SweepAngle:=", "%fdeg")\n', SweepAngle); 71 | -------------------------------------------------------------------------------- /3dmodeler/hfssUnite.m: -------------------------------------------------------------------------------- 1 | 2 | function hfssUnite(fid, name1,name2) 3 | 4 | % Preamble. 5 | fprintf(fid, '\n'); 6 | fprintf(fid, 'oEditor.Unite _\n'); 7 | fprintf(fid, 'Array("NAME:Selections", _\n'); 8 | fprintf(fid, '"Selections:=", _\n'); 9 | fprintf(fid,'"%s,%s"), _\n',name1,name2); 10 | 11 | 12 | % Postamble. 13 | fprintf(fid, 'Array("NAME:UniteParameters", "KeepOriginals:=", false)\n'); 14 | 15 | -------------------------------------------------------------------------------- /3dmodeler/hfssUnite2.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssUnite(fid, varargin) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary for unite a given set of objects already 7 | % present in the HFSS 3D Modeler. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % varargin - names of the objects that need to be united. It can be specified 13 | % either as a single cell array of strings, or several individual 14 | % cell strings containing a single object name (see example ...) 15 | % 16 | % Note : 17 | % ------ 18 | % 19 | % Example : 20 | % --------- 21 | % fid = fopen('myantenna.vbs', 'wt'); 22 | % ... 23 | % % Method 1. 24 | % hfssUnite(fid, {'Object1', 'Object2', Object3'}); 25 | % % ... or Method 2. 26 | % hfssUnite(fid, {'Object1'}, {'Object2'}, {'Object3'}); 27 | % 28 | % ---------------------------------------------------------------------------- 29 | 30 | % ---------------------------------------------------------------------------- 31 | % This file is part of HFSS-MATLAB-API. 32 | % 33 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 34 | % under the terms of the GNU General Public License as published by the Free 35 | % Software Foundation; either version 2 of the License, or (at your option) 36 | % any later version. 37 | % 38 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 39 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 40 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41 | % for more details. 42 | % 43 | % You should have received a copy of the GNU General Public License along with 44 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 45 | % Place, Suite 330, Boston, MA 02111-1307 USA 46 | % 47 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 48 | % ---------------------------------------------------------------------------- 49 | 50 | function hfssUnite2(fid, n,name) 51 | 52 | % Preamble. 53 | fprintf(fid, '\n'); 54 | fprintf(fid, 'oEditor.Unite _\n'); 55 | fprintf(fid, 'Array("NAME:Selections", _\n'); 56 | fprintf(fid, '"Selections:=", _\n'); 57 | fprintf(fid,'"'); 58 | for i=1:n-1 59 | fprintf(fid,strcat(name,num2str(i),',')); 60 | end 61 | fprintf(fid,strcat(name,num2str(n),'"), _\n')); 62 | fprintf(fid, 'Array("NAME:UniteParameters", "KeepOriginals:=", false)\n'); 63 | 64 | -------------------------------------------------------------------------------- /3dmodeler/hfssdrawline.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/3dmodeler/hfssdrawline.m -------------------------------------------------------------------------------- /3dmodeler/hfssdrawline1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/3dmodeler/hfssdrawline1.m -------------------------------------------------------------------------------- /3dmodeler/hfssdrawline2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/3dmodeler/hfssdrawline2.m -------------------------------------------------------------------------------- /3dmodeler/hfssdrawline3.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/3dmodeler/hfssdrawline3.m -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | HFSS-MATLAB-SCRIPTING-API 2 | ========================= 3 | 4 | Introdution 5 | ----------- 6 | 7 | HFSS-MATLAB-API is a library toolbox to control Ansoft HFSS from MATLAB using 8 | the HFSS Scripting Interface. This tool provides a set of MATLAB functions to 9 | create 3D objects in HFSS by generating the required HFSS Scripts. Basically, 10 | anything that can be done in HFSS user interface and the 3D Modeler can be 11 | done with this library of functions. Once a script is generated in this 12 | manner, it can be run in HFSS to generate the 3D model, solve it and export 13 | the data. You create your entire design in MATLAB and basically use HFSS to 14 | solve it. 15 | 16 | Files: 17 | ------ 18 | All the files are organized in the following directories. 19 | 20 | 3dmodeler/ - contains m-files that generate VBScripts for the 3D-Modeler. 21 | analysis/ - contains m-files for Analysis (Setup/Solve/Export). 22 | boundary/ - contains m-files for setting up boundaries. 23 | doc/ - contains the HTML documentation. 24 | examples/ - contains example usage m-files. 25 | general/ - contains files for operations such as File Open/Save/Close, and 26 | Project Create/Save/Make Active etc., 27 | 28 | For questions and comments, please contact me. 29 | 30 | Author: 31 | ------- 32 | Vijay Ramasami, 33 | RSL, Univ. of Kansas, 34 | Lawrence, KS, 66046. 35 | E-Mail: rvijayc@gmail.com, rvc@ieee.org 36 | 37 | Author: 38 | ------- 39 | Wu Di, 40 | CN, ShangHai, 41 | E-Mail: woodybuendia@gmail.com, tinywoody@126.com 42 | -------------------------------------------------------------------------------- /README.asv: -------------------------------------------------------------------------------- 1 | HFSS-MATLAB-SCRIPTING-API 2 | ========================= 3 | 4 | Introdution 5 | ----------- 6 | 7 | HFSS-MATLAB-API is a library toolbox to control Ansoft HFSS from MATLAB using 8 | the HFSS Scripting Interface. This tool provides a set of MATLAB functions to 9 | create 3D objects in HFSS by generating the required HFSS Scripts. Basically, 10 | anything that can be done in HFSS user interface and the 3D Modeler can be 11 | done with this library of functions. Once a script is generated in this 12 | manner, it can be run in HFSS to generate the 3D model, solve it and export 13 | the data. You create your entire design in MATLAB and basically use HFSS to 14 | solve it. 15 | 16 | Files: 17 | ------ 18 | All the files are organized in the following directories. 19 | 20 | 3dmodeler/ - contains m-files that generate VBScripts for the 3D-Modeler. 21 | analysis/ - contains m-files for Analysis (Setup/Solve/Export). 22 | boundary/ - contains m-files for setting up boundaries. 23 | doc/ - contains the HTML documentation. 24 | examples/ - contains example usage m-files. 25 | general/ - contains files for operations such as File Open/Save/Close, and 26 | Project Create/Save/Make Active etc., 27 | 28 | For questions and comments, please contact me. 29 | 30 | Author: 31 | ------- 32 | Vijay Ramasami, 33 | RSL, Univ. of Kansas, 34 | Lawrence, KS, 66046. 35 | E-Mail: rvijayc@gmail.com, rvc@ieee.org 36 | 37 | Author: 38 | ------- 39 | Wu Di, 40 | Chan, Univ. of Kansas, 41 | Lawrence, KS, 66046. 42 | E-Mail: woodybuendia@gmail.com, tinywoody@126.com 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HFSS-MATLAB-SCRIPTING-API 2 | ========================= 3 | HFSS-MATLAB-API 使用教程 By WoodyBuendia 4 | http://woodybuendia.site/?p=155 5 | 根据HFSS 15版本帮助文件介绍,HFSS软件使用Microsoft®Visual Basic® Scripting Edition (VBScript)脚本语言记录宏指令。 6 | 7 | 一方面,在打开HFSS软件进行一些造作时,如果选择Tools——Record Script to file,新建一个.vbs后缀的脚本文件,可以将所有的操作记录在新建的脚本中;另一方面可以编写符合格式的脚本文件,通过Tools——Run Script来让HFSS软件运行编写好的脚本。 8 | 9 | 在一些特定的场景,事先编写脚本让HFSS执行相关操作,是非常高效和准确的,可以节省大量的重复性造作;不仅如此,在有些情况下,由于建模过于复杂或者模型变量需要通过第三方优化算法相互调用,那么只能使用编写脚本的方法才能完成。 10 | 11 | 在这个最简单的脚本中,可以看到即使是新建一个圆面的操作,需要的脚本也是比较多和复杂的,如果手动一行行敲入这些脚本代码,一方面过于冗长难免出现各种错误,另一方面也无法实现提高效率的初衷。 12 | 13 | 好在前辈们给出了一些简便的方法,可以将重复性的操作变成可以调用的函数,将需要指定的相关参数作为输入,通过相关编程语言自动完成vbs脚本文件。这些操作可以通过MATLAB或者Python完成,本文介绍的HFSS-MATLAB API就是通过MATLAB编写一套可调用的程序库,通过编写MATLAB代码来生成所需的vbs脚本。 14 | Introdution 15 | ----------- 16 | 17 | HFSS-MATLAB-API is a library toolbox to control Ansoft HFSS from MATLAB using 18 | the HFSS Scripting Interface. This tool provides a set of MATLAB functions to 19 | create 3D objects in HFSS by generating the required HFSS Scripts. Basically, 20 | anything that can be done in HFSS user interface and the 3D Modeler can be 21 | done with this library of functions. Once a script is generated in this 22 | manner, it can be run in HFSS to generate the 3D model, solve it and export 23 | the data. You create your entire design in MATLAB and basically use HFSS to 24 | solve it. 25 | 26 | Files: 27 | ------ 28 | All the files are organized in the following directories. 29 | 30 | 3dmodeler/ - contains m-files that generate VBScripts for the 3D-Modeler. 31 | analysis/ - contains m-files for Analysis (Setup/Solve/Export). 32 | boundary/ - contains m-files for setting up boundaries. 33 | doc/ - contains the HTML documentation. 34 | examples/ - contains example usage m-files. 35 | general/ - contains files for operations such as File Open/Save/Close, and 36 | Project Create/Save/Make Active etc., 37 | 38 | For questions and comments, please contact me. 39 | 40 | Author: 41 | ------- 42 | Vijay Ramasami, 43 | RSL, Univ. of Kansas, 44 | Lawrence, KS, 66046. 45 | E-Mail: rvijayc@gmail.com, rvc@ieee.org 46 | 47 | Author: 48 | ------- 49 | Wu Di, 50 | CN, ShangHai, 51 | E-Mail: woodybuendia@gmail.com, tinywoody@126.com 52 | -------------------------------------------------------------------------------- /Untitled.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/Untitled.m -------------------------------------------------------------------------------- /analysis/hfssAddOptVar.asv: -------------------------------------------------------------------------------- 1 | % add LocalVariables to Optimization 2 | % Example : 3 | % --------- 4 | %hfssAddOptVar(fid, {'length1','length2','length3',...}) 5 | %You should Use hfssaddVar to add Variables to design 6 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 7 | function hfssAddOptVar(fid, VarList, minList, maxList,Units) 8 | if iscell(VarList) == 0 9 | error('VarList should be a Cell!') 10 | else 11 | ListSize = size(VarList); 12 | if isvector(ListSize) == 0 13 | error('VarList should be One Dimenson!') 14 | end 15 | end 16 | 17 | VarNum = max(size(VarList)); 18 | 19 | fprintf(fid, '\n'); 20 | fprintf(fid, 'oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", _\n'); 21 | fprintf(fid, 'Array("NAME:PropServers", "LocalVariables"), Array("NAME:ChangedProps", _\n'); 22 | 23 | if VarNum ==1 24 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{1}); 25 | fprintf(fid, 'Array("NAME:Optimization", "Included:=", true))))) \n'); 26 | else 27 | for i = 1:VarNum-1 28 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{i}); 29 | fprintf(fid, 'Array("NAME:Optimization", "Included:=", true)), _\n'); 30 | end 31 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{VarNum}); 32 | fprintf(fid, 'Array("NAME:Optimization", "Included:=", true))))) \n'); 33 | end -------------------------------------------------------------------------------- /analysis/hfssAddOptVar.m: -------------------------------------------------------------------------------- 1 | % add LocalVariables to Optimization 2 | % Example : 3 | % --------- 4 | %hfssAddOptVar(fid, {'length1','length2','length3',...}) 5 | %You should Use hfssaddVar to add Variables to design 6 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 7 | function hfssAddOptVar(fid, VarList) 8 | if iscell(VarList) == 0 9 | error('VarList should be a Cell!') 10 | else 11 | ListSize = size(VarList); 12 | if isvector(ListSize) == 0 13 | error('VarList should be One Dimenson!') 14 | end 15 | end 16 | 17 | VarNum = max(size(VarList)); 18 | 19 | fprintf(fid, '\n'); 20 | fprintf(fid, 'oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", _\n'); 21 | fprintf(fid, 'Array("NAME:PropServers", "LocalVariables"), Array("NAME:ChangedProps", _\n'); 22 | 23 | for i = 1:VarNum-1 24 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{i}); 25 | fprintf(fid, 'Array("NAME:Optimization", "Included:=", true)), _\n'); 26 | end 27 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{VarNum}); 28 | fprintf(fid, 'Array("NAME:Optimization", "Included:=", true))))) \n'); 29 | 30 | end -------------------------------------------------------------------------------- /analysis/hfssCreateReport.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/analysis/hfssCreateReport.m -------------------------------------------------------------------------------- /analysis/hfssExportGain.m: -------------------------------------------------------------------------------- 1 | function hfssExportGain(fid, filename,setupName,planeName, freq) 2 | 3 | fprintf(fid, '\n'); 4 | fprintf(fid, 'Set oModule = oDesign.GetModule("ReportSetup") \n'); 5 | fprintf(fid, 'oModule.CreateReport "XY Plot 1", _\n'); 6 | fprintf(fid, '"Far Fields", _\n'); 7 | fprintf(fid, '"Rectangular Plot", _\n'); 8 | fprintf(fid, '"%s : LastAdaptive", _\n',setupName); 9 | fprintf(fid, 'Array("Context:=", "%s"), _\n', planeName); 10 | fprintf(fid, 'Array("Theta:=", _\n'); 11 | fprintf(fid, 'Array("All"), _\n'); 12 | fprintf(fid, '"Phi:=", Array("All"), _\n'); 13 | fprintf(fid, '"Freq:=", Array("%dGHz")), _\n',freq); 14 | fprintf(fid, 'Array("X Component:=", _\n'); 15 | fprintf(fid, '"Theta", _\n'); 16 | fprintf(fid, '"Y Component:=", Array("dB(GainTotal)")), _\n'); 17 | fprintf(fid, 'Array()\n'); 18 | fprintf(fid, 'oModule.ExportToFile "XY Plot 1", "I:/zzm/matlab/source/%s.csv"\n',filename); 19 | fprintf(fid, 'oProject.Save'); 20 | 21 | 22 | -------------------------------------------------------------------------------- /analysis/hfssExportNetworkData.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssExportNetworkData(fid, fileName, setupName, sweepName, ... 3 | % [expFileType], [renormZ]) 4 | % 5 | % Description : 6 | % ------------- 7 | % Creates the VB Script necessary for HFSS to export the current matrix data 8 | % (S, Z, f) into a data file. 9 | % 10 | % Parameters : 11 | % ------------ 12 | % fid - file identifier of the HFSS script file. 13 | % fileName - outdata data file name. 14 | % setupName - the name of the Solution Setup whose solution data needs to 15 | % be exported. 16 | % sweepName - the name of the Frequency Sweep whose solution data needs to 17 | % be exported. 18 | % [expFileType] - (optional), the output file format (the default is an 19 | % m-file). Specify as: 20 | % 'h' - HFSS 8.x format (.szg) 21 | % 't' - Tab delimited spreadsheet format (.tab) 22 | % 's' - Touchstone SnP format (.sNp) 23 | % 'c' - CitiFile (.cit) 24 | % 'm' - MATLAB File (.m ) - default. 25 | % 'z' - Terminal Z0 spreadsheet. 26 | % [renormZ] - (optional), the re-normalizing impedance (if different from 27 | % 50 Ohms). The default is (ofcourse) 50. 28 | % 29 | % Note : 30 | % ------ 31 | % 32 | % Example : 33 | % --------- 34 | % fid = fopen('myantenna.vbs', 'wt'); 35 | % ... 36 | % hfssExportNetworkData(fid, 'C:\temp\tempData.m', 'Setup150MHz', ... 37 | % 'Sweep100to200MHz', 'm', 75); 38 | % 39 | % ---------------------------------------------------------------------------- 40 | 41 | % ---------------------------------------------------------------------------- 42 | % This file is part of HFSS-MATLAB-API. 43 | % 44 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 45 | % under the terms of the GNU General Public License as published by the Free 46 | % Software Foundation; either version 2 of the License, or (at your option) 47 | % any later version. 48 | % 49 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 50 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 51 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 52 | % for more details. 53 | % 54 | % You should have received a copy of the GNU General Public License along with 55 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 56 | % Place, Suite 330, Boston, MA 02111-1307 USA 57 | % 58 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 59 | % ---------------------------------------------------------------------------- 60 | 61 | function hfssExportNetworkData(fid, fileName, setupName, sweepName, ... 62 | varargin) 63 | 64 | % Export File Type - default is MATLAB. 65 | if (length(varargin) > 0) 66 | expFileType = varargin{1}; 67 | else 68 | expFileType = 'm'; 69 | end; 70 | 71 | % Renormalizing Impedance. 72 | if (length(varargin) > 1) 73 | renormZ = varargin{2}; 74 | else 75 | renormZ = 50.0; 76 | end; 77 | 78 | % Export File Type Switch. 79 | switch (expFileType) 80 | case 'h', expType = 1; 81 | case 't', expType = 2; 82 | case 's', expType = 3; 83 | case 'c', expType = 4; 84 | case 'm', expType = 7; 85 | case 'z', expType = 8; 86 | otherwise, error('Export File Type Unknown !'); 87 | end; 88 | 89 | % The usual fprintf()'s 90 | fprintf(fid, '\n'); 91 | fprintf(fid, 'Set oModule = oDesign.GetModule("Solutions")\n'); 92 | fprintf(fid, 'oModule.ExportNetworkData _\n'); 93 | fprintf(fid, ' "", _\n'); 94 | fprintf(fid, ' Array("%s:%s"), _\n', setupName, sweepName); 95 | fprintf(fid, ' %d, _\n', expType); 96 | fprintf(fid, ' "%s", _\n', fileName); 97 | fprintf(fid, ' Array("All"), _\n'); 98 | fprintf(fid, ' true, _\n'); 99 | fprintf(fid, ' %.2f \n', renormZ); 100 | 101 | -------------------------------------------------------------------------------- /analysis/hfssExportRadiationParameters.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssExportRadiationParameters(fid, fileName, setupName, solutionName, freq) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary for HFSS to export the max quantities of a 7 | % near-field setup and,in the case of far fields,the antenna parameters to 8 | % the specified file. 9 | % 10 | % Parameters : 11 | % ------------ 12 | % fid - file identifier of the HFSS script file. 13 | % fileName - outdata data file name. 14 | % setupName - the name of the Radiation Setup whose solution data needs to 15 | % be exported. 16 | % solutionName - the name of the Solution Setup whose solution data needs to 17 | % be exported. 18 | % freq - the frequency of the design. 19 | % 20 | % Note : 21 | % ------ 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('myantenna.vbs', 'wt'); 26 | % ... 27 | % hfssExportNetworkData(fid, 'C:\temp\tempData.m', 'InfiniteSphere1', ... 28 | % 'horn500MHz', 0.1); 29 | % 30 | % ---------------------------------------------------------------------------- 31 | 32 | % ---------------------------------------------------------------------------- 33 | % This file is part of HFSS-MATLAB-API. 34 | % 35 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 36 | % under the terms of the GNU General Public License as published by the Free 37 | % Software Foundation; either version 2 of the License, or (at your option) 38 | % any later version. 39 | % 40 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 41 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 42 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43 | % for more details. 44 | % 45 | % You should have received a copy of the GNU General Public License along with 46 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 47 | % Place, Suite 330, Boston, MA 02111-1307 USA 48 | % 49 | % Copyright 2007, YueLiang (yue_liang423@163.com) 50 | % ---------------------------------------------------------------------------- 51 | 52 | function hfssExportRadiationParameters(fid, fileName, setupName, solutionName, freq) 53 | 54 | fprintf(fid, '\n'); 55 | fprintf(fid, 'Set oModule = oDesign.GetModule("RadField") \n'); 56 | fprintf(fid, 'oModule.ExportRadiationParametersToFile _\n'); 57 | fprintf(fid, 'Array("ExportFileName:=", _\n'); 58 | fprintf(fid, ' "%s", _\n', fileName); 59 | fprintf(fid, ' "SetupName:=", "%s", _\n', setupName); 60 | fprintf(fid, ' "IntrinsicVariationKey:=", "Freq=''%fGHz''", _\n', freq); 61 | fprintf(fid, ' "DesignVariationKey:=", "", _\n'); 62 | fprintf(fid, ' "SolutionName:=", "%s") \n', solutionName); 63 | 64 | 65 | -------------------------------------------------------------------------------- /analysis/hfssExportReport.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssExportReport(fid, designName, reportName, fileName) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary for HFSS to From a data table or plot, 7 | % generates text format, comma delimited, tab delimited, or .dat type output 8 | % files. 9 | % 10 | % Parameters : 11 | % ------------ 12 | % fid - file identifier of the HFSS script file. 13 | % designName- the name of active design. 14 | % reportName- the name of report 15 | % fileName - outdata data file name. 16 | % 17 | % Note : 18 | % ------ 19 | % 20 | % Example : 21 | % --------- 22 | % fid = fopen('myantenna.vbs', 'wt'); 23 | % ... 24 | % hfssExportNetworkData(fid, 'HFSSModel1', 'plot1', 'c:\temp\report1.dat'); 25 | % 26 | % ---------------------------------------------------------------------------- 27 | 28 | % ---------------------------------------------------------------------------- 29 | % This file is part of HFSS-MATLAB-API. 30 | % 31 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 32 | % under the terms of the GNU General Public License as published by the Free 33 | % Software Foundation; either version 2 of the License, or (at your option) 34 | % any later version. 35 | % 36 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 37 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 38 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39 | % for more details. 40 | % 41 | % You should have received a copy of the GNU General Public License along with 42 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 43 | % Place, Suite 330, Boston, MA 02111-1307 USA 44 | % 45 | % Copyright 2007, YueLiang (yue_liang423@163.com) 46 | % ---------------------------------------------------------------------------- 47 | 48 | function hfssExportReport(fid, designName, reportName, fileName) 49 | 50 | fprintf(fid, '\n'); 51 | fprintf(fid, 'Set oDesign = oProject.SetActiveDesign("%s") \n', designName); 52 | fprintf(fid, 'oDesign.ExportReport "%s", "%s" \n', reportName, fileName); -------------------------------------------------------------------------------- /analysis/hfssExportToFile.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssExportToFile(fid, reportName, fileName) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary for HFSS to From a data table or plot, 7 | % generates text format, comma delimited, tab delimited, or .dat type output 8 | % files. 9 | % 10 | % Parameters : 11 | % ------------ 12 | % fid - file identifier of the HFSS script file. 13 | % reportName- the name of report 14 | % fileName - outdata data file name. 15 | % 16 | % Note : 17 | % ------ 18 | % 19 | % Example : 20 | % --------- 21 | % fid = fopen('myantenna.vbs', 'wt'); 22 | % ... 23 | % hfssExportNetworkData(fid, 'HFSSModel1', 'plot1', 'c:\temp\report1.dat'); 24 | % 25 | % ---------------------------------------------------------------------------- 26 | 27 | % ---------------------------------------------------------------------------- 28 | % This file is part of HFSS-MATLAB-API. 29 | % 30 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 31 | % under the terms of the GNU General Public License as published by the Free 32 | % Software Foundation; either version 2 of the License, or (at your option) 33 | % any later version. 34 | % 35 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 36 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38 | % for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License along with 41 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 42 | % Place, Suite 330, Boston, MA 02111-1307 USA 43 | % 44 | % Copyright 2008, YueLiang (yue_liang423@163.com) 45 | % ------------------------------------------------------------------------- 46 | % --- 47 | 48 | function hfssExportToFile(fid, reportName, fileName_Path) 49 | fprintf(fid, '\n'); 50 | fprintf(fid,'Set oModule = oDesign.GetModule("ReportSetup") \n'); 51 | fprintf(fid, 'oModule.ExportToFile _\n'); 52 | fprintf(fid, '"%s", _\n', reportName); 53 | fprintf(fid, '"%s" \n', fileName_Path); -------------------------------------------------------------------------------- /analysis/hfssFarField.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssBox(fid, Name, Start, Size, Units, [Center1], [Radius1], ... 3 | % [Axis1], [Center2], [Radius2], [Axis2], ...) 4 | % 5 | % Description : 6 | % ------------- 7 | % Create the VB Script necessary to create a Box (or Cuboid) in HFSS. This 8 | % function also provides for optional holes (specified by their Center, 9 | % Radii and Axes) in the box. This feature is useful to allow things like 10 | % vias, cables etc., to penetrate the box without intersection violations. 11 | % 12 | % Parameters : 13 | % ------------ 14 | % fid - file identifier of the HFSS script file. 15 | % Name - name of the box (appears in HFSS). 16 | % Start - starting location of the box (specify as [x, y, z]). 17 | % Size - size of the box (specify as [sx, sy, sz]). 18 | % Units - units of the box (specify using either 'in', 'mm', 'meter' or 19 | % anything else defined in HFSS). 20 | % Center - (Optional) center of the hole to be punched through the box. 21 | % It can lie anywhere within or on the surface of the box. 22 | % Radius - (Optional) radius of the hole to be punched through the box. 23 | % Axis - (Optional) axis of the hole to be punched through the box. 24 | % 25 | % Note : 26 | % ------ 27 | % If you happen to specify a hole that lies outside the box, it will have 28 | % no effect. The script will run without interruption. 29 | % 30 | % Example : 31 | % --------- 32 | % fid = fopen('myantenna.vbs', 'wt'); 33 | % ... 34 | % % a Box with 2 holes punched thro' it. 35 | % hfssBox(fid, 'FR4_Base', [-bpHeight/2, -baseLength/2, 0], [bpHeight, ... 36 | % baseLength, -baseThick], 'in', [cX1, cY1, cZ1], R1, 'Z',... 37 | % [cX2, cY2, cZ2], R2, 'X'); 38 | % 39 | % ---------------------------------------------------------------------------- 40 | 41 | % ---------------------------------------------------------------------------- 42 | % This file is part of HFSS-MATLAB-API. 43 | % 44 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 45 | % under the terms of the GNU General Public License as published by the Free 46 | % Software Foundation; either version 2 of the License, or (at your option) 47 | % any later version. 48 | % 49 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 50 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 51 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 52 | % for more details. 53 | % 54 | % You should have received a copy of the GNU General Public License along with 55 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 56 | % Place, Suite 330, Boston, MA 02111-1307 USA 57 | % 58 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 59 | % ---------------------------------------------------------------------------- 60 | function hfssFarField(fid, Name, Starttheta, Stoptheta,Steptheta,Startphi,Stopphi,Stepphi, Units) 61 | 62 | % Preamble. 63 | fprintf(fid, '\n'); 64 | fprintf(fid, 'Set oModule = oDesign.GetModule("RadField")\n'); 65 | 66 | % Box Parameters. 67 | fprintf(fid, 'oModule.InsertFarFieldSphereSetup _\n'); 68 | fprintf(fid, 'Array("NAME:%s", _\n',Name); 69 | fprintf(fid, '"UseCustomRadiationSurface:=", _\n'); 70 | fprintf(fid, ' false, _\n'); 71 | fprintf(fid, '"ThetaStart:=", "%d%s", _\n',Starttheta,Units); 72 | fprintf(fid, '"ThetaStop:=", "%d%s", _\n', Stoptheta, Units); 73 | fprintf(fid, '"ThetaStep:=", "%d%s", _\n', Steptheta, Units); 74 | 75 | % Box Attributes. 76 | fprintf(fid, '"PhiStart:=", "%d%s", _\n',Startphi,Units); 77 | fprintf(fid, '"PhiStop:=", "%d%s", _\n', Stopphi,Units); 78 | fprintf(fid, '"PhiStep:=", "%d%s", _\n',Stepphi,Units); 79 | fprintf(fid, '"UseLocalCS:=", false)\n'); 80 | 81 | 82 | -------------------------------------------------------------------------------- /analysis/hfssFarFieldSphere.asv: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssFarFieldSphere(fid, Name, TStart, TStop, TStep, PStart, PStop, PStep) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB script to creats/inserts a far-field infinite sphere 7 | % radiation setup. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % SetupName - name of the setup to be solved. 13 | % TStart - the start degree of theta 14 | % TStop - the stop degree of theta 15 | % TStep - the step of degree 16 | % PStart - the start degree of phi 17 | % PStop - the stop degree of phi 18 | % PStep - the step of phi 19 | % Note : 20 | % ------ 21 | % 22 | % Example : 23 | % --------- 24 | % fid = fopen('myantenna.vbs', 'wt'); 25 | % ... 26 | % hfssFarFieldSphere(fid, 'FFSphere', -180, 180, 2, 0, 360, 2); 27 | % ---------------------------------------------------------------------------- 28 | 29 | % ---------------------------------------------------------------------------- 30 | % This file is part of HFSS-MATLAB-API. 31 | % 32 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 33 | % under the terms of the GNU General Public License as published by the Free 34 | % Software Foundation; either version 2 of the License, or (at your option) 35 | % any later version. 36 | % 37 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 38 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 39 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40 | % for more details. 41 | % 42 | % You should have received a copy of the GNU General Public License along with 43 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 44 | % Place, Suite 330, Boston, MA 02111-1307 USA 45 | % 46 | % Copyright 2007, YueLiang (yue_liang423@163.com) 47 | %add UseLocalCS, don't use local CS is default whe 48 | % ---------------------------------------------------------------------------- 49 | 50 | function hfssFarFieldSphere(fid, Name, TStart, TStop, TStep, PStart, PStop, PStep,CSName) 51 | if nargin < 9 52 | UseLocalCS = 0; 53 | else 54 | UseLocalCS = 1; 55 | end 56 | fprintf(fid, '\n'); 57 | fprintf(fid, 'Set oModule = oDesign.GetModule("RadField") \n'); 58 | fprintf(fid, 'oModule.InsertFarFieldSphereSetup _\n'); 59 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 60 | fprintf(fid, '"UseCustomRadiationSurface:=", false, _\n'); 61 | fprintf(fid, '"ThetaStart:=", "%ddeg", _\n', TStart); 62 | fprintf(fid, '"ThetaStop:=", "%ddeg", _\n', TStop); 63 | fprintf(fid, '"ThetaStep:=", "%ddeg", _\n', TStep); 64 | fprintf(fid, '"PhiStart:=", "%ddeg", _\n', PStart); 65 | fprintf(fid, '"PhiStop:=", "%ddeg", _\n', PStop); 66 | fprintf(fid, '"PhiStep:=", "%ddeg", _\n', PStep); 67 | if UseLocalCS == 0 68 | fprintf(fid, '"UseLocalCS:=", false) \n'); 69 | else 70 | fprintf(fid, '"UseLocalCS:=", true, _\n'); 71 | fprintf(fid, '"CoordSystem:=", "%s")', CSName); 72 | end 73 | 74 | -------------------------------------------------------------------------------- /analysis/hfssFarFieldSphere.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssFarFieldSphere(fid, Name, TStart, TStop, TStep, PStart, PStop, PStep) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB script to creats/inserts a far-field infinite sphere 7 | % radiation setup. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % SetupName - name of the setup to be solved. 13 | % TStart - the start degree of theta 14 | % TStop - the stop degree of theta 15 | % TStep - the step of degree 16 | % PStart - the start degree of phi 17 | % PStop - the stop degree of phi 18 | % PStep - the step of phi 19 | % Note : 20 | % ------ 21 | % 22 | % Example : 23 | % --------- 24 | % fid = fopen('myantenna.vbs', 'wt'); 25 | % ... 26 | % hfssFarFieldSphere(fid, 'FFSphere', -180, 180, 2, 0, 360, 2); 27 | % ---------------------------------------------------------------------------- 28 | 29 | % ---------------------------------------------------------------------------- 30 | % This file is part of HFSS-MATLAB-API. 31 | % 32 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 33 | % under the terms of the GNU General Public License as published by the Free 34 | % Software Foundation; either version 2 of the License, or (at your option) 35 | % any later version. 36 | % 37 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 38 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 39 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40 | % for more details. 41 | % 42 | % You should have received a copy of the GNU General Public License along with 43 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 44 | % Place, Suite 330, Boston, MA 02111-1307 USA 45 | % 46 | % Copyright 2007, YueLiang (yue_liang423@163.com) 47 | %add UseLocalCS, don't use local CS is default when no input CSName 48 | % ---------------------------------------------------------------------------- 49 | 50 | function hfssFarFieldSphere(fid, Name, TStart, TStop, TStep, PStart, PStop, PStep,CSName) 51 | if nargin < 9 52 | UseLocalCS = 0; 53 | else 54 | UseLocalCS = 1; 55 | end 56 | fprintf(fid, '\n'); 57 | fprintf(fid, 'Set oModule = oDesign.GetModule("RadField") \n'); 58 | fprintf(fid, 'oModule.InsertFarFieldSphereSetup _\n'); 59 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 60 | fprintf(fid, '"UseCustomRadiationSurface:=", false, _\n'); 61 | fprintf(fid, '"ThetaStart:=", "%ddeg", _\n', TStart); 62 | fprintf(fid, '"ThetaStop:=", "%ddeg", _\n', TStop); 63 | fprintf(fid, '"ThetaStep:=", "%ddeg", _\n', TStep); 64 | fprintf(fid, '"PhiStart:=", "%ddeg", _\n', PStart); 65 | fprintf(fid, '"PhiStop:=", "%ddeg", _\n', PStop); 66 | fprintf(fid, '"PhiStep:=", "%ddeg", _\n', PStep); 67 | if UseLocalCS == 0 68 | fprintf(fid, '"UseLocalCS:=", false) \n'); 69 | else 70 | fprintf(fid, '"UseLocalCS:=", true, _\n'); 71 | fprintf(fid, '"CoordSystem:=", "%s")', CSName); 72 | end 73 | 74 | -------------------------------------------------------------------------------- /analysis/hfssInsertSolution.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssInsertSolution(fid, Name, fGHz, [maxDeltaS = 0.02], 3 | % [maxPass = 25]) 4 | % 5 | % Description : 6 | % ------------- 7 | % Creates the VBScript necessary to insert a Solution Setup in HFSS. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the solution setup. 13 | % fGHz - solution frequency (in GHz). 14 | % maxError - maximum error that can be tolerated (should be between 0 and 1, 15 | % default is 0.02). 16 | % maxPasses - max # of passes to be run before the simulation is declared 17 | % as 'did not converge' (default is 25). 18 | % 19 | % Note : 20 | % ------ 21 | % 22 | % Example : 23 | % --------- 24 | % fid = fopen('myantenna.vbs', 'wt'); 25 | % ... 26 | % hfssInsertSolution(fid, 'Setup750MHz', 0.75, 0.01, 100); 27 | % ---------------------------------------------------------------------------- 28 | 29 | % ---------------------------------------------------------------------------- 30 | % This file is part of HFSS-MATLAB-API. 31 | % 32 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 33 | % under the terms of the GNU General Public License as published by the Free 34 | % Software Foundation; either version 2 of the License, or (at your option) 35 | % any later version. 36 | % 37 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 38 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 39 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40 | % for more details. 41 | % 42 | % You should have received a copy of the GNU General Public License along with 43 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 44 | % Place, Suite 330, Boston, MA 02111-1307 USA 45 | % 46 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 47 | % ---------------------------------------------------------------------------- 48 | function hfssInsertSolution(fid, Name, fGHz, maxDeltaS, maxPass) 49 | 50 | % arguments processor. 51 | if (nargin < 3) 52 | error('Insufficient number of arguments !'); 53 | elseif (nargin < 4) 54 | maxDeltaS = []; 55 | maxPass = []; 56 | elseif (nargin < 5) 57 | maxPass = []; 58 | end; 59 | 60 | % defaults processing. 61 | if isempty(maxDeltaS) 62 | maxDeltaS = 0.02; 63 | end; 64 | if isempty(maxPass) 65 | maxPass = 25; 66 | end; 67 | 68 | % create the necessary script. 69 | fprintf(fid, '\n'); 70 | fprintf(fid, 'Set oModule = oDesign.GetModule("AnalysisSetup")\n'); 71 | fprintf(fid, 'oModule.InsertSetup "HfssDriven", _\n'); 72 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 73 | fprintf(fid, '"Frequency:=", "%fGHz", _\n', fGHz); 74 | fprintf(fid, '"PortsOnly:=", false, _\n'); 75 | fprintf(fid, '"maxDeltaS:=", %f, _\n', maxDeltaS); 76 | fprintf(fid, '"UseMatrixConv:=", false, _\n'); 77 | fprintf(fid, '"MaximumPasses:=", %d, _\n', maxPass); 78 | fprintf(fid, '"MinimumPasses:=", 1, _\n'); 79 | fprintf(fid, '"MinimumConvergedPasses:=", 1, _\n'); 80 | fprintf(fid, '"PercentRefinement:=", 20, _\n'); 81 | fprintf(fid, '"ReducedSolutionBasis:=", false, _\n'); 82 | fprintf(fid, '"DoLambdaRefine:=", true, _\n'); 83 | fprintf(fid, '"DoMaterialLambda:=", true, _\n'); 84 | fprintf(fid, '"Target:=", 0.3333, _\n'); 85 | fprintf(fid, '"PortAccuracy:=", 2, _\n'); 86 | fprintf(fid, '"SetPortMinMaxTri:=", false)\n'); 87 | 88 | -------------------------------------------------------------------------------- /analysis/hfssInterpolatingSweep.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssInterpolatingSweep(fid, Name, SolutionName, fStartGHz, ... 3 | % fStopGHz, [nPoints = 1000], [nMaxSols = 101], 4 | % [iTol = 0.5]) 5 | % 6 | % Description : 7 | % ------------- 8 | % Create the VB Script necessary to add an interpolating sweep to an existing 9 | % solution. 10 | % 11 | % Parameters : 12 | % ------------ 13 | % fid - file identifier of the HFSS script file. 14 | % Name - name of the interpolating sweep. 15 | % SolutionName - name of the solution to which this interpolating sweep needs 16 | % to be added. 17 | % fStartGHz - starting frequency of sweep in GHz. 18 | % fStopGHz - stop frequency of sweep in GHz. 19 | % nPoints - # of output points (defaults to 1000). 20 | % nMaxSols - max # of interpolating points that need to be solved (more 21 | % points will guarentee convergence) - defaults to 101. 22 | % iTol - interpolation tolerance (defaults to 0.5). 23 | % 24 | % Note : 25 | % ------ 26 | % 27 | % Example : 28 | % --------- 29 | % fid = fopen('myantenna.vbs', 'wt'); 30 | % ... 31 | % hfssInterpolatingSweep(fid, 'Interp600to900MHz', 'Solve750MHz', 0.6, ... 32 | % 0.9, 1000, 101, 0.5); 33 | % 34 | % ---------------------------------------------------------------------------- 35 | 36 | % ---------------------------------------------------------------------------- 37 | % This file is part of HFSS-MATLAB-API. 38 | % 39 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 40 | % under the terms of the GNU General Public License as published by the Free 41 | % Software Foundation; either version 2 of the License, or (at your option) 42 | % any later version. 43 | % 44 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 45 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 46 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47 | % for more details. 48 | % 49 | % You should have received a copy of the GNU General Public License along with 50 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 51 | % Place, Suite 330, Boston, MA 02111-1307 USA 52 | % 53 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 54 | % ---------------------------------------------------------------------------- 55 | 56 | function hfssInterpolatingSweep(fid, Name, SolutionName, fStartGHz, ... 57 | fStopGHz, nPoints, nMaxSols, iTol) 58 | 59 | % arguments processor. 60 | if (nargin < 5) 61 | error('Insufficient # of arguments'); 62 | elseif (nargin < 6) 63 | nPoints = []; 64 | nMaxSols = []; 65 | iTol = []; 66 | elseif (nargin < 7) 67 | nMaxSols = []; 68 | iTol = []; 69 | elseif (nargin < 8) 70 | iTol = []; 71 | end; 72 | 73 | % process default arguments. 74 | if isempty(nPoints) 75 | nPoints = 1000; 76 | end; 77 | if isempty(nMaxSols) 78 | nMaxSols = 101; 79 | end; 80 | if isempty(iTol) 81 | iTol = 0.5; 82 | end; 83 | 84 | % create script. 85 | fprintf(fid, '\n'); 86 | fprintf(fid, 'Set oModule = oDesign.GetModule("AnalysisSetup")\n'); 87 | 88 | fprintf(fid, 'oModule.InsertDrivenSweep _\n'); 89 | fprintf(fid, '"%s", _\n', SolutionName); 90 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 91 | fprintf(fid, '"Type:=", "Interpolating", _\n'); 92 | fprintf(fid, '"InterpTolerance:=", %f, _\n', iTol); 93 | fprintf(fid, '"InterpMaxSolns:=", %d, _\n', nMaxSols); 94 | fprintf(fid, '"SetupType:=", "LinearCount", _\n'); 95 | fprintf(fid, '"StartFreq:=", "%fGHz", _\n', fStartGHz); 96 | fprintf(fid, '"StopFreq:=", "%fGHz", _\n', fStopGHz); 97 | fprintf(fid, '"Count:=", %d, _\n', nPoints); 98 | fprintf(fid, '"SaveFields:=", false, _\n'); 99 | fprintf(fid, '"ExtrapToDC:=", false)\n'); 100 | -------------------------------------------------------------------------------- /analysis/hfssSolveSetup.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssSolveSetup(fid, SetupName) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB script to solve a given solution setup. 7 | % 8 | % Parameters : 9 | % ------------ 10 | % fid - file identifier of the HFSS script file. 11 | % SetupName - name of the setup to be solved. 12 | % 13 | % Note : 14 | % ------ 15 | % 16 | % Example : 17 | % --------- 18 | % fid = fopen('myantenna.vbs', 'wt'); 19 | % ... 20 | % hfssSolveSetup(fid, 'Setup750MHz'); 21 | % ---------------------------------------------------------------------------- 22 | 23 | % ---------------------------------------------------------------------------- 24 | % This file is part of HFSS-MATLAB-API. 25 | % 26 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 27 | % under the terms of the GNU General Public License as published by the Free 28 | % Software Foundation; either version 2 of the License, or (at your option) 29 | % any later version. 30 | % 31 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 32 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 33 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34 | % for more details. 35 | % 36 | % You should have received a copy of the GNU General Public License along with 37 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 38 | % Place, Suite 330, Boston, MA 02111-1307 USA 39 | % 40 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 41 | % ---------------------------------------------------------------------------- 42 | 43 | function hfssSolveSetup(fid, SetupName) 44 | 45 | fprintf(fid, '\n'); 46 | fprintf(fid, 'oDesign.Solve _\n'); 47 | fprintf(fid, ' Array("%s") \n', SetupName); 48 | -------------------------------------------------------------------------------- /batch.log: -------------------------------------------------------------------------------- 1 | 2 | Ansoft HFSS Version 14.0.0, Build: 2011-10-22 21:03:32 3 | Location: D:\program\hfss\HFSS14.0\Win64\hfss.exe 4 | Non Graphical Mode: No Project?? 5 | Starting Batch Run: 10:08:08 下午 9月 13, 2013 6 | Running as user: zzm\cuc-zzm 7 | Temp directory: C:\Users\cuc-zzm\AppData\Local\Temp 8 | Project directory: C:\Users\cuc-zzm\Documents\Ansoft 9 | [warning] Unable to find script file E:/my_conicalhorn_3.6GHz.vbs. 10 | -------------------------------------------------------------------------------- /boundary/hfssAssignPE.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignPE(fid, Name, ObjectList, [infGND = false]) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VB Script necessary to assign a PEC boundary to 7 | % the given object(s). 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the PEC boundary. This will appear under "Boundaries" 13 | % in HFSS 14 | % ObjList - a cell array of objects to which the PEC boundary condition will 15 | % be applied. 16 | % infGND - (boolean) specify as true to make the PEC represent an infinite 17 | % ground plane (default is false). 18 | % 19 | % 20 | % Note : 21 | % ------ 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('myantenna.vbs', 'wt'); 26 | % ... 27 | % hfssAssignPE(fid, 'GNDplane', {'AntennaGND'}, true); 28 | % 29 | % ---------------------------------------------------------------------------- 30 | 31 | % ---------------------------------------------------------------------------- 32 | % This file is part of HFSS-MATLAB-API. 33 | % 34 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 35 | % under the terms of the GNU General Public License as published by the Free 36 | % Software Foundation; either version 2 of the License, or (at your option) 37 | % any later version. 38 | % 39 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 40 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 41 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42 | % for more details. 43 | % 44 | % You should have received a copy of the GNU General Public License along with 45 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 46 | % Place, Suite 330, Boston, MA 02111-1307 USA 47 | % 48 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 49 | % ---------------------------------------------------------------------------- 50 | 51 | function hfssAssignPE(fid, Name, ObjectList, infGND) 52 | 53 | % arguments processor. 54 | if (nargin < 3) 55 | error('Insufficient # of arguments !'); 56 | elseif (nargin < 4) 57 | infGND = []; 58 | end; 59 | 60 | % default arguments. 61 | if isempty(infGND) 62 | infGND = false; 63 | end; 64 | 65 | % # of objects. 66 | nObjects = length(ObjectList); 67 | 68 | % create the necessary script. 69 | fprintf(fid, '\n'); 70 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup")\n'); 71 | fprintf(fid, 'oModule.AssignPerfectE _\n'); 72 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 73 | 74 | % is infinite GND ? 75 | if (infGND) 76 | fprintf(fid, '"InfGroundPlane:=", true, _\n'); 77 | else 78 | fprintf(fid, '"InfGroundPlane:=", false, _\n'); 79 | end; 80 | 81 | fprintf(fid, '"Objects:=", _\n'); 82 | fprintf(fid, 'Array('); 83 | for iObj = 1:nObjects, 84 | fprintf(fid, '"%s"', ObjectList{iObj}); 85 | if (iObj ~= nObjects) 86 | fprintf(fid, ','); 87 | end; 88 | end; 89 | fprintf(fid, '))\n'); 90 | -------------------------------------------------------------------------------- /boundary/hfssAssignPE_face.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignPE_face(fid, Name, FIDList, [infGND = false]) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VB Script necessary to assign a PEC boundary to 7 | % the given object(s). 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the PEC boundary. This will appear under "Boundaries" 13 | % in HFSS 14 | % FIDList - a array of faces to which the PEC boundary condition will 15 | % be applied. 16 | % infGND - (boolean) specify as true to make the PEC represent an infinite 17 | % ground plane (default is false). 18 | % 19 | % 20 | % Note : 21 | % ------ 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('myantenna.vbs', 'wt'); 26 | % ... 27 | % hfssAssignPE_face(fid, 'GNDplane', [7,8], true); 28 | % 29 | % ---------------------------------------------------------------------------- 30 | 31 | % ---------------------------------------------------------------------------- 32 | % This file is part of HFSS-MATLAB-API. 33 | % 34 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 35 | % under the terms of the GNU General Public License as published by the Free 36 | % Software Foundation; either version 2 of the License, or (at your option) 37 | % any later version. 38 | % 39 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 40 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 41 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42 | % for more details. 43 | % 44 | % You should have received a copy of the GNU General Public License along with 45 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 46 | % Place, Suite 330, Boston, MA 02111-1307 USA 47 | % 48 | % Copyright 2007, YueLiang (yue_liang423@163.com) 49 | % ---------------------------------------------------------------------------- 50 | 51 | function hfssAssignPE_face(fid, Name, FIDList, infGND) 52 | 53 | % arguments processor. 54 | if (nargin < 3) 55 | error('Insufficient # of arguments !'); 56 | elseif (nargin < 4) 57 | infGND = []; 58 | end; 59 | 60 | % default arguments. 61 | if isempty(infGND) 62 | infGND = false; 63 | end; 64 | 65 | % # of objects. 66 | nFaces = length(FIDList); 67 | 68 | % create the necessary script. 69 | fprintf(fid, '\n'); 70 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup")\n'); 71 | fprintf(fid, 'oModule.AssignPerfectE _\n'); 72 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 73 | 74 | fprintf(fid, '"Faces:=", _\n'); 75 | fprintf(fid, 'Array('); 76 | for iF = 1:nFaces, 77 | fprintf(fid, '%d', FIDList(iF)); 78 | if (iF ~= nFaces) 79 | fprintf(fid, ','); 80 | end; 81 | end; 82 | fprintf(fid, '), _\n'); 83 | 84 | % is infinite GND ? 85 | if (infGND) 86 | fprintf(fid, '"InfGroundPlane:=", true) \n'); 87 | else 88 | fprintf(fid, '"InfGroundPlane:=", false) \n'); 89 | end; -------------------------------------------------------------------------------- /boundary/hfssAssignPH.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignPE(fid, Name, ObjectList, [infGND = false]) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VB Script necessary to assign a PEC boundary to 7 | % the given object(s). 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the PEC boundary. This will appear under "Boundaries" 13 | % in HFSS 14 | % ObjList - a cell array of objects to which the PEC boundary condition will 15 | % be applied. 16 | % infGND - (boolean) specify as true to make the PEC represent an infinite 17 | % ground plane (default is false). 18 | % 19 | % 20 | % Note : 21 | % ------ 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('myantenna.vbs', 'wt'); 26 | % ... 27 | % hfssAssignPE(fid, 'GNDplane', {'AntennaGND'}, true); 28 | % 29 | % ---------------------------------------------------------------------------- 30 | 31 | % ---------------------------------------------------------------------------- 32 | % This file is part of HFSS-MATLAB-API. 33 | % 34 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 35 | % under the terms of the GNU General Public License as published by the Free 36 | % Software Foundation; either version 2 of the License, or (at your option) 37 | % any later version. 38 | % 39 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 40 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 41 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42 | % for more details. 43 | % 44 | % You should have received a copy of the GNU General Public License along with 45 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 46 | % Place, Suite 330, Boston, MA 02111-1307 USA 47 | % 48 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 49 | % ---------------------------------------------------------------------------- 50 | 51 | function hfssAssignPH(fid, Name, ObjectList, infGND) 52 | 53 | % arguments processor. 54 | if (nargin < 3) 55 | error('Insufficient # of arguments !'); 56 | elseif (nargin < 4) 57 | infGND = []; 58 | end; 59 | 60 | % default arguments. 61 | if isempty(infGND) 62 | infGND = false; 63 | end; 64 | 65 | % # of objects. 66 | nObjects = length(ObjectList); 67 | 68 | % create the necessary script. 69 | fprintf(fid, '\n'); 70 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup")\n'); 71 | fprintf(fid, 'oModule.AssignPerfectH _\n'); 72 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 73 | 74 | % is infinite GND ? 75 | if (infGND) 76 | fprintf(fid, '"InfGroundPlane:=", true, _\n'); 77 | else 78 | fprintf(fid, '"InfGroundPlane:=", false, _\n'); 79 | end; 80 | 81 | fprintf(fid, '"Objects:=", _\n'); 82 | fprintf(fid, 'Array('); 83 | for iObj = 1:nObjects, 84 | fprintf(fid, '"%s"', ObjectList{iObj}); 85 | if (iObj ~= nObjects) 86 | fprintf(fid, ','); 87 | end; 88 | end; 89 | fprintf(fid, '))\n'); 90 | -------------------------------------------------------------------------------- /boundary/hfssAssignRadiation.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignRadiation(fid, Name, Object) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to assign the radiation boundary condition 7 | % to a (closed) Object. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the radiation boundary condition (under HFSS). 13 | % Object - object to which the radiation boundary conditions needs to be 14 | % applied. 15 | % 16 | % Note : 17 | % ------ 18 | % This function cannot be used to apply radiation boundary conditions to 19 | % individual faces of an object. 20 | % 21 | % Example : 22 | % --------- 23 | % fid = fopen('myantenna.vbs', 'wt'); 24 | % ... 25 | % hfssAssignRadiation(fid, 'ABC', 'AirBox'); 26 | % ---------------------------------------------------------------------------- 27 | 28 | % ---------------------------------------------------------------------------- 29 | % This file is part of HFSS-MATLAB-API. 30 | % 31 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 32 | % under the terms of the GNU General Public License as published by the Free 33 | % Software Foundation; either version 2 of the License, or (at your option) 34 | % any later version. 35 | % 36 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 37 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 38 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39 | % for more details. 40 | % 41 | % You should have received a copy of the GNU General Public License along with 42 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 43 | % Place, Suite 330, Boston, MA 02111-1307 USA 44 | % 45 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 46 | % ---------------------------------------------------------------------------- 47 | 48 | 49 | function hfssAssignRadiation(fid, Name, BoxObject) 50 | 51 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup")\n'); 52 | fprintf(fid, 'oModule.AssignRadiation _\n'); 53 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 54 | fprintf(fid, '"Objects:=", Array("%s"))\n', BoxObject); 55 | -------------------------------------------------------------------------------- /boundary/hfssAssignRadiation_face.asv: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignRadiation_face(fid, Name, FIDList) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VB Script necessary to assign a PEC boundary to 7 | % the given object(s). 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the Radiation boundary. This will appear under "Boundaries" 13 | % in HFSS 14 | % FIDList - a array of faces to which the Radiation boundary condition will 15 | % be applied. 16 | % 17 | % 18 | % Note : 19 | % ------ 20 | % 21 | % Example : 22 | % --------- 23 | % fid = fopen('myantenna.vbs', 'wt'); 24 | % ... 25 | % hfssAssignPE_face(fid, 'GNDplane', [7,8], true); 26 | % 27 | % ---------------------------------------------------------------------------- 28 | 29 | % ---------------------------------------------------------------------------- 30 | % This file is part of HFSS-MATLAB-API. 31 | % 32 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 33 | % under the terms of the GNU General Public License as published by the Free 34 | % Software Foundation; either version 2 of the License, or (at your option) 35 | % any later version. 36 | % 37 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 38 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 39 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40 | % for more details. 41 | % 42 | % You should have received a copy of the GNU General Public License along with 43 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 44 | % Place, Suite 330, Boston, MA 02111-1307 USA 45 | % 46 | % Copyright 2007, YueLiang (yue_liang423@163.com) 47 | % ---------------------------------------------------------------------------- 48 | 49 | function hfssAssignRadiation_face(fid, Name, FIDList) 50 | 51 | 52 | % # of objects. 53 | nFaces = length(FIDList); 54 | 55 | % create the necessary script. 56 | fprintf(fid, '\n'); 57 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup")\n'); 58 | fprintf(fid, 'oModule.AssignPerfectE _\n'); 59 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 60 | 61 | fprintf(fid, '"Faces:=", _\n'); 62 | fprintf(fid, 'Array('); 63 | for iF = 1:nFaces, 64 | fprintf(fid, '%d', FIDList(iF)); 65 | if (iF ~= nFaces) 66 | fprintf(fid, ','); 67 | end; 68 | end; 69 | fprintf(fid, '), _\n'); 70 | 71 | % is infinite GND ? 72 | if (infGND) 73 | fprintf(fid, '"InfGroundPlane:=", true) \n'); 74 | else 75 | fprintf(fid, '"InfGroundPlane:=", false) \n'); 76 | end; -------------------------------------------------------------------------------- /boundary/hfssAssignRadiation_face.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignRadiation_face(fid, Name, FIDList) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VB Script necessary to assign a PEC boundary to 7 | % the given object(s). 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the Radiation boundary. This will appear under "Boundaries" 13 | % in HFSS 14 | % FIDList - a array of faces to which the Radiation boundary condition will 15 | % be applied. 16 | % 17 | % 18 | % Note : 19 | % ------ 20 | % 21 | % Example : 22 | % --------- 23 | % fid = fopen('myantenna.vbs', 'wt'); 24 | % ... 25 | % hfssAssignPE_face(fid, 'GNDplane', [7,8], true); 26 | % 27 | % ---------------------------------------------------------------------------- 28 | 29 | % ---------------------------------------------------------------------------- 30 | % This file is part of HFSS-MATLAB-API. 31 | % 32 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 33 | % under the terms of the GNU General Public License as published by the Free 34 | % Software Foundation; either version 2 of the License, or (at your option) 35 | % any later version. 36 | % 37 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 38 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 39 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40 | % for more details. 41 | % 42 | % You should have received a copy of the GNU General Public License along with 43 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 44 | % Place, Suite 330, Boston, MA 02111-1307 USA 45 | % 46 | % Copyright 2007, YueLiang (yue_liang423@163.com) 47 | % ---------------------------------------------------------------------------- 48 | 49 | function hfssAssignRadiation_face(fid, Name, FIDList) 50 | 51 | % # of objects. 52 | nFaces = length(FIDList); 53 | 54 | % create the necessary script. 55 | fprintf(fid, '\n'); 56 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup")\n'); 57 | fprintf(fid, 'oModule.AssignRadiation _\n'); 58 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 59 | 60 | fprintf(fid, '"Faces:=", _\n'); 61 | fprintf(fid, 'Array('); 62 | for iF = 1:nFaces, 63 | fprintf(fid, '%d', FIDList(iF)); 64 | if (iF ~= nFaces) 65 | fprintf(fid, ','); 66 | end; 67 | end; 68 | fprintf(fid, '), _\n'); 69 | 70 | fprintf(fid, '"IsIncidentField:=", false, _\n'); 71 | fprintf(fid, '"IsEnforcedField:=", false, _\n'); 72 | fprintf(fid, '"IsFssReference:=", false, _\n'); 73 | fprintf(fid, '"IsForPML:=", false, _\n'); 74 | fprintf(fid, '"UseAdaptiveIE:=", false) \n'); -------------------------------------------------------------------------------- /boundary/hfssAssignWavePort_face2.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignWavePort_face(fid, PortName, FaceID, nModes, isLine, ... 3 | % intStart, intEnd, Units) 4 | % 5 | % Description : 6 | % ------------- 7 | % Creates the VB Script necessary to assign a waveport to a face. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % PortName - name of the wave port (will appear under 'Boundaries'). 13 | % FaceID - ID of the face to which the wave port is 14 | % to be assigned. 15 | % nModes - # of modes. 16 | % isLine - a boolean array of length (nModes) that specifies whether the 17 | % corresponding mode has an integration line or not. 18 | % intStart - (nModes x 3 matrix) an array of vectors that represent the 19 | % starting points for the integration lines for the 20 | % respective modes (see note). 21 | % intEnd - (nModes x 3 matrix) an array of vectors that represent the 22 | % ending points for the integration lines for the 23 | % respective modes (note note). 24 | % Units - specify as either 'in', 'meter', 'mm' or anything else 25 | % defined in HFSS. 26 | % 27 | % Note : 28 | % ------ 29 | % 1. if an integration line is not required for a particular mode, then the 30 | % corresponding entries in intStart and intEnd are ignored. 31 | % 2. mostly, we will be using a single-mode and a single integration line. 32 | % 33 | % Example : 34 | % --------- 35 | % fid = fopen('myantenna.vbs', 'wt'); 36 | % ... 37 | % % single mode, no integration line specified. 38 | % hfssAssignWavePort(fid, Name, 8, 1, false, [0,0,0], ... 39 | % [0,0,0], Units); 40 | % 41 | % ---------------------------------------------------------------------------- 42 | 43 | % ---------------------------------------------------------------------------- 44 | % This file is part of HFSS-MATLAB-API. 45 | % 46 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 47 | % under the terms of the GNU General Public License as published by the Free 48 | % Software Foundation; either version 2 of the License, or (at your option) 49 | % any later version. 50 | % 51 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 52 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 53 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 54 | % for more details. 55 | % 56 | % You should have received a copy of the GNU General Public License along with 57 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 58 | % Place, Suite 330, Boston, MA 02111-1307 USA 59 | % 60 | % Copyright 2007, YueLiang (yue_liang423@163.com) 61 | % ---------------------------------------------------------------------------- 62 | 63 | function hfssAssignWavePort_face2(fid, PortName) 64 | 65 | % Preamble. 66 | fprintf(fid, '\n'); 67 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup") \n'); 68 | fprintf(fid, 'oModule.AssignWavePort _\n'); 69 | fprintf(fid, 'Array("NAME:1", _\n'); 70 | fprintf(fid, '"Objects:=", Array("%s"), _\n',PortName); 71 | fprintf(fid, '"NumModes:=", 1, _\n'); 72 | fprintf(fid, '"RenormalizeAllTerminals:=", _\n'); 73 | fprintf(fid, 'true, _\n'); 74 | fprintf(fid, '"UseLineModeAlignment:=", false, _\n'); 75 | fprintf(fid, '"DoDeembed:=", false, _\n'); 76 | fprintf(fid, 'Array("NAME:Modes", _\n'); 77 | fprintf(fid, 'Array("NAME:Mode1", _\n'); 78 | fprintf(fid, '"ModeNum:=", 1, _\n'); 79 | fprintf(fid, '"UseIntLine:=", false)), _\n'); 80 | fprintf(fid, '"ShowReporterFilter:=", false, _\n'); 81 | fprintf(fid, '"ReporterFilter:=", _\n'); 82 | fprintf(fid, 'Array( true), _\n'); 83 | fprintf(fid, '"UseAnalyticAlignment:=", false)\n'); 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /boundary/hfssCircularPort.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssCircularPort(fid, Name, ObjectName, Axis, Center, Radius, ... 3 | % Units) 4 | % 5 | % Description : 6 | % ------------- 7 | % Creates the VB Script necessary to create a circular wave port. This 8 | % function generates BOTH the circle object AND the wave port. This function 9 | % is useful to add ports at the end of co-axial cables. 10 | % 11 | % Parameters : 12 | % ------------ 13 | % fid - file identifier of the HFSS script file. 14 | % Name - name of the wave port. 15 | % ObjectName - name of the circle to which the wave port is assigned. 16 | % Axis - axis of the circle. Specify as 'X', 'Y' or 'Z'. 17 | % Center - the center of the circle. 18 | % Radius - raduis of the circle. 19 | % Units - specify as either 'mm', 'meter', 'in', ... or anything else 20 | % defined in HFSS. 21 | % 22 | % Note : 23 | % ------ 24 | % No integration lines are added and a single-mode solution is assumed. 25 | % 26 | % Example : 27 | % --------- 28 | % fid = fopen('myantenna.vbs', 'wt'); 29 | % ... 30 | % hfssCircularPort(fid, 'Port1', 'CoaxSource', 'Z', [10, 0, 0], 0.1, 'in'); 31 | % 32 | % ---------------------------------------------------------------------------- 33 | 34 | % ---------------------------------------------------------------------------- 35 | % This file is part of HFSS-MATLAB-API. 36 | % 37 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 38 | % under the terms of the GNU General Public License as published by the Free 39 | % Software Foundation; either version 2 of the License, or (at your option) 40 | % any later version. 41 | % 42 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 43 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 44 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45 | % for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License along with 48 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 49 | % Place, Suite 330, Boston, MA 02111-1307 USA 50 | % 51 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 52 | % ---------------------------------------------------------------------------- 53 | function hfssCircularPort(fid, Name, ObjectName, Axis, Center, Radius, Units) 54 | 55 | hfssCircle(fid, ObjectName, Axis, Center, Radius, Units); 56 | hfssAssignWavePort(fid, Name, ObjectName, 1, false, [0,0,0], ... 57 | [0,0,0], Units); 58 | -------------------------------------------------------------------------------- /boundary/hfssEditSources.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssEditSources(fid, num, name, mag, phase) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates the VB Script necessary to indicates which source excitations 7 | % should be used for fields post processing. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % num - the number of source. 13 | % name - a source name is typically the name of the associated 14 | % excitation. 15 | % mag - this gives the mag of the complex excitation for each 16 | % source. 17 | % phase - this gives the phase in degrees of the complex excitation 18 | % for each source. 19 | % 20 | % Note : 21 | % ------ 22 | % 1. if an integration line is not required for a particular mode, then the 23 | % corresponding entries in intStart and intEnd are ignored. 24 | % 2. mostly, we will be using a single-mode and a single integration line. 25 | % 26 | % Example : 27 | % --------- 28 | % fid = fopen('myantenna.vbs', 'wt'); 29 | % ... 30 | % 31 | % ---------------------------------------------------------------------------- 32 | 33 | % ---------------------------------------------------------------------------- 34 | % This file is part of HFSS-MATLAB-API. 35 | % 36 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 37 | % under the terms of the GNU General Public License as published by the Free 38 | % Software Foundation; either version 2 of the License, or (at your option) 39 | % any later version. 40 | % 41 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 42 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 43 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 44 | % for more details. 45 | % 46 | % You should have received a copy of the GNU General Public License along with 47 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 48 | % Place, Suite 330, Boston, MA 02111-1307 USA 49 | % 50 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 51 | % ------------------------------------------------------------------------- 52 | % --- 53 | function hfssEditSources(fid, num, name, mag, phase) 54 | 55 | % preamble 56 | fprintf(fid, '\n'); 57 | fprintf(fid, 'Set oModule = oDesign.GetModule("Solutions") \n'); 58 | fprintf(fid, 'oModule.EditSources "TotalFields", _\n'); 59 | fprintf(fid, 'Array("NAME:Names", _\n'); 60 | for i = 1:num-1 61 | fprintf(fid, '"%s", _\n', name{i}); 62 | end 63 | fprintf(fid, '"%s"), Array("NAME:Modes", _\n', name{num}); 64 | for i = 1:num-1 65 | fprintf(fid, '1, '); 66 | end 67 | fprintf(fid, '1), Array("NAME:Magnitudes", _\n'); 68 | for i = 1:num-1 69 | fprintf(fid, '"%fw", ', mag(i)); 70 | end 71 | fprintf(fid, '"%fw"), Array("NAME:Phases", _\n', mag(num)); 72 | for i = 1:num-1 73 | fprintf(fid, '"%fdeg", ', phase(i)); 74 | end 75 | fprintf(fid, '"%fdeg"), Array("NAME:Terminated"), _\n', phase(num)); 76 | fprintf(fid, 'Array("NAME:Impedances"), _\n'); 77 | fprintf(fid, ' false, false,false,"1W"'); -------------------------------------------------------------------------------- /boundary/hfssPE.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/boundary/hfssPE.m -------------------------------------------------------------------------------- /boundary/hfssPH.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/boundary/hfssPH.m -------------------------------------------------------------------------------- /doc/dipole_balun.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/doc/dipole_balun.jpg -------------------------------------------------------------------------------- /doc/hfssclose.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssRectangle(fid, Name, Axis, Start, Width, Height, Units) 3 | % 4 | % Description : 5 | % ------------- 6 | % Create the VB Script necessary to construct a rectangle using the HFSS 7 | % 3D Modeler. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the rectangle object (appears in the HFSS objects tree). 13 | % Axis - axis that is normal to the rectangle object. 14 | % Start - starting location of the rectangle (one of its corners). Specify 15 | % as [sx, sy, sz]. 16 | % Width - (scalar) the width of the rectangle. If the axis is 'X' then this 17 | % represents the Y-axis size of the rectangle, and so on. 18 | % Height - (scalar) the height of the rectangle. If the axis is 'X', then 19 | % this represents the Z-axis size of the rectangle, and so on. 20 | % Units - specify as 'in', 'meter', 'mm', ... or anything else defined in 21 | % HFSS. 22 | % 23 | % Note : 24 | % ------ 25 | % Todo: a feature to add automatic holes in the rectangle object. 26 | % 27 | % Example : 28 | % --------- 29 | % fid = fopen('myantenna.vbs', 'wt'); 30 | % ... 31 | % % in this example, Y-axis size is 10in and Z-axis size is 20in. 32 | % hfssRectangle(fid, 'Rect1', 'X', [0,0,0], 10, 20, 'in'); 33 | % 34 | % ---------------------------------------------------------------------------- 35 | 36 | % ---------------------------------------------------------------------------- 37 | % This file is part of HFSS-MATLAB-API. 38 | % 39 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 40 | % under the terms of the GNU General Public License as published by the Free 41 | % Software Foundation; either version 2 of the License, or (at your option) 42 | % any later version. 43 | % 44 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 45 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 46 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47 | % for more details. 48 | % 49 | % You should have received a copy of the GNU General Public License along with 50 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 51 | % Place, Suite 330, Boston, MA 02111-1307 USA 52 | % 53 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 54 | % ---------------------------------------------------------------------------- 55 | % Width and Height follow the right-hand rule. If the Axis is Z, then Width 56 | % represents X-direction size and Height represents the Y-direction size 57 | % and so on ... 58 | function hfssclose(fid) 59 | 60 | %Transparency = 0.5; 61 | 62 | % Preamble. 63 | fprintf(fid, '\n'); 64 | fprintf(fid, 'oDesktop.QuitApplication\n'); 65 | 66 | -------------------------------------------------------------------------------- /doc/style.css: -------------------------------------------------------------------------------- 1 | /* ------------ Page Headings ------------------- */ 2 | h1 3 | { 4 | font-family: Arial, Verdana, Serif; 5 | color: #999900; 6 | font-size: x-large; 7 | text-align: center 8 | } 9 | 10 | h1.left 11 | { 12 | font-family: Arial, Verdana, Serif; 13 | color: #999900; 14 | font-size: x-large; 15 | text-align: left 16 | } 17 | 18 | /* ----------- Sections (within a page) ------------*/ 19 | h2 20 | { 21 | font-family: Arial, Verdana, Serif; 22 | color: #009999; 23 | font-size: medium 24 | } 25 | 26 | /* ----------- Sections (within a page) ------------*/ 27 | h2.center 28 | { 29 | font-family: Arial, Verdana, Serif; 30 | color: #009999; 31 | font-size: medium; 32 | text-align: center 33 | } 34 | 35 | /* ----------- Sub Sections (within Sections) ---------*/ 36 | h3 37 | { 38 | font-family: Arial, Helvetica, Verdana, Serif; 39 | color: #990099; 40 | font-size: small 41 | } 42 | 43 | h3.white 44 | { 45 | color:white 46 | } 47 | 48 | h4 49 | { 50 | font-family: Arial, Helvetica, Verdana, Serif; 51 | color: #000000; 52 | font-size: 10pt; 53 | font-weight: bold 54 | } 55 | 56 | h4.white 57 | { 58 | color: white 59 | } 60 | 61 | h4.center 62 | { 63 | text-align: center 64 | } 65 | 66 | /* ---------------- A Style for questions ---------------- */ 67 | .question 68 | { 69 | font-weight: bold; 70 | } 71 | 72 | ol.question 73 | { 74 | font-weight: bold; 75 | font-size: 10pt; 76 | font-family: Arial, Helvetica, Verdana, Serif; 77 | } 78 | 79 | /* ------------- Font for Paragraphs --------------- */ 80 | p 81 | { 82 | font-family: Arial, Helvetica, Verdana, Serif; 83 | font-size: 10pt; 84 | color: #000000; 85 | font-weight: normal; 86 | } 87 | /* ------------ Special Paragraphs that start with a different first letter ----------*/ 88 | p.fletter:first-letter 89 | { 90 | font-size: large; 91 | } 92 | 93 | p.white 94 | { 95 | color: #ffffff; 96 | } 97 | 98 | p.largewhite 99 | { 100 | font-size: 12pt; 101 | color: #ffffff; 102 | font-weight: bold; 103 | } 104 | 105 | p.signature 106 | { 107 | font-family: Arial, Helvetica, Verdana, Serif; 108 | font-size: x-small; 109 | color: #000000; 110 | text-align: center; 111 | font-style: italic 112 | } 113 | 114 | p.caption 115 | { 116 | font-weight: bold; 117 | text-align: center 118 | } 119 | 120 | /* ------------- Numbered Lists ---------------- */ 121 | ol.h4size 122 | { 123 | font-size: x-small; 124 | } 125 | 126 | /* ----------- First line on a page (on top of the title) -------------*/ 127 | hr.bottomline, hr.titletop 128 | { 129 | width: 80%; 130 | align: center; 131 | } 132 | 133 | /* ----------- Bottom Line of the title --*/ 134 | hr.titlebottom 135 | { 136 | width: 70%; 137 | align: center; 138 | } 139 | 140 | /* ----------- Address Tag ----------------*/ 141 | address 142 | { 143 | font-family: Arial, Helvetica, Verdana, Serif; 144 | font-size: 10pt; 145 | color: #000000; 146 | } 147 | 148 | table.bluenote 149 | { 150 | float: right; 151 | width: 20%; 152 | background-color: #009999; 153 | table-layout: auto; 154 | border: thin #00bbbb solid 155 | } 156 | 157 | /* --- The Default color patterns for links -----------------*/ 158 | a:link { color: blue} 159 | a:visited { color: red} 160 | a:hover { color: green} 161 | a:active { color: black} 162 | 163 | /* The Color pattern for links which are white in color ----*/ 164 | a.white:link { color: white} 165 | a.white:visited { color: white} 166 | a.white:hover { color: #ff00ff } 167 | a.white:active { color: white} 168 | 169 | /* ------- Code Listings ------- */ 170 | code.latex 171 | { 172 | font-family: Verdana, Courier, Arial, Serif; 173 | font-size: 10pt; 174 | color: #0000aa; 175 | } 176 | 177 | code.shell 178 | { 179 | font-family: Verdana, Courier, Arial, Serif; 180 | font-size: 10pt; 181 | color: #000000; 182 | font-weight: bold; 183 | } 184 | -------------------------------------------------------------------------------- /examples/folded_dipole.m: -------------------------------------------------------------------------------- 1 | % this example script creates a Folded Dipole array design in HFSS. 2 | clear all; 3 | close all; 4 | 5 | % add necessary paths. 6 | %addpath('../3dmodeler'); 7 | %addpath('../general'); 8 | %addpath('../boundary'); 9 | %addpath('../analysis'); 10 | 11 | % temporary script file to output script commands. 12 | hfssScriptFile = 'D:/tmpFoldedDipole.vbs'; 13 | fid = fopen(hfssScriptFile, 'wt'); 14 | 15 | % General parameters. 16 | c = 3e8; 17 | fc = 150e6; 18 | Wv = c/fc; 19 | 20 | % Solution parameters. 21 | fSolve = fc; 22 | f0 = 130e6; 23 | f1 = 170e6; 24 | 25 | % Number of elements. 26 | N = 2; 27 | 28 | % Dimensions of folded dipole. 29 | % 1. length of the inner section. 30 | L = 0.70; 31 | % 2. radius of the outer semi-circles. 32 | Rs = L/10; 33 | % 3. width between the folded arms. 34 | W = 2*Rs; 35 | % 4. radius (thickness) of the arm. 36 | Rd = 0.01; 37 | % 5. feeding gap. 38 | G = L/25; 39 | 40 | % General dimensions. 41 | % ground plane height (from bottom arm). 42 | GpH = Wv/4; 43 | % length of the harness rod. 44 | Lhrns = 0.9*GpH; 45 | % radius (thickness) of the harness rod. 46 | Rhrns = 2*Rd; 47 | % antenna spacing. 48 | dAnt = Wv/2; 49 | 50 | % Ground Plane Dimensions. 51 | GpL = (N-1)*dAnt + 2*(Wv/4); 52 | GpW = L + Rs + 2*(Wv/4); 53 | 54 | % AirBox. 55 | AirX = GpL; 56 | AirY = GpW; 57 | AirZt = GpH - W/2; 58 | AirZb = W/2 + Wv/4; 59 | 60 | % Port Parameters (Lumped Port) 61 | PortW = G; % same as the antenna gap. 62 | PortH = 2*Rd; % same as the diameter of the rods. 63 | 64 | % Create a new HFSS Project and insert a new design. 65 | hfssNewProject(fid); 66 | hfssInsertDesign(fid, 'folded_dipole'); 67 | 68 | % ---- Single Element Design --- 69 | 70 | % Create the Outer Semi-Circles first. 71 | % semicircle-1 72 | hfssCircle(fid, 'SemiCircle1', 'Y', [0, 0, W/2], Rd, 'meter'); 73 | hfssSweepAroundAxis(fid, 'SemiCircle1', 'X', -180); 74 | hfssMove(fid, {'SemiCircle1'}, [0, L/2, 0], 'meter'); 75 | % semicircle-2 76 | hfssCircle(fid, 'SemiCircle2', 'Y', [0, 0, W/2], Rd, 'meter'); 77 | hfssSweepAroundAxis(fid, 'SemiCircle2', 'X', 180); 78 | hfssMove(fid, {'SemiCircle2'}, [0, -L/2, 0], 'meter'); 79 | 80 | % Create the connecting cylinders. 81 | hfssCylinder(fid, 'TopCylinder', 'Y', [0, -L/2, W/2], Rd, L, 'meter'); 82 | hfssCylinder(fid, 'BottomCylinder1', 'Y', [0, -L/2, -W/2], Rd, (L/2 - G/2), 'meter'); 83 | hfssCylinder(fid, 'BottomCylinder2', 'Y', [0, L/2, -W/2], Rd, -(L/2 - G/2), 'meter'); 84 | 85 | % Create the harness rod. 86 | %hfssCylinder(fid, 'Harness', 'Z', [0, 0, GpH - W/2], Rhrns, -Lhrns, 'meter'); 87 | 88 | % Unite all the Objects together. 89 | %hfssUnite(fid, {'TopCylinder', 'SemiCircle1', 'BottomCylinder1', ... 90 | % 'BottomCylinder2', 'SemiCircle2', 'Harness'}); 91 | hfssUnite(fid, {'TopCylinder', 'SemiCircle1', 'BottomCylinder1', ... 92 | 'BottomCylinder2', 'SemiCircle2'}); 93 | hfssRename(fid, 'TopCylinder', 'FoldedDipole'); 94 | 95 | % Assign material to coppper. 96 | hfssAssignMaterial(fid, 'FoldedDipole', 'copper'); 97 | 98 | % Create a Gap Source and add a Lumped port. 99 | hfssRectangle(fid, 'GapSource', 'X', [0, -PortW/2, -W/2 - PortH/2], PortW, PortH, 'meter'); 100 | hfssAssignLumpedPort(fid, 'Port', 'GapSource', [0, -PortW/2, -W/2], [0, PortW/2, -W/2], 'meter', 200); 101 | 102 | % --- Array, Ground Plane and Airbox ---- 103 | 104 | % Repeat the elements as an array. 105 | if (N > 1) 106 | hfssMove(fid, {'FoldedDipole', 'GapSource'}, [-((N-1)/2)*dAnt, 0, 0], 'meter'); 107 | hfssDuplicateAlongLine(fid, {'FoldedDipole', 'GapSource'}, [dAnt, 0, 0], N, 'meter'); 108 | end; 109 | 110 | % Create an airbox. 111 | hfssBox(fid, 'AirBox', [-AirX/2, -AirY/2, AirZt], [AirX, AirY, -(AirZt + AirZb)], 'meter'); 112 | hfssAssignRadiation(fid, 'ABC', 'AirBox'); 113 | 114 | % Create the Ground Plane. 115 | hfssRectangle(fid, 'GroundPlane', 'Z', [-GpL/2, -GpW/2, GpH - W/2], GpL, GpW, 'meter'); 116 | hfssAssignPE(fid, 'Ground', {'GroundPlane'}); 117 | 118 | % Set Transparencies. 119 | hfssSetTransparency(fid, {'AirBox'}, 0.95); 120 | hfssSetTransparency(fid, {'GroundPlane'}, 0.90); 121 | 122 | % Solution Setup and Sweeps. 123 | hfssInsertSolution(fid, 'Setup150MHz', fSolve/1e9); 124 | hfssInterpolatingSweep(fid, 'Sweep130to170MHz', 'Setup150MHz', f0/1e9, f1/1e9); 125 | 126 | fclose(fid); 127 | -------------------------------------------------------------------------------- /function_w/fclose_w.m: -------------------------------------------------------------------------------- 1 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 2 | function fclose_w(fid) 3 | status = fclose(fid); 4 | if status == 0 5 | disp('VSB file closed') 6 | else 7 | disp('VSB file closed fail') 8 | status = fclose('all'); 9 | if status == 0 10 | disp('ALL file closed') 11 | else 12 | disp('Plz manually close MATLAB') 13 | end 14 | end 15 | disp('Sctrip Completed') -------------------------------------------------------------------------------- /function_w/hfssAssignPE_unknowfaceID.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAssignPE_unknowfaceID(fid, Name, BodyName,Position, Units, [infGND = false]) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VB Script necessary to assign a PEC boundary to 7 | % the given object(s). 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the PEC boundary. This will appear under "Boundaries" 13 | % in HFSS 14 | % FIDList - a array of faces to which the PEC boundary condition will 15 | % be applied. 16 | % infGND - (boolean) specify as true to make the PEC represent an infinite 17 | % ground plane (default is false). 18 | % 19 | % 20 | % Note : 21 | % ------ 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('myantenna.vbs', 'wt'); 26 | % ... 27 | % hfssAssignPE_face(fid, 'GNDplane', [7,8], true); 28 | % 29 | % ---------------------------------------------------------------------------- 30 | 31 | % ---------------------------------------------------------------------------- 32 | % This file is part of HFSS-MATLAB-API. 33 | % 34 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 35 | % under the terms of the GNU General Public License as published by the Free 36 | % Software Foundation; either version 2 of the License, or (at your option) 37 | % any later version. 38 | % 39 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 40 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 41 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42 | % for more details. 43 | % 44 | % You should have received a copy of the GNU General Public License along with 45 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 46 | % Place, Suite 330, Boston, MA 02111-1307 USA 47 | % 48 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 49 | % ---------------------------------------------------------------------------- 50 | 51 | function hfssAssignPE_unknowfaceID(fid, Name, BodyName,Position, Units, infGND) 52 | 53 | % arguments processor. 54 | if (nargin < 5) 55 | error('Insufficient # of arguments !'); 56 | elseif (nargin < 6) 57 | infGND = []; 58 | end; 59 | 60 | % default arguments. 61 | if isempty(infGND) 62 | infGND = false; 63 | end; 64 | 65 | % Gets the face id corresponding to position input. 66 | fprintf(fid, '\n'); 67 | fprintf(fid,'Dim faceid \n'); 68 | fprintf(fid, 'faceid = oEditor.GetFaceByPosition(Array("NAME:Parameters", _\n'); 69 | fprintf(fid, '"BodyName:=", "%s",_\n', BodyName); 70 | fprintf(fid, '"XPosition:=", "%f%s",_\n', Position(1),Units); 71 | fprintf(fid, '"YPosition:=", "%f%s",_\n', Position(2),Units); 72 | fprintf(fid, '"ZPosition:=", "%f%s"))\n', Position(3),Units); 73 | 74 | % create the necessary script. 75 | fprintf(fid, '\n'); 76 | fprintf(fid, 'Set oModule = oDesign.GetModule("BoundarySetup")\n'); 77 | fprintf(fid, 'oModule.AssignPerfectE _\n'); 78 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 79 | 80 | fprintf(fid, '"Faces:=", _\n'); 81 | fprintf(fid, 'Array('); 82 | fprintf(fid, 'faceid'); 83 | fprintf(fid, '), _\n'); 84 | 85 | % is infinite GND ? 86 | if (infGND) 87 | fprintf(fid, '"InfGroundPlane:=", true) \n'); 88 | else 89 | fprintf(fid, '"InfGroundPlane:=", false) \n'); 90 | end; -------------------------------------------------------------------------------- /function_w/hfssChangeMarkerProperty.m: -------------------------------------------------------------------------------- 1 | function hfssChangeMarkerProperty(fid,reportName,markerName,theta) 2 | fprintf(fid,'Set oModule = oDesign.GetModule("ReportSetup") \n'); 3 | fprintf(fid,'oModule.ChangeProperty Array("NAME:AllTabs", Array("NAME:Marker", _\n'); 4 | fprintf(fid,'Array("NAME:PropServers", "%s:%s"), _\n',reportName,markerName); 5 | fprintf(fid,'Array("NAME:ChangedProps", Array("NAME:Theta", "Value:=", "%d deg")))) \n',theta); 6 | end -------------------------------------------------------------------------------- /function_w/hfssChangeOptVar.m: -------------------------------------------------------------------------------- 1 | % Change LocalVariables range in Optimization 2 | % Example : 3 | % --------- 4 | %hfssAddOptVar(fid, {'length1','length2','length3',...}, [min1, min2, min3...], [max1,max2...],'mm') 5 | %You should Use hfssaddVar to add Variables to design 6 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 7 | function hfssChangeOptVar(fid, VarList, minList, maxList,Units) 8 | if iscell(VarList) == 0 9 | error('VarList should be a Cell!') 10 | else 11 | ListSize = size(VarList); 12 | if isvector(ListSize) == 0 13 | error('VarList should be One Dimenson!') 14 | end 15 | end 16 | VarNum = max(size(VarList)); 17 | fpirntf(fid, '\n'); 18 | fprintf(fid, 'oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", _\n'); 19 | fprintf(fid, 'Array("NAME:PropServers", "LocalVariables"), Array("NAME:ChangedProps", _\n'); 20 | 21 | for i = 1:VarNum-1 22 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{i}); 23 | fprintf(fid, 'Array("NAME:Optimization", "Min:=", "%f%s")), _\n', minList(i), Units); 24 | fprintf(fid, 'Array("NAME:%s", _\n', VarList(1)); 25 | fprintf(fid, 'Array("NAME:Optimization", "Min:=", "%f%s")), _\n', maxList(i), Units); 26 | end 27 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{VarNum}); 28 | fprintf(fid, 'Array("NAME:Optimization", "Min:=", "%f%s")), _\n', minList(VarNum), Units); 29 | fprintf(fid, 'Array("NAME:%s", _\n', VarList(1)); 30 | fprintf(fid, 'Array("NAME:Optimization", "Min:=", "%f%s"))))) \n', maxList(VarNum), Units); 31 | end 32 | -------------------------------------------------------------------------------- /function_w/hfssChangeOptVarRange.m: -------------------------------------------------------------------------------- 1 | % Change LocalVariables range in Optimization 2 | % Example : 3 | % --------- 4 | %hfssAddOptVar(fid, {'length1','length2','length3',...}, [min1, min2, min3...], [max1,max2...],'mm') 5 | %You should Use hfssaddVar to add Variables to design 6 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 7 | function hfssChangeOptVarRange(fid, VarList, minList, maxList,Units) 8 | if iscell(VarList) == 0 9 | error('VarList should be a Cell!') 10 | else 11 | ListSize = size(VarList); 12 | if isvector(ListSize) == 0 13 | error('VarList should be One Dimenson!') 14 | end 15 | end 16 | VarNum = max(size(VarList)); 17 | fprintf(fid, '\n'); 18 | fprintf(fid, 'oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", _\n'); 19 | fprintf(fid, 'Array("NAME:PropServers", "LocalVariables"), Array("NAME:ChangedProps", _\n'); 20 | if VarNum ==1 21 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{1}); 22 | fprintf(fid, 'Array("NAME:Optimization", "Min:=", "%f%s")), _\n', minList(1), Units); 23 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{1}); 24 | fprintf(fid, 'Array("NAME:Optimization", "Max:=", "%f%s"))))) \n', maxList(1), Units); 25 | else 26 | for i = 1:VarNum-1 27 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{i}); 28 | fprintf(fid, 'Array("NAME:Optimization", "Min:=", "%f%s")), _\n', minList(i), Units); 29 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{i}); 30 | fprintf(fid, 'Array("NAME:Optimization", "Max:=", "%f%s")), _\n', maxList(i), Units); 31 | end 32 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{VarNum}); 33 | fprintf(fid, 'Array("NAME:Optimization", "Min:=", "%f%s")), _\n', minList(VarNum), Units); 34 | fprintf(fid, 'Array("NAME:%s", _\n', VarList{VarNum}); 35 | fprintf(fid, 'Array("NAME:Optimization", "Max:=", "%f%s"))))) \n', maxList(VarNum), Units); 36 | end 37 | 38 | end 39 | -------------------------------------------------------------------------------- /function_w/hfssChangeVar.m: -------------------------------------------------------------------------------- 1 | % function hfssChangeVar(fid,VarName,Vaule,Units) 2 | % change vaule LocalVariable 3 | % only one Variable can be add once 4 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 5 | function hfssChangeVar(fid,VarName,Vaule,Units) 6 | fprintf(fid, '\n'); 7 | fprintf(fid, 'oDesign.ChangeProperty _\n'); 8 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 9 | fprintf(fid, 'Array("NAME:LocalVariableTab", _\n'); 10 | fprintf(fid, 'Array("NAME:PropServers","LocalVariables"), _\n'); 11 | fprintf(fid, 'Array("NAME:ChangedProps", _\n'); 12 | fprintf(fid, 'Array("NAME:%s", "Value:=", "%d%s")))) \n', VarName, Vaule, Units); 13 | end -------------------------------------------------------------------------------- /function_w/hfssCreate3DGainReport.m: -------------------------------------------------------------------------------- 1 | function hfssCreate3DGainReport(fid, ReportName, VarList, Geometry, f) 2 | fprintf(fid, '\n'); 3 | fprintf(fid, 'Set oModule = oDesign.GetModule("ReportSetup") \n'); 4 | fprintf(fid, 'oModule.CreateReport "%s", "Far Fields", _\n', ReportName); 5 | fprintf(fid, '"3D Polar Plot", "Setup1 : LastAdaptive", _\n'); 6 | fprintf(fid, 'Array("Context:=", "%s"), _\n', Geometry); 7 | fprintf(fid,'Array("Theta:=", Array("All"), "Phi:=", Array("All"), _\n'); 8 | fprintf(fid, '"Freq:=", Array("%dGHz")', f); 9 | if length(VarList) >= 1 10 | fprintf(fid, ', _\n'); 11 | for i = 1:length(VarList) 12 | fprintf(fid, '"%s:=", Array( "Nominal")', VarList{i}); 13 | if i ~= length(VarList) 14 | fprintf(fid, ', _\n'); 15 | else 16 | fprintf(fid, '), _\n'); 17 | end 18 | end 19 | else 20 | fprintf(fid, '), _\n'); 21 | end 22 | 23 | fprintf(fid, 'Array("Phi Component:=", "Phi", "Theta Component:=", "Theta", "Mag Component:=", Array("dB(GainTotal)")), Array()'); 24 | end -------------------------------------------------------------------------------- /function_w/hfssCreateEHGainReport.m: -------------------------------------------------------------------------------- 1 | function hfssCreateEHGainReport(fid, ReportName, VarList, Geometry, f) 2 | fprintf(fid, '\n'); 3 | fprintf(fid, 'Set oModule = oDesign.GetModule("ReportSetup") \n'); 4 | fprintf(fid, 'oModule.CreateReport "%s", "Far Fields", _\n', ReportName); 5 | fprintf(fid, '"Rectangular Plot", "solve : LastAdaptive", _\n'); 6 | fprintf(fid, 'Array("Context:=", "%s"), _\n', Geometry); 7 | fprintf(fid,'Array("Theta:=", Array("All"), "Phi:=", Array("All"), _\n'); 8 | fprintf(fid, '"Freq:=", Array("%dGHz")', f); 9 | if length(VarList) >= 1 10 | fprintf(fid, ', _\n'); 11 | for i = 1:length(VarList) 12 | fprintf(fid, '"%s:=", Array( "Nominal")', VarList{i}); 13 | if i ~= length(VarList) 14 | fprintf(fid, ', _\n'); 15 | else 16 | fprintf(fid, '), _\n'); 17 | end 18 | end 19 | else 20 | fprintf(fid, '), _\n'); 21 | end 22 | 23 | fprintf(fid, 'Array("X Component:=", "Theta", "Y Component:=", Array("dB(GainTotal)")), Array() \n'); 24 | end -------------------------------------------------------------------------------- /function_w/hfssCreateEHGainReport2.m: -------------------------------------------------------------------------------- 1 | function hfssCreateEHGainReport2(fid, ReportName, NominalVarList, OptVarList, VarValue, Geometry, f,Units) 2 | fprintf(fid, '\n'); 3 | fprintf(fid, 'Set oModule = oDesign.GetModule("ReportSetup") \n'); 4 | fprintf(fid, 'oModule.CreateReport "%s", "Far Fields", _\n', ReportName); 5 | fprintf(fid, '"Rectangular Plot", "solve : LastAdaptive", _\n'); 6 | fprintf(fid, 'Array("Context:=", "%s"), _\n', Geometry); 7 | fprintf(fid,'Array("Theta:=", Array("All"), "Phi:=", Array("All"), _\n'); 8 | fprintf(fid, '"Freq:=", Array("%dGHz"), _\n', f); 9 | 10 | for i = 1:length(NominalVarList) 11 | 12 | fprintf(fid, '"%s:=", Array( "Nominal"), _\n', NominalVarList{i}); 13 | 14 | end 15 | 16 | 17 | 18 | for i = 1:length(OptVarList) 19 | fprintf(fid, '"%s:=", Array( ', cell2mat(OptVarList{i})); 20 | clearvars temp 21 | temp = VarValue{i}; 22 | for j = 1:length(temp)-1 23 | fprintf(fid, '"%.15f%s",',temp(j),Units); 24 | end 25 | fprintf(fid, '"%.15f%s")',temp(length(temp)),Units); 26 | if i ~= length(OptVarList) 27 | fprintf(fid, ', _\n'); 28 | else 29 | fprintf(fid, '), _\n'); 30 | end 31 | 32 | end 33 | 34 | 35 | 36 | fprintf(fid, 'Array("X Component:=", "Theta", "Y Component:=", Array("dB(GainTotal)")), Array()'); 37 | end -------------------------------------------------------------------------------- /function_w/hfssCreateEquationCurve.m: -------------------------------------------------------------------------------- 1 | %CreateEquationCurve 2 | function hfssCreateEquationCurve(fid, Name,XFunc, YFunc, ZFunc, tStrat, tEnd, PointNum) 3 | % fprintf(fid, 'Dim oAnsoftApp \n'); 4 | % fprintf(fid, 'Dim oDesktop \n'); 5 | % fprintf(fid, 'Dim oProject \n'); 6 | % fprintf(fid, 'Dim oDesign \n'); 7 | % fprintf(fid, 'Dim oEditor \n'); 8 | % fprintf(fid, 'Dim oModule \n'); 9 | % fprintf(fid, 'Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface") \n'); 10 | % fprintf(fid, 'Set oDesktop = oAnsoftApp.GetAppDesktop() \n'); 11 | % fprintf(fid, 'oDesktop.RestoreWindow \n'); 12 | fprintf(fid, 'Set oEditor = oDesign.SetActiveEditor("3D Modeler") \n'); 13 | fprintf(fid, 'oEditor.CreateEquationCurve Array('); 14 | fprintf(fid, '"NAME:EquationBasedCurveParameters", "XtFunction:=", "%s", _\n', XFunc); 15 | fprintf(fid, '"YtFunction:=", "%s", _\n', YFunc); 16 | fprintf(fid, '"ZtFunction:=", "%s", _\n', ZFunc); 17 | if isnumeric(tStrat) 18 | fprintf(fid, '"tStart:=", "%f", _\n', tStrat); 19 | else 20 | fprintf(fid, '"tStart:=", "%s", _\n', tStrat); 21 | end 22 | 23 | if isnumeric(tEnd) 24 | fprintf(fid, '"tEnd:=", "%f", _\n', tEnd); 25 | else 26 | fprintf(fid, '"tEnd:=", "%s", _\n', tEnd); 27 | end 28 | 29 | if isnumeric(PointNum) 30 | fprintf(fid, '"NumOfPointsOnCurve:=", "%f", _\n', PointNum); 31 | else 32 | fprintf(fid, '"NumOfPointsOnCurve:=", "%s", _\n', PointNum); 33 | end 34 | 35 | fprintf(fid, '"Version:=", 1, _\n'); 36 | fprintf(fid, 'Array("NAME:PolylineXSection", "XSectionType:=", "None", "XSectionOrient:=", "Auto", "XSectionWidth:=", "0", "XSectionTopWidth:=", "0", "XSectionHeight:=", "0", "XSectionNumSegments:=", "0", "XSectionBendType:=", "Corner")), _\n'); 37 | fprintf(fid, 'Array("NAME:Attributes", "Name:=", "%s", "Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", true)',Name); 38 | 39 | 40 | -------------------------------------------------------------------------------- /function_w/hfssCreatePolyline.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % function hfssCreatePolyline(fid, Points, Name, Units) 3 | % 4 | % Description: 5 | % ------------ 6 | % Create a CreatePolyline in HFSS. This function also provides 7 | % an option to punch a bunch of (circular) holes into the polygon object (so 8 | % as to make way for cables, wires, etc.,). 9 | % 10 | 11 | % You should have received a copy of the GNU General Public License along with 12 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 13 | % Place, Suite 330, ShangHai, CN 20171222 14 | % Copyright 2018, WoodyBuendia (woodybuendia@gmail.com) 15 | 16 | function hfssCreatePolyline(fid, Points, Name, Units) 17 | Num_points = length(Points); 18 | 19 | fprintf(fid, 'Set oEditor = oDesign.SetActiveEditor("3D Modeler") \n'); 20 | fprintf(fid, 'oEditor.CreatePolyline Array("NAME:PolylineParameters", _\n'); 21 | fprintf(fid, '"IsPolylineCovered:=", true, "IsPolylineClosed:=", false, _\n'); 22 | fprintf(fid, 'Array("NAME:PolylinePoints", _\n'); 23 | 24 | Coor = {'X','Y','Z'}; 25 | for i = 1:Num_points-1 26 | fprintf(fid, 'Array("NAME:PLPoint", _\n'); 27 | clearvars temp 28 | temp = Points{i,1}; 29 | for j = 1:2 30 | if isnumeric(temp{1,j}) 31 | fprintf(fid, '"%s:=", "%f%s", _\n', Coor{j},temp{1,j}, Units); 32 | else 33 | fprintf(fid, '"%s:=", "%s", _\n', Coor{j}, temp{1,j}); 34 | end 35 | end 36 | if isnumeric(temp{1,3}) 37 | fprintf(fid, '"%s:=", "%f%s"), _\n', Coor{3}, temp{1,3}, Units); 38 | else 39 | fprintf(fid, '"%s:=", "%s"), _\n', Coor{3}, temp{1,3}); 40 | end 41 | 42 | end 43 | 44 | i = Num_points; 45 | fprintf(fid, 'Array("NAME:PLPoint", _\n'); 46 | clearvars temp 47 | temp = Points{i,1}; 48 | for j = 1:2 49 | if isnumeric(temp{1,j}) 50 | fprintf(fid, '"%s:=", "%f%s", _\n', Coor{j}, temp{1,j}, Units); 51 | else 52 | fprintf(fid, '"%s:=", "%s", _\n', Coor{j}, temp{1,j}); 53 | end 54 | end 55 | if isnumeric(temp{1,3}) 56 | fprintf(fid, '"%s:=", "%f%s")), _\n', Coor{3}, temp{1,3}, Units); 57 | else 58 | fprintf(fid, '"%s:=", "%s")), _\n', Coor{3}, temp{1,3}); 59 | end 60 | 61 | fprintf(fid, 'Array("NAME:PolylineSegments", Array("NAME:PLSegment", "SegmentType:=", "Line", "StartIndex:=", 0, _\n'); 62 | fprintf(fid, '"NoOfPoints:=", %d)), _\n', Num_points); 63 | fprintf(fid, 'Array("NAME:PolylineXSection", "XSectionType:=", "None", "XSectionOrient:=", "Auto", _\n'); 64 | fprintf(fid, '"XSectionWidth:=", "0mm", "XSectionTopWidth:=", "0mm", "XSectionHeight:=", "0mm", "XSectionNumSegments:=", "0", "XSectionBendType:=", "Corner")), _\n'); 65 | fprintf(fid, 'Array("NAME:Attributes", "Name:=", "%s", _\n', Name); 66 | fprintf(fid, '"Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=", 0, _\n'); 67 | fprintf(fid, '"PartCoordinateSystem:=", "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", true) \n'); 68 | 69 | -------------------------------------------------------------------------------- /function_w/hfssCreateRelativeCS.asv: -------------------------------------------------------------------------------- 1 | function hfssCreateRelativeCS(fid, Name, Origin, XAxisVec, YAxisVec, Units) 2 | XAxisVec = reshape(XAxisVec, length(XAxisVec), 1); 3 | YAxisVec = reshape(YAxisVec, length(YAxisVec), 1); 4 | if iscell(XAxisVec) ~= 1 5 | XAxisVec = mat2cell(XAxisVec,[1,1,1],1); 6 | end 7 | if iscell(YAxisVec) == 0 8 | YAxisVec = mat2cell(YAxisVec,[1,1,1],1); 9 | end 10 | 11 | fprintf(fid, '\n'); 12 | fprintf(fid, 'oEditor.CreateRelativeCS Array("NAME:RelativeCSParameters", _\n'); 13 | 14 | fprintf(fid, '"OriginX:=", "%f%s", _\n', Origin(1), Units); 15 | fprintf(fid, '"OriginY:=", "%f%s", _\n', Origin(2), Units); 16 | fprintf(fid, '"OriginZ:=", "%f%s", _\n', Origin(3), Units); 17 | 18 | 19 | xyz = ['XYZ']; 20 | for i = 1:3 21 | if isnumeric(XAxisVec{i,1}) 22 | fprintf(fid, '"XAxis%svec:=", "%f%s", _\n', xyz(i), XAxisVec{i,1}, Units); 23 | else 24 | fprintf(fid, '"XAxis%svec:=", "%s", _\n', xyz(i), XAxisVec{i,1}); 25 | end 26 | end 27 | 28 | for i = 1:2 29 | if isnumeric(YAxisVec{i,1}) 30 | fprintf(fid, '"YAxis%svec:=", "%f%s", _\n', xyz(i), YAxisVec{i,1}, Units); 31 | else 32 | fprintf(fid, '"YAxis%svec:=", "%s", _\n', xyz(i), YAxisVec{i,1}); 33 | end 34 | end 35 | if isnumeric(YAxisVec{3,1}) 36 | fprintf(fid, '"YAxis%svec:=", "%f%s"), _\n', xyz(3), YAxisVec{3,1}, Units); 37 | else 38 | fprintf(fid, '"YAxis%svec:=", "%s"), _\n', xyz(3), YAxisVec{3,1}); 39 | end 40 | 41 | fprintf(fid, 'Array("NAME:Attributes", _\n'); 42 | fprintf(fid, '"Name:=", "%s")', Name); 43 | -------------------------------------------------------------------------------- /function_w/hfssCreateRelativeCS.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % function hfssCreateRelativeCS(fid, Name, Origin, XAxisVec, YAxisVec, Units) 3 | % 4 | % Description: 5 | % ------------ 6 | % Create a RelativeCS in HFSS. This function also provides 7 | % an option to punch a bunch of (circular) holes into the polygon object (so 8 | % as to make way for cables, wires, etc.,). 9 | % 10 | 11 | % You should have received a copy of the GNU General Public License along with 12 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 13 | % Place, Suite 330, Shanghai, CN 20171222 14 | % Copyright 2018, WoodyBuendia (woodybuendia@gmail.com) 15 | 16 | function hfssCreateRelativeCS(fid, Name, Origin, XAxisVec, YAxisVec, Units) 17 | Origin = reshape(Origin, length(Origin), 1); 18 | XAxisVec = reshape(XAxisVec, length(XAxisVec), 1); 19 | YAxisVec = reshape(YAxisVec, length(YAxisVec), 1); 20 | if iscell(Origin) == 0 21 | Origin = mat2cell(Origin,[1,1,1],1); 22 | end 23 | if iscell(XAxisVec) == 0 24 | XAxisVec = mat2cell(XAxisVec,[1,1,1],1); 25 | end 26 | if iscell(YAxisVec) == 0 27 | YAxisVec = mat2cell(YAxisVec,[1,1,1],1); 28 | end 29 | 30 | fprintf(fid, '\n'); 31 | fprintf(fid, 'oEditor.CreateRelativeCS Array("NAME:RelativeCSParameters", _\n'); 32 | xyz = 'XYZ'; 33 | 34 | for i = 1:3 35 | if isnumeric(Origin{i,1}) 36 | fprintf(fid, '"Origin%s:=", "%f%s", _\n', xyz(i), Origin{i,1}, Units); 37 | else 38 | fprintf(fid, '"Origin%s:=", "%s", _\n', xyz(i), Origin{i,1}); 39 | end 40 | end 41 | 42 | for i = 1:3 43 | if isnumeric(XAxisVec{i,1}) 44 | fprintf(fid, '"XAxis%svec:=", "%f%s", _\n', xyz(i), XAxisVec{i,1}, Units); 45 | else 46 | fprintf(fid, '"XAxis%svec:=", "%s", _\n', xyz(i), XAxisVec{i,1}); 47 | end 48 | end 49 | 50 | for i = 1:2 51 | if isnumeric(YAxisVec{i,1}) 52 | fprintf(fid, '"YAxis%svec:=", "%f%s", _\n', xyz(i), YAxisVec{i,1}, Units); 53 | else 54 | fprintf(fid, '"YAxis%svec:=", "%s", _\n', xyz(i), YAxisVec{i,1}); 55 | end 56 | end 57 | if isnumeric(YAxisVec{3,1}) 58 | fprintf(fid, '"YAxis%svec:=", "%f%s"), _\n', xyz(3), YAxisVec{3,1}, Units); 59 | else 60 | fprintf(fid, '"YAxis%svec:=", "%s"), _\n', xyz(3), YAxisVec{3,1}); 61 | end 62 | 63 | fprintf(fid, 'Array("NAME:Attributes", _\n'); 64 | fprintf(fid, '"Name:=", "%s")', Name); 65 | -------------------------------------------------------------------------------- /function_w/hfssCreateReportFF.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % function hfssCreateReportFF(fid, PlotType,ReportName, VarList, Geometry, Category,Quantity,Function,f) 3 | % 4 | % Description: 5 | % ------------ 6 | % Create a Far Fields hfssCreateReport in HFSS. 7 | % Input: 8 | % PlotType: 9 | % 1:Rectangular Plot; 2:3D Polar Plot 10 | % ReportName: the name of Report, such as "rE Plot 1" 11 | % VarList: VarList, {} for Nominal to all Var 12 | % Geometry: "Infinite Sphere2" 13 | % Quantity: such as 'rERHCP', 'GainTatol'... 14 | % Function: such as 'abs', 'ang_deg'... 15 | % You should have received a copy of the GNU General Public License along with 16 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | % Place, Suite 330, ShangHai, CN 20171224 18 | % Copyright 2018, WoodyBuendia (woodybuendia@gmail.com) 19 | 20 | function hfssCreateReportFF(fid, PlotType,ReportName, VarList, Geometry,Quantity,Function,f) 21 | 22 | if PlotType == 1 23 | type = 'Rectangular Plot'; 24 | else 25 | if plotTpye == 2 26 | type = '3D Polar Plot'; 27 | end 28 | end 29 | 30 | Y = [Function,'(',Quantity,')']; 31 | 32 | fprintf(fid, '\n'); 33 | fprintf(fid, 'Set oModule = oDesign.GetModule("ReportSetup") \n'); 34 | fprintf(fid, 'oModule.CreateReport "%s", "Far Fields", _\n', ReportName); 35 | fprintf(fid, '"%s", "Setup1 : LastAdaptive", _\n', type); 36 | fprintf(fid, 'Array("Context:=", "%s"), _\n', Geometry); 37 | fprintf(fid,'Array("Theta:=", Array("All"), "Phi:=", Array("All"), _\n'); 38 | fprintf(fid, '"Freq:=", Array("%dGHz")', f); 39 | if length(VarList) >= 1 40 | fprintf(fid, ', _\n'); 41 | for i = 1:length(VarList) 42 | fprintf(fid, '"%s:=", Array( "Nominal")', VarList{i}); 43 | if i ~= length(VarList) 44 | fprintf(fid, ', _\n'); 45 | else 46 | fprintf(fid, '), _\n'); 47 | end 48 | end 49 | else 50 | fprintf(fid, '), _\n'); 51 | end 52 | 53 | if PlotType == 1 54 | fprintf(fid, 'Array("X Component:=", "Theta", "Y Component:=", Array("%s")), Array() \n',Y); 55 | else 56 | if PlotType == 2 57 | fprintf(fid, 'Array("Phi Component:=", "Phi", "Theta Component:=", "Theta", "Mag Component:=", Array("%s")), Array()',Y); 58 | end 59 | end 60 | fprintf(fid, '\n'); 61 | -------------------------------------------------------------------------------- /function_w/hfssCreateS11Report.m: -------------------------------------------------------------------------------- 1 | function hfssCreateS11Report(fid, ReportName, NominalVarList, OptVarList, VarValue, Units) 2 | fprintf(fid, '\n'); 3 | fprintf(fid, 'Set oModule = oDesign.GetModule("ReportSetup") \n'); 4 | fprintf(fid, 'oModule.CreateReport "%s", "Modal Solution Data", _\n', ReportName); 5 | fprintf(fid, '"Rectangular Plot", "solve : sweep1", Array("Domain:=", "Sweep"), _\n'); 6 | fprintf(fid,'Array( _\n'); 7 | fprintf(fid, '"Freq:=", Array("All"), _\n'); 8 | 9 | for i = 1:length(NominalVarList) 10 | 11 | fprintf(fid, '"%s:=", Array( "Nominal"), _\n', NominalVarList{i}); 12 | 13 | end 14 | 15 | 16 | 17 | for i = 1:length(OptVarList) 18 | fprintf(fid, '"%s:=", Array( ', cell2mat(OptVarList{i})); 19 | clearvars temp 20 | temp = VarValue{i}; 21 | for j = 1:length(temp)-1 22 | fprintf(fid, '"%.15f%s",',temp(j),Units); 23 | end 24 | fprintf(fid, '"%.15f%s")',temp(length(temp)),Units); 25 | if i ~= length(OptVarList) 26 | fprintf(fid, ', _\n'); 27 | else 28 | fprintf(fid, '), _\n'); 29 | end 30 | 31 | end 32 | 33 | 34 | 35 | fprintf(fid, 'Array("X Component:=", "Freq", "Y Component:=", Array( "dB(S(p1,p1))")), Array()'); 36 | end -------------------------------------------------------------------------------- /function_w/hfssExportImageToFile.m: -------------------------------------------------------------------------------- 1 | function hfssExportImageToFile(fid,reportName,filepath) 2 | fprintf(fid,'Set oModule = oDesign.GetModule("ReportSetup") \n'); 3 | fprintf(fid,'oModule.ExportImageToFile "%s", _\n',reportName); 4 | fprintf(fid,'"%s", 0, 0 \n',filepath); 5 | -------------------------------------------------------------------------------- /function_w/hfssFaceID.m: -------------------------------------------------------------------------------- 1 | %% 2 | %Dim faceid 3 | 4 | % faceid = oEditor.GetFaceByPosition(Array("NAME:Parameters", _ 5 | 6 | % "BodyName:=" "Box1", "XPosition:=", "3.4mm", "YPosition:=, _ 7 | 8 | % "2.8mm", "ZPosition:=", "0.4mm")) 9 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 10 | function faceID = hfssFaceID(fid,BodyName,Position,Units) 11 | fprintf(fid, '\n'); 12 | fprintf(fid,'Dim faceid \n'); 13 | fprintf(fid, 'faceid = oEditor.GetFaceByPosition(Array("NAME:Parameters", _\n'); 14 | fprintf(fid, '"BodyName:=", "%s",_\n', BodyName); 15 | fprintf(fid, '"XPosition:=", "%f%s",_\n', Position(1),Units); 16 | fprintf(fid, '"YPosition:=", "%f%s",_\n', Position(2),Units); 17 | fprintf(fid, '"ZPosition:=", "%f%s"))\n', Position(3),Units); 18 | -------------------------------------------------------------------------------- /function_w/hfssModel.m: -------------------------------------------------------------------------------- 1 | function hfssModel(fid, ObjList, state) 2 | fprintf(fid, 'Set oEditor = oDesign.SetActiveEditor("3D Modeler") \n'); 3 | fprintf(fid, 'oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", _\n'); 4 | fprintf(fid, 'Array("NAME:PropServers", _\n'); 5 | Num = length(ObjList); 6 | for i = 1:Num-1 7 | fprintf(fid, '"%s", _\n', ObjList{i}); 8 | end 9 | fprintf(fid, '"%s"), _\n', ObjList{Num}); 10 | fprintf(fid, 'Array("NAME:ChangedProps", Array("NAME:Model", "Value:=", _\n'); 11 | if state == 1 12 | Model = 'true'; 13 | else 14 | Model = 'false'; 15 | 16 | end 17 | fprintf(fid, '%s)))) \n', Model); 18 | end -------------------------------------------------------------------------------- /function_w/hfssSetWCS.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % function hfssSetWCS(fid, Name) 3 | % 4 | % Description: 5 | % ------------ 6 | % Create a hfss SetWCS in HFSS. This function also provides 7 | % an option to punch a bunch of (circular) holes into the polygon object (so 8 | % as to make way for cables, wires, etc.,). 9 | % 10 | 11 | % You should have received a copy of the GNU General Public License along with 12 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 13 | % Place, Suite 330, ShangHai, CN 20171222 14 | % Copyright 2018, WoodyBuendia (woodybuendia@gmail.com) 15 | function hfssSetWCS(fid, Name) 16 | %oEditor.SetWCS Array("NAME:SetWCS Parameter", "Working Coordinate System:=", "RelativeCS1") 17 | fprintf(fid, '\n'); 18 | fprintf(fid, 'Set oEditor = oDesign.SetActiveEditor("3D Modeler") \n'); 19 | fprintf(fid, 'oEditor.SetWCS Array("NAME:SetWCS Parameter", _\n'); 20 | fprintf(fid, '"Working Coordinate System:=", "%s")', Name); 21 | fprintf(fid, '\n'); 22 | end -------------------------------------------------------------------------------- /function_w/hfssaddVar.asv: -------------------------------------------------------------------------------- 1 | % function hfssaddVar(fid,VarName,Vaule,Units) 2 | % add LocalVariable 3 | % only one Variable can be add once 4 | 5 | function hfssaddVar(fid,VarName,Vaule,Units) 6 | fprintf(fid, '\n'); 7 | fprintf(fid, 'oEditor.ChangeProperty _\n'); 8 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 9 | fprintf(fid, 'Array("NAME:LocalVariableTab", _\n'); 10 | fprintf(fid, 'Array("NAME:PropServers","LocalVariables"), _\n'); 11 | fprintf(fid, 'Array("NAME:NewProps", _\n'); 12 | fprintf(fid, 'Array("NAME:%s", _\n',VarName); 13 | fprintf(fid, '"PropType:=", "VariableProp", "UserDef:=",true, _\n'); 14 | if isnumi 15 | if isempty(Units) 16 | fprintf(fid, '"Value:=", "%f")))) \n', Vaule); 17 | else 18 | fprintf(fid, '"Value:=", "%f%s")))) \n', Vaule, Units); 19 | end 20 | 21 | % oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers", _ 22 | % "LocalVariables"), Array("NAME:NewProps", Array("NAME:c", "PropType:=", "VariableProp", "UserDef:=", _ 23 | % true, "Value:=", "10mm")))) -------------------------------------------------------------------------------- /function_w/hfssaddVar.m: -------------------------------------------------------------------------------- 1 | % function hfssaddVar(fid,VarName,Vaule,Units) 2 | % add LocalVariable 3 | % only one Variable can be add once 4 | % Copyright 2016, WoodyBuendia (woodybuendia@gmail.com) 5 | function hfssaddVar(fid,VarName,Vaule,Units) 6 | fprintf(fid, '\n'); 7 | fprintf(fid, 'oEditor.ChangeProperty _\n'); 8 | fprintf(fid, 'Array("NAME:AllTabs", _\n'); 9 | fprintf(fid, 'Array("NAME:LocalVariableTab", _\n'); 10 | fprintf(fid, 'Array("NAME:PropServers","LocalVariables"), _\n'); 11 | fprintf(fid, 'Array("NAME:NewProps", _\n'); 12 | fprintf(fid, 'Array("NAME:%s", _\n',VarName); 13 | fprintf(fid, '"PropType:=", "VariableProp", "UserDef:=",true, _\n'); 14 | if isnumeric(Vaule) 15 | if isempty(Units) 16 | fprintf(fid, '"Value:=", "%f")))) \n', Vaule); 17 | else 18 | fprintf(fid, '"Value:=", "%f%s")))) \n', Vaule, Units); 19 | end 20 | else 21 | if isempty(Units) 22 | fprintf(fid, '"Value:=", "%s")))) \n', Vaule); 23 | else 24 | fprintf(fid, '"Value:=", "%s%s")))) \n', Vaule, Units); 25 | end 26 | end 27 | 28 | 29 | % oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers", _ 30 | % "LocalVariables"), Array("NAME:NewProps", Array("NAME:c", "PropType:=", "VariableProp", "UserDef:=", _ 31 | % true, "Value:=", "10mm")))) -------------------------------------------------------------------------------- /general/hfssAddMaterial.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssAddMaterial(fid, Name, Er, bSigma, tanDelta) 3 | % 4 | % Description : 5 | % ------------- 6 | % Creates VB Script necessary to add a new material to the HFSS Materials 7 | % Manager. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % Name - name of the material to be added. 13 | % Er - dielectric constant of the material to be added. 14 | % bSigma - bulk conductivity of the material to be added (Siemens) 15 | % tanDelta - loss tangent of the material. 16 | % 17 | % Note : 18 | % ------ 19 | % If a material with the given name already exists in HFSS, this code will 20 | % have no effect and the script will continue running. A warning message will 21 | % appear in the HFSS message log. 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('Dipole.vbs', 'wt'); 26 | % ... 27 | % hfssAddMaterial(fid, 'CoaxDielectric', 2.07, 0, 0); 28 | % ---------------------------------------------------------------------------- 29 | 30 | % ---------------------------------------------------------------------------- 31 | % This file is part of HFSS-MATLAB-API. 32 | % 33 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 34 | % under the terms of the GNU General Public License as published by the Free 35 | % Software Foundation; either version 2 of the License, or (at your option) 36 | % any later version. 37 | % 38 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 39 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 40 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41 | % for more details. 42 | % 43 | % You should have received a copy of the GNU General Public License along with 44 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 45 | % Place, Suite 330, Boston, MA 02111-1307 USA 46 | % 47 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 48 | % ---------------------------------------------------------------------------- 49 | function hfssAddMaterial(fid, Name, Er, bSigma, tanDelta) 50 | 51 | % Preamble. 52 | fprintf(fid, '\n'); 53 | fprintf(fid, 'oProject.AddMaterial _\n'); 54 | 55 | % Name. 56 | fprintf(fid, 'Array("NAME:%s", _\n', Name); 57 | 58 | % Dielectric Properties. 59 | fprintf(fid, '"permittivity:=", "%f", _\n', Er); 60 | fprintf(fid, '"conductivity:=", "%f", _\n', bSigma); 61 | fprintf(fid, '"dielectric_loss_tangent:=", "%f")\n', tanDelta); 62 | -------------------------------------------------------------------------------- /general/hfssCloseActiveProject.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssCloseActiveProject(fid) 3 | % 4 | % Description : 5 | % ------------- 6 | % Create the VB Script necessary to close the active project. The unsaved 7 | % changes made so far will be IGNORED. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % 13 | % Note : 14 | % ------ 15 | % To repeat, the unsaved changes will be ignored. Use hfssSaveProject() 16 | % before this if you wish to retain all the changes that you did. 17 | % 18 | % Example : 19 | % --------- 20 | % fid = fopen('myantenna.vbs', 'wt'); 21 | % ... 22 | % hfssCloseActiveProject(fid); 23 | % 24 | % ---------------------------------------------------------------------------- 25 | 26 | % ---------------------------------------------------------------------------- 27 | % This file is part of HFSS-MATLAB-API. 28 | % 29 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 30 | % under the terms of the GNU General Public License as published by the Free 31 | % Software Foundation; either version 2 of the License, or (at your option) 32 | % any later version. 33 | % 34 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 35 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 36 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 37 | % for more details. 38 | % 39 | % You should have received a copy of the GNU General Public License along with 40 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 41 | % Place, Suite 330, Boston, MA 02111-1307 USA 42 | % 43 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 44 | % ---------------------------------------------------------------------------- 45 | 46 | function hfssCloseActiveProject(fid) 47 | 48 | fprintf(fid, '\n'); 49 | fprintf(fid, 'Set oProject = oDesktop.GetActiveProject()\n'); 50 | fprintf(fid, 'oProject.Close\n'); 51 | -------------------------------------------------------------------------------- /general/hfssInsertDesign.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssInsertDesign(fid, designName, [designType = 'driven modal']) 3 | % 4 | % Description : 5 | % ------------- 6 | % Create the necessary VB Script to insert an HFSS Design into the Project 7 | % and set it as the active design. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % designName - name of the new design to be inserted. 13 | % designType - (Optional String) choose from the following: 14 | % 1. 'driven modal' (default) 15 | % 2. 'driven terminal' 16 | % 3. 'eigenmode' 17 | % 18 | % Note : 19 | % ------ 20 | % This function is usually called after a call to either hfssNewProject() 21 | % or hfssOpenProject(), but this is not necessary. 22 | % 23 | % Example : 24 | % --------- 25 | % fid = fopen('myantenna.vbs', 'wt'); 26 | % ... 27 | % hfssInsertDesign(fid, 'Dipole_SingleElement'); 28 | % ---------------------------------------------------------------------------- 29 | 30 | % ---------------------------------------------------------------------------- 31 | % This file is part of HFSS-MATLAB-API. 32 | % 33 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 34 | % under the terms of the GNU General Public License as published by the Free 35 | % Software Foundation; either version 2 of the License, or (at your option) 36 | % any later version. 37 | % 38 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 39 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 40 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41 | % for more details. 42 | % 43 | % You should have received a copy of the GNU General Public License along with 44 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 45 | % Place, Suite 330, Boston, MA 02111-1307 USA 46 | % 47 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 48 | % ---------------------------------------------------------------------------- 49 | function hfssInsertDesign(fid, designName, designType) 50 | 51 | % arguments processor. 52 | if (nargin < 2) 53 | error('Insufficient number of arguments !'); 54 | elseif (nargin < 3) 55 | designType = []; 56 | end; 57 | 58 | % default arguments. 59 | if isempty(designType) 60 | designType = 'driven modal'; 61 | end; 62 | 63 | % create the necessary script. 64 | fprintf(fid, '\n'); 65 | fprintf(fid, 'oProject.InsertDesign "HFSS", '); 66 | fprintf(fid, '"%s", ', designName); 67 | switch (lower(designType)) 68 | case 'driven terminal', 69 | fprintf(fid, '"DrivenTerminal", ""\n'); 70 | case 'driven modal' 71 | fprintf(fid, '"DrivenModal", ""\n'); 72 | case 'eigenmode' 73 | fprintf(fid, '"Eigenmode", ""\n'); 74 | end; 75 | fprintf(fid, 'Set oDesign = oProject.SetActiveDesign("%s")\n', designName); 76 | fprintf(fid, 'Set oEditor = oDesign.SetActiveEditor("3D Modeler")\n'); 77 | -------------------------------------------------------------------------------- /general/hfssNewProject.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % function hfssNewProject(fid) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the necessary VBScript to create a new HFSS project 7 | % file, set it as the active project. 8 | % 9 | % Parameters: 10 | % ----------- 11 | % fid - file identifier of the VBScript File. 12 | % -------------------------------------------------------------------------- % 13 | 14 | % ---------------------------------------------------------------------------- 15 | % This file is part of HFSS-MATLAB-API. 16 | % 17 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 18 | % under the terms of the GNU General Public License as published by the Free 19 | % Software Foundation; either version 2 of the License, or (at your option) 20 | % any later version. 21 | % 22 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 23 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 24 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25 | % for more details. 26 | % 27 | % You should have received a copy of the GNU General Public License along with 28 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 29 | % Place, Suite 330, Boston, MA 02111-1307 USA 30 | % 31 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 32 | % ---------------------------------------------------------------------------- 33 | function hfssNewProject(fid) 34 | 35 | % Preamble. 36 | fprintf(fid, 'Dim oAnsoftApp\n'); 37 | fprintf(fid, 'Dim oDesktop\n'); 38 | fprintf(fid, 'Dim oProject\n'); 39 | fprintf(fid, 'Dim oDesign\n'); 40 | fprintf(fid, 'Dim oEditor\n'); 41 | fprintf(fid, 'Dim oModule\n'); 42 | fprintf(fid, '\n'); 43 | 44 | % Create a New Project. 45 | fprintf(fid, 'Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")\n'); 46 | fprintf(fid, 'Set oDesktop = oAnsoftApp.GetAppDesktop()\n'); 47 | fprintf(fid, 'oDesktop.RestoreWindow\n'); 48 | fprintf(fid,'Set oProject = oDesktop.NewProject \n'); 49 | 50 | % The new project created is the active project. 51 | 52 | -------------------------------------------------------------------------------- /general/hfssOpenProject.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % function hfssOpenProject(fid, hfssFile) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the VB Script necessary to open a specified HFSS 7 | % project file in HFSS. The FULL PATH of the HFSS project file must be 8 | % provided for HFSS to properly open the file (and ofcourse, the file must 9 | % already exist !) 10 | % 11 | % Parameters : 12 | % ------------ 13 | % fid - file identifier for the VBScript file. 14 | % hfssFile - the (existing) HFSS project file to be opened. The file 15 | % specification must include the FULL FILE PATH and the file 16 | % extension. 17 | % 18 | % Note : 19 | % ------ 20 | % Use this function if you wish to open an already existing HFSS design and 21 | % add some MATLAB-generated VB script components into it. 22 | % 23 | % -------------------------------------------------------------------------- % 24 | 25 | % ---------------------------------------------------------------------------- 26 | % This file is part of HFSS-MATLAB-API. 27 | % 28 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 29 | % under the terms of the GNU General Public License as published by the Free 30 | % Software Foundation; either version 2 of the License, or (at your option) 31 | % any later version. 32 | % 33 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 34 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 35 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 36 | % for more details. 37 | % 38 | % You should have received a copy of the GNU General Public License along with 39 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 40 | % Place, Suite 330, Boston, MA 02111-1307 USA 41 | % 42 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 43 | % ---------------------------------------------------------------------------- 44 | 45 | function hfssOpenProject(fid, hfssProjectFile, DesignName) 46 | 47 | [Path, projectName, Ext] = fileparts(hfssProjectFile); 48 | 49 | % Check extension. 50 | if (~strcmp(Ext, '.hfss')) 51 | warning('File Extension is not .hfss !'); 52 | end; 53 | 54 | % Preamble. 55 | fprintf(fid, 'Dim oHfssApp\n'); 56 | fprintf(fid, 'Dim oDesktop\n'); 57 | fprintf(fid, 'Dim oProject\n'); 58 | fprintf(fid, 'Dim oDesign\n'); 59 | fprintf(fid, 'Dim oEditor\n'); 60 | fprintf(fid, 'Dim oModule\n'); 61 | fprintf(fid, '\n'); 62 | fprintf(fid, 'Set oHfssApp = CreateObject("AnsoftHfss.HfssScriptInterface")\n'); 63 | fprintf(fid, 'Set oDesktop = oHfssApp.GetAppDesktop()\n'); 64 | fprintf(fid, 'oDesktop.RestoreWindow\n'); 65 | fprintf(fid, 'oDesktop.OpenProject "%s"\n', hfssProjectFile); 66 | fprintf(fid, 'Set oProject = oDesktop.SetActiveProject("%s")\n', projectName); 67 | fprintf(fid, 'Set oDesign = oProject.SetActiveDesign("%s")\n', DesignName); -------------------------------------------------------------------------------- /general/hfssSaveProject.m: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------------- 2 | % function hfssSaveProject(fid, projectFile, [Overwrite = false]) 3 | % 4 | % Description : 5 | % ------------- 6 | % This function creates the necessary VB script to save the active HFSS 7 | % project onto a disk file. 8 | % 9 | % Parameters : 10 | % ------------ 11 | % fid - file identifier of the HFSS script file. 12 | % projectFile - full file name of the project file into which the active HFSS 13 | % project will be saved. 14 | % [Overwrite] - (boolean) if set to true will overwrite any existing file with 15 | % the same name as that specified by projectFile. 16 | % 17 | % 18 | % Note : 19 | % ------ 20 | % The active HFSS project MUST be saved prior to solving it. This is slightly 21 | % disadvantageous because we cannot create and solve projects "on-the-fly" - 22 | % i.e., in memory without creating a project file on the disk. One workaround 23 | % is to write the project to a temporary file and then delete the temporary 24 | % file after the required solution is obtained. 25 | % 26 | % Example : 27 | % --------- 28 | % fid = fopen('myantenna.vbs', 'wt'); 29 | % ... 30 | % 31 | % ---------------------------------------------------------------------------- 32 | 33 | % ---------------------------------------------------------------------------- 34 | % This file is part of HFSS-MATLAB-API. 35 | % 36 | % HFSS-MATLAB-API is free software; you can redistribute it and/or modify it 37 | % under the terms of the GNU General Public License as published by the Free 38 | % Software Foundation; either version 2 of the License, or (at your option) 39 | % any later version. 40 | % 41 | % HFSS-MATLAB-API is distributed in the hope that it will be useful, but 42 | % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 43 | % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 44 | % for more details. 45 | % 46 | % You should have received a copy of the GNU General Public License along with 47 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 48 | % Place, Suite 330, Boston, MA 02111-1307 USA 49 | % 50 | % Copyright 2004, Vijay Ramasami (rvc@ku.edu) 51 | % ---------------------------------------------------------------------------- 52 | 53 | function hfssSaveProject(fid, projectFile, Overwrite) 54 | 55 | % arguments processor. 56 | if (nargin < 2) 57 | error('Insufficient # of arguments !'); 58 | elseif (nargin < 3) 59 | Overwrite = []; 60 | end; 61 | 62 | % default arguments. 63 | if isempty(Overwrite) 64 | Overwrite = false; 65 | end; 66 | 67 | % create the script. 68 | fprintf(fid, '\n'); 69 | fprintf(fid, 'oProject.SaveAs _\n'); 70 | fprintf(fid, '"%s", _\n', projectFile); 71 | if (Overwrite) 72 | fprintf(fid, ' true\n'); 73 | else 74 | fprintf(fid, ' false\n'); 75 | end; 76 | 77 | -------------------------------------------------------------------------------- /general/hfssSetActiveProject.m: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- % 2 | % function hfssSetActiveProject(fid,fileName,DesignName) 3 | % 4 | % Description: 5 | % ------------ 6 | % SetActiveProject with a opened porject in HFSS. 7 | % 8 | % You should have received a copy of the GNU General Public License along with 9 | % Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple 10 | % Place, Suite 330, ShangHai, CN 20180208 11 | % Copyright 2018, WoodyBuendia (woodybuendia@gmail.com) 12 | function hfssSetActiveProject(fid, hfssProjectFile, DesignName) 13 | [Path, projectName, Ext] = fileparts(hfssProjectFile); 14 | 15 | % Check extension. 16 | if (~strcmp(Ext, '.hfss')) 17 | warning('File Extension is not .hfss !'); 18 | end; 19 | 20 | % Preamble. 21 | fprintf(fid, 'Dim oHfssApp\n'); 22 | fprintf(fid, 'Dim oDesktop\n'); 23 | fprintf(fid, 'Dim oProject\n'); 24 | fprintf(fid, 'Dim oDesign\n'); 25 | fprintf(fid, 'Dim oEditor\n'); 26 | fprintf(fid, 'Dim oModule\n'); 27 | fprintf(fid, '\n'); 28 | fprintf(fid, 'Set oHfssApp = CreateObject("AnsoftHfss.HfssScriptInterface")\n'); 29 | fprintf(fid, 'Set oDesktop = oHfssApp.GetAppDesktop()\n'); 30 | fprintf(fid, 'oDesktop.RestoreWindow\n'); 31 | fprintf(fid, 'Set oProject = oDesktop.SetActiveProject("%s")\n', projectName); 32 | fprintf(fid, 'Set oDesign = oProject.SetActiveDesign("%s")\n', DesignName); -------------------------------------------------------------------------------- /hfssapi.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/hfssapi.rar -------------------------------------------------------------------------------- /my_polar.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/my_polar.m -------------------------------------------------------------------------------- /yueliang/example/my_cone.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/yueliang/example/my_cone.m -------------------------------------------------------------------------------- /yueliang/example/my_conicalhorn.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/yueliang/example/my_conicalhorn.m -------------------------------------------------------------------------------- /yueliang/example/my_cylinder.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoodyBuendia/HFSS-MATLAB-API/8e5a5879054282d50328528ce00be2be3fbdfbb2/yueliang/example/my_cylinder.m --------------------------------------------------------------------------------