How to control HFSS v11 from Matlab?

Status
Not open for further replies.
mathlab hfss

has anybody got working examples on antenna in HFSS11 not earlier versions
 

hfss11.2 download

Hi,
This is the famous HFSS-API. It works well with HFSS9x. You could just follow these examples, and adapt them to HFSS11.

Have fun!
 
matlab api hfss

very useful!!!
 

matlab hfssv11

hi couless
thanks for your kindness,
but i found that the script.pdf file you uploaded is the same as my own.
ansoft didn't update their this file correctly.

the outputvariable script has been deprecated as indicated in HFSS, although it still works.

i try to implement an API to export the network parameters, such as S,Y,Z,Gamma,Zo, just like the built-in script "oModule.ExportNetworkData"

but I can only export the results of the first frequency point, the later ones are all outflow, i don't know why
 

hfss matlab scripting

i try to optim antenna using PSO with HFSS
 

hfss-matlab


You can implement an API to create a report and extract its data. I did it and it worked.
 

Re: hfss-matlab

danieldani said:
You can implement an API to create a report and extract its data. I did it and it worked.

Did you build a function which can report Gain of antenna? Can you upload this function? Thanks
 

Re: MATLAB-HFSSv11

This post has not been active for some time, but I haven't seen this information mentioned elsewhere; I will post it in the hopes that it is useful for someone.

Instead of generating VBscript code as text, writing it to a file, then executing in HFSS as the oft-mentioned MATLAB-HFSS api operates, the current version of MATLAB supports COM objects directly. This means that Matlab scripts and functions can be created to directly execute and control HFSS live, without the delay caused by generating and executing a script. This is very handy for debugging purposes and the original design of the scripts.

(Note - I don't know which versions of Matlab support COM objects. I feel as though it is a relatively new feature ( I use R2009a ), but I don't remember.)

(Another note - since the real interface is the collection of COM objects and the methods that they implement, any programming language/framework that supports COM interop would work to control HFSS, not only Matlab and VBscript)

All of the same objects and function calls as the VBscript version will apply. The only difference between the vbscript and the Matlab version of the interface is different calling semantics.

For example: Where the vbscript uses an Array(...) in a method signature, use a cell array {..} in matlab. Use single quotes instead of double quotes. Wrap all of the arguments to the functions in parentheses, unlike the VB convention. Boolean values in matlab to be passed to HFSS functions can be either in Matlab booleans (true, false), or in string format ('true','false').

Here are some examples of how to translate between VB to matlab:

The setup code is nearly the same:
Code:
hfss = actxserver('AnsoftHfss.HfssScriptInterface');
desktop = hfss.GetAppDesktop();
project = desktop.GetActiveProject();
design = project.GetActiveDesign();
editor = design.SetActiveEditor('3D Modeler');
boundary = design.GetModule('BoundarySetup');

Calling functions to modify the geometry is also very similar, except for the syntactic differences required by matlab. For example, the Box and Move commands:

Code:
%name = HFSSBox(editor,name,position,size,varargin)
%name/value parameters: Material, Color, SolveInside,Transparency
function var = HFSSBox(editor,name,position,size,varargin)

    p = inputParser;
    p.addParamValue('Material','pec');
    p.addParamValue('Color','(132 132 193)');
    p.addParamValue('SolveInside',false);
    p.addParamValue('Transparency',0);
    p.parse(varargin{:});
    mm = @(x)sprintf('%0.4fmm',x);
    var = editor.CreateBox({'NAME:BoxParameters','CoordinateSystemID:=',-1,...
            'XPosition:=',mm(position(1)),'YPosition:=',mm(position(2)),'ZPosition:=',mm(position(3)),...
            'XSize:=',mm(size(1)),'YSize:=',mm(size(2)),'ZSize:=',mm(size(3))},...
            {'NAME:Attributes','Name:=',name,'Flags:=','','MaterialName:=',p.Results.Material,...
            'SolveInside:=',false,'Color:=',p.Results.Color,'Transparency:=',p.Results.Transparency,...
            'PartCoordinateSystem:=','global'});

end


