Sie sind auf Seite 1von 24

Tricks and Treats for CST Programmers

Amit Rappel, Itzik Haimov


CST EUC MAY 2012

Background

Proprietary and Confidential

Background
Goji Ltd develops technology for spatially controlled

energy delivery
Goji processes of dielectric heating involve complex
co-simulations
Many user-defined combinations of monitors are
to be evaluated
An in-house tool was developed to facilitate such
manipulations (SARA)

This presentation shares some useful notes about


harnessing CST for external data manipulations
3

Who is SARA?

Proprietary and Confidential

Product Overview
SAR, Antenna & Resonator Analyzer

Completely simulates Goji processes


Inspects CST simulations
Applies Goji algorithms

Manipulates CST results

Assesses overall performance

SARA visual example 1/2

SARA visual example 2/2

Design Challenges
User-friendly (fire and forget)
Run CST Run SARA

Programmer-friendly
Robust and flexible coding environment

Performance
Accuracy and running time should be acceptable

Disk space
A single process should be manageable

Selected Architecture

VB.NET
GUI

Matlab

Project Management

Main Calculations

CST & VBA


Simulation

Additional tools

Data manipulation
(CSTResultReader
library)

Notes for the CST programmer


VB.NET VBA
M AT L A B V B A
CST TWILIGHT ZONE

Proprietary and Confidential

10

VB.NET VBA

VB.NET VBA
CST offers Command Line options for invoking VBA
via external programs (Windows, Matlab, etc.)
Command Line options in CST help files
Application note Calling CST studio from Matlab

This method is inconvenient when many commands


are to be executed
Our method comprises a single command line:
VB.NET command

Installation path

Shell("C:\Program Files (x86)\CST STUDIO SUITE 2011\CST DESIGN ENVIRONMENT.exe


-m C:\script.bas")

MWS option

Our flexible macro

VB.NET VBA
Public Sub some_function_1()
model_path = a_model_path
Using sw As StreamWriter = New StreamWriter("C:\script.bas")
sw.WriteLine("'#include "sara_globals.lib")
sw.WriteLine("Option Explicit")
sw.WriteLine("sub main()")
sw.WriteLine(" OpenFile ("model_path.cst") ")
sw.WriteLine(" ports_num=Solver.GetNumberOfPorts")
sw.WriteLine(" analyze_files()")
sw.WriteLine(" Data_Process()")
sw.WriteLine(" SARA_done()")
sw.WriteLine(" Wait(100000000)")
sw.WriteLine("End Sub")
End Using
End Sub

VB.NET VBA
The same command line is used in VB.NET
regardless of the selected process
The auxiliary script is written in real time, and its
internal content is determined by the user input
Troubleshooting
VBA engine blocks nested macros, therefore weve
included our own library of functions
(SARA_globals.lib)
To avoid automatic closing of CST at the end of SARA
process we add Wait(100000000) to view results
When dealing with CST externally, one should recognize
already-open CST instances. We use the task manager.

Matlab VBA

Matlab VBA
Main problems with manipulating CST results
Most calculations are relatively heavy for VBA
ASCII export is both time- and storage-consuming

We chose to work with CSTResultReader.dll library

Pros
Fast processing
External data
manipulation
Works with Matlab

Cons
Writing back into CST
Limited functionality
Only hexahedral
mesh is supported
16

VBA vs. CSTResultReader.dll


Goal: determine which tool is faster

Method: measure execution time of a fictive task


100

Fictive task: Evaluate the fictive field Etot i Ei

(given 100 available E-field monitors Ei

Results:

i 1

i 1..100

10k cells

300k cells

1350k cells

VBA, regular

18s

49s

146s

VBA, no selection

0.86s

20s

81s

Matlab

0.27s

2.75s

11s

Sub-volume monitors will be available soon

Bring the Data Back Home


With CSTResultReader the manipulated result is
outside CST

Matlab offers strong plotting tools, yet CST


visualization is superior
Importing monitors back into CST is not supported,
but can be done by the following 3-step trick:
1. Create a fictive monitor for the same processed CST model
2. Select the final externally-manipulated result you wish to
import into CST
3. Set each point in the fictive monitor to the corresponding
data of the selected result (Done within VBA using SetXRe)

18

CST Twilight Zone

The Data is Here Somewhere


Disclaimer: CSTs staff will not like you after using the
following techniques
When working with CST externally, some internal
information is not easily available

The straight-forward approach of open CST, run a


short script and close CST has two disadvantages:
Wasting (or waiting for) a valuable CST license
Consuming a relatively long time

We suggest an alternative (and less robust) approach

The Data is Here Somewhere


Much of the model information and configurations is
kept in system files that can be easily accessed
The trick is to be familiar with those files (most of
them are called model.xyz) and know how to read and
interpret their content
The main drawback of this trick is that (obviously) CST
does not guarantee neither the content nor the
availability of those files

Lets see two useful examples

ModelCache\model.mif
History list information
Frequency range
Units
Boundaries
Material properties
Ports information
Etc

Result\model.res
Available results
Existence. Not data.
Type
HIDDENITEM
Monitors name and type

The End

24

Das könnte Ihnen auch gefallen