CST STUDIO SUITE™2006 -...

111
CST STUDIO SUITE 2006 CST DESIGN ENVIRONMENT™ | CST MICROWAVE STUDIO® CST EM STUDIO™ | CST PARTICLE STUDIO™ | CST DESIGN STUDIO™ ADVANCED TOPICS CST STUDIO SUITE 2006

Transcript of CST STUDIO SUITE™2006 -...

Page 1: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006CST DESIGN ENVI RONMENT™ | CST MICROWAVE STUDIO®

CST EM STUDIO™ | CST PARTICLE STUDIO™ | CST DESIGN STUDIO™

A D VA N C E D TO P I C S

C S T S T U D I O S U I T E ™ 2 0 0 6

Page 2: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

Copyright© 2005CST GmbH – Computer Simulation TechnologyAll rights reserved.

Information in this document is subject to changewithout notice. The software described in this document is furnished under a license agreementor non-disclosure agreement. The software may be used only in accordance with the terms of thoseagreements.

No part of this documentation may be reproduced,stored in a retrieval system, or transmitted in any form or any means electronic or mechanical,including photocopying and recording for any purpose other than the purchaser’s personal usewithout the written permission of CST.

TrademarksCST MICROWAVE STUDIO,CST DESIGN ENVIRONMENT,CST EM STUDIO, CST PARTICLE STUDIO, CST DESIGNSTUDIO are trademarks or registered trademarks ofCST GmbH.Other brands and their products are trademarks orregistered trademarks of their respective holders andshould be noted as such.

CST – Computer Simulation Technologywww.cst.com

Page 3: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 1

September 24th, 2005

Contents

CHAPTER 1 - INTRODUCTION.................................................................................................................. 3

CHAPTER 2 – THE SIMULATION METHOD.............................................................................................. 4 2.1 Background of the Simulation Method...................................................................................4

The Finite Integration Technique (FIT) ................................................................................... 4 CST MICROWAVE STUDIO Solvers.................................................................................... 7 CST EM STUDIO™ Solvers ................................................................................................... 9 CST PARTICLE STUDIO™ Solvers..................................................................................... 10 References ........................................................................................................................... 11

2.2 Error Sources / Sources of Inaccuracy ................................................................................12 Disagreement between Simulation Model and Reality.......................................................... 12 Inaccuracies due to the Simulation....................................................................................... 12

CHAPTER 3 – MESH GENERATION ........................................................................................................14 3.1 Methods of Hexahedral Mesh Generation ...........................................................................14 3.2 Hexahedral Mesh Generation for High Frequency Problems ..............................................15 3.3 Hexahedral Mesh Adaptation for High Frequency Problems ...............................................20 3.4 Hexahedral Mesh Generation for Low Frequency Problems ...............................................25 3.5 Hexahedral Mesh Adaptation for Low Frequency Problems................................................29 3.6 Tetrahedral Mesh Generation..............................................................................................33 3.7 Recommended Initial Hexahedral Discretizations ...............................................................39

Coaxial Structures ................................................................................................................ 39 Planar Structures .................................................................................................................. 39 Helical Structures ................................................................................................................. 40

3.8 Mesh Tuning........................................................................................................................41 Local Mesh Parameters for Hexahedral Mesh Generation ................................................... 41 Local Mesh Parameters for Tetrahedral Mesh Generation ................................................... 46

CHAPTER 4 – PERFORMANCE IMPROVEMENTS..................................................................................48 4.1 General Hints.......................................................................................................................48 4.2 High Frequency Transient Simulations ................................................................................48

Non Resonating Structures................................................................................................... 52 Resonating Structures .......................................................................................................... 53

4.3 Auto-Regressive Filtering (AR-Filter) ...................................................................................54 4.4 Meshing Thin Conductors Using Tetrahedral Grids.............................................................61

CHAPTER 5 - CAD DATA IMPORT AND HEALING .................................................................................62 5.1 Import 2D Files ....................................................................................................................63 5.2 Import 3D Files ....................................................................................................................64 5.3 Inspect and Repair the Imported Model...............................................................................66 5.4 Parameterize the Imported Model .......................................................................................72

Page 4: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

2 CST STUDIO SUITE™ 2006 – Advanced Topics

CHAPTER 6 – TEMPLATE BASED POST-PROCESSING .......................................................................75 6.1 Framework to Control Result Templates .............................................................................75 6.2 Pre-Loaded Post-processing Templates..............................................................................77

Example for Post-processing Templates .............................................................................. 77

CHAPTER 7 - VBA MACRO LANGUAGE.................................................................................................83 7.1 Introduction..........................................................................................................................83 7.2 VBA Development Environment ..........................................................................................83

VBA Help System ................................................................................................................. 84 VBA Editor Shortcuts ............................................................................................................ 85

7.3 VBA Language Elements.....................................................................................................86 Subroutines and Functions ................................................................................................... 86 Variables, Data Types and Type Conversions...................................................................... 87 Applications, Objects and Their Methods ............................................................................. 88 Flow Control ......................................................................................................................... 90 File Operations ..................................................................................................................... 91 Graphical User Interface Builder........................................................................................... 91 Mathematical Functions, Operators and Constants.............................................................. 92

7.4 Concepts of Macro Programming in CST STUDIO SUITE™...............................................93 User-Defined Functions ........................................................................................................ 93 Local Project Macros ............................................................................................................ 94 Global Macros and Global Library Path ................................................................................ 94

7.5 Control Macros ....................................................................................................................95 Result1D Object ................................................................................................................... 96 Result3D Object ................................................................................................................... 98 Adding Data Items to the Navigation Tree ............................................................................ 99 Traverse Folders and Select Items from the Navigation Tree............................................... 99 Access the Currently Displayed Plot Data .......................................................................... 100 Access Farfield Data from a VBA Script ............................................................................. 101

7.6 Structure Macros ...............................................................................................................102 Create a Structure Macro or a New Project Template ........................................................ 102 Difficulties in Creating Structure Macros............................................................................. 104 Use Dialog Boxes in Structure Macros ............................................................................... 105 Common Pitfalls in the Usage of Structure Macros ............................................................ 105

7.7 Pre-Loaded VBA Macros ...................................................................................................106

Page 5: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 3

Chapter 1 - Introduction This manual is primarily designed for advanced users of CST STUDIO SUITETM who are already familiar with the basic concepts of using the software. Before you start reading this book, we strongly recommend you carefully work through the Getting Started manuals and the Tutorials. This collection of Advanced Topics offers some additional information on subjects that are usually of a more involved nature. The following list gives a short summary of this manual’s contents:

• Chapter 2 is dedicated to the FI method, which is the underlying mathematical

simulation technique. After a general introduction into the method’s fundamentals, the PBA technique (Perfect Boundary Approximation) is also introduced. Further sections in this chapter then explain possible sources of errors or inaccuracies.

• Chapter 3 focuses on mesh generation strategies for both, hexahedral and

tetrahedral meshes.

• Chapter 4 introduces some techniques helping to improve the performance of simulations.

• Chapter 5 covers the basic principles of importing CAD data in two and three

dimensions. Some hints are given on how to improve the robustness and reliability of exchanging CAD data files.

• Chapter 6 explains the Postprocessing Templates and how they can be utilized

to automate the post-processing.

• Chapter 7 provides an introduction to the key concepts of the VBA-based macro programming language used in CST STUDIO SUITETM. You will obtain information on the most important VBA elements through a couple of examples. A basic understanding of these language elements will be very helpful for you in order to write your own macros and user-defined functions.

Please note that this book is not intended to be a complete reference guide. For successfully mastering these more advanced topics, we strongly recommend that you visit a specialized training class. Please contact your local support center for more information.

Page 6: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

4 CST STUDIO SUITE™ 2006 – Advanced Topics

Chapter 2 – The Simulation Method

2.1 Background of the Simulation Method

The Finite Integration Technique (FIT) CST STUDIO SUITETM is a general-purpose electromagnetic simulator based on the Finite Integration Technique (FIT), first proposed by Weiland in 1976/1977 [1]. This numerical method provides a universal spatial discretization scheme applicable to various electromagnetic problems ranging from static field calculations to high frequency applications in time or frequency domain. In the following section the main aspects of this procedure are explained and extended to specialized forms concerning the different solver types. Unlike most numerical methods, FIT discretizes the following integral form of Maxwell’s equations rather than the differential one:

∫∫ ⋅∂∂

−=⋅∂ AA

AdtBsdE

rr

rr , ∫∫ ⋅

+

∂∂

=⋅∂ AA

AdJtDsdH

rrv

rr ,

∫∫ =⋅

∂ VV

dVAdD ρrr

, 0=⋅∫∂V

AdBrr

.

To solve these equations numerically, you must define a finite calculation domain, enclosing the considered application problem. Creating a suitable mesh system splits this domain up into many small elements, or grid cells. For simplicity, we will restrict the following explanations to orthogonal hexahedral grid systems first. The first or primary mesh can be visualized in CST STUDIO SUITETM in the Mesh View; however, internally a second or dual mesh is set up orthogonally to the first one. The spatial discretization of Maxwell’s equations is finally performed on these two orthogonal grid systems where the degrees of freedom are introduced as integral values. Referring to the following picture, the electric grid voltages e and magnetic facet fluxes b are allocated on the primary grid G . In addition, the dielectric facet fluxes d as well as the magnetic grid voltages h are defined on the dual grid G~ (indicated by the tilde):

Page 7: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 5

Now Maxwell’s equations are formulated for each of the cell facets separately as demonstrated in the following. Considering Faraday’s Law, the closed integral on the equation’s left side can be rewritten as a sum of four grid voltages without introducing any supplementary errors. Consequently, the time derivative of the magnetic flux defined on the enclosed primary cell facet represents the right-hand side of the equation, as illustrated in the figure below. Repeating this procedure for all available cell facets summarizes the calculation rule in a matrix formulation, introducing the topological matrix C as the discrete equivalent of the analytical curl operator:

Applying this scheme to Ampère’s law on the dual grid involves the definition of a corresponding dual discrete curl operator C~ . Similarly the discretization of the remaining divergence equations introduces discrete divergence operators S and S~ , belonging to the primary and dual grids, respectively. As previously indicated, these discrete matrix operators consist of elements ‘0’, ‘1’ and ‘-1’, representing merely topological information. Finally we obtain the complete discretized set of Maxwell’s Grid Equations (MGEs):

bCedtd

−= , jdhC +=dtd~ ,

qdS =~

, 0Sb = .

Page 8: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

6 CST STUDIO SUITE™ 2006 – Advanced Topics

Compared to the continuous form of Maxwell’s equations, the similarity between both descriptions is obvious. Once again it should be mentioned that no discretization error has yet been introduced. A remarkable feature of FIT is that important properties of the continuous gradient, curl and divergence operators are still maintained in grid space:

0CSSC ==~~

⇔ 0rotdiv ≡

0SCSC == TT ~~ ⇔ 0gradrot ≡

At this point it should be mentioned that even the spatial discretization of a numerical algorithm could cause long-term instability. However, based on the presented fundamental relations, it can be shown that the FIT formulation is not affected by such problems since the set of MGEs maintain energy and charge conservation [2].

Finally, the missing material relations introduce inevitable numerical inaccuracy due to spatial discretization. In defining the necessary relations between voltages and fluxes, their integral values have to be approximated over the grid edges and cell areas, respectively. Consequently, the resulting coefficients depend on the averaged material parameters as well as on the spatial resolution of the grid and are summarized again in correspondent matrices: ED

rrε= eMd ε=

HBrr

µ= ⇒ hMb µ=

SJEJrrr

+= σ SjeMj += σ Now all matrix equations are available to solve electromagnetic field problems on the discrete grid space. The fact that the topological and metric information is divided into different equations has important theoretical, numerical and algorithmic consequences [2]. In addition to orthogonal hexahedral grids, FIT can also be applied to more general mesh types such as topologically irregular grids (subgrids) and tetrahedral grids, respectively. The picture below shows the allocation of the electric voltages and magnetic fluxes on a tetrahedral mesh cell.

The application of FIT to these more general types of meshes can be seen as an extension to the basic method outlined above. However, due to the limited space in this manual these advanced techniques cannot be presented here. Please refer to the references for more information [4].

ek

ej

ei

bn

Page 9: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 7

In the case of Cartesian grids, the FIT formulation can be rewritten in time domain to yield standard Finite Difference Time Domain methods (FDTD). However, classical FDTD methods are limited to staircase approximations of complex boundaries. In contrast, the Perfect Boundary Approximation (PBA) technique [3] applied to the FIT algorithm maintains all the advantages of structured Cartesian grids while allowing accurate modeling of curved structures. The FI method can be even further enhanced by the Thin Sheet Technique™ (TST) which improves the modeling of thin perfectly electric conducting sheets.

As demonstrated, the FIT formulation is a general method and therefore can be applied to all frequency ranges from DC to high frequencies. One outstanding feature of CST STUDIO SUITETM is the Mesh on DemandTM strategy, which is a combination of hexahedral grids (including PBA® and TST™) and tetrahedral grids. This flexibility allows choosing the best-suited mesh type for every particular application. The Mesh on DemandTM approach is exceptionally powerful in combination with the Method on DemandTM capability which allows choosing the most efficient solver module for the given problem.

Currently, three electromagnetic solver products are available within CST STUDIO SUITETM:

1. CST MICROWAVE STUDIO (MWS), covering the high frequency range, both in transient and in time harmonic state

2. CST EM STUDIO™ (EMS), the low-frequency package, which includes a variety of static and low frequency solvers

3. CST PARTICLE STUDIO™ (PS), the particle tracking solver package

CST MICROWAVE STUDIO Solvers

Three solver types are available concerning high frequency electromagnetic field problems: transient, frequency domain and eigenmode solver. More details about these solvers can be found in the CST MICROWAVE STUDIO® Getting Started manual. The purpose of the following section is to provide basic information about the solvers and to present the corresponding fundamental equations.

Transient Solver The CST MICROWAVE STUDIO transient solver allows the simulation of a structure’s behavior in a wide frequency range in just a single computation run. Consequently, this is an efficient solver for most driven problems, especially for devices with open boundaries or large dimensions. Refer to section 4.2 to get detailed information on how to improve the solver’s performance. The transient solver is based on the solution of the discretized set of Maxwell’s Grid Equations. Substituting the time derivatives by central differences yields explicit update formulation for the loss-free case: [ ]nSnnn t jbMCMee +∆+= −−−+ 112/12/1 ~

µε ,

2/11 ++ ∆−= nnn t eCbb . Regarding the relations above, calculation variables are given by electric voltages and

Page 10: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

8 CST STUDIO SUITE™ 2006 – Advanced Topics

