CST中定义激励信号的vba编程方法
CST中定义激励信号的vba编程方法

Faq-020802: 定义激励信号1) CST MWS自带的激励信号在整个时域仿真过程中,时域求解器通过时间信号的激励来计算空间上各个时刻的场值。
因此任何一个用于时域仿真的结构都至少应该含有一个用于场输入和输出的端口。
将仿真结构抽象为含有一个输入端口和一个输出端口的系统,根据输入信号i1,输出信号o2,1和反射信号o1,1,以及这些信号的频域值即可得系统特性,并最终设计出需要的系统结构。
因此,时域仿真过程中选择合适的激励信号是很重要的。
在MWS的时域求解过程中,定义激励端口后,系统会给出缺省的激励信号,该缺省的激励信号是由仿真的频率范围决定的高斯脉冲信号。
如上图所示,高斯脉冲信号的频谱仍是高斯函数。
高斯脉冲带宽是有限的,因此可以确保整个频带上网格的生成,有利于求解器在整个频带上对所有频点进行采样。
另外,高斯脉冲的频谱在带宽中不含有零点,故高斯脉冲信号可以在其频带上可以准确地计算S参量。
因此对S参量的求解等,该缺省的高斯脉冲就足够了。
微波工作室®的信号库中含有几个预先定义好的激励信号,可供用户选择。
完成结构建模,并设置好仿真频率等仿真参数后,点击导航树ÖExcitation Signals即可查看当前缺省设置下的激励信号。
如果对缺省的激励信号不满意,还可以在导航树的Excitation Signals上点击右键,选择右键菜单中的Load from Signal Library.....打开信号库(Load New Excitation Signal From Library)选择需要的激励信号。
在下图的信号库对话框中选择需要的激励信号后,点击Apply按钮即可完成信号的加载,在以后的仿真中,可以从求解器对话框中加载该信号对结构进行激励。
2) 自定义激励信号如果信号库中的信号都不能符合仿真要求,您还可以自己定义需要的激励信号。
完成结构建模,并设置好仿真频率等仿真参数后,在导航树的Excitation Signals上点击右键选择右键菜单中的New Excitation Signal......在打开的Excitation Signal对话框中选择Gaussian选项即可通过设定频率范围Fmin和Fmx来定义高斯脉冲信号,选择Rectangular选项即可通过指定信号的上升(Trise)、下降(Tfall)、保持(Thold)以及总激励时间(Ttotal)来定义矩形脉冲信号,并可以在Name栏中为定义的激励信号指定一个您喜欢的名字,这里我们定义一个矩形脉冲,并将名字命名为rectangular。
第5章03_1_CST MWS应用基础

模式分析
频域
6
License
License(File->License)是最重要的设置
有效期 指定新的License文件
已经具备的配置选项
Dongle编号
7
历史记录
历史记录(Edit->History List)里包含了迄今为止所做的所有操作 通过历史记录,可以很方便的更改模型和任意多次的Undo、Redo
在线帮助
在任何窗口按“F1”或点击 ,便可弹出与当前相关的帮助
MWS帮助 VBA帮助 在线例题 仿真向导
还可从主菜单(Help)
版本号
直接启动各类帮助
5
在线例题
系统内置诸多例题(Help->Examples Overview) 其建模、设置和计算均已完成,供大家学习和参考
基础教程 时域 提取SPICE模型 本征模
此种模板所设置的参数
进入方式: 1. 创建新项目 File->New
模板类型
2. 直接选用模板 File->Select Template
45
单位设置
一、设置单位 点击工具栏上图标 或从主菜单选择 Solve->Units
尺寸单位
频率单位
时间单位
在通常情况下,时间单位可以不用设置
46
背景材料设置
CST MICROWAVE STUDIOTM
应用基础
电子科技大学
2010年9月
CST MWS 应用基础
01-概述 02-建立仿真模型 03-仿真流程
2
CST MWS 功能简介
概
述
3
主窗口介绍
主菜单
工具栏 导航树(NT)
绘图平面
CST使用技巧