Code:
%HFSSMove(editor,name,vector)
%Arguments:
%   editor: HFSS Editor COM object
%   name: Name of object to be moved
%   vector: [x,y,z] movement vector.
function HFSSMove(editor,name,vector)

    error(nargchk(3,3,nargin,'struct'));
    mm = @(x)sprintf('%0.4fmm',x);
    editor.Move({'NAME:Selections','Selections:=',name},{'NAME:TranslateParameters',...
        'TranslateVectorX:=',mm(vector(1)),'TranslateVectorY:=',mm(vector(2)),...
        'TranslateVectorZ:=',mm(vector(3))});
    
end

I am using this interface for extensive HFSS automation for creating complex parametrized geometry, and am building a library of wrapper functions by adding new functions as I need them. My code has functioned identically on HFSS 11.2 and 12.1.
 
Re: MATLAB-HFSSv11

There is no easy way of optimizing antenna structure using your own generic algorithm in Matlab.I have successfully modelled and simulated my antenna structure in HFSS.Now i just want to Export this structure to Matlab so i can optimize it using some generic algorithm e.g PSO algorithm. There is no way or File format in which we can export the structure to matlab from HFSS.Is it a must to use VBS scripting language for this purpose and there is no other way???
 

Re: MATLAB-HFSSv11

Do you know any method that can save HFSS result by Matlab?
I executed Eigenmode calculation in HFSS controlled by Matlab code as follows.

Code:
oAnsoftApp=actxserver('AnsoftHfss.HfssScriptInterface.12');
oDesktop=oAnsoftApp.GetAppDesktop;
oProject=oDesktop.NewProject;
oDesign=oProject.InsertDesign('HFSS', 'HFSSDesign1','DrivenModal', '');
oEditor=oDesign.SetActiveEditor('3D Modeler');

...........

oDesign.Analyze('Setup1');

But, I don't know how to save result.
I made codes as follows but error message appears.

Code:
oSolutions=oDesign.GetModule('Solutions');
invoke(oSolutions,'ExportEigenmodes','Setup1', '', 'C:\Documents and Settings\sh\My Documents\Ansoft\eig1.eig')

If there is any good idea to solve this problem, please let me know.
 

Re: MATLAB-HFSSv11


What is the error message? Remember to check the HFSS error console for more detailed error messages than appear in the Matlab terminal.

Most of the data export to file commands can be found in the script recorder and translated to Matlab. I haven't used this function, however, so I would need to have a better idea of the error message to be of any more assistance.

Another resource is to look in the HFSS scripting help documentation for the function you are working with. Their example code for this function:

Code:
Set oModule = oDesign.GetModule("Solutions")
oModule.ExportEigenmodes "Setup1 : LastAdaptive", "", _
"C:\mydir\myeigenmode" & _ 
".eig"

They use "Setup1 : LastAdaptive" instead of simply "Setup1"; Could that be an issue?
 

Re: hfss å’Œmatlab

Thanks for the script file that is uploadad. I am working on the same procedure, desgining a patch antenna in hfss and optimizing it with matlab. This topic will be very useful.

Hello Isilb,

I'm working on designing a patch array antenna using HFSS and I want to ingrate SPST switch to make short and long range. Do you have any idea how to implement this? I'm a newbie and I just started working on it.

Thanks,
 

Re: MATLAB-HFSSv11

Hello; has someone a book about this prob? thanks.
 

Re: hfss matlab ink

I attach here the modifications I have done to both, the visual script and de matlab script for HFSS version 11. I think it works.
The program is useful for me.After read it,I know how to use it!
 

Re: hfss 和 matlab

hii..
im new to hfss.rght now im learing how to write the files i mean only some files are there relted to matlab hfss api.so i need the steps how to run it.
i know the commands but im not understanding to generate it.
can u please help me
 

Re: hfss 和 matlab

samyuk!

I am also having the same problem. Have you found the solution? Or can anyone tell us how to do it?

---------- Post added at 07:50 ---------- Previous post was at 07:29 ----------

I am having this error, when I run code in MATLAB
First it says


The Initial Dipole Length is 1.00 meter ...
Running iteration #1 ...
Creating the Script File ...


then it says

??? Error using ==> fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in ==> hfssNewProject at 36
fprintf(fid, 'Dim oHfssApp\n');

Error in ==> example_antenna at 61
hfssNewProject(fid);
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…