magnetic fluxes. Both types of unknowns are located alternately in time, as in the well-known leap-frog scheme shown below: For example, the magnetic flux at tnt ∆+= )1( is computed from the magnetic flux at the previous time step tnt ∆= and from the electric voltage at half a time step before, at tnt ∆+= )2/1( . Explicit time integration schemes are conditionally stable. The stability limit for the time step ∆t is given by the Courant-Friedrichs-Levy (CFL)-criterion--

222 111

∆+

+

≤∆

zyx

tεµ

--which has to be fulfilled in every single mesh cell.

Frequency Domain Solver

The CST MICROWAVE STUDIO frequency domain solver is useful for simulating electrically small to mid-size problems or for narrowband structures. Other application areas are problems where arbitrary periodic boundaries or even unit cell boundaries are needed. The frequency domain solver is based on Maxwell’s Grid Equations in the time harmonic case ( ωi/ →∂∂ t ). For loss-free problems this leads to the following second-order relation:

( ) ( ) jeMCMC ωωωεωµ εµiJiEcurlcurl −=−⇒−=− −

− 2211

~rr .

The general-purpose frequency domain solver can be used together with hexahedral or tetrahedral grids. The general-purpose solver is accompanied by a solver module specialized for S-parameter calculations in highly resonant loss-free structures such as filters. This solver does not compute fields but is extremely fast compared to other simulation methods. As a third alternative, an extension of the latter solver is available which is able to calculate the fields as well. However, the additional field computation takes quite a bit of time, significantly reducing performance.

ten-1/2 en+1/2bn bn+1

Page 11: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 9

Eigenmode Solver The CST MICROWAVE STUDIO eigenmode solver allows computation of the structure’s eigenmodes and the corresponding eigenvalues. The eigenmode solver is based on the eigenvalue equation for non-driven and loss-free time harmonic problems. The solution is obtained in the loss-free case via the Krylov-Subspace or Jacobi-Davidson method:

eMCeMC εµωεωµ 221

1

~=⇒= −

− EEcurlcurlrr

.

For lossy problems, a Jacobi-Davidson solver is used.

CST EM STUDIO™ Solvers

Five different solver types are available: electrostatic, stationary current, magnetostatic, low-frequency and stationary thermal solvers. More details about these solvers can be found in the CST EM STUDIO™ Getting Started manual. The purpose of this section is to describe the fundamental equations on which the solvers are based.

Electrostatic Solver Based on the discretized Faraday’s Law without time dependency ( 0/ =∂∂ t ) and the appropriate divergence equation, you can construct a linear equation system for electrostatic problems:

qφSMS eT

ε =⇒−= ~~ρφε graddiv

This solver module can be used together with hexahedral or tetrahedral grids.

Stationary Current Solver Based on the discretized Ampere’s Law without time dependency ( 0/ =∂∂ t ) and the appropriate divergence equation, you can construct a linear equation system for stationary current problems:

0φSMS jT =⇒=

~~0 κφκ graddiv

Magnetostatic Solver

To solve magnetostatic field problems, a non-physical vector field hi is constructed in a first step fulfilling Ampère’s Law:

jhC i =⇒=~JHrot i

rr

In general, this field contains magnetic charges that can be eliminated by solving a scalar field problem:

Page 12: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

10 CST STUDIO SUITE™ 2006 – Advanced Topics

miµ qhMS =⇒= miHdiv ρµr

mmmgraddiv qφSMS T =⇒−= µρφµ

Finally, the actual magnetic field vector solution can be obtained from the hi field and the scalar potential by:

mT

i Shh ϕ−=

This solver module can be used together with hexahedral or tetrahedral grids.

Low Frequency Solver The Low Frequency Solver is based on Maxwell’s Grid Equations in the time harmonic case ( ωi/ →∂∂ t ), which leads to the following second-order relation: ( ) ( ) jeMMCMC ωωωωωσεωµ σεµ

iiJiEicurlcurl −=+−⇒−=+− −− 221

1

~rr.

This solver module can be used together with hexahedral or tetrahedral grids.

Stationary Thermal Solver Based on the discretized Fourier’s Law of Heat Conduction without time dependency ( 0/ =∂∂ t ) and the appropriate divergence equation, a linear equation system for stationary thermal problems can be derived:

QTQTgradkdiv k&& =⇒−= TSMS ~~

CST PARTICLE STUDIO™ Solvers CST PARTICLE STUDIOTM contains some of the solver modules which have been already discussed above:

Electrostatic solver Magnetostatic solver Eigenmode solver

In addition to this, CST PARTICLE STUDIOTM also includes some specialized solvers which will be explained in the following. Note that CST PARTICLE STUDIOTM is currently operating on hexahedral grids only.

Particle Tracking Solver The CST PARTICLE STUDIO Particle Tracking Solver calculates the effect of electromagnetic fields on the movement of charged particles. The solver is based on the discretized versions of the electric- and magnetic force law:

Page 13: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 11

)(dd BvEqtvm

rr×+= , )( 2/12/12/111 +++++ ×+∆+= nnnnnnn BvEtvmvm

rr,

vtr rr

=dd

12/12/3 +++ ∆+= nnn vtrr rrr.

Gun Iteration Solver

The Gun Iteration Solver performs alternately electromagnetic calculations of space charge effects and particle tracking calculations. Based on a previous particle tracking run, the corresponding electric space charge caused by the particles is calculated. Then the electric field caused by the space charge is calculated and considered for the next particle tracking iteration. This iteration is repeated until convergence is reached. The picture below illustrates this scheme:

References [1] Weiland, T.: A discretization method for the solution of Maxwell's equations for six-component fields: Electronics and Communication, (AEÜ), Vol. 31, pp. 116-120, 1977. [2] Weiland, T.: Time domain electromagnetic field computation with finite difference methods. International Journal of Numerical Modelling, Vol. 9, pp. 295-319, 1996. [3] Krietenstein, B.; Schuhmann, R.; Thoma, P.; Weiland, T.: The Perfect Boundary Approximation technique facing the challenge of high precision field computation: Proc. of the XIX International Linear Accelerator Conference (LINAC’98), Chicago, USA, pp. 860-862, 1998. [4] T. Weiland: RF & Microwave Simulators - From Component to System Design Proceedings of the European Microwave Week (EUMW 2003), München, Oktober 2003, Vol. 2, pp. 591 - 596.

START

END

Gun Iteration:

Calculate electrostatic

field distribution

Track particles and monitor space-charge

Has space-charge converged?

Relaxation of space-charge

Page 14: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

12 CST STUDIO SUITE™ 2006 – Advanced Topics

2.2 Error Sources / Sources of Inaccuracy Every discretization method is potentially affected by introducing errors either because the model is not identical to the actual device or because the numerical simulation is subject to errors itself. This section gives you an overview of the most important error sources. Many of them may be negligible in practice, but you always should be aware of them in order to make sure that you can rely on your results.

Disagreement between Simulation Model and Reality

Geometric dimensions may be wrong, or geometric details may have been neglected. This happens quite often and can only be avoided by comparing the model carefully with the drawing and the real structure. The influence of small details can be studied by carrying out the same simulation with and without details.

Material parameters may be wrong either because they are not exactly known or because a value was taken which is valid for another frequency band but not for the band of interest. It might be necessary, especially when investigating a broader band, to enter the correct frequency dependency of the material values. For example, for some dielectrics a constant tan δ is an appropriate choice rather than a constant conductivity.

The source of excitation may have not been chosen correctly, e.g. a perfectly matched microstrip port instead of a coax fed microstrip with normalized impedance. Furthermore, for open ports such as microstrips or coplanar lines, the port size should be chosen sufficiently large to correctly capture the field pattern of the propagating modes. Bear in mind that discrete ports are typically not perfectly matched, even when they have the same impedance as the waveguide.

The same considerations are valid for output ports for which you should try to find a simulation model that best fits the measurement structure.

Sometimes the environment is not considered correctly. Objects that are placed near the measured structure may influence the result and, in this case, should be included in the simulation model.

Inaccuracies due to the Simulation

Discretization error: To ensure accurate results, the electromagnetic fields need to be sampled sufficiently dense in space. Generally, the accuracy of the field solution increases with a finer mesh, and it can be proven that convergence is ensured by the FI method. CST STUDIO SUITETM supports convergence studies by automatic adaptation of the mesh density parameters and by visualization of the convergence progress (see sections 3.3 and 3.5).

Truncation error: If a transient calculation stops before the time-domain signals have decayed down to zero, a “truncation error” is introduced. A more detailed discussion of this topic can be found in sections 4.2 and 4.3.

The geometry error is the deviation between the CAD structure and the meshed model. Some methods based on orthogonal grids convert rounded structures into staircase models before starting the simulation. In tetrahedral grids, piecewise straight objects replace rounded structures (see section 3.6). For hexahedral grids in combination with the employed PBA technique (Perfect Boundary Approximation™), the geometrical error becomes very small or even negligible, especially for rounded conductors. However, if an object becomes small compared to the size of the mesh cells, the geometry error may not always be negligible.

Some inaccuracy may be introduced by imperfect boundary conditions. In the case of radiating structures, the open space is simulated by open boundaries. For

Page 15: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 13

high frequency problems, the PML technique (Perfectly Matched Layer) is well suited and very accurate even when the structure is close to the object. CST STUDIO SUITETM chooses the optimum size of the surrounding simulation box automatically, but in some rare cases it may be worthwhile to check the sensitivity of the result to changes of this box.

Waveguide ports have a specific open boundary technique in which the waves are decomposed into their mode patterns. This technique allows even higher accuracies than the PML boundary condition mentioned above. In cases of inhomogeneous ports such as microstrip lines, combined with very large frequency bands, it might be necessary to activate special treatment to keep the error below -50 or -60 dB. As mentioned before, the size of the waveguide port must be defined large enough.

Even if the field values are calculated correctly, interpolation errors may still occur, e.g. when deriving secondary field quantities or when calculating the field values at locations other than the grid’s edges.

Numerical errors may be caused by the finite representation of numbers but can typically be neglected for the explicit algorithm in time domain. However, except for the transient solver, a numerical error may arise when the correspondent matrix system is solved.

Taking these potential sources of inaccuracies into account, you can ensure obtaining higly accurate simulation results by performing mesh convergence studies. Furthermore CST STUDIO SUITE™ offers the feature of simulating the same structure with different discretization types and solvers. This powerful option allows you to double-check the results in critical cases by even using fundamentally different mathematical approaches.

Page 16: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

14 CST STUDIO SUITE™ 2006 – Advanced Topics

Chapter 3 – Mesh Generation

After you have set up your model geometrically and assigned the appropriate power sources and boundary conditions, your model has to be translated into a computer accessible format. As already mentioned above, the FI method, which is the foundation of CST STUDIO SUITETM, is a volume discretization method. Your calculation domain has to be subdivided into small cells on which Maxwell’s Grid Equations must be solved. CST STUDIO SUITETM can use the FI formulation on orthogonal Cartesian grids or on tetrahedral grids. The mesh influences the accuracy and speed of your simulation, so it is worth spending some time on understanding this process.

3.1 Methods of Hexahedral Mesh Generation In general, there are three ways to define a hexahedral mesh: manually, automatically and adaptively. We will introduce their principles briefly before discussing details of the implementation in CST STUDIO SUITETM.

Manual Meshing

A manual mesh can be defined at any time, even before the geometrical model is generated. This is an old-fashioned way of working which we do not recommend.

Automatic Mesh Generation – Expert System

This is probably the most effective way of working with CST STUDIO SUITETM. The mesh generator determines the important features of your structure and automatically creates a mesh, which represents your structure and the fields equally well. This means that the frequency range and dielectrics, metallic edges, etc. are considered by the expert system, but certain mesh properties for individual shapes can also be set manually. At the first level, this mesh generator is governed by only a few settings, but there are many other possibilities to influence the meshing. Furthermore, Project Templates facilitate the mesh creation, and with a little bit of experience, you will be able to obtain reliable solutions in minimal time.

Adaptive Meshing (Energy Based or Expert System Based)

Adaptive meshing replaces your expertise by repeatedly running the simulation and evaluating the solutions. Usually regions with high field concentration or field gradients are recognized where the mesh needs to be locally refined. If the deviation in the results falls below a given accuracy level, the adaptation terminates. This approach always improves the start solution at the expense of simulation time. Since the CST STUDIO SUITETM expert mesher always guarantees a reasonable initial mesh and thus a good starting solution for the mesh adaptation process, the number of passes will normally be small. This following diagram shows the comparison of expert system meshing and adaptive mesh refinement.

Page 17: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 15

However, modifications to the structure force conventional mesh adaptation algorithms to start again from the beginning with each and every change of a parameter. Therefore the adaptive expert system hexahedral mesh refinement trains the expert system for a given structure. It can then maintain the mesh properties while the associated structure parts are slightly modified. You can increase your own expertise on mesh generation by analyzing the steps taken by the adaptive mesh refinement. You can use this knowledge to manually tune the mesh to increase the simulation speed for subsequent simulations. The strategies for mesh generation are quite different for high frequency problems as compared to low frequency applications.

3.2 Hexahedral Mesh Generation for High Frequency Problems

After this overview of meshing techniques, we go into the details of CST STUDIO SUITETM’s hexahedral mesh generation for high frequency problems. The expert system uses lots of parameters controlling the mesh generation, having either local or global influence on the mesh. There are a few settings which you may frequently modify in order to obtain highly efficient meshes. Let's start with the most important global ones:

• Lines per wavelength • Lower mesh limit • Ratio limit (or smallest mesh cell) • Refinement at PEC-edges

These parameters are also set by the Project Templates and the adaptive expert system mesh refinement. Let's start a new project, e.g. a simple coupled microstrip line. In this case the following dialog appears:

Page 18: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

16 CST STUDIO SUITE™ 2006 – Advanced Topics

Select the Planar Coupler template. The info box tells which parameters are set by this template in order to optimize the settings for planar structures. The structure used for the following explanations is shown in the picture below:

Now visualize the mesh by entering the Mesh View (Mesh Mesh View, ).

Page 19: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 17

a) Default Settings b) Project Template Settings

The picture above shows the grid being created using the default settings on the left side and using the Project Template’s settings on the right side. The red dots in the model are critical points (called fixpoints) at which the expert system finds it necessary to set mesh lines. They can be found on the bounding box, at the ends of straight lines, at circle centres and radii. In addition to these fixpoints, the yellow dots (white in the picture) show points where the automatic mesh generation improves the mesh density. Different settings of the global meshing parameters explain the different grids seen above. For a closer look, open the special settings dialog box (Mesh Mesh Properties or the corresponding icon ). Again, the default settings are shown on the left, and the Project Template’s settings are displayed on the right. a) Default Settings b) Project Template Settings

Page 20: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

18 CST STUDIO SUITE™ 2006 – Advanced Topics

Mesh type

The Mesh type setting is the general switch between hexahedral and tetrahedral meshes. Please note that this applies to the mesh preview only. The solver modules will automatically switch to the corresponding mesh type if necessary.

Lines per wavelength

The Lines per wavelength parameter describes the spatial sampling rate of the field. A Lines per wavelength setting of 10 means that a plane wave propagating along one of the coordinate axes is sampled at least 10 times. The reduction of the wavelength when propagating through dielectric materials is taken into account here.

Lower mesh limit

The diagonal of the calculation domain’s smallest boundary face is divided by the value of the Lower mesh limit parameter. The resulting value will then be taken as a maximum mesh step width. Therefore both the Lines per wavelength and the Lower mesh limit settings determine the maximum step width of the mesh.

Mesh line ratio limit / smallest mesh step

The Mesh line ratio limit parameter controls the ratio between the largest and the smallest mesh steps. Since the mesh lines are snapped to fixpoints, the smallest mesh step is usually determined by the structure’s details. If no lower limit is applied, this could result in very small mesh steps severely affecting the simulation performance (see section 4.2). Therefore, the Mesh line ratio limit parameter limits the creation of small mesh steps relative to the size of the largest mesh steps. In case of small details resulting in clustered fixpoints, mesh lines may not be placed at all fixpoints' positions. The following picture illustrates the meaning of the Mesh line ratio limit parameter:

dxn

dyi

The smallest mesh step in this picture corresponds to dyi, whereas the largest mesh step is dxn. Therefore, the Mesh line ratio limit parameter needs to be chosen large enough to allow the mesh ratio to be at least dxn / dyi. Otherwise the two mesh lines at the ends of the mesh step dyi will merged together to a single line. It is obvious from the explanations above that the Mesh line ratio limit parameter has to be adjusted carefully. Too small settings of this parameter prevent the mesh from resolving small details. On the other hand, specifying very large values may result in very small mesh steps significantly affecting the performance of the simulation. As an alternative to the specification of the Mesh line ratio limit parameter, the size of the Smallest mesh step can also be specified directly as a global mesh setting.

The mesh properties dialog box also shows some statistics about the total number of mesh cells, the smallest and the largest mesh step sizes and the number of mesh lines along each coordinate direction.

Page 21: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 19

Further settings of the expert system can be adjusted from within the Special Mesh Properties which can be displayed by clicking the Specials button in the mesh properties dialog box.

The General page contains an option Equilibrate mesh to reduce the local ratio between adjacent mesh steps resulting in much smoother density transitions. Furthermore, a special model for improved modelling of singularities at PEC or lossy metal edges can be controlled by the Use singularity model for pec and lossy metal edges button. Activating this feature significantly reduces the need for very fine meshes around such edges in order to achieve typically required accuracies. Finally, the Mesh type can be controlled, too. We do not recommend changing the global Mesh type to Staircase mesh unless the inaccuracy of imported CAD models causes the PBA mesher to fail. The PBA acceleration option allows using a new matrix calculator which should be faster and more robust for complex models. This will become the default setting in future releases. The Refinement page of the special mesh properties dialog box also contains some useful and frequently changed settings.

Page 22: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

20 CST STUDIO SUITE™ 2006 – Advanced Topics

Due to the field singularities at PEC or lossy metal edges, the mesh usually needs to be refined around these edges. This is necessary even when the special singularity treatment is activated on the General page. The Refine at pec / lossy metal edges by factor option forces the expert system to automatically refine the mesh at critical edges by the given factor. The default setting is 2, but many of the Project Templates already increase this factor to 4 or more.

The Consider pec / lossy metal edges along coordinate axes only switch determines whether the automatic refinement should be applied only to such edges. Since the refinement is also necessary along curved edges, this option should not normally be activated. The Wavelength refinement option ensures that the mesh will be automatically refined in substrates according to the corresponding material properties in order to meet the Lines per wavelength criterion described above. This setting is the default choice and should always be used for high frequency applications.

3.3 Hexahedral Mesh Adaptation for High Frequency Problems

Performing a single simulation does not provide any information about the accuracy of the solution. As mentioned in section 2.1, the FI method guarantees that the discretization error decreases with an increasing number of mesh cells. This property can be used to check the accuracy by refining the mesh, re-running the simulation and comparing the results. It is, however, important to find a good compromise between mesh density (affecting the simulation time) and accuracy. The Project Templates try to adjust the global mesh settings to the particular kind of structure in order to obtain reasonable accuracy. The resulting mesh can then be used as an initial mesh for a subsequent mesh adaptation run. The following picture shows how the adaptive process is activated, e.g. for the transient solver by simply checking the Adaptive mesh refinement option:

Page 23: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 21

The Delta S quantity is defined as the maximum deviation of the S-parameters between two subsequent passes. This deviation is calculated by determining the actual distance between the corresponding curves in the complex plane rather than simply doing a frequency-by-frequency comparison. Small shifts in resonance frequencies therefore cause small differences only. Furthermore a weighting function is applied decreasing the contribution of errors at frequencies farther away from the center of the frequency band. The mesh adaptation stops once the S-parameters converge such that the Delta S value falls below a certain limit (2% by default). For the example consisting of two adjacent striplines, the mesh adaptation stops after 3 passes if the initial mesh were created using the Project Template. The mesh adaptation takes 6 passes using the default initial mesh.

Page 24: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

22 CST STUDIO SUITE™ 2006 – Advanced Topics