© CST China - Shanghai -
单机RCS宏
Macros -> Solver -> RCS -> Calculate monostatic RCS(V2)
33
2004.11.12 电大报告会-北京站
© CST China - Shanghai -
© CST China - Shanghai -
构建贴片柱
选择Objects->Pick->Pick face ,双击贴片选中 选择Objects->Extrude ,输入拉伸高度10后确定,生成贴片柱
29
2004.11.12 电大报告会-北京站
© CST China - Shanghai -
构建圆柱体
先画一个半径=5,高=20的圆柱
26
2004.11.12 电大报告会-北京站
© CST China - Shanghai -
构建贴片轮廓
选择Curves->New Curve
选择Curves->Polygon 标
,按ESC键,输入三角形轮廓坐
(其他任意形状的图形均可采用此方式输入)
2
2004.11.12 电大报告会-北京站
© CST China - Shanghai -
基本概念:网络理论
路理论 x(t)
H(ω)
y(t)
H(w) = F{ y(t) } / F{ x(t) }
场理论 a1(t)
S21(ω)
b2(t)
S21(ω) = F{ b2(t) } / F{ a1(t) }
31
2004.11.12 电大报告会-北京站
© CST China - Shanghai -
cst编写方波信号

CST (Computer Simulation Technology) 是一款电磁场仿真软件,可以用来模拟电磁波在各种材料和结构中的传播和散射特性。
如果您想要使用 CST 编写方波信号,可以通过以下步骤来实现:
1. 打开 CST 软件,并创建一个新的项目。
2. 在项目窗口中,选择“Signal”选项卡,并创建一个新的信号。
3. 在信号编辑器中,选择“Analog”选项卡,并设置信号的频率、幅度和相位等参数。
4. 将信号设置为方波信号,可以通过设置信号的上升沿和下降沿时间来实现。
5. 在 CST 中创建一个新的电磁波源,并将方波信号连接到该源。
6. 运行仿真,并观察电磁波在材料和结构中的传播和散射特性。
需要注意的是,CST 是一款专业的电磁场仿真软件,需要一定的专业知识和技能才能熟练使用。
如果您不熟悉 CST 的使用方法,建议先学习 CST 的基本操作和原理,再尝试编写方波信号。
CST宏讲解

