See discussions, stats, and author profiles for this publication at: [Link]
net/publication/330520619
Using CST with Matlab
Method · January 2019
CITATIONS READS
0 1,017
1 author:
Elena Mikheeva
Institut Fresnel
2 PUBLICATIONS 1 CITATION
SEE PROFILE
All content following this page was uploaded by Elena Mikheeva on 21 January 2019.
The user has requested enhancement of the downloaded file.
Running CST Studio simulations with Matlab
This document is to describe how to run a simulation in CST Studio from Matlab: how to pass
commands, change parameters, save the result and others.
It can be done by using ActiveX framework ([Link]
It is sufficient to only use few basic ActiveX functions:
actxserver – initialization (opening) of the controlled program (CST)
invoke – calling the units of controlled program
Examples:
сst = actxserver('[Link]')
Command connects variable “cst” and object “[Link]”. In this case
“[Link]” is a unique name in the ActiveX environment showing which program we are
calling.
mws = invoke(cst , 'NewMWS')
Like that we are sending a command into the variable “cst” connected with the application CST Studio to
create a new empty window
invoke(mws, 'OpenFile', '<File path>')
Sends a command to open a concrete file situated in the “File path” directory in a just opened empty
window connected with a variable “mws”
solver = invoke(mws, ‘Solver’)
Writes into the variable “solver” a call to the time domain-solver. If we want to call other solvers, we
should replace ‘Solver’ with ‘FDSolver’ for frequency domain, ‘EigenmodeSolver’ for eigenmode and so
on.
invoke(solver, 'start')
Starts the solver
invoke(mws, 'save')
Saves changes
invoke(cst, 'quit')
Closes the file.
More explanation and examples:
1. General description of using CST through Matlab, building the object, changing units and
parameters
[Link]
2. Concrete example of antenna simulation (parameters sweep and results treatment) with scripts:
[Link]
My example:
Frequency-domain simulation of the periodic structure with the unit cell boundary conditions. I am
considering 2 Floquet modes corresponding to TM and TE polarizations and making simulations at
oblique incidence:
%running an oblique incidence simulations in CST with a periodic
%structure
clear all; clc;
close all;
cst = actxserver('[Link]');
mws = [Link]('NewMWS');
plot1d = [Link]('Plot1D');
export = [Link]('ASCIIExport');
[Link]('OpenFile','file_path\file_name.cst');
N = 10;
theta=linspace(0,45,N);
for ii = 1:N
[Link]('StoreDoubleParameter','theta', theta(ii)); %send into
parameter theta a new value
[Link]('Rebuild'); %rebuild a structure
hSolver = invoke(mws,'FDSolver');
invoke(hSolver,'Start');
str_theta = num2str(theta(ii));
f_name = strcat('file_path\file_name\',str_theta,'[Link]'); %create a
name
%saving the result, absolute value, TM-polarization
[Link]('SelectTreeItem','1D Results\S-Parameters\SZmin(1),Zmax(1)');
%select results
[Link]('PlotView','magnitude'); %switch to the absolute value, can
be 'phase' or others
[Link]('Reset');
[Link]('FileName',f_name);
[Link]('Mode','FixedNumber');
[Link]('Step','1001'); %number of points can be changed in CST in
simulation, setup solver, properties
[Link]('Execute')
t = h_remove(f_name); %using a script from the link 2 to remove first 2
lines in a saved file
A(:,ii)= t(:,2)'; %saving results for each value into a matrix
end
%saving a matrix
fid = fopen('[Link]','wt');
for ii = 1:size(A,1)
fprintf(fid,'%g\t',A(ii,:));
fprintf(fid,'\n');
end
fclose(fid)
More information on possible commands can be found in CST help:
View publication stats