The mesh has been significantly refined along the PEC edges during the adaptive passes. In particular, additional mesh lines have been inserted between the conductors and at the edges of the stripline driven by the excitation:

The adaptive meshing process can be controlled by setting its parameters in the Adaptive Mesh Refinement dialog box which you can open by clicking the Adaptive Properties button in the solver control dialog box.

2%

Page 25: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 23

The Maximum Delta S parameter determines the desired accuracy of the adaptive process. The adaptation will be terminated when the current Delta S value (see above) falls below this limit. You can also force the mesh adaptation to perform a Minimum number of passes by setting the corresponding value. Furthermore, the Maximum number of passes can be specified as a termination criterion. The mesh adaptation will stop once the specified maximum number of passes is reached regardless of the actual Delta S values. The mesh adaptation process can be carried out by either an Energy based strategy or an Expert system based strategy. The Project Templates activate the Energy based method by default for planar structures.

Energy based mesh refinement

This is the conventional approach to mesh adaptation. While the electromagnetic field simulation is performed, the energy density in the computation domain is recorded. Regions with high energy density and high field gradients are identified, and the mesh is locally refined there. The amount of refinement per pass is controlled by the Factor for mesh cell increase. A setting of 0.7 means that 0.7 times more mesh cells will be used for the next calculation than were used for the previous one. In other words, the number of mesh cells increases by about 70 % from pass to pass. This adaptation strategy is a field-based approach that delivers mesh refinement in strategically important regions. The disadvantage of this method is that the refinement regions are coupled neither to the structure parts nor to the global meshing parameters. Parameter studies and optimizations will therefore lead to repeated adaption runs, which negatively affect the overall performance.

Page 26: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

24 CST STUDIO SUITE™ 2006 – Advanced Topics

Adaptive expert system mesh refinement

The major difference between this strategy and Energy based refinement is that the former adjusts the expert system’s parameters directly. As a result of this approach, the expert system is trained for a particular structure so that the same settings can be kept for subsequent calculations. The contents of the adaptive mesh refinement dialog box change if the Refinement strategy is set to Expert system based:

The Mesh increment parameter determines the absolute increase for the Lower mesh limit and Lines per wavelength values per adaptation pass. At the end of a successful expert system based mesh adaptation, CST STUDIO SUITETM informs you that the expert system has been trained to yield accurate results for this structure. This means that it will not be necessary to start further adaptation runs with this structure since the quality of the mesh will be maintained even if you slightly change the geometry during parametric sweeps or automatic optimizations.

Page 27: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 25

3.4 Hexahedral Mesh Generation for Low Frequency Problems

This section goes into the details of CST STUDIO SUITETM’s hexahedral mesh generation for either static or low frequency problems. The mesh generation system

uses lots of parameters controlling the mesh generation, having either local or global influence on the mesh. There are a few settings which you may frequently modify in order to obtain highly efficient meshes. Let's start with the most important global ones

• Lower mesh limit • Ratio limit (or smallest mesh cell) • Refinement at PEC-edges • Mesh refinement inside dielectric/permeable material

These parameters are also set by the Project Templates and the adaptive expert system mesh refinement. Let's start a new project, e.g. a simple C-magnet. In this case the following dialog appears:

Select the Magnetostatics template. The info box tells which parameters are set by this template in order to optimize the settings for this type of structure. The example used for the following explanations is shown in the picture below:

Page 28: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

26 CST STUDIO SUITE™ 2006 – Advanced Topics

Now visualize the mesh by entering the Mesh View (Mesh Mesh View, ). a) Default Settings b) Project Template Settings

The picture above shows the grid created using the default settings on the left side and using the Project Template’s settings on the right side. The red dots in the model are critical points (called fixpoints) at which the expert system finds it necessary to set mesh lines. They can be found on the bounding box, at the ends of straight lines, at circle centers and radii. In addition to these fixpoints, the yellow dots show points where the automatic mesh generation improves the mesh density. Different settings of the global meshing parameters explain the different grids seen above. For a closer look, open the special settings dialog box (Mesh Mesh Properties or the corresponding icon ). Again, the default settings are shown on the left side, and the Project Template’s settings are displayed on the right side.

Page 29: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 27

a) Default Settings b) Project Template Settings

Mesh type

The Mesh type setting is the general switch between hexahedral and tetrahedral meshes. Please note that this applies to the mesh preview only. The solver modules will automatically switch to the corresponding mesh type if necessary.

Lower mesh limit

The diagonal of the calculation domain’s smallest boundary face is divided by the value of the Lower mesh limit parameter. The resulting value will then be taken as a maximum mesh step width.

Mesh line ratio limit / smallest mesh step

The Mesh line ratio limit parameter controls the ratio between the largest and the smallest mesh steps. Since the mesh lines are snapped to fixpoints, the smallest mesh step is usually determined by the structure’s details. If no lower limit is applied, this could result in very small mesh steps severely affecting the simulation performance. Therefore, the Mesh line ratio limit parameter limits the creation of small mesh steps relative to the size of the largest mesh steps. Please note that in case of small details resulting in clustered fixpoints, mesh lines may not be placed at all fixpoints' positions. The following picture illustrates the meaning of the Mesh line ratio limit parameter:

dxn

dyi

Page 30: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

28 CST STUDIO SUITE™ 2006 – Advanced Topics

The smallest mesh step in this picture corresponds to dyi, whereas the largest mesh step is dxn. Therefore, the Mesh line ratio limit parameter needs to be chosen large enough to allow the mesh ratio to be at least dxn / dyi. Otherwise the two mesh lines at the ends of the mesh step dyi will merge together into a single line. It is obvious from the explanations above that the Mesh line ratio limit parameter must be adjusted carefully. Too small settings of this parameter prevent the mesh from resolving small details. On the other hand, specifying very large values may result in very small mesh steps, significantly affecting the performance of the simulation. As an alternative to the specification of the Mesh line ratio limit parameter, the size of the Smallest mesh step can also be specified directly as a global mesh setting.

The mesh properties dialog box shows some statistics on the total number of mesh cells, the smallest and the largest mesh step sizes and the number of mesh lines along each coordinate direction. Even more settings of the expert system can be adjusted from within the Special Mesh Properties which you can view by clicking the Specials button in the mesh properties dialog box.

The General page contains the option Equilibrate mesh to reduce the local ratio between adjacent mesh steps resulting in much smoother density transitions. Furthermore, a special model for improved modelling of singularities at PEC or lossy metal edges can be controlled by the Use singularity model for pec and lossy metal edges button. Activating this feature significantly reduces the need for very fine meshes around such edges in order to achieve typically required accuracies. Finally, the Mesh type can be controlled, too. We do not recommend changing the global Mesh type to Staircase mesh unless the inaccuracy of imported CAD models causes the PBA mesher to fail. The PBA acceleration option allows you to use a new matrix calculator which should be faster and more robust for complex models. This will become the default setting in future releases.

Page 31: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 29

The Refinement page of the special mesh properties dialog box also contains some useful and frequently changed settings.

Due to the field singularities at PEC or lossy metal edges, the mesh usually needs to be refined around these edges. This is necessary even when the special singularity treatment is activated on the General page. The Refine at pec / lossy metal edges by factor option forces the expert system to automatically refine the mesh at critical edges by the given factor. The default setting is 2, but many of the Project Templates already increase this factor to 4 or more. The Consider pec / lossy metal edges along coordinate axes only switch determines whether the automatic refinement should only be applied to such edges. Since the refinement is also necessary along curved edges, this option should not normally be activated.

The Low frequency refinement option ensures that the mesh will be automatically refined in substrates according to the corresponding material properties by the factors

rε and rµ , respectively. This setting is the default choice and should always be used for static or low frequency frequency applications.

3.5 Hexahedral Mesh Adaptation for Low Frequency Problems

Performing a single simulation does not provide any information about the accuracy of the solution. As mentioned in section 2.1, the FI method guarantees that the discretization error decreases with an increasing number of mesh cells. This property can be used to check the accuracy by refining the mesh, re-running the simulation and comparing the results. It is, however, important to find a good compromise between mesh density (affecting the simulation time) and accuracy.

Page 32: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

30 CST STUDIO SUITE™ 2006 – Advanced Topics

The Project Templates try to adjust the global mesh settings to the particular kind of structure in order to obtain reasonable accuracy. The resulting mesh can then be used as an initial mesh for a subsequent mesh adaptation run. The following picture shows how the adaptive process is activated, e.g. for the magnetostatic solver by simply checking the Adaptive mesh refinement option:

In the C-magnet example, the adaptation stops after 5 passes, if the initial mesh were created using the Project Template. The energy error, which is defined as the deviation of the energy between two consecutive passes, has fallen below 1%.

1%

Page 33: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 31

The mesh has been significantly refined during the adaptive passes. In particular, additional mesh lines have been inserted inside and around the air gap:

The adaptive meshing process can be controlled by setting its parameters in the Adaptive Mesh Refinement dialog box which you can open by clicking the Properties button in the solver control’s Adaptive mesh refinement frame.

The Errorlimit parameter determines the desired accuracy of the adaptive process. The adaptation will terminate when the energy deviation between two consecutive passes falls below this limit. You can also force the mesh adaptation to perform a Minimum number of passes by setting the corresponding value. Furthermore, the Maximum number of passes can be specified as a termination criterion. The mesh adaptation will stop once the specified maximum number of passes is reached regardless of the actual energy deviation.

Page 34: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

32 CST STUDIO SUITE™ 2006 – Advanced Topics

The mesh adaptation process can be carried out by either an Energy based strategy or an Expert system based strategy. The Project Templates activate the Energy based method by default for magnetostatic applications.

Energy based mesh refinement

This is the conventional approach to mesh adaptation. While the electromagnetic field simulation is performed, the energy density in the computation domain is recorded. Regions with high energy density and high field gradients are identified, and the mesh is locally refined there. The amount of refinement per pass is controlled by the Factor for mesh cell increase. A setting of 0.7 means that 0.7 times more mesh cells will be used for the next calculation than were used for the previous one. In other words, the number of mesh cells increases by about 70 % from pass to pass. This adaptation strategy is a field-based approach, which delivers mesh refinement in strategically important regions. The disadvantage of this method is that the refinement regions are coupled neither to the structure parts nor to the global meshing parameters. Parameter studies and optimizations will therefore lead to repeated adaption runs, which negatively affect overall performance.

Adaptive expert system mesh refinement

The major difference between this strategy and Energy based refinement is that the former adjusts the expert system’s parameters directly. As a result of this approach, the expert system is trained for a particular structure so that the same settings can be kept for subsequent calculations. The contents of the adaptive mesh refinement dialog box change if the Refinement strategy is set to Expert system based:

The Mesh increment parameter determines the absolute increase for the Lower mesh limit value per adaptation pass. At the end of a successful expert system based mesh adaptation, CST STUDIO SUITETM informs you that the expert system has been trained to yield accurate results

Page 35: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 33

for this structure. This means that it will not be necessary to start further adaptation runs with this structure since the quality of the mesh will be maintained even if you slightly change the geometry during parametric sweeps or automatic optimizations.

3.6 Tetrahedral Mesh Generation The following section focuses on the principles of tetrahedral mesh generation. These general considerations apply to both high and low frequency problems. First, we explain the basic procedure of creating a tetrahedral mesh. Let us assume that a model consisting of several parts needs to be meshed. The solution methods require consistent meshes at the interfaces of different parts in order to set up the matrix equations correctly. The following picture shows two blocks touching each other at one of their faces. If the meshes were created independently for both blocks, the meshes might become inconsistent at the interfaces.

Inconsistent Mesh Consistent Mesh The typical solution to this problem is to create a “non-manifold” simulation model first. This intermediate operation converts coincident faces from two solids to a single common double-sided face. Once this is done, the edges and faces of the model can be meshed in a first step. Based on this surface mesh, the volume mesh can then be created afterward. The non-manifold model guarantees that the surface meshes of neighboring solids are identical at their interfaces since they are built from the same surface mesh of the mutual double-sided face.

Page 36: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

34 CST STUDIO SUITE™ 2006 – Advanced Topics

The following picture illustrates this procedure:

The tetrahedral mesh generation can be summarized as follows:

1. Build the non-manifold simulation model. 2. Mesh the model’s edges and faces “surface meshing.” 3. Mesh the model’s volumes based on surface mesh “volume meshing.”

Once the initial volume mesh is created, its quality can be improved by mesh smoothing or mesh optimization. Mesh smoothing is an iterative scheme that moves the mesh nodes in order to improve the quality of the tetrahedrons. In contrast, mesh optimization is a technique that swaps edges and faces and reconnects them to form better quality tetrahedrons. The following picture shows a 2D example of how mesh optimization can improve mesh quality:

The tetrahedral mesh will be automatically created whenever a solver is started requesting this type of mesh. However, in order to visualize the mesh before running a simulation, you can enter the mesh view at any time (Mesh Mesh View , ). The global mesh properties dialog box (Mesh Mesh Properties, ) allows you to change the mesh preview to the tetrahedral mesh type if this has not already been done by a previous solver run.

Cell A Cell B Non-manifold

model

Mesh surface

Mesh interior

edge swapping

Page 37: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 35

a) High Frequency b) Low Frequency

Since the creation of the tetrahedral mesh is a computational expensive task, the mesh is not automatically updated after each change. You can force a mesh update by clicking the Update button in the mesh properties dialog box or by choosing Mesh Update from the main menu ( ).

The global meshing parameters such as Steps per wavelength and Min. number of steps correspond to the Lines per wavelength and Min. number of lines settings for the hexahedral mesh generation. Refer to the corresponding sections above for details concerning the meaning of these settings. It is important to note that the high frequency tetrahedral mesh based solver uses a second order technique. Therefore, the default setting of 4 steps per wavelength corresponds to the 10 lines per wavelength default setting used for the hexahedral mesh creation.

Page 38: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

36 CST STUDIO SUITE™ 2006 – Advanced Topics

d

h

d = h * curvature refinement ratio

The tetrahedral mesh generation can be further controlled by parameters specified in the Specials dialog box. This dialog box contains two pages in order to influence surface mesh generation and volume mesh generation, respectively:

On the Surface mesh tab, the Surface optimization option and the Surface smoothing should normally be kept at their defaults. The Curvature refinement parameters control the quality of the approximation of curved faces by the surface mesh.

The Curvature refinement ratio specifies the ratio of the maximum deviation (d) of the surface mesh from the actual shape of the structure divided by the edge length (h) of the surface triangle (as shown in the picture above). Smaller values lead to better approximations of curved objects. Typical values are between 0.01 and 0.1.

Page 39: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 37

Due to mesh refinement based on the curvature of the object’s faces, the mesh becomes infinitely dense at a structure’s singularities such as the tip of a cone:

The Max. number of steps from curvature ref. parameter limits the amount of refinement due to the curvature of the model relative to the global mesh size specification. Large values allow a good approximation of high curvatures but will produce very fine meshes. Typical values for this setting are between 100 and 1000. Some imported models may contain small misalignments. The following picture shows such an example with a small gap and a small spike:

Even if the tetrahedral mesh generation is able to properly mesh these types of geometry, this may nevertheless result in unnecessarily fine meshes as shown in the picture below:

Page 40: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

38 CST STUDIO SUITE™ 2006 – Advanced Topics

Small structure details (“features”) can be suppressed by setting the Size of the smallest feature. If this value is set to zero, all details will be meshed. If a value greater than zero is specified, all features below this size will be suppressed as shown in the next picture:

The Volume mesh tab contains parameters to control the volume mesh creation stage:

The Volume optimization and Volume smoothing options should normally be kept activated. The Density transitions slider allows you to adjust how quickly the mesh changes between regions of different mesh densities. Smooth transitions result in good mesh quality but also increase the number of tetrahedrons in the mesh. The default setting is a good compromise for many cases and can usually be kept.

Page 41: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 39

3.7 Recommended Initial Hexahedral Discretizations The purpose of this section is to provide guidelines for the discretization of some typical types of structures using hexahedral meshes. We also recommend visiting a special training class on this topic. Please contact your support center for details.

Coaxial Structures

The following picture shows the coarsest recommended discretization for a coaxial structure as it may, for example, be used as initial mesh for adaptive mesh refinements:

Make sure to adjust the Mesh line ratio limit parameter so that you have mesh lines at the center of the coaxial structures as well as at the inner and outer radii.

Planar Structures

Planar structures are usually quite sensitive in regard to meshing. We strongly recommend using the corresponding Project Template to adjust the meshing parameters to this type of structure. One of the most critical settings is the choice of the Mesh line ratio limit parameter. The expert system automatically identifies the small thickness of the conductors and avoids snapping the mesh lines to these tiny steps. Therefore, the Mesh line ratio limit can normally be chosen relatively large. However, sometimes planar structures have small distances between structure edges in the metallization planes. In such cases, it must be carefully decided whether to place mesh lines at these positions.

Please note: The identification of conductor thickness as described above is only performed when the Merge fixpoints on thin PEC and lossy sheets setting is activated on the Fixpoints page of the Special Mesh Properties dialog box. This option is automatically set by the Project Templates for planar types of structures.

The following picture shows a microstrip step (two microstrips with slightly different widths connected to each other):

Page 42: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

40 CST STUDIO SUITE™ 2006 – Advanced Topics