CST宏讲解Examples OverviewThe usage of the VBA macro language is described in detail in the printed documentation "Advanced topics".Here are some typical examples to get in touch with the CST MICROWAVESTUDIO® VBA language:GeneralHow to use the VBA Objects in general.Modelling:Create analytical 2D curve.Create analytical 3D curve.Solver and Post processingAccessing S-Parameter Phase.Calculating the real part of S11 at a certain frequency.Define an excitation function.Adding user defined entries to the result tree.Creating 3D scalar and vector plots:Create a farfield array.How to use the VBA ObjectsExample 1: Call CST MICROWAVE STUDIO? from within an external application Creates a CST MICROWAVE STUDIO? Application Object, opens a project and creates a brick: dim app as Object‘Starts the CST MICROWAVE STUDIO?set app = CreateObject(”MWStudio.Application”)app.OpenFile(”c:Exampleswg.mod”)dim br as Objectset br = CreateObj ect(”MWStudio.Brick”)With br.Reset.Name "BrickOne".Layer "default".Xrange "0", "1".Yrange "0", "2".Zrange "0", "4".CreateEnd WithExample2: Open a file within the build-in VBA interpreterOpens a project from the VBA-Interpreter of the CST MICROWA VE STUDIO?: OpenFile(”c:Exampleswg.mod”) With br.Reset.Name "BrickOne".Layer "default".Xrange "0", "1".Yrange "0", "2".Zrange "0", "4".CreateEnd WithCreate an anayltical 2D curve'--------------------------------------------------' arbitrary xy-function is converted into a curve'--------------------------------------------------Sub Main ()On Error GoTo Curve_ExistsCurve.NewCurve "2D-Analytical"Curve_Exists:On Error GoTo 0Dim sCurveName As StringBeginHideDim iii As Integeriii = 1While SelectTreeItem("Curves2D-Analyticalspline_"+CStr(iii)) iii = iii+1WendsCurveName = "spline_"+CStr(iii)assign "sCurveName"EndHideWith Spline.Reset.Name sCurveName.Curve "2D-Analytical"' ====================================== ' Do not change ABOVE this line' ====================================== ' -----------------------------------------------------------' adjust x-range as for-loop parameters (xmin,max,stepsize) ' enter y-Function-statement within for-loop' fixed parameters a,b,c have to be declared via Dim-Statement' -----------------------------------------------------------' NOTE: available MWS-Parameters can be used without' declaration at any place (loop-dimensions, ...)' (for parametric curves during parameter-sweeps and optimisation !) ' ------------------------------------------- Dim xxx As Double, yyy As DoubleDim aaa As Double ' not necessary if aaa is model parameter aaa = 1.23456/Atn(0.5)For xxx = 1.5 To 10 STEP 0.5yyy = 3*aaa/xxx + Sin(xxx^2).LineT o xxx , yyyNext xxx' ====================================== ' Do not change BELOW this line' ====================================== .CreateEnd WithSelectTreeItem("Curves2D-Analytical"+sCurveName)End SubCreate an analytical 3D curve'--------------------------------------------------' arbitrary analytical xyz-function is converted into a curve '--------------------------------------------------Sub Main ()On Error GoTo Curve_ExistsCurve.NewCurve "3D-Analytical"Curve_Exists:On Error GoTo 0Dim sCurveName As StringBeginHideDim iii As Integeriii = 1While SelectTreeItem("Curves3D-Analytical3dpolygon_"+CStr(iii))iii = iii+1WendsCurveName = "3dpolygon_"+CStr(iii)assign "sCurveName"With Polygon3D.Reset.Name sCurveName.Curve "3D-Analytical"' ====================================== ' Do not change ABOVE this line' ====================================== ' -----------------------------------------------------------' adjust x-range as for-loop parameters (xmin,max,step)' enter y/z-Function-statement within for-loop' fixed parameters a,b,c have to be declared via Dim-Statement' -----------------------------------------------------------' NOTE: available MWS-Parameters can be used without' declaration at any place (loop-dimensions, ...)' (for parametric curves during parameter-sweeps and optimisation !)' -------------------------------------------Dim xxx As Double, yyy As Double, zzz As DoubleDim aaa As Double ' not necessary if aaa is model parameter aaa = 0.3For xxx = Pi/2 To 10*2*Pi STEP 0.2yyy = Sqr(2*Abs(Cos(xxx))) + 3*aaa/xxx + 2*Sin(xxx)zzz = Abs(yyy) - Sqr(2*Abs(Cos(xxx))) + 3*aaa/xxx + 2*Sin(xxx) .Point Sin(xxx) , Cos(xxx) , aaa*xxxNext xxx' ====================================== ' Do not change BELOW this line' ======================================End WithSelectTreeItem("Curves3D-Analytical"+sCurveName)End SubAccessing S-Parameter PhaseExample 1: Accessing all values of S-Parameter phase, stored in file ^p1(1)1(1).sig With Result1D ("p1(1)1(1)") ‘ Co nnect to phase of S11nn = .GetN ‘ Get number of frq-pointsFor ii = 0 To nn-1' Read all points; index of first point is zero.v x = .GetX(ii) ‘ here: frequencyvy = .GetY(ii) ‘ here: according phaseNext iiEnd WithCalculating the real part of S11 at a certain frequencyCalculating the real part of S11 at a certain frequency (here 0.65 GHz)Dim a11 As ObjectDim p11 As ObjectSet a11 = Result1D ("a1(1)1(1)")Set p11 = Result1D ("p1(1)1(1)")Dim n As IntegerDim frq As Doublefrq=0.65n=a11.GetClosestIndexFromX(frq)phase = Pi/180.0 * p11.GetY(n)ampli = a11.GetY(n)real = ampli * cos(phase)ResultTree ExamplesThe ResultTree VBA Object offers very interesting possibilities to configure the Navigation Tree. It is possible to insert different simulation results as well as VBA macros. The following examples will show its functionality.Examples to add Signal Views into the treeAll following examples add items into the folder ”My S-Parameters”. If this folder does not exist it will be crea ted.For inserting signals into the tree it is possible to import results from other projects. Therefore the complete result file name must be specified with the File method. If the results of the current project shall be inserted, the project name in the result file name may be omitted.Signal into Tree 1: Adds a linear view of the amplitude of an extern S11 S-Parameter into the folder.Signal into Tree 2: Adds a linear view of the phase of an extern S11 S-Parameter into the folder.Signal into Tree 3: Adds a Smith Chart view of a S11 S-Parameter into the folder.Signal into Tree 4: Adds a Polar Plot of the S11 S-Parameter into the folder.Examples to add Field Plot Views into the treeFor results others than Signals only those of the current project can be inserted into the tree!Field Plot into Tree: Adds a 3D-Vector plot into the tree.Farfield into Tree: Adds a Farfield into the tree.Examples to add a macro into the treeEvery time a macro is executed from the tree, a VBA command interpreter is started and evaluates the string that has been set by the Macro method. Therefore no variables that are defined within the script that creates the folder entry can beaccessed by the macro. Macro into Tree 1: Adds a command to start the time domain solver into the tree.Macro into Tree 2: Adds a macro into the tree.Macro into Tree 3: Adds an external VBA script into the tree.Signal into Tree 1Adds a linear view of the amplitude of the S11 S-Parameter from the projectxtProj?into the folder. ExtProj is supposed to be located in the directory of the current project.With ResultTree.Reset.Name "My S-ParametersS11 (lin)" ' The entry name and its destination folder.Title "S11 (linear)" ' Title of the plot.File "ExtProj^a1(1)1(1).sig" ' The name of the signal file.Type "XYSignal" ' Plot Type.XLabel "f/Hz" ' Label for the x-axis.Subtype "Linear" ' Sub Plot Type.AddEnd WithSee also: Result TreeSignal into Tree 2Adds a linear view of the phase of the S11 S-Parameter from the project ?xtProj?into the folder. ExtProj is supposed to be located in the directory of the current project.With ResultTree.Reset' The entry name and its destination folder.Name "My S-ParametersS11 (phase)".Title "S11 (phase)" ' Title of the plot.File "ExtProj^p1(1)1(1).sig" ' The name of the signal file.Type "XYSignal" ' Plot Type.XLabel "f/Hz" ' Label for the x-axis.Subtype "Phase" ' Sub Plot Type.AddEnd WithSee also: Result TreeSignal into Tree 3Adds a Smith Chart view of the S11 S-Parameter from the current project into the folder.A value has to be given to which the values in the plot are normalized.With ResultTree.Reset' The entry name and its destination folder.Name "My S-ParametersS11 (Smith Chart)".Title "S11" ' Title of the plot.ReferenceImpedance "50" ' Impedance to which the Values ' will be normalized' Result files with the amplitude and phase values.File "^a1(1)1(1).sig".File2 "^p1(1)1(1).sig".Type "SmithSignal" ' Type of the plot.AddEnd WithSee also: Result TreeSignal into Tree 4Adds a Polar Plot view of the S11 S-Parameter from the current project into the folder. With ResultTree.Reset' The entry name and its destination folder.Name "My S-ParametersS11 (polar)"' Result files with the amplitude and phase values.File "^a1(1)1(1).sig".File2 "^p1(1)1(1).sig".Type "PolarSignal" ' Type of the plot.AddEnd WithField Plot into TreeAdds a Field Plot view of the electric field from the current project into the folder ”MyFieldView”.With ResultTree' The entry name and its destination folder.Name "My FieldViewE_Field".File "^e1_1.m3d" ' Result file name.Type "Efield3D" ' Entry type.AddEnd WithFarfield into TreeAdds a Farfield Plot view from the current project into the folder ?y FieldView?With ResultTree' The entry name and its destination folder.Name "My FieldViewFarfield".File "^ff1_1.ffm" ' Result file name.Type "Farfield" ' Entry type.AddEnd WithMacro into Tree 1Adds a command into the ?serdefined?folder that starts the time domain solver.With ResultTree' The entry name and its destination folder.Name "UserdefinedMacro1"' String to be evaluated by the VBA Interpreter.Macro "Solver.Start".Type "Macro" ' Entry type.AddEnd WithMacro into Tree 2Adds the pr eviously defined control macro ”AutoTest” into the tree.At first a string will be defined that contains a VBA command that executes the control macro. The command is ”RunMacro” that takes a string (the name of the control macro) as its argument. However, strings have to be specified within quotes. Unfortunately quotes are special characters which are not recognized as normal characters. They mark the start and the end of a string. Therefore the variable a is defined with a single quote as its only content. With this quote the entire command string can be constructed.Dim a As Stringa = """a = "RunMacro " & a & "AutoTest" & a' a contains the string: RunMacro "AutoTest"With ResultTree' The entry name and its destination folder.Name "UserdefinedMacro2"' String to be evaluated by the VBA Interpreter.Macro a.Type "Macro" ' Entry type.AddEnd WithMacro into Tree 3Adds an external VBA script into the tree. Let the name of the external macrobe ”Macro1.bas” that will be located in the directory of t he current project.At first a string will be defined that contains a VBA command that executes an external VBA script file. The command is ”MacroRun” that takes a string (the name of t he script) as its argument. However, strings have to be specified within quotes. Unfortunately quotes are special characters which are not recognized as normal characters. They mark the start and the end of a string. Therefore the variable a is defined with a single quote as its only content. With this quote the entire command string can be constructed.Dim a As Stringa = """a = "MacroRun " & a & "Macro1.bas" & a' a contains the string: MacroRun "Macro1.bas"With ResultTree' The entry name and its destination folder.Name "UserdefinedMacro3"' String to be evaluated by the VBA Interpreter.Macro a.Type "Macro" ' Entry type.AddEnd WithScalarPlot3D ExampleThe following script plots surfaces of equal amplitude of the vector field component Y of the electric field ”e1”.‘ Plot only a wire frame of the structure to be able to look insidePlot.wireframe True‘ Select the Y-Component of the electric field e1 in the tree SelectTreeItem ("2D/3D ResultsE-Fielde1Y")‘ Plot the scalar field of the selecte d monitorWith ScalarPlot3D.Type "isosurfaces".PlotAmplitude False.Scaling 50.LogScale False.ContourLines False.ScaleToVectorMaximum True.Quality 60.PlotEnd WithSee Also: SelectTreeItem, PlotVectorPlot3D ExampleThe following script plots the electric field ”e1” (if available) in a linear scale by using 400 colored arrows.‘ Plot only a wire frame of the structure to be able to look insidePlot.wireframe True‘ Select the desired monitor in the tree.SelectTreeItem ("2D/3D ResultsE-Fielde1")‘ Plot the field of the selected monitorWith VectorPlot3D.Type "arrowscolor".Objects 400.Scaling 50.LogScale False.PlotEnd WithSee Also: SelectTreeItem, PlotFarfieldArray ObjectGroup: PostprocessingDescription: Defines the antenna array pattern for a farfieldplot based on a single antenna element.Methods: Reset , UseArray , Arraytype , XSet , YSet , Zset , SetList , DeleteList , AntennaFunctions: noneExample:With FarfieldArray.Reset.UseArray "True".Arraytype "Rectangular".ZSet "2", "2,5", "90".SetList.Arraytype "Edit".Antenna "0", "0", "0", "1.0", "0"End With。
CST-VBA程序化建模(附实例解析)

