|
Modeling
High Frequency
Low Frequency
Multiphysics
Particles
モニター
加速空洞
データ処理
|
CST StudioParticles: モニターCST Studio のパーティクルダイナミックス計算のモニターについて説明します. 目次はじめにこのページでは,CST Studio の PIC モジュールを使ったビームダイナミクス計算のモニターの設定について説明します. Particle 2D MonitorParticle 2D Monitor は,粒子の位置や速度を 2 次元でモニターするための機能です. 等間隔モニターPIC solver の Particle 2D Monitor は等間隔でモニターが設定できないので,不便です.特に大量のモニターを扱う場合,いちいちマウスで設定していると時間がかかります.そこで,VBA スクリプト (Par2Dmon_series.mcr) を使って自動化します. リスト 1 Particle 2D Monitor を等間隔で設定するスクリプト (Par2Dmon_series.mcr) Option Explicit
' ==========================================================
' Par2Dmon_series.vba
' Purpose: This program is used to continuously generate particle 2D monitors in CST Studio.
' ==========================================================
Private Function CSTNum(ByVal x As Double) As String
CSTNum = Trim$(Str$(x))
End Function
Private Function MonitorZNamePart(ByVal z As Double) As String
Dim zText As String
Dim dotPos As Long
Dim wholePart As String
zText = CSTNum(z)
dotPos = InStr(1, zText, ".")
If dotPos = 0 Then
MonitorZNamePart = Format$(CLng(zText), "000")
Else
wholePart = Left$(zText, dotPos - 1)
If wholePart = "" Or wholePart = "-" Then
wholePart = wholePart & "0"
End If
MonitorZNamePart = Format$(CLng(wholePart), "000") & "p" & Mid$(zText, dotPos + 1)
End If
End Function
Sub Main()
Dim z0 As Double ' Start position
Dim z1 As Double ' stop position
Dim dz As Double ' step size
Dim umin As Double ' Umin/Umax define the X range
Dim umax As Double
Dim vmin As Double ' Vmin/Vmax define the Y range
Dim vmax As Double
' If dt is 0, CST stores data using the solver time step.
Dim t0 As Double ' monitor start time
Dim dt As Double ' monitor time step / bin width
Dim t1 As Double ' monitor end time
Dim z As Double ' Current monitor position.
Dim i As Long ' Loop index and number of intervals.
Dim n As Long
Dim monName As String ' Monitor name.
Dim s As String ' VBA history command string.
' ------------------------------------------------------------
' User settings
' ------------------------------------------------------------
' Create monitor planes from z0 to z1 with spacing dz.
z0 = 10
z1 = 550
dz = 2
umin = -20
umax = 20
vmin = -20
vmax = 20
t0 = 0
dt = 0.0
' t1 =
' ------------------------------------------------------------
' Create monitors
' ------------------------------------------------------------
n = CLng((z1 - z0) / dz)
' Loop over all monitor positions.
For i = 0 To n
z = z0 + i * dz
' Generate a monitor name.
' Example:
' z = 5 -> pic2d_z005mm
' z = 10 -> pic2d_z010mm
' z = 10.5 -> pic2d_z010p5mm
' z = 486 -> pic2d_z486mm
monName = "pic2d_z" & MonitorZNamePart(z) & "mm"
' Build the CST history command.
s = "With PIC2DMonitor" & vbLf & _
" .Reset" & vbLf & _
" .Name """ & monName & """" & vbLf & _
" .SetDirection ""Z""" & vbLf & _
" .SetWPosition """ & CSTNum(z) & """" & vbLf & _
" .Umin """ & CSTNum(umin) & """" & vbLf & _
" .Umax """ & CSTNum(umax) & """" & vbLf & _
" .Vmin """ & CSTNum(vmin) & """" & vbLf & _
" .Vmax """ & CSTNum(vmax) & """" & vbLf & _
" .Tstart """ & CSTNum(t0) & """" & vbLf & _
" .Tstep """ & CSTNum(dt) & """" & vbLf & _
" .Tend """ & CSTNum(t1) & """" & vbLf & _
" .UseTend ""False""" & vbLf & _
" .Create" & vbLf & _
"End With"
' Add the command to CST History.
AddToHistory "create " & monName, s
Next i
End Sub
このスクリプトの使い方は,以下の通りです.
ページ作成情報参考資料
更新履歴
|