The picture on the left shows a mesh with a Mesh line ratio limit of 10. In this case, the mesh is not able to snap to the edges of both line segments, which results in poor discretization of the step. The picture on the right illustrates that the mesh lines can snap to the geometric details when the Mesh line ratio limit parameter is increased to 20 in this case. We strongly recommend that you inspect your mesh carefully and, in case of unwanted merging of mesh lines, increase the Mesh line ratio limit parameter accordingly. Furthermore, we recommend using at least 1-2 mesh lines across the width of the microstrip’s top conductor and 1-3 mesh lines along the height of the substrate.

Helical Structures

The following picture shows the recommended initial discretization for a helical structure:

1-2 mesh lines

3-5 mesh lines

1-3 mesh lines 1-2 mesh lines

Page 43: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 41

We recommend using at least 1-2 mesh lines across the diameter of the helix’s cross-section. Furthermore, 3-5 mesh lines should be used along the helix’s axis in between the turns. In cases where the diameter of the cross-section is very small, you should also consider modeling the helix as an infinitely thin PEC wire.

3.8 Mesh Tuning So far we have discussed how to obtain simulation results and how to check their reliability with minimal effort spent on the meshing process. If you now feel confident with the global parameters and switches, let's go on to improve the mesh with respect to simulation time and memory requirements. Please note that there is an additional chapter 4 on performance tuning.

Local Mesh Parameters for Hexahedral Mesh Generation

Until now we have discussed the approach to creating a mesh and studying the convergence by setting only a few parameters. CST STUDIO SUITETM offers further useful ways of influencing the mesh, which can be used to save mesh points and thus decrease simulation time. After selecting one shape and pressing the right mouse button, you can open the Mesh Properties dialog box from the context menu:

This dialog box contains a couple of shape specific settings which are discussed below.

Page 44: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

42 CST STUDIO SUITE™ 2006 – Advanced Topics

Consider for automesh

If the Consider for automesh option is switched off, CST STUDIO SUITETM will consider neither the dielectric properties nor any fixpoint of the particular shape, not even the bounding box. This option is sometimes useful when dealing with imported geometries. Let us now assume that you imported a sphere, but instead of an analytic description (left side), you got a faceted representation of it (right side):

Although this is not a bad approximation of the sphere’s geometry, it is obviously not perfect. The CST STUDIO SUITETM mesher always tries to model the shapes exactly as they have been defined. As a result, it will mesh this faceted approximation with fixpoints at the end of every straight line. And as you see below, instead of a very efficient grid representation (left), you end up with an unnecessarily large number of mesh points (right):

In case of a simple sphere, a reconstruction can be easily carried out, but in general you will need to keep your imported geometry as is. Switching off the Consider for automesh option will result in a representation as shown in the picture below:

Page 45: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 43

Now no fixpoints have been generated for the faceted sphere which leads to a more efficient mesh representation of the object. This option is also useful if your imported geometry is flawed because fixpoints are usually located at the most critical points of a geometric object. You should consider using this option if your structure contains an object that forces a lot of additional mesh lines but does not contribute much to the field solution to your problem.

Maximum mesh step width

This option allows you to locally increase the mesh density. This is important if you want to maintain a coarser grid in the peripheral regions but accurately sample the fields in the area of interest. For simplicity, let us again consider the sphere with its default mesh:

If we want to refine the mesh in the sphere’s volume, different values can be assigned to the three spatial directions in the Maximum mesh step width frame. You may also make use of parameters (e.g. zdensity = 0.3 here).

Page 46: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

44 CST STUDIO SUITE™ 2006 – Advanced Topics

Especially in the case of PEC objects, the adjacent surrounding space is even more important than its interior. CST STUDIO SUITETM offers the possibility to simply extend the volume within which the special settings will be applied:

Page 47: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 45

Priority

The Priority setting determines a weight for the fixpoints of one geometrical object compared to another. If two fixpoints of different objects are so close together that the ratio limit does not allow the resolution of both of them, then a mesh line will be snapped to the point with the higher priority.

Mesh type

The type of structure representation can be individually determined for every object. The Default setting means that the global setting is taken, as chosen in the global Mesh properties, Specials dialog box (usually PBA®). For corrupted import data, where the healing algorithm failed, or for very large and complex CAD imports, switching to the standard staircase mesh might be helpful. Manually set fixpoints

As explained above, too many fixpoints can be avoided by switching off the Consider for automesh option. As a result, the fixpoints at the circumference of the imported sphere are also missing. It is, however, possible to manually set fixpoints at arbitrary locations. The pick operations which can be used for structure generation create fixpoints when applied in the Mesh view:

Manually defined fixpoints are marked by blue dots and have the highest priority in the mesh priority scheme.

no fixpoint manual fixpoint

Page 48: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

46 CST STUDIO SUITE™ 2006 – Advanced Topics

Local Mesh Parameters for Tetrahedral Mesh Generation

In the same way as explained above for the hexahedral mesh generation, the tetrahedral mesh generation allows you to set local mesh parameters for individual shapes:

The mesh properties dialog box for a particular shape allows you to set a Max. stepwidth for the shapes volume, which then locally overrides the global setting. The tetrahedral mesh generation usually tries to generate tetrahedrons as equilateral as possible in order to obtain a high quality mesh. Therefore, the Max. stepwidth setting is a single value consistently applied to all directions.

Page 49: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 47

Now consider the following structure as an example:

The feeds are modelled by two cylinders with a relatively small radius. Using the default settings, the shape of the cylinders is not accurately represented by the tetrahedral mesh as shown in the following picture:

Specifying a maximum mesh step width for the two cylinders (e.g. half the radius) forces the mesher to sample the cylinders more accurately. As an alternative, the curvature refinement factor could be increased which would also yield a better resolution of the cylinders. The latter criterion, however, would be applied to all other shapes as well, which is not always the desired solution.

Shape mesh setting (stepwidth = radius / 2)

Page 50: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

48 CST STUDIO SUITE™ 2006 – Advanced Topics

Chapter 4 – Performance Improvements

The following section starts by showing some general hints on how to increase the performance of your simulation runs. Then special aspects of high frequency transient simulations are discussed in more detail. Finally, some suggestions concerning the meshing of thin conductors using tetrahedral grids are given.

4.1 General Hints Use the PBA® technique and its TST™ extension. Always make use of geometric symmetry planes and of all known S-parameter

symmetries. Avoid an unnecessarily large calculation domain size. Choose the solver module best suited to the particular application. Consider splitting the structure into smaller parts and combining them in CST

DESIGN STUDIO™. Consider using the multi-processor or distributed computing options. Use a high-end PC.

4.2 High Frequency Transient Simulations The transient solver uses an explicit time integration scheme, which implies that the solution is derived by simple matrix vector multiplications. This results in linear scaling of the numerical effort with the number of mesh points. Consequently the easiest way of reducing the simulation time is to use symmetry conditions, which reduce the number of mesh points by up to a factor of 8. The number of mesh cells also can be significantly reduced by using shape specific mesh settings properly. Therefore we recommend reading through chapter 3 in order to find a good compromise between simulation speed and manual work involved in tuning the mesh.

To better understand the following explanations, let's look at how the transient solver calculates S-parameters. The transient solver operates with time pulses, which can be easily transformed into the frequency domain via a Fast Fourier Transformation (FFT). The S-parameters can then be derived from the resulting frequency domain spectra:

Page 51: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 49

For instance, a division of the reflected signal by the input signal in the frequency domain yields the reflection factor S11. Within just one simulation run in time domain, the full broadband information for the frequency band of interest can be extracted without the risk of missing any sharp resonance peaks. CST STUDIO SUITETM automatically calculates the appropriate excitation time pulse from the frequency range setting. The default Gaussian-shaped pulse guarantees a nonzero spectrum in the frequency domain’s band of interest, which allows an accurate calculation of the S-parameters.

Please note: The number of frequency samples in Solver Parameters Specials ... Solver Number of F-Steps determines how many frequency points are calculated in the FFT. This does not require much calculation effort, so there is no need to reduce this number (default is 1000). Note that the number of frequency points determines the quality of the S-parameter plots.

Page 52: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

50 CST STUDIO SUITE™ 2006 – Advanced Topics

Numerical Effort ~ Nt (Number of simulated Timesteps)

Nt = t_end / ∆t

Numerical Effort can be reduced bya) Increasing ∆tb) Decreasing t_end

t_end∆t

Numerical Effort ~ Nt (Number of simulated Timesteps)

Nt = t_end / ∆t

Numerical Effort can be reduced bya) Increasing ∆tb) Decreasing t_end

Numerical Effort can be reduced bya) Increasing ∆tb) Decreasing t_end

t_end∆t

Now take a closer look at the time pulses. The numerical effort and hence the total calculation time is determined by the total number of timesteps to be calculated. It can be reduced in two ways: a) Increasing the timestep width ∆t or b) reducing the time t_end (see picture above).

a) Increasing ∆t

Thin wires Thin microstrips

wt <<

RATIO > 30allows fine meshing

t

small ∆tslow

t

RATIO < 5ONE mesh line

large ∆tfast

wt << wt <<

Thin wires Thin microstrips

wt <<

RATIO > 30allows fine meshing

t

small ∆tslow

Thin wires Thin microstrips

wt <<

RATIO > 30allows fine meshing

tt

small ∆tslow

t

RATIO < 5ONE mesh line

large ∆tfast

wt << wt <<t

RATIO < 5ONE mesh line

large ∆tfast

wt << wt <<

As already mentioned in section 2.1, the time step ∆t is proportional to the smallest mesh step. It can be increased by avoiding unnecessarily small mesh steps. Here PBA® allows the discretization of thin wires or thin microstrip lines without using a mesh step for the wire radius or the conductor thickness. As can be seen in the picture above, the Ratio limit setting controls the creation of small mesh steps.

Page 53: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 51

b) Decreasing t_end

t1 t2

-50

0.5

Time / ns

Field Energy / dB

1

Non-Resonating structure: t2 ≤ t1

-100

-150

Duration of Excitation Pulse (t1)

+ Duration of Transient Process (t2)______________________________

Total Time (t_end)

= Energy Rise-TimeIndependent of structure‘s behaviour !!!(only defined by frequency band)

= Energy Rise-TimeIndependent of structure‘s behaviour !!!(only defined by frequency band)

= Energy Fall-Time to desired dB-levelDependent on structure‘s behaviour (number and Q-values of resonances)

= Energy Fall-Time to desired dB-levelDependent on structure‘s behaviour (number and Q-values of resonances)

t1 t2

-50

-100

-1501 2 3

Time / ns

Field Energy / dB

Resonating structure: t2 >> t1

Reduce t2 (small frequency band)Calc. only frequencies of interest / use AR-Filter

Reduce t1 (increase frequency band,until t2 > t1 shorter excitation pulse)

The total calculation time t_end is the sum of the duration of the excitation pulse t1 and the duration of the transient process t2. Depending on the structure’s behavior, it is useful to reduce either t1 or t2.

Page 54: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

52 CST STUDIO SUITE™ 2006 – Advanced Topics

Non Resonating Structures For non-resonating structures t_end can be shortened by reducing t1. This value is determined by the excitation pulse length and therefore directly influenced by the frequency range setting. The larger the bandwidth, the shorter the excitation time. In other words, for non-resonating structures you should always avoid very small frequency bands. This is demonstrated in the next picture for a coaxial line. By defining a wider frequency band, calculation time can be significantly reduced:

Please note that for models without a cut-off frequency (e.g. TEM and microstrip structures), DC should always be included in the frequency range since it shortens the excitation pulse by a factor of 2. For instance, the excitation time for a frequency range 0.01 ... 10 GHz is twice as long as for a range 0 ... 10 GHz. Regarding the choice of an appropriate upper frequency limit, two points have to be considered: you should avoid a) the excitation of resonances at higher frequencies and b) a large increase in the number of mesh points. However, if t_end is determined by the transit time of the signals, reducing t1 is not very efficient. That means that if the propagating pulse arrives at the output long after the excitation signal has vanished, the reduction of t1 will not influence the total time t_end significantly.

Page 55: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 53

Resonating Structures For resonating structures the reduction of t1 has no remarkable effect either since the total calculation time is dominated by the transient process t2. However, if you are just interested in the resonance frequency of a system, one possibility to reduce the calculation time t2 is to stop the simulation before the time signals have decayed to zero. This can be achieved by reducing the following:

1) the accuracy in the transient solver control dialog box. (Default setting: -30 dB. In this case the solver stops when the remaining energy in the calculation domain decreases to -30 dB compared to the maximum energy.) 2) the maximum number of pulses in the transient solver’s special settings (Specials Steady State). (Default setting: 20 pulse lengths. In this case the solver stops when the simulation time reaches 20 durations of the excitation pulse.)

If there is still a certain amount of energy left in the structure when stopping the solver, a “truncation error” will appear. It causes ripples in the S-Parameter curves but does not shift the pole’s frequency.

Time Signals not decayed to zero

Reducing the Truncation Error:

a) Increase Accuracy ( Energy level), e.g. –60dB

or - without increasing t_end - b) Use AR -Filter to predict accurate

S - Parameters even for non - decayed signals

Energy - level – 30 dB Approx. 1 pulse - length

• Truncation Error may cause ripples in the S-Parameters ( sinx/x - function )

• Trunc. Error DOES NOT SHIFT reson . frqs !

In order to shorten the calculation time t2 for resonant structures and avoid the truncation error, you can make use of the Autoregressive Filter (Results Time Signal Calculations AR Filter…). Refer to section 3.7 for details of this technique. If you have found appropriate settings for the AR Filter, it can be used during the time domain calculation to stop the solver once it converges to a sufficient accuracy (transient solver control dialog box, Specials AR Filter).

Some other suggestions for increasing the simulation performance of the transient solver are the following:

Avoid unnecessary field monitors (farfield monitors are less critical). Use open (PML) boundaries only for radiation problems.

Page 56: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

54 CST STUDIO SUITE™ 2006 – Advanced Topics

Do not include cut-off in your frequency range if you are not interested in the results below cut-off. Choose the lower frequency limit 10% higher than the cut-off frequency of the waveguide.

4.3 Auto-Regressive Filtering (AR-Filter) The performance of the high frequency transient solver can be significantly reduced when strongly resonating devices are simulated. The main reason for this is that calculating the S-parameters using a Fourier Transform requires the time signals to have sufficiently decayed to zero; otherwise a truncation error will occur. Especially for highly resonating devices, a ringing in the time signals may occur so that the signals decay very slowly and therefore require long simulation times for accurate Fourier Transforms. If a S-parameter calculation is performed using time signals which still exhibit some oscillation, a ripple will appear on the S-parameters as shown in the picture below:

Please note that the curve’s minimum or maximum locations (i.e. the position of the resonance frequencies) are not affected by the ripple, so if this is the only information needed from the simulation, the truncation error may be tolerated. Otherwise, the usage of the AR-filter feature may be useful. The idea of this technique is to train an auto-regressive (AR) filter by using a short interval of the time signals. Afterwards, the AR-filter is used to predict the signal for the next time steps. Once the prediction and the actual simulation agree sufficiently, the AR-filter contains all relevant information about the device. Therefore the simulation can be stopped, and the S-parameters can be derived mathematically from the AR-filter’s representation.

The following picture shows a typical time signal for a strongly resonating structure. It can be clearly seen that the time signals decay very slowly:

Page 57: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 55

Once such a simulation is completed (or aborted manually), you can enter the AR-filter dialog box by choosing Results Time Signal Calculations AR-Filter for Port Signals:

First, you should always press the Defaults button to let the dialog optimize its settings for currently available time domain data. Next, you should carefully inspect the signals and determine the time when the excitation pulse has vanished. In the example above, this may be at around 2 ns. Afterward, enter this time in the First time step field to start the AR-filter analysis when the device’s response is dominated by the resonant parts only. Now check the order of the AR-filter. If the signal contains a few resonances only (e.g. you are expecting only a few poles inside the frequency band of interest), you should start with a Max. order of filter set to 40. After making these settings, the dialog box should look as follows:

Page 58: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

56 CST STUDIO SUITE™ 2006 – Advanced Topics

Now click the Start button to perform the AR-filter analysis. Once the computation is finished, a dialog box will appear containing handy information. A header provides information about the AR-filter’s settings and the currently investigated time signal:

=================================================================== Analysis 1 of 2 for stimulation port 1, mode 1 =================================================================== First time step : 2.001828e+000 ns Skip time steps : 10 Max. frequency : 1.020000e+001 GHz Max. order of filter : 40 Relative Window length: 2.000000e+000 Input signal samples : 7913 Input signal length : 5.617186e+001 ns

The AR-filter information is extracted from a window that moves along the time signal. The following information displays the bounds of this window for each evaluation step and the energy error of the resulting filter approximation. This error should ideally be below 1e-3 in order to obtain good accuracy. ------------------------------------------------------------------------------- step | window range | rel. wnd. | filter | energy | pulses to | ns | length | order | error | calculate ------|---------------------------|-----------|--------|-----------|----------- 1 | 1.7747e+000 - 4.6141e+000 | 2.50 | 32 | 4.83e-007 | 1.95e+000 2 | 1.8457e+000 - 4.6851e+000 | 2.50 | 33 | 4.80e-007 | 1.98e+000 3 | 1.9166e+000 - 4.7561e+000 | 2.50 | 30 | 1.00e-006 | 2.01e+000 4 | 1.9876e+000 - 4.8271e+000 | 2.50 | 30 | 1.14e-006 | 2.04e+000 5 | 1.4907e+000 - 4.8981e+000 | 3.00 | 36 | 8.60e-007 | 2.07e+000 6 | 1.5617e+000 - 4.9691e+000 | 3.00 | 37 | 1.38e-006 | 2.10e+000 7 | 1.6327e+000 - 5.0401e+000 | 3.00 | 35 | 2.68e-006 | 2.13e+000 ------------------------------------------------------------------------------- filter step 2 used for s-parameter calculation -------------------------------------------------------------------------------