3 VBA基础实例(零基础入门)
零基础入门:宏命令一键生成圆柱体周期阵列 VBA一键生成圆柱体周期阵列(将以上三段程序分别顺序粘贴
到空白程序的main函数内部即可,如下)
可用上述的两种方法重建物体: VBA命令框中点击Run Run Macro 中点击Cylinder_array
12
4 VBA进阶实例(参数化)
参数化建模:长方体周期阵列
参数定义
创建空白宏命令 写入宏命令代码
高 宽 长 间距 数量
运行宏命令,得到模型
13
4 VBA进阶实例(参数化)
参数化建模:长方体周期阵列(宏命令解析)
注释:’Box_Array 定义变量: Dim x As double 给物体命名: BrickName=“box1_”+Str(n) 【这样物体的名称为box1_ n,
消除空格的命令为: BrickName=“box1_”+LTrim(Str(n))】 关键:长方体的位置BrickX1等需用参数和n表征 合并物体: Solid.Add "component1:"+BrickName(1), "component1:"+BrickName(n)
14
5 VBA进阶实例(函数调用)
6
2 开启VBA之路
VBA宏进阶:创建空白宏命令
创建空白VBA命令,so easy!
7
2 开启VBA之路
VBA宏进阶:操作宏命令
点击它,直接生成物体 像CST自带宏命令一样运行 运行VBA宏命令的第二种方法
修改,Edit 其他CST程序也能
打开该宏命令,To Global 不想要了,delete
VBA程序设计基础教程