=================================================================== Analysis 2 of 2 for stimulation port 1, mode 1 =================================================================== First time step : 2.001828e+000 ns Skip time steps : 10 Max. frequency : 1.020000e+001 GHz Max. order of filter : 40 Relative Window length: 2.000000e+000

Page 59: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 57

Input signal samples : 7913 Input signal length : 5.617186e+001 ns ------------------------------------------------------------------------------- step | window range | rel. wnd. | filter | energy | pulses to | ns | length | order | error | calculate ------|---------------------------|-----------|--------|-----------|----------- 1 | 6.3888e-001 - 4.6141e+000 | 3.50 | 1 | 1.00e+000 | 1.95e+000 2 | 2.4136e+000 - 4.6851e+000 | 2.00 | 31 | 6.54e-009 | 1.98e+000 3 | 2.4845e+000 - 4.7561e+000 | 2.00 | 33 | 1.49e-009 | 2.01e+000 4 | 2.5555e+000 - 4.8271e+000 | 2.00 | 32 | 7.95e-010 | 2.04e+000 5 | 2.6265e+000 - 4.8981e+000 | 2.00 | 32 | 1.91e-010 | 2.07e+000 6 | 2.6975e+000 - 4.9691e+000 | 2.00 | 31 | 1.23e-009 | 2.10e+000 7 | 2.7685e+000 - 5.0401e+000 | 2.00 | 31 | 4.99e-010 | 2.13e+000 8 | 2.8395e+000 - 5.1111e+000 | 2.00 | 31 | 1.53e-010 | 2.16e+000 9 | 2.9105e+000 - 5.1820e+000 | 2.00 | 30 | 4.50e-010 | 2.19e+000 10 | 2.4136e+000 - 5.2530e+000 | 2.50 | 37 | 3.76e-010 | 2.22e+000 11 | 2.4845e+000 - 5.3240e+000 | 2.50 | 37 | 4.13e-010 | 2.25e+000 12 | 2.5555e+000 - 5.3950e+000 | 2.50 | 35 | 1.61e-009 | 2.28e+000 13 | 2.6265e+000 - 5.4660e+000 | 2.50 | 37 | 4.10e-010 | 2.31e+000 ------------------------------------------------------------------------------- filter step 8 used for s-parameter calculation -------------------------------------------------------------------------------

In this example, excellent filter accuracy can be obtained for both time signals. As a next step, the S-parameters are calculated from the AR-filter’s representation, and the energy balance of the S-matrix is evaluated. The following lines show information about how well the energy conservation is maintained. =========================================================== Stimulation at port 1 (mode 1) Average deviation in s-parameter energy balance: 6.094664e-004 Maximum deviation in s-parameter energy balance: 2.756003e-001 ===========================================================

=================================================================== Maximum deviation in s-parameter energy balance = 0.2756 (regarding all successfull filter runs) ===================================================================

It can be seen from these data that the average energy error is sufficiently small, but the maximum error is much larger. This happens quite often if the S-parameters show some very sharp resonances and the locations of the poles and zeros in the various S-parameter curves do not match exactly. In most cases, this inaccuracy can simply be ignored. The AR-filter’s results are added to the navigation tree in the same way as the standard S-parameter curves, but marked by an extension “(AR)”. The following picture shows an original S-parameter with its AR-filter approximation (the curves may easily be overlaid using the Copy / Paste feature of curves in the navigation tree):

Page 60: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

58 CST STUDIO SUITE™ 2006 – Advanced Topics

Furthermore, the balance of the AR-filter S-parameters looks as follows:

The energy balance is very close to one for the most part of the spectrum. Even if the balance is significantly disturbed close to the location of the peaks, this inaccuracy can hardly be seen in the S-parameter results.

Page 61: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 59

Taking a closer look at the AR-filter output shown above, you can check that the AR-filter calculation uses time windows up to a maximum time of 5.466ns. This means that at least this maximum time needs to be simulated. In order to minimize the simulation time, you may consider decreasing the filter’s order. This in turn would require shorter time windows. Every system, however, needs a certain minimum number of poles to be described properly. If the order is set lower than the actual order of the device’s response, accuracy will be degraded significantly. Performing an AR-filter calculation using a filter order of only 10 for this example would yield the following output: ===========================================================----- Stimulation at port 1 (mode 1) Average deviation in s-parameter energy balance: 3.669134e-003 Maximum deviation in s-parameter energy balance: 1.463659e+000 ===========================================================----- =================================================================== Maximum deviation in s-parameter energy balance = 1.46366 (regarding all successful filter runs) ===================================================================

Large deviations of the energy balance (e.g. significantly larger than 0.5) usually indicate highly inaccurate results. Another criterion for the quality of the AR-filter approximation is the energy error shown in the dialog box after the AR-filter computation has finished:

The energy error shown here should usually be lower than 1e-3 for reliable results (it was 1.5e-10 for a filter order of 40). If the AR-filter yields inaccurate results and you cannot improve its quality by increasing the Max. order of filter and the First time step settings, you should try to follow these guidelines:

1. Avoid including DC (frequency = 0) in the simulation. The AR-filter approximation is most critical for very low frequencies.

2. Use sufficiently small simulation bandwidths. Especially for narrow band filters, very small ranges of the spectrum contain most of the significant device information.

3. It rarely makes sense to use filter orders of more than 100-150. It may be better to increase the First time step setting instead or to reduce the simulation frequency range.

Page 62: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

60 CST STUDIO SUITE™ 2006 – Advanced Topics

After the AR-filter has been successfully applied to a device in post-processing, it can be used as an Online AR-Filter for subsequent calculations such as parameter sweeps or optimizations. This feature can be activated from the Specials dialog box (AR-Filter tab) from within the transient solver dialog box:

You can check the Online AR-filter analysis box and specify its parameters by clicking the Settings button. If an AR-filter calculation has been previously performed in post-processing, its parameters will be retained here. During the transient simulation, the AR-filter calculation will frequently be performed (Pulse widths between checks), and the balance of the resulting S-parameters will be checked. If the balance error turns out to be better than Max. energy dev. for steady state, the transient simulation will automatically stop. We recommend you refer to the online documentation for more information about this powerful feature or visit a specialized training class on this topic. Please contact your support center for more information.

Page 63: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 61

4.4 Meshing Thin Conductors Using Tetrahedral Grids Meshing thin conductors using tetrahedral grids can noticeably reduce the mesh quality. Note that due to the PBA® technique, this is not the case for hexahedral types of meshes. The following picture shows a cross-section of a mesh for a structure with a thin perfectly electrically conducting strip:

As can clearly be seen, the thin strip causes some of the tetrahedrons to become very flat, resulting in poor overall mesh quality. The latter will cause performance degradation since the convergence of the iterative equation system solvers strongly depends on the mesh quality. Furthermore, the convergence of the adaptive mesh refinement strategies is negatively affected by low quality meshes. As a rule, you should always consider whether the finite thickness of the conductors should be taken into account when using tetrahedral meshes. Whenever possible, you should model such conductors as infinitely thin which yields shorter simulation times. If you already have a model with finitely thick conductors, it may be easiest to use the Shape from picked faces operation which is explained in detail in the Planar Structure Tutorial.

Page 64: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

62 CST STUDIO SUITE™ 2006 – Advanced Topics

Chapter 5 - CAD Data Import and Healing

The ability to import geometrical CAD data from other systems plays an increasingly important role in the operation of modern CAE tools. Reducing the need for re-modeling structures (which have already been drawn in a CAD system) for electromagnetic analysis can significantly reduce the cost for computer simulations. CST STUDIO SUITETM offers powerful import options for geometrical data in both two and three dimensions. This chapter will provide an introduction on how import options should be used without focusing on the actual dialog boxes. Refer to the online documentation for more information. The structural import process usually consists of two steps: 1. Import of the geometrical data and its conversion into ACIS models. Note that the

origin of the imported CAD model will automatically be adjusted to the origin of the currently active coordinate system.

2. Healing of the newly created ACIS models in order to obtain valid geometry. The first step can be seen as a pure geometric language translation step. All inaccuracies in the imported models remain during this stage. The second step then repairs the data so that valid ACIS models are obtained. In general, problems during the import and healing process arise from different accuracy levels of the CAD system and the ACIS kernel used in CST STUDIO SUITETM. The accuracy of a CAD system is usually the distance for which the system considers two points to be identical. The ACIS kernel uses an accuracy of 1e-6 whereas some other CAD systems operate at accuracies of 1e-3 only. Assuming that the CAD data have been created on a system with an accuracy level of 1e-3, it may easily contain gaps of this size (which the CAD system would still consider to be closed). Importing such a model into the ACIS kernel afterward would keep these gaps. However, in contrast to the less accurate CAD system, ACIS would not consider these gaps to be closed which may consequently cause failures in creating solids. To circumvent these problems, sophisticated automatic healing technology can be used to close the gaps in the imported model. The following screenshot illustrates this step in the case of a 3D part:

Close gaps

by automatic healing

Page 65: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 63

The healing modifies the imported model so that it forms a valid solid shape. The following section discusses the import process in 2D and 3D in more detail.

5.1 Import 2D Files CST STUDIO SUITETM currently supports the following 2D data file formats:

□ DXF □ GDSII □ Gerber

We recommend using the DXF file format whenever possible because this is the most robust choice for 2D data transfer. Two different levels of DXF import are available:

1. Standard DXF 2. Extended DXF

The main advantage of the optionally licensed Extended DXF import feature is the support of hierarchical data (blocks) in the DXF file and the support of thick lines. By default (if the option Import as curves only is NOT used), CST STUDIO SUITETM tries to connect the imported 2D elements (lines, arcs, polygons, etc.) so that they form closed profiles. Additionally a healing option is available which automatically tries to close small gaps in the resulting profiles. Once a closed profile is obtained, it will automatically be covered and extruded by the height specified for the corresponding DXF layer. If no height has been specified, CST STUDIO SUITETM will import the DXF data as an infinitely thin double-sided face. You can use this face as a basis for further construction. You may, for instance, use the Objects Thicken Sheet operation to create a solid from the face. The following picture shows a typical yet simple model imported from a DXF file:

If you zoom into the structure, you can check the finite thickness of the imported metallization layer:

Page 66: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

64 CST STUDIO SUITE™ 2006 – Advanced Topics

Please note: Due to the PBA® technique, these thin layers do not slow down the solution process for solvers based on hexahedral grids.

Even though the import of 2D files is usually much less critical than the import of 3D models, problems may sometimes occur. The following hints should help to make the import as robust as possible: 1. Organize your structure into layers. Always put the structural drawing and

additional data (such as hatchings, measure lines, text, etc.) on different layers, and only import the structural layers.

2. Only import those parts you are actually interested in. Since CST STUDIO SUITETM needs to build 3D objects from the 2D input data, the complexity of the model is heavily increased during the import process. The deletion of unwanted objects after importing the complete structure is unnecessarily inefficient.

3. Try to use polygons in the drawing of the 2D files as opposed to a collection of independent lines. Due to some accuracy constraints or a less accurate drawing, independent lines may have gaps, which must be closed with much effort during the import process.

Following these rules will usually yield successful import results. However, if you experience problems, read the Inspect and Repair the Imported Model section later in this chapter to get information on how defects in the model can be resolved.

5.2 Import 3D Files CST STUDIO SUITETM offers import filters for various 3D geometrical CAD formats:

SAT (up to version 14) STL IGES (4.0, 5.2, 5.3) VDA-FS (up to 2.0) STEP (AP 203, AP 214) Autodesk Inventor (up to 9) Pro/E (16 up to Wildfire 2) Catia 4 (4.1.9 to 4.2.4) Catia 5 (R2 to R14)

The SAT file format is the native data format of the ACIS kernel and should therefore be used whenever possible. The STL data format contains only facet information. Importing these kinds of data usually becomes problematic when more than one shape of this type is imported and the shapes touch each other. The following picture illustrates this problem:

Page 67: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 65

Since the two-faceted representations of the cylindrical hole and the cylinder are not identical, the assembly contains holes and overlapping rather than a cylinder that perfectly fits into the hole.

Please note: The STL import is often most useful in combination with the staircase meshing option. Refer to the online documentation for more information.

The IGES, STEP and VDA-FS data formats are based on standardized file format specifications, in contrast to proprietary file formats such as Pro/E, Autodesk Inventor, CATIA V4 and CATIA V5. The data translation process consists of two stages. First the CAD system converts and exports its data into a certain file format. Afterwards CST STUDIO SUITETM reads the file and converts it into its own internal data structures. It is usually preferable to import the native data format of the CAD system in order to avoid the first data translation step. Since every translation step may entail a loss of accuracy, it is advantageous to avoid unnecessary translation steps. With regard to standardized CAD data formats, the STEP format should is preferable to the IGES or VDA-FS formats because it also contains topology information about the relationship of neighbored faces. This important information must be recreated from pure geometry data if IGES or VDA-FS files are imported. Therefore, the guidelines as to which data format should be used for which CAD system are as follows:

CATIA V4: Use the CATIA V4 file format. CATIA V5: Use the CATIA V5 file format. Pro/E: Use the Pro/E file format. Autodesk Inventor: Use the Autodesk Inventor or SAT file formats. ACIS based systems: Use the SAT file format. Other CAD systems: Try to use the STEP (AP203, AP 214) format, if

available. Otherwise use the IGES and VDA-FS formats in this order. If these are not available either, use the STL format (which will most likely require staircase meshing).

Assembly

of both shapes

Page 68: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

66 CST STUDIO SUITE™ 2006 – Advanced Topics

The following list of rules applies to all types of file formats and should help you get the best results for importing CAD data: 1. Keep the complexity reasonably low: Bear in mind that you are going to run an

electromagnetic analysis with your models. Importing an entire car including details, such as the door locks for instance, will exceed today’s computational resources. Please import only the most relevant parts for highly complex models (e.g. the car’s body).

2. Avoid unnecessary blends in the CAD model: Excessive application of blends will also increase the complexity in the data. You should always try to avoid unnecessary blends and other complex shape details (e.g. embossed text) in the exported files whenever possible.

3. Avoid tiny model sizes: Due to the limited numerical precision in the file formats, you should use units in which the model has reasonably large absolute dimensions. If your model has a bounding box diagonal of 0.1 m, for instance, you should export it in mm in order to get a larger absolute diagonal of 100 (mm).

4. Avoid Boolean operations before exporting the model: Whenever possible, you should try to avoid Boolean operations between parts before exporting the model to a file. In the example of the STL import shown earlier, the problem is due to the insertion of a cylinder into a plate, which then contains a hole. If the insertion were omitted in this case, inserting the imported and healed shapes within CST STUDIO SUITETM would not cause any problems. This issue is most critical when faceted CAD data are used (e.g. STL) but still should be considered for the other more accurate data formats as well.

5. Try different export options: Whenever you experience problems in any of the data translation steps, you should try to use different export options for your CAD system. You may need to experiment a bit in order to find the combination which works best for your system and your type of models.

5.3 Inspect and Repair the Imported Model As outlined above, an automated healing step is necessary after importing a model from foreign CAD data. Therefore you should always use the option Healing in the CAD data import dialog boxes. After importing and healing the data, a message box will appear informing you of the status of the model. The following picture shows such a message box as it appears for a STEP file import:

Page 69: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 67

Some shapes have been imported and healed without any problems (100% OK). However, some other shapes show minor defects indicated by a percentage of 98-99%. Clicking on the shape default:import_3 and selecting Healing Details would, in this example, provide a text output window as shown below:

In order to understand the healing process better, it is advantageous to know the meaning of this output. Thus we will provide some explanations of the most important information in this text step by step. The first section gives some statistics about the solid after the import and before the actual healing process starts:

SIMPLIFICATION ANALYSIS : ========================= INPUT STATISTICS : 296 Splines, 0 Planes, 0 Spheres, 0 Cylinders, 0 Cones, 0 Tori 0 Straights, 0 Circles, 0 Ellipses, 757 Intcurves, Simplification tolerance set to 0.0001 Planes-Only option set OFF

In the case investigated here, the imported shape consists of spline faces only. However, the healing technology tries to reduce the complexity of the imported data by converting as much of the imported spline faces to analytical trimmed surfaces as possible (simplification). The result of this stage is shown in the next section:

SIMPLIFICATION CALCULATION RESULTS : ==================================== CALCULATED AT TOLERANCE = 0.0001 : Expected spline conversions 116 Planes, 2 Spheres,

Page 70: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

68 CST STUDIO SUITE™ 2006 – Advanced Topics

114 Cylinders, 8 Cones, 48 Tori SIMPLIFICATION FIX RESULTS : ============================ Simplification tolerance = 0.0001 no. of initial splines = 296 no. of final splines = 8 Number of analytics made from splines: 116 Planes, 2 Spheres, 114 Cylinders, 8 Cones, 48 Tori 757 Intcurves, 115 Intcurves, 408 Straights, 234 Circles, 0 Ellipses,

The simplification step is able to simplify 288 of the originally 296 spline faces to analytic geometry (e.g. planes, spheres, cylinders, etc.). The next section in the text files gives information on the original status of the model’s geometry:

GEOMBUILD ANALYSIS : ==================== geom build tol = 10 analytic solver tol = 0.0101 no. of edges = 757 no. of bad edges = 177 no. of coedges = 1514 no. of bad coedges = 360 no. of vertices = 471 no. of bad vertices = 51 no. of bad tangent edges = 44 no. of bad tangent edges analytic = 37 no. of G1 bad tangent edges analytic = 39 no. of bad tangent edges uv_uv = 1 no. of bad tangent edges boundary uv_uv = 1 no. of bad tangent edges uv_nonuv = 6 no. of bad tangent edges nonuv_nonuv = 0 no. of bad tangent edges 3_4_sided = 7 no. of surfaces = 296 no. of discontinuous surfaces = 0 percentage of good geom = 92

A lot of elements (171 edges and 51 vertices) have somehow invalid geometry data indicating that this model clearly needs healing. The next sections in the text file give more involved information which is not addressed in this introduction. However, the final section in the text file shows the result of the healing process:

GEOMBUILD FIX RESULTS : ======================= Statistics of the healed body after geombuild fix : no. of edges = 757 no. of bad edges = 2 no. of coedges = 1514 no. of bad coedges = 29 no. of vertices = 471 no. of bad vertices = 2 no. of bad tangent edges = 0 no. of bad tangent edges analytic = 0 no. of G1 bad tangent edges analytic = 7 no. of bad tangent edges uv_uv = 0 no. of bad tangent edges boundary uv_uv = 0 no. of bad tangent edges uv_nonuv = 0 no. of bad tangent edges nonuv_nonuv = 0

Page 71: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 69

no. of bad tangent edges 3_4_sided = 0 no. of surfaces = 296 no. of discontinuous surfaces = 0 percentage of good geom = 99

Automatic healing is quite successful in this case. Only two edges and two vertices are still invalid. After getting the general information that there are still some defects in the model, it is important to localize the problems. Usually the automatic healing will convert the incorrect elements to tolerant objects. By applying tolerances, the modeler is able to perform a limited set of structural modifications on the model even if it is not 100% valid. Thus all erroneous elements become tolerant elements in the final stage of automatic healing. These tolerant elements can easily be visualized by selecting Objects Solid Healing Tools Show Tolerant Vertices and Objects Solid Healing Tools Show Tolerant Edges, respectively. A toolbar is available providing accelerated access to the healing tools.

In this example, the problems arise mainly due to the imported blends’ faces. Whenever you encounter such problems in the healing process, we recommend contacting your CAD drawing department first. On many occasions a careful inspection of the CAD model at these locations may show some minor defects or inaccuracies in the original model. After revising the drawing and re-importing the structure, you should check whether the problem disappeared. If improving the quality of the CAD data is not possible, or if the problem still persists, you may need to manually repair the model. In the example shown here, it is sufficient to delete the inaccurate blend using the Local Modifications tool. If you plan to re-apply the blend later and do not know its radius, you should measure it before its removal. Afterward you only need to select the blend’s face using the face pick tools and choose Objects Local Modifications Remove Feature from the main menu or the healing toolbar.

Remove

blend face

Tolerant vertices Tolerant edges

Page 72: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

70 CST STUDIO SUITE™ 2006 – Advanced Topics

The blend can then be re-applied by selecting the edge and using Objects Blend Edges.

The procedure above is typical for the manual healing of invalid blends. However, in many cases it is advantageous to avoid these blends before exporting the model from the original CAD system. Quite often, the blends have little or no effect on the electromagnetic behavior of the structure, so there may be no need to re-apply them.

Remember the best rule for CAD data exchange: Keep it simple! In the second example, the following steps explain how unnecessary details can be simply removed from the model. Let us assume that the pin shown in the picture below does not affect the electromagnetic properties and should thus be removed from the model:

The easiest way to achieve this is to use the Remove Feature tool after selecting all faces of the unwanted structure detail. To easily obtain this face selection, activate the Objects Pick Pick Edge Chain tool (shortcut Shift+E) and double-click on the edge that connects the detail with the rest of the model:

Re-apply

blend

Page 73: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 71

After properly selecting this edge, activate the Objects Pick Pick Face Chain tool (shortcut Shift+F) and double-click on one of the detail’s faces:

Now all faces connected to the currently picked one will be selected. However, the face selection will stop at previously picked edges. By properly selecting the picked edges, you can advise the tool to select the faces of the unnecessary structure detail only. Finally the Objects Local Modifications Remove Feature tool can be used to remove the shape and automatically close the gaps:

This section only provides some ideas on how imported models can be healed manually if the automatic healing is unable to fix all problems. However, there are many more options available. Optimal strategies may also differ according to your structure and the originating CAD system. We strongly recommend that you attend a specialized training

Page 74: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

72 CST STUDIO SUITE™ 2006 – Advanced Topics

class on this topic in order to obtain best results. Please contact your support center for more details.

5.4 Parameterize the Imported Model Quite often, the aim of the electromagnetic analysis is not just to know the given structure’s behavior but also to optimize it according to various goals. Such optimizations require the ability to modify the model even if it was obtained by importing a CAD data file. CST STUDIO SUITETM offers the outstanding possibility of parameterizing shapes for which no construction history exists by using Local Modifications. The Getting Started manuals contain a section explaining how these tools are generally applied. You should familiarize yourself with this functionality before you proceed to the next sections since they focus on the application of these operations to imported solids. For the following explanations, let's assume you wish to change the radius of the cylinder’s outer face shown in the picture below:

You could simply pick the corresponding face and apply the Objects Local Modifications Change Face Radius tool to yield the following result:

In order to close the resulting gaps, the chamfer’s face automatically extends up to its intersection with the modified cylindrical face. This results in an enlargement of the chamfer which is probably not what is required. This problem can be circumvented by removing the chamfer, changing the face’s radius, and finally re-applying the chamfer. If you don’t know the size of the chamfer, you will need to measure it first by picking two points and checking the distance:

Change face

radius

Page 75: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 73

In this example, you will find the chamfer has a width of 0.2. Now you can pick the chamfer’s face and select the Objects Local Modifications Remove Feature tool:

The next step is to change the radius of the face and to re-apply the chamfer as shown in the picture below:

Remove

feature

Re-apply

chamfer

Page 76: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

74 CST STUDIO SUITE™ 2006 – Advanced Topics

You can use a variable to specify the new radius of the face. This will allow you to fully parameterize (and thus later optimize) the model even though it has been imported from CAD data. The example outlined above should provide you with some idea as to how imported models can be parameterized by using local modifications. Since many different (more or less efficient) solutions exist to achieve such a parameterization, we recommend that you visit a specialized training class on this topic. Please contact your support center for more information.

Page 77: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 75

Chapter 6 – Template Based Post-processing

This chapter introduces a functionality of CST STUDIO SUITE™ which enables you to easily perform very powerful post-processing operations. The Postprocessing Templates allow for flexible processing of 2D/3D Fields, 1D Signals or scalar values (0D results). The Postprocessing Templates are evaluated after every calculation during parametric sweeps or optimizations. The data are then stored in tables to allow for flexible access to the parametric data. Typical examples for Postprocessing Templates are 1D results such as the following:

Z, Y, VSWR versus frequency Farfield 1D plots at a single frequency Broadband farfield values Group delay times 1D Plots of 2D/3D results along arbitrary curves FFT of existing time signals Exchange excitations and TDR functionality Mixture of any of these 1D-results using an analytic formula and more…

or 0D-Results (single real scalar values)

Min, max, mean, integral, … values of existing 1D-results Q-values, energies, losses, coupling coefficients of eigenmodes Curve-, face- or volume integrals of 2D/3D results Mixture of any of these 0D-results using an analytic formula and more…

The following sections introduce the framework of this feature and present its application with an example.

6.1 Framework to Control Result Templates The following picture shows the template-based post-processing dialog box which you can open by choosing Results Template Based Postprocessing ( , Shortcut Shift+P):

Page 78: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

76 CST STUDIO SUITE™ 2006 – Advanced Topics

The dialog box contains two pages for processing 1D results and 0D results. The list contains the currently defined sequence of post-processing operations of each type. You can add new tasks to the list by selecting them from the drop-down list above. You can easily rename a task by clicking on the corresponding line and directly changing its name in the list. The Settings button allows you to change the parameters for the currently selected item. This button, however, is active only when the corresponding task provides a settings dialog box. Clicking the Duplicate button creates a copy of the currently selected item. Some post-processing operations require a lot of common settings. Instead of repeatedly entering all those settings, you may simply duplicate an existing entry and modify a few settings afterward. The Evaluate button executes the currently selected task whereas the Evaluate All button executes the entire list from the beginning.

All Postprocessing Templates are automatically processed after each solver run including parametric sweeps and optimizations. The execution takes place in the order shown in the list. You may need to change the order (up / down arrow buttons), especially if tasks refer to previously obtained data. The template based post-processing results are managed as follows:

1D Results are shown in the navigation tree under Tables 1D Results … 0D Results are shown in the navigation tree under Tables 0D Results … .

Additionally the latest result value is shown on the 0D-Results page of the definition window.

Templates with a “-“ sign in front of their name do not add useful results to the navigation tree’s Tables folder, but store their results at other locations. Refer to the corresponding template’s description for more information.

Page 79: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 77

6.2 Pre-Loaded Post-processing Templates The standard installation includes an extensive list of pre-loaded Postprocessing Templates. They can be mainly categorized as follows:

1. Load data into the post-processing chain. 2. Calculate secondary quantities. 3. Extract data from other post-processing results.

Besides operations on S-parameters, a variety of pre-loaded Postprocessing Templates deals with the extraction of 1D or 0D data from fields (including farfields, etc.). We recommend you browse through the list of available templates to get an overview of what is already available. Each of the Postprocessing Template’s settings dialog boxes contains a Help button which will open an online help system providing more information. Since all Postprocessing Templares are written in VBA programming language, you can add your own specific post-processing operations. Please refer to the online documentation or contact technical support for more information.

Example for Post-processing Templates The following example shows a typical Postprocessing Template for CST MICROWAVE STUDIO®. However, even if you are using another module, we still recommend reading through this example since it gives general procedures common to all modules. Let's assume you have simulated a device and want to directly obtain the VSWR and calculate the delivered Power (1-S11^2). You can take any example here that calculates S-parameters. Within the 1D Result page of the template-based post-processing dialog box, you should select the entry VSWR first and in a second step S Parameter afterward:

Page 80: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

78 CST STUDIO SUITE™ 2006 – Advanced Topics

The S-parameter S11 is available from the navigation tree. However, since we would like to do further calculations with it, we have to explicitly load S11 as a task to be referred to later in another Postprocessing Template.

After confirming the defaults of the S Parameter window (we are interested in the linear amplitude of S11), you will see the following two 1D Results defined in your list:

If the project has already been calculated and results are present, you may click Evaluate All, resulting in two tables in the tree, which you can select and plot. Otherwise start the calculation with the transient solver, which at the end automatically evaluates all templates in the given order.

Page 81: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 79

Now we can calculate the delivered power (1-S11^2) using the 1D Postprocessing Template named Mix 1D Results:

Selecting this task from the list opens the following window, where arbitrarily defined 1D Results can be combined using VBA expressions. If we select A as a placeholder for S11, our expression would be 1-A^2.

Back in the template-based post-processing dialog box, you can set the name of the newly created task by clicking on the corresponding item and changing its name to Delivered Power. Clicking the button Evaluate will immediately add the corresponding result to the navigation tree’s Tables folder:

Page 82: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

80 CST STUDIO SUITE™ 2006 – Advanced Topics

Evaluate:

You can change the definition of any task by selecting the corresponding line and clicking Settings. Once defined, these extra results such as VSWR and Delivered Power will always be computed automatically once a simulation run is complete. Opening the Parameter Sweep dialog box shows that all Postprocessing Templates are automatically listed as watches. Once the parameter sweep is complete, the VSWR or Delivered Power results can be visualized as a function of the structure’s parameters:

Let's now assume that you want to optimize the Delivered Power averaged over the entire simulation frequency band. This can be achieved by adding a Postprocessing

Page 83: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 81

Template calculating the mean value of the Delivered Power. Therefore you can switch to the 0D Results page and select the task 0D Value from 1D Result:

The results of 0D Postprocessing Templates are also written to the Tables folder in the navigation tree after pressing the Evaluate button. In addition, the latest results are shown in the template-based post-processing dialog box directly:

Latest value

Page 84: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

82 CST STUDIO SUITE™ 2006 – Advanced Topics

A 0D Results task can also be used as the optimization goal of type 0D Result:

Page 85: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 83

Chapter 7 - VBA Macro Language

7.1 Introduction CST STUDIO SUITE™ offers a powerful environment for automating any task within its modules or even in combination with external programs. The powerful VBA (Visual Basic for Applications) compatible macro language is equipped with a fully featured development environment including an editor and a debugger. An interface to OLE automation enables a seamless integration into the Windows environment (e.g. Microsoft Office®, MATLAB®, AutoCAD®, MathCAD®, Windows Scripting Host, etc.).

The following sections start by providing general information on the VBA-based macro language before the actual integration into CST STUDIO SUITE™ is discussed. The explanations are supported by a variety of examples which should assist you in building your own macros. We strongly recommend you work through this introduction, which should only take a few hours, to obtain a good working knowledge of macro programming in general.

7.2 VBA Development Environment You can open the VBA development environment by choosing Macros Open VBA Macro Editor in CST MICROWAVE STUDIO®, CST EM STUDIO™ or CST PARTICLE STUDIO™ or by choosing File Macros New Macro in CST DESIGN STUDIO™. The development environment consists of a toolbar and an editor window as shown below:

Pause Set Breakpoint Step Into Step out Set Next Statement

GUI Bilder Quick Watch

Run Stop Clear Breakpoints Step over Goto Show Next Statement

Page 86: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

84 CST STUDIO SUITE™ 2006 – Advanced Topics

In addition to its toolbar, the editor also features a context menu (opened by pressing the right mouse button) which contains more tools such as find, replace, etc.

VBA Help System You can easily access the VBA online help system from CST STUDIO SUITE™ by selecting Help VBA Language Help from the main menu. The contents of this help system are divided into three different sections. The first section provides reference information on the basic VBA language elements. A second part contains specific information on the collection of CST STUDIO SUITE™ objects and a detailed explanation of their methods. Finally, the third section contains examples that may be used right away or give you some ideas for developing your own macros. Pressing the F1-key in the editor window provides some context-specific help on the keyword positioned at the mouse cursor’s location. If no keyword can be found, a general help page will appear allowing you to navigate through the help system.

Editor window

Context menu

Page 87: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 85

VBA Editor Shortcuts

The following shortcuts are available within the VBA editor or debugger:

Ctrl+N Open new file Ctrl+O Open existing file Ctrl+S Save current sheet Ctrl+P Print current sheet Ctrl+Z Undo Ctrl+X Cut Ctrl+C Copy Ctrl+V Paste Del Delete Tab Indent Shift+Tab Outdent Ctrl+F Find Ctrl+R Replace F3 Find or replace again Ctrl+Space Complete word / command Ctrl+I Parameter info F5 Run macro execution Shift+F5 Stop macro execution Esc Pause macro execution F8 Debug step into Shift+F8 Debug step over Ctrl+F8 Debug step out F7 Debug step to cursor F9 Debug toggle breakpoint Shift+Ctrl+F9 Clear all breakpoints Shift+F9 Quick watch Ctrl+F9 Add watch

Page 88: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

86 CST STUDIO SUITE™ 2006 – Advanced Topics

7.3 VBA Language Elements The following subsections provide a basic overview of typically used VBA language elements and should help you get started with this programming language. The online documentation contains more detailed information on these topics as well.

Subroutines and Functions

A VBA-script can be regarded as a collection of subroutines and functions. Each VBA program must have at least a subroutine Sub Main which will automatically be called when the program is started. The following example illustrates how other functions can be used from within this main routine:

Option Explicit Sub Main Dim s3 As String s3 = MultiStr ("Hello ",4) ' This is a comment (displayed in green colour) MsgBox s3 End Sub Function MultiStr (s1 As String, n As Integer) As String Dim i As Integer Dim s2 As String s2 = "" For i = 1 To n s2 = s2 & s1 Next I MultiStr = s2 End Function

You should now enter this simple example into the VBA development environment while familiarizing yourself with the editor’s functions. Start by selecting the corresponding toolbar button: (F5). The program should display a message box containing a single line of text: “Hello Hello Hello Hello." Place the cursor over a keyword for which you want to see an explanation. Pressing the F1 key will then automatically invoke the online help system showing some detailed information about the particular keyword if available. You can now set a breakpoint at the line “s2 = s2 & s1” by placing the cursor somewhere in this line and selecting the toolbar icon (F9). Breakpoints are visualized by highlighting the corresponding line and showing a red dot at the beginning of the line. Start the macro execution again by selecting (F5). The execution should then pause automatically at the breakpoint. Once the execution is paused, you can check the current values of a variable by moving the mouse-pointer over the variable of interest. A tooltip will then appear informing you of the variable’s content. You may also double-click on the variable (e.g. s2) and select the option Debug Add Watch (Ctrl+F9) from the context menu (opened by pressing the right mouse button). The latter function automatically places a variable watch inside the “watch” frame on top of the editor

Breakpoint