VBA程序设计基础教程VBA(Visual Basic for Applications)是一种宏编程语言,广泛应用于Microsoft Office套件中的各种应用程序,如Excel、Word和Access等。
它能够帮助用户自动化任务、增加功能、提高效率等。
本文将介绍VBA程序设计的基础知识和技巧。
接下来,需要了解VBA的基本语法和语句。
VBA使用类似于其他编程语言的语法,包括变量的声明、条件和循环语句等。
可以使用Dim语句声明变量,例如Dim x As Integer。
可以使用If语句进行条件判断,例如If x > 10 Then...End If。
可以使用For循环语句进行迭代,例如For i = 1 to 10...Next i。
在VBA中,可以使用对象模型来操作应用程序中的对象。
每个Office应用程序都有自己的对象模型,其中包含了各种对象和属性、方法。
通过这些对象和属性、方法,可以对应用程序进行自定义和控制。
例如,在Excel中,可以使用Worksheet对象表示工作表,Range对象表示单元格区域,可以使用Range对象的Value属性获取或设置单元格的值。
VBA还提供了大量的内置函数,可以用于处理数据和执行各种操作。
这些函数包括数学函数、字符串函数、日期和时间函数等。
例如,可以使用Sum函数计算一列数据的和,可以使用Len函数计算字符串的长度,可以使用Date函数获取当前日期等。
在编写VBA程序时,还需要注意一些最佳实践。
首先,应该对变量进行适当的命名,以反映其用途或内容。
其次,应该合理地使用注释,对代码进行解释和说明。
此外,要按照模块或功能将代码分组,以提高程序的可读性和维护性。
最后,应该经常进行代码测试和调试,以确保程序的正确性和稳定性。
总结起来,VBA程序设计是一项强大而有用的技能,可以帮助用户自动化任务、增加功能和提高效率。
通过学习VBA的基础知识和技巧,可以编写出高效、可靠的程序。
CST VBA的使用方法

4
| Oct-07
Integration Into Workflow
MS Windows Scripting Host COM DCOM Excel, Word, Matlab, AutoCad, etc...
e.g. ppt-Reports
reports
e.g. bidirectional Excel link
Returns a value
21
| Oct-07
Outline
Why macro programming? Existing macros Different types of macros Creating and testing new macros Getting more information
CST STUDIO SUITE‘s macro language: Compatible to the widely used VBA (Visual Basic for Applications) COM based CST STUDIO SUITE can be controlled by other applications CST STUDIO SUITE can control other applications
Execute command in Matlab
CST MWS is called Path of the VBA script within the CST DESIGN Sub Main ENVIRONMENT Opens an existing CST MWS file OpenFile("D:\MBK\test1\test1.mod") Solver.Start Start of Transient Solver Save End Sub Saves results and gives control back to Matlab