Page 89: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 87

window. This watch will then always display the current value of the variable making debugging very easy.

This simple example demonstrates the ability of the interactive design environment for developing, testing and executing scripts. Before you are able to completely understand the script used in the example above, we need to introduce some other important language elements.

Variables, Data Types and Type Conversions As in every programming language, VBA offers the ability to define variables. We strongly recommend declaring all variables before using them in order to prevent naming conflicts. The statement Option Explicit at the very beginning of the script (see the example above) forces the declaration of variables before they can be accessed by the program. Each variable must belong to a certain data type with the most important ones being Double, Integer, Long, String and Boolean.

Please note: VBA allows a very general data type called Variant. We do not usually recommend using this data type and will therefore skip it in this introduction.

Variables are declared using the Dim statement with the following syntax:

Dim s As String Dim d As Double

Dim i As Integer Dim j As Long

Instead of explicitly declaring the data type by using the As statement, you may also append a $ sign to the variable name to indicate that it is of a string type. The same is valid for integer (%), long (&) and double (#) data types. Thus the following declarations are equivalent although we recommend using the first one:

Dim s As String Dim s$ Dim d As Double Dim d#

Dim i As Integer Dim i% Dim j As Long Dim j&

Please note: The integer data type is only 16 bits wide and thus can only contain values within the range of –32768, …, 32767. Use the long data type for storing 32 bit integer values.

All CST STUDIO SUITE™ parameters which are currently defined in the project can automatically be accessed as Double variables from within the script. Problems may occur if the same names are accidentally used in a VBA script for local variables. To prevent naming conflicts, we strongly recommend always using the statement Option Explicit. Following this rule, you will automatically get an error message in the event of multiply defined variables.

Page 90: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

88 CST STUDIO SUITE™ 2006 – Advanced Topics

You can also change the CST STUDIO SUITE™ parameters from within the script by using the StoreParameter command as shown in the following code segment:

StoreParameter("width", 20)

VBA is type safe. Therefore type-conversions are sometimes necessary, e.g. when printing out a double value as a string by using the MsgBox function: Dim d1 As Double d1 = 1.23 MsgBox CStr(d1) Here the function CStr() is used to convert the given argument into a string data type (Convert into String). Another quite common conversion function is CDbl(), which can be used to convert an arbitrary data type into a double, if possible. If the conversion fails, an error will occur. A much more general way to evaluate an expression and to convert the result to a double data type is to use the Evaluate() function: Dim d as Double d = CDbl("5") OK d = CDbl("5+3") ERROR d = Evaluate("5+3") OK

For further information such as on how to declare array elements or how to use constants, please refer to the online help system.

Applications, Objects and Their Methods One of the most powerful aspects of VBA language is the object-oriented approach, which allows the seamless combination and integration of component objects from various applications, e.g. MS Office (Word, PowerPoint, Excel, Outlook), Matlab, CST STUDIO SUITE™. A single script may thus access functionality from several applications at the same time. External objects need to be created by using the CreateObject() command before they can be accessed from within the script: Dim word as object, ppt as object Set word = CreateObject("Word.Application") Set ppt = CreateObject("PowerPoint.Application")

Page 91: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 89

After creating an external COM object, you are able to access its methods directly from within your VBA script. For more information on its COM interface, please refer to the documentation for that particular application. Since CST STUDIO SUITE™ also features a COM interface, the corresponding objects can also be accessed by third-party applications. The following code segment shows how to start and control e.g. CST MICROWAVE STUDIO® from an external program using VBA:

Sub Main() Dim studio As Object Set studio = CreateObject("CSTStudio.Application") Dim mws As Object Set mws = studio.NewMWS Dim brick As Object Set brick = mws.brick brick.Name "brick" brick.Xrange 0, 1 brick.Yrange 0, 1 brick.Zrange 0, 1 brick.Create mws.SaveAs "C:\temp\test.mod", False mws.Quit Set studio = Nothing End Sub

Please refer to the online documentation for more information on the particular methods available for the COM objects provided by CST STUDIO SUITE™. Access to the object’s methods can be simplified by using a With – End With block as shown in the example below:

Sub Main() Dim studio As Object Set studio = CreateObject("CSTStudio.Application") With studio.NewMWS With .Brick .Name "brick" .Xrange 0, 1 .Yrange 0, 1 .Zrange 0, 1 .Create End With .SaveAs "C:\temp\test.mod", False .Quit End With

Page 92: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

90 CST STUDIO SUITE™ 2006 – Advanced Topics

Set studio = Nothing End Sub

Please note that in the case of nested With – End With structures, the innermost block is used. The VBA interpreter of CST STUDIO SUITE™ allows you to access its objects directly without using the CreateObject command. The methods of the application object are available as global functions, and all other objects can be used as global objects. For use in the CST STUDIO SUITE™ environment, the example shown above can be simplified to the following:

Sub Main With Brick .Name "brick" .Xrange 0, 1 .Yrange 0, 1 .Zrange 0, 1 .Create End With SaveAs "C:\temp\test.mod", False End Sub

Flow Control

The VBA language offers a wide variety of flow control elements. The most frequently used ones are the If – Then – Else – End If, While – Wend or For – Next statements shown in the examples below:

If Boolean_Expression Then ' IF - STATEMENT Else ' Else-STATEMENT End If While Boolean_Expression STATEMENTs Wend For i = 1 To n STATEMENTs Next i

Please find more information on these and other flow control elements in the online help which can be easily accessed by selecting Help VBA Language Help and choosing the topic Language Reference Overview.

Page 93: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 91

File Operations

Accessing files from a VBA script is rather straightforward. After opening a file for either reading or writing, you can assign a numbered stream to it which can then be used to access the file. This is shown in the example below:

Dim sline as String

Open "mydata.txt" For Input As #1 While Not EOF(1)

Line Input #1,sline Debug.Print sline

Wend Close #1 Open "mydata.txt" For Output As #2 Print #2, "Test Output" Close #2 Open "mydata.txt" For Append As #3 Print #3, "Test Output 2" Close #3

Please note: The Debug.Print method is used to generate debug text output which is written to an output window in the development environment.

Any CST STUDIO SUITE™ result which is displayed in the navigation tree’s 1D Results folder should be accessed using the Result1D object rather than by direct file access. A similar Result3D object exists for the access of 3D result field data. The usage of these objects are introduced later in this section.

Find further information on file handling (e.g. checking directory contents with the Dir$ command) in the File Group of the language reference part of the VBA online help system.

Graphical User Interface Builder

You can easily create and customize your own dialog boxes by using the graphical user interface builder which you can open either by selecting the icon or Edit UserDialog from the VBA editor’s context menu.

Page 94: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

92 CST STUDIO SUITE™ 2006 – Advanced Topics

A customized dialog box can then be created by placing user interface components on the dialog sheet. However, describing all the details of creating user defined dialog boxes is beyond the scope of this manual. Refer to the online help for more information. Most dialogs' controls store their data as strings, so a conversion of strings to other data types may be necessary. As already shown earlier, a string can be easily converted to a double value by using the CDbl() or Evaluate() functions. Another important source of information on this topic is the pre-loaded result templates or macros which are covered later in this document. Most of these scripts contain user-defined dialog boxes with a variety of controls.

Mathematical Functions, Operators and Constants The VBA language offers various mathematical functions and operators. If you are familiar with other programming languages, you may already know most of them. However, there are a few functions that have a slightly different meaning when compared to other programming languages such as C or C++:

Sqr(a) Square root of a a^2 a * a Log(a) Natural logarithm of a Log(a) / Log(10) Logarithm of a to a base of 10

Refer to the help on operators and general mathematics in the online help system.

Page 95: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 93

In addition to the VBA standard language elements, CST STUDIO SUITE™ provides a collection of mathematical functions that are frequently used in scientific computing:

Pi 3.141592654…. re(am,phD) / im(am,phD) Real or imaginary part of a complex number

(am = amplitude, phD = phase in degrees) ASin(), ACos() Arc sin and Arc cos in radian SinD(x), CosD(x), TanD(x) Sin, cos, tan with x being the angle in degrees ASinD(), ACosD(), ATnD() Arc sin / Arc cos / Arc tan with the result being an

angle in degrees ATn2(y,x) Polar angle of the complex number x + iy measured in

radian ATn2D(y,x) Polar angle of the complex number x + iy measured in

degrees Evaluate(x) Evaluates the mathematical expression x and returns

its numerical value (as double)

Please note: All mathematical functions can also be used in dialog box entry fields whenever CST STUDIO SUITE™ allows you to enter a mathematical expression.

7.4 Concepts of Macro Programming in CST STUDIO SUITE™

After introducing the fundamental concepts of VBA programming, the next sections focus on how VBA language is integrated in CST STUDIO SUITE™ modules. A few tools within CST STUDIO SUITE™ can be extended by providing user-defined functions:

Project templates for the customization of the settings for particular structures Result templates for the automated extraction of simulation results User-defined excitation functions for transient analysis (accessed from the

Excitation signal dialog box) User-defined optimizer goal function (accessed from the Optimization dialog

box) User-defined parameter sweep watch function (accessed from the Parameter

sweep dialog box) You an also create macros to automate common tasks. Each of these macros can be assigned to either of the following groups:

Structure modeling macros: These macros need to be stored in the history list to ensure a proper structure update as a consequence of parametric changes.

Control Macros: These macros do not need to be stored in the history list and are thus usually employed for post-processing calculations.

This does not apply to CST DESIGN STUDIO™ where all macros can be considered as Control Macros.

User-Defined Functions

Page 96: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

94 CST STUDIO SUITE™ 2006 – Advanced Topics

The user-defined functions are always stored as part of a certain project. The text files containing the functions’ VBA code have the following file extensions:

Type of function File name extension User-defined excitation function usf User-defined goal function gfc User-defined watch function pfc

Therefore, if the project’s name is “test.mod," the file name of a user defined goal function will be “test.gfc." Storage of the structure or control macros can be local (within the project) or global (available for all projects). Project templates and the result templates are always stored globally.

Please note: CST DESIGN STUDIO™ does currently not support local macros. Therefore all macros created in CST DESIGN STUDIO™ are stored globally for all projects.

Local Project Macros Local macros are stored as part of a particular project and obtain a numbered file extension, e.g. 000, 001, 002, etc. Assuming the name of the project to be “test.mod," the file names of the local macros could be any one of the following: “test.000," “test.001," etc.

Global Macros and Global Library Path All global macros are stored in a folder named “Macros” located in the Global Library Path. Refer to the CST DESIGN ENVIRONMENT™ First Steps manual for more information on how to set the location of this path. By default, this path is set to the Library folder in the CST STUDIO SUITE™ installation directory. However, when working in a group of users, you may change the location of this directory to a shared folder accessible to everyone. Each user should then specify its location from the Set Global Library Paths dialog box. The file names of global macros are always built by the keyword “macro” and a numbered extension, e.g. “macro.000," “macro.001," etc. It is not necessary to ensure consecutive numbering of the macros. By default, each installation of CST STUDIO SUITE™ contains a collection of useful global macros. The file extension of these macros starts at 500 in order to avoid naming conflicts with your own global macros.

The following picture shows the contents of the Macros submenu in CST MICROWAVE STUDIO® after a couple of macros have been created:

Page 97: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 95

7.5 Control Macros A macro belongs to the class of control macros if it does not need to be stored in the history list. The following list provides an overview of frequently used control macros:

Any kind of numerical post-processing of S-parameters, farfields, probes, voltages

or electromagnetic fields Exporting the screen’s contents as pictures or videos in various formats Project management, e.g. archiving models, cleaning up temporary working

directories, etc. Control and execution of computational sequences Comparison of result data from several projects or measurements

The following sections introduce the most important building blocks used by control macros. These code segments are frequently used in the rather complex pre-loaded result templates or macros which are covered in more detail in the next chapters.

Please note: A control macro always has a “*” sign in front of its name, indicating that it is a control macro rather than a structure macro.

Global macros (hierarchical structure

can contain subfolders)

Local project macros

Create a macro

Page 98: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

96 CST STUDIO SUITE™ 2006 – Advanced Topics

Result1D Object The Result1D object offers convenient access to one-dimensional result data. The following list gives an overview of which result types can be accessed using this object (refer to the online help for details on file naming conventions):

1. Result data stored as part of the project with the file extension “sig”, e.g. time signals, S-parameters, etc.

2. Voltage monitor data 3. Probe results 4. VSWR results, Z+Y-matrices

The Result1D object allows the corresponding file to be opened and its contents to be accessed via methods of an object-oriented manner. Many methods of the Result1D object deliver the index of a particular element rather than its value directly (e.g. .GetClosestIndexFromX, .GetGlobalMaximum, .GetFirstMinimum). You can then access the numerical X/Y value of the indexed data point by using the object’s functions .GetX, and .GetY. The following examples demonstrate the usage of the Result1D object for various tasks. Please refer to the VBA online documentation for more information. Example 1: Access S11 phase results which are stored in the file <project name>^p1(1)1(1).sig

Dim n As Long, i As Long Dim vx As Double, vy As Double With Result1D ("p1(1)1(1)") ' Open the phase of S11 n = .GetN ' Get number of frequency samples For i = 0 To n-1

' Read all points with zero based ' indices

vx = .GetX(i) ' Get frequency of data point vy = .GetY(i) ' Get phase of data point Next i End With

In order to create a new data set containing the group delay time as a function of frequency (which can be calculated from the S-parameter’s phase data), you would need to implement the following steps:

1. Create a new Result1D object. 2. Loop over all frequency samples, calculate each frequency’s delay time and

store its result in the new Result1D object. 3. Save the Result1D object.

Example 2: Determine the maximum return loss and the magnitude of S11 at a frequency of 33 GHz (both in dB).

Dim maxr As double, s11_33GHz As Double Dim s11 As Object

Page 99: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 97

Set s11 = Result1D("d1(1)1(1)") ' S11 in dB maxr = s11.GetY(s11.GetGlobalMaximum()) s11_33GHz = s11.GetY(s11.GetClosestIndexFromX(33))

Example 3: Determine the frequency of the VSWR’s global minimum.

Solver.CalculateVSWR ' calculate the VSWR and ' and store it in ' <project name>^vswr1(1).sig Dim fmin As Double With Result1D("vswr1(1)")

Fmin = .GetX(.GetGlobalMinimum()) ' please note that this frequency is returned in ' the currently active frequency unit, e.g. GHz ' to obtain its value in Hz, you need to ' multiply it by Units.GetFrequencyUnitToSI

End With Example 4: Calculate the real part of S11 at a certain frequency (here 0.65 GHz)

Dim a11 As Object Dim p11 As Object Set a11 = Result1D ("a1(1)1(1)") Set p11 = Result1D ("p1(1)1(1)") Dim n As Integer Dim frq As Double, phase As Double, ampli As Double Dim real As Double frq=0.65 n=a11.GetClosestIndexFromX(frq) phase = Pi/180.0 * p11.GetY(n) ampli = a11.GetY(n) real = ampli * cos(phase)

Example 5: Minimize the real part of S11 at a certain frequency by a user-defined goal function. The optimizer will automatically provide the function's body once you choose to define a user-defined goal function. ' userdefined goal function for optimizer Option Explicit Function GoalFunction() As Double ' code segment from example 4 Dim a11 As Object Dim p11 As Object Set a11 = Result1D ("a1(1)1(1)") Set p11 = Result1D ("p1(1)1(1)") Dim n As Integer Dim frq As Double, phase As Double, ampli As Double Dim real As Double

Page 100: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

98 CST STUDIO SUITE™ 2006 – Advanced Topics

frq=0.65 n=a11.GetClosestIndexFromX(frq) phase = Pi/180.0 * p11.GetY(n) ampli = a11.GetY(n) real = ampli * cos(phase)

' assign the result to the goal function GoalFunction = real

End Function

You may also access files that have been created by a VBA script using the Result1D object. However, these files must contain two columned X/Y data. In order to access external data, you may use a code segment similar to the following: ' just copying the file in order to access it by using the ' Result1D object With Result1D("") .LoadPlainFile("C:\TEMP\mydata.txt") . . . End With

Result3D Object

The Result3D object offers convenient access to 3D result file data similarly to the previously discussed Result1D object. In particular, the Result3D object allows the loading and saving of binary 3D field data in addition to some basic mathematical operations such as add, subtract, multiply, etc. The following example demonstrates how to load 3D result field data in order to calculate a superposition of fields which is then saved as binary result field data. Example: Calculate a superposition of 3D result fields.

Dim field1 as Object, field2 as Object ' Load the 3D result data fields "e1" and "e2" ' (e.g. modes calculated by the eigenmode solver) Set field1 = Result3D("^mode_e_1") Set field2 = Result3D("^mode_e_2") ' First scale field1 and field2 by scalar factors field1.ScalarMult 2 field2.ScalarMult 1.5 ' Now add field2 to field1 (field1 will be overridden)

Page 101: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 99

field1.Add field2 ' Finally save field1 as a new result data field field1.Save "^combination"

Please refer to the online help for more explanations about methods available for this powerful object.

Adding Data Items to the Navigation Tree

CST STUDIO SUITE™ offers the possibility of adding two columned X/Y ASCII data files to the result tree which can then be displayed in the same way as other one-dimensional data sets. The following exemplary code segment illustrates how this can be achieved for an external data file: With ResultTree

.Reset .Type "XYSignal" .Subtype "Linear" .Title "TDR: Time Dependent Impedance Z(t) in Ohms" .Xlabel "Time / " + Units.GetTimeUnit() .Ylabel "Z(t)" .Name "1D Results\TDR Results\Z(t)" .File "C:\Data\myfile.txt" .Add End With

In order to compare curves by plotting them together on the same graph, both curves must have identical titles, x-labels and y-labels. Otherwise the message “Incompatible result data” will be displayed when both curves are selected. In the same way, 3D field result data can be added to the navigation tree: With ResultTree

.Reset .Type "Efield3D" .Name "3D Results\E-Field\My E-field" .File "C:\Data\myfile.m3d" .Add End With

Traverse Folders and Select Items from the Navigation Tree

A particular item in the navigation tree can be easily selected using the SelectTreeItem function. This function returns a Boolean value indicating whether the specified item existed and therefore could be selected. The name of a tree item is specified by its sequence of folders starting at the tree’s root with the folder names separated by “\” characters, e.g.:

SelectTreeItem "1D Results\TDR Results\My Result"

Page 102: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

100 CST STUDIO SUITE™ 2006 – Advanced Topics

You can traverse the tree starting from a particular item (e.g. the root item) by using a script similar to the following code segment:

Dim sItem As String sItem = ResultTree.GetFirstChildName("Farfields") While sItem <> "" SelectTreeItem sItem . . . sItem = ResultTree.GetNextItemName(sItem) Wend

Please note that the navigation tree’s contents are mode-dependent (e.g. results are not accessible in the mesh mode). To ensure that the program is currently not in mesh mode, use the following statement:

' ensure that the mesh mode has been switched off Mesh.ViewMeshMode False

Access the Currently Displayed Plot Data

A few commands can be used to access the data of the currently active plot. Therefore, you should first select a particular plot by using the SelectTreeItem method before using one of the following commands:

GetFieldVector GetFieldFrequency GetFieldPlotMaximum GetFieldPlotMinimum

Refer to the online documentation for more information on these methods. Example 1: Select the fundamental 3D eigenmode and determine its resonance frequency and the field vector at a particular position. Finally, display a message box that provides the maximum value of the field. ' select the corresponding navigation tree item to display ' the mode’s electric field SelectTreeItem "2D/3D Results\Modes\Mode 1\e" ' determine the mode’s frequency dFrequency = GetFieldFrequency() Dim xp As Double, yp As Double, zp As Double xp = 0.0 yp = 0.0 zp = 0.0 ' get the field vector at a particular location (xp, yp, zp) ' the real and imaginary parts of the vector’s components

Page 103: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 101

' are stored in the variables: vxre, vyre, vzre (real parts) ' and vxim, vyim, vzim (imaginary parts) Dim vxre As Double, yvre As Double, vzre As Double Dim vxim As Double, yvim As Double, vzim As Double GetFieldVector(xp, yp, zp, vxre, vyre, vzre, vxim, vyim, vzim ) ' display the field’s maximum strength MsgBox "Max=" + CStr(GetFieldPlotMaximum)

Example 2: Plot a table’s contents and export the data to an ASCII file.

SelectTreeItem "Tables\s11" ExportPlotData "test^mys11.sig"

Access Farfield Data from a VBA Script

Direct access to the farfield at a particular location can easily be obtained using the CalculatePoint method of the FarfieldPlot object as shown below:

FarfieldPlot.SetPlotMode "Directivity" FarfieldPlot.CalculatePoint (dTheta, 0, "Abs", "farfield [1]")

The third argument of the .CalculatePoint method can be any member of the following list:

"Abs"/"Theta"/"Phi"/"Axial Ratio"/"Left Polarisation"/"Right Polarisation"/"Th_Re"/"Th_Im"/"Ph_Re"/"Ph_Im"/"Th_Phase"/"Ph_Phase"

Note that the result obtained by the .CalculatePoint method depends on the currently selected plot mode. Make sure that the plot mode is adjusted to the desired one (directivity / gain / efield / hfield / pfield / rcs / rcssw / scale2max) by using the .SetPlotMode method before accessing the farfield’s data. In addition to direct access to individual farfield data, you can also create a one-dimensional farfield plot and then export its data:

SelectTreeItem("Farfield\farfield [1]") With FarfieldPlot .SetPlotMode "directivity" .Vary "theta" .ThetaStep 25 .PlotType "3d" .Plot End With ExportPlotData "farfield.sig"

The following example demonstrates how to create an X/Y data file containing the vertical diagram using the .CalculatePoint method rather than exporting plot data:

Dim dTheta As Double, dValue As Double Open "C:\Data\mydata.txt" For Output As #1

Page 104: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

102 CST STUDIO SUITE™ 2006 – Advanced Topics

FarfieldPlot.SetPlotMode "directivity" For dTheta = 0 To 180 STEP 5

dValue = FarfieldPlot.CalculatePoint( _ dTheta, 0, "Abs", ”farfield [1]")

Print #1, CStr(dTheta) + " " + CStr(dValue) Next dTheta Close #1

7.6 Structure Macros The main difference between structure macros and the previously introduced command macros is that structure macros are stored in the history list after their execution. Whenever a macro becomes part of the structure’s construction, it is important that history updates recall the macro execution in order to fully regenerate the structure. Structure macros may be used for various purposes at different complexity levels. However, this document can cover only some fundamental concepts on structure macro development. If you frequently need to develop such macros, we advise you to attend a training class specialized on this topic. Contact your support center for more information. Please note that CST DESIGN STUDIO™ does not support structure macros.

Create a Structure Macro or a New Project Template You may frequently need to change some default settings for your particular kind of application. The following list gives some examples for such default settings:

Set the units to “mil” and “MHz” rather than use “mm” and “GHz”. Define a certain set of material properties Set the frequency range to a default of e.g. 0 - 3 GHz. Define farfield monitors for frequencies of 0.9 GHz and 1.8 GHz.

The most convenient way to achieve such changes to the default settings depending on the structure type is to define project templates for these devices. Such a template is simply a particular kind of structure macro and can be created as such. You should start creating your template with an empty history list. Select File New and select the corresponding module in order to start a new project. Afterwards, you should perform all the frequently used steps which should later be automatically provided by the macro:

1. Select a Project Template 2. Define the units. 3. Define default materials (e.g. a set of standard dielectric materials, etc.). 4. Define the background material. 5. Define a default frequency range. 6. Define a collection of frequently used monitors.

Page 105: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 103

7. Change some default settings for the mesh generation. 8. Change some solver settings.

This list can provide only some ideas on what can be customized by the template. You may include other operations as well. Once all necessary steps have been completed, you should open the history list by selecting Edit History List or just the corresponding toolbar icon . The history list will then appear as in the following picture:

You should then select all commands to be included in the template and click the Macro button. You will be prompted to assign a name to the macro (e.g. “My Defaults”) and click OK.

The VBA editor will then automatically open showing the contents of the new structure macro. The first line in the macro contains a comment line with the name of the macro. You can now call this project macro by selecting its name from the Macros menu. Once a structure macro is executed by choosing it from the main menu, it will be appended to the history list. You can create global structure macros in the same way by activating the Make globally available option in the dialog box where you also specify the name for the macro. To create a Project Template, you need to save the VBA editor’s contents to the New Project Templates folder using File Save As. This folder is located in the Macros\[MWS, EMS, PS] subdirectory of the Global Library Path. Please ensure that the

Create a Structure Macro

Page 106: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

104 CST STUDIO SUITE™ 2006 – Advanced Topics

name of the file allows proper identification of the macro’s purpose and that the file extension is set to “tpl," e.g. “UMTS base station filters.tpl." In addition to the macro code, you can provide a text file with the same name but the extension “txt” rather than “tpl” describing the macro's operation. This text file will automatically appear when you select the template in the Create a New Project dialog box. Similarly, a bitmap file (150 x 129 pixel, 256 colors) with the extension “bmp” can also be specified.

Difficulties in Creating Structure Macros Creating structure macros by selecting a couple of lines in the history list and then automatically converting this into a VBA code sequence is very convenient. However, it is important to note that just taking a few lines out of a construction history and building a macro from this will not usually work for the following reasons: 1. The construction may depend on earlier operations in the history that are not part of

the newly created macro. Therefore, pick operations may fail, or the structure elements for deletions or transformations simply do not exist. In order to avoid these problems, we recommend exporting a command sequence from the beginning of the history list.

2. Naming conflicts may occur if the macro uses shape names that have already been defined elsewhere. This problem can be solved only by adding some additional coding in regard to shape naming in the macro.

Because of these pitfalls, we do not recommend you use the macro functionality for simply re-using parts of a model’s history to build a new structure. We strongly suggest exporting the corresponding parts of the existing model into a SAT file first. In a second step, you may import this file into the new project using the working coordinate system for proper placement of imported shapes. The import feature will

<Name>.tpl

<Name>.txt

<Name>.bmp

Page 107: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

CST STUDIO SUITE™ 2006 – Advanced Topics 105

automatically take care of possible naming conflicts and rename the imported shapes in order to avoid such problems. The imported structure can then be modified to some extent using the Local Modification commands. Refer to the corresponding Getting Started manual for more information on this topic.

Use Dialog Boxes in Structure Macros Creating parametric structure macros usually requires user-defined dialog boxes for defining structural parameters. However, these dialog boxes should appear only when the macro is called from the menu and should not be shown when the history list is processed. This behavior can be achieved using the VBA statements BeginHide and EndHide in the structure macro. All VBA code placed between these two lines will automatically be removed from the macro’s code before being written into the history list. However, the dialog box code should usually provide some parameters which will later be used in the macro. Therefore, you need to declare these parameters before the BeginHide statement. The keyword Assign should then be placed right before the EndHide command for each parameter in order to define its current value, which will then be stored as such in the history list. The following code segment shows the usage of these commands:

Dim dRadius As Double BeginHide ' some code defining dRadius by using user dialog boxes . . . Assign("dRadius") EndHide

After you run this code segment, the history list item will contain the following VBA code only:

Dim dRadius As Double dRadius = 0.23 ' or whatever has been assigned to it ' by the user

Common Pitfalls in the Usage of Structure Macros The following list summarizes some common pitfalls in the usage of structure macros:

1. The first comment line of a structure macro must not contain an asterisk *

character preceding the macro’s name (otherwise it would be considered as a command macro and would therefore not be stored in the history list).

Page 108: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

106 CST STUDIO SUITE™ 2006 – Advanced Topics

2. A structure macro is appended to the history list only if it is called from the Macros menu. Running the macro in the VBA debugger by clicking the start button will not store the macro’s contents in the history list.

3. Naming conflicts with existing parts of the project may occur which need to be addressed carefully.

More information on VBA macro programming can be obtained from any one of the following sources:

1. The online help system which contains a book on macro programming (Help VBA Language Help). A few examples are provided there which contain code segments for various frequently used tasks.

2. The macros directory (Global Library Path\Macros\[MWS, EMS, PS]) contains a folder named “VBA_userdefined” which holds a collection of examples on accessing result data.

3. The examples folder in the CST STUDIO SUITETM installation directory contains a “VBA” folder which also contains some examples on using VBA programming.

7.7 Pre-Loaded VBA Macros The installation of CST STUDIO SUITETM contains a selection of pre-loaded global macros which are useful to automate a variety of common tasks. These macros can mainly be categorized as follows:

1. File and result handling 2. Structure generation macros 3. Creating pictures, videos and reports 4. Post-processing individual simulations 5. Post-processing multiple simulations and running parameter sweeps

You can start each of these macros by selecting its name from the hierarchical structure in the Macros menu. For CST DESIGN STUDIO™; however, macros are accessed from the Macros folder in the navigation tree. The macros’ dialog boxes contain Help buttons that open the online help system providing more information. We recommend you browse through the contents of the Macros menu to familiarize yourself with the macros already available. Global macros are stored in the Macros\[MWS, EMS, PS, DS] subfolders of the Global Library Path. The latter path can be set by choosing Macros Set Global Library Path and Macros Set Global Library Paths (CST DESIGN STUDIO™ only), respectively. Refer to the CST DESIGN ENVIRONMENT™ First Steps manual for more information. If you experience any problems using the pre-loaded macros, or if you have suggestions for new macros, please contact technical support ([email protected]).

Page 109: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

© C ST G M B H , 2 0 0 5 . A L L R I G H TS R E S E RV E D.

Page 110: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

专注于微波、射频、天线设计人才的培养 易迪拓培训 网址:http://www.edatop.com

射 频 和 天 线 设 计 培 训 课 程 推 荐

易迪拓培训(www.edatop.com)由数名来自于研发第一线的资深工程师发起成立,致力并专注于微

波、射频、天线设计研发人才的培养;我们于 2006 年整合合并微波 EDA 网(www.mweda.com),现

已发展成为国内最大的微波射频和天线设计人才培养基地,成功推出多套微波射频以及天线设计经典

培训课程和 ADS、HFSS 等专业软件使用培训课程,广受客户好评;并先后与人民邮电出版社、电子

工业出版社合作出版了多本专业图书,帮助数万名工程师提升了专业技术能力。客户遍布中兴通讯、

研通高频、埃威航电、国人通信等多家国内知名公司,以及台湾工业技术研究院、永业科技、全一电

子等多家台湾地区企业。

易迪拓培训课程列表:http://www.edatop.com/peixun/rfe/129.html

射频工程师养成培训课程套装

该套装精选了射频专业基础培训课程、射频仿真设计培训课程和射频电

路测量培训课程三个类别共 30 门视频培训课程和 3 本图书教材;旨在

引领学员全面学习一个射频工程师需要熟悉、理解和掌握的专业知识和

研发设计能力。通过套装的学习,能够让学员完全达到和胜任一个合格

的射频工程师的要求…

课程网址:http://www.edatop.com/peixun/rfe/110.html

ADS 学习培训课程套装

该套装是迄今国内最全面、最权威的 ADS 培训教程,共包含 10 门 ADS

学习培训课程。课程是由具有多年 ADS 使用经验的微波射频与通信系

统设计领域资深专家讲解,并多结合设计实例,由浅入深、详细而又

全面地讲解了 ADS 在微波射频电路设计、通信系统设计和电磁仿真设

计方面的内容。能让您在最短的时间内学会使用 ADS,迅速提升个人技

术能力,把 ADS 真正应用到实际研发工作中去,成为 ADS 设计专家...

课程网址: http://www.edatop.com/peixun/ads/13.html

HFSS 学习培训课程套装

该套课程套装包含了本站全部 HFSS 培训课程,是迄今国内最全面、最

专业的HFSS培训教程套装,可以帮助您从零开始,全面深入学习HFSS

的各项功能和在多个方面的工程应用。购买套装,更可超值赠送 3 个月

免费学习答疑,随时解答您学习过程中遇到的棘手问题,让您的 HFSS

学习更加轻松顺畅…

课程网址:http://www.edatop.com/peixun/hfss/11.html

`

Page 111: CST STUDIO SUITE™2006 - bbs.hwrf.com.cnbbs.hwrf.com.cn/downebd/35254d1228804019-advanced_topics_1789… · CST STUDIO SUITE™2006 ... solver types. Unlike most ... the closed integral

专注于微波、射频、天线设计人才的培养 易迪拓培训 网址:http://www.edatop.com

CST 学习培训课程套装

该培训套装由易迪拓培训联合微波 EDA 网共同推出,是最全面、系统、

专业的 CST 微波工作室培训课程套装,所有课程都由经验丰富的专家授

课,视频教学,可以帮助您从零开始,全面系统地学习 CST 微波工作的

各项功能及其在微波射频、天线设计等领域的设计应用。且购买该套装,

还可超值赠送 3 个月免费学习答疑…

课程网址:http://www.edatop.com/peixun/cst/24.html

HFSS 天线设计培训课程套装

套装包含 6 门视频课程和 1 本图书,课程从基础讲起,内容由浅入深,

理论介绍和实际操作讲解相结合,全面系统的讲解了 HFSS 天线设计的

全过程。是国内最全面、最专业的 HFSS 天线设计课程,可以帮助您快

速学习掌握如何使用 HFSS 设计天线,让天线设计不再难…

课程网址:http://www.edatop.com/peixun/hfss/122.html

13.56MHz NFC/RFID 线圈天线设计培训课程套装

套装包含 4 门视频培训课程,培训将 13.56MHz 线圈天线设计原理和仿

真设计实践相结合,全面系统地讲解了 13.56MHz线圈天线的工作原理、

设计方法、设计考量以及使用 HFSS 和 CST 仿真分析线圈天线的具体

操作,同时还介绍了 13.56MHz 线圈天线匹配电路的设计和调试。通过

该套课程的学习,可以帮助您快速学习掌握 13.56MHz 线圈天线及其匹

配电路的原理、设计和调试…

详情浏览:http://www.edatop.com/peixun/antenna/116.html

我们的课程优势:

※ 成立于 2004 年,10 多年丰富的行业经验,

※ 一直致力并专注于微波射频和天线设计工程师的培养,更了解该行业对人才的要求

※ 经验丰富的一线资深工程师讲授,结合实际工程案例,直观、实用、易学

联系我们:

※ 易迪拓培训官网:http://www.edatop.com

※ 微波 EDA 网:http://www.mweda.com

※ 官方淘宝店:http://shop36920890.taobao.com

专注于微波、射频、天线设计人才的培养

官方网址:http://www.edatop.com 易迪拓培训 淘宝网店:http://shop36920890.taobao.com