Excel-VBA による SU(3) の構造定数の計算 ゲルマン行列 λa , SU(3) の構造定数 fabc に対して、 tr ([λa , λb ] λc ) = 4ifabc でした。これを利用して fabc を Excel-VBA で数値計算します。以下はそのソー ス です。(アポストロフィ ’ に続く文は REM 文です。Dim で宣言されていない 変数は Variant 型で、型の選択をインタプリタに委ねます。これにより BASIC 言 語らしく宣言文を少なくできるわけです。) Function gellmann(a) As matrix ’ ゲルマン行列 Dim g As matrix g = zeromatrix(3) ’g を 3 次零行列とする If a = 1 Then g.ele(1, 2) = cn(1, 0): g.ele(2, 1) = cn(1, 0) ’ 行列要素修正 If a = 2 Then g.ele(1, 2) = cn(0, -1): g.ele(2, 1) = cn(0, 1) If a = 3 Then g.ele(1, 1) = cn(1, 0): g.ele(2, 2) = cn(-1, 0) If a = 4 Then g.ele(1, 3) = cn(1, 0): g.ele(3, 1) = cn(1, 0) If a = 5 Then g.ele(1, 3) = cn(0, -1): g.ele(3, 1) = cn(0, 1) If a = 6 Then g.ele(2, 3) = cn(1, 0): g.ele(3, 2) = cn(1, 0) If a = 7 Then g.ele(2, 3) = cn(0, -1): g.ele(3, 2) = cn(0, 1) If a = 8 Then g.ele(1, 1) = cn(1, 0): g.ele(2, 2) = cn(1, 0): g.ele(3, 3) = cn(-2, 0) g = cmproduct(cn(3 ^ (-0.5), 0), g) ’g → (1/√ 3)g End If gellmann = g End Function Function tstr3(a, b, c) As String ’3 数値の連続文字化 tstr3 = Trim(Str(a)) + Trim(Str(b)) + Trim(Str(c)) End Function Function ctostr(a As complex) As String ’ 複素数の定型文字化 ctostr = "(" + Format(a.re, "0.000000") + ", " + Format(a.im, "0.000000") + ")" End Function Sub main() Dim λ (8) As matrix, f As complex For a = 1 To 8 λ (a) = gellmann(a) Next a i = 1 For a = 1 To 8: For b = a + 1 To 8: For c = b + 1 To 8 f = cproduct(cn(0, -0.25), trace(mproduct(commutator(λ (a), λ (b)), λ (c)))) ’ ↑ f = (-i/4) tr( [λ (a), λ (b)] λ (c) ) If Not (f.re = 0 And f.im = 0) Then ’f ≠ 0 のときだけ出力 i = i + 1 Cells(i, 2).Value = "f[" + tstr3(a, b, c) + "]=" Cells(i, 3).Value = ctostr(f) ’ 複素数 f を文字化したものを出力 End If Next c: Next b: Next a i = i + 2 Cells(i, 2).Value = "√ 3/2=": Cells(i, 3).Value = 3 ^ 0.5 / 2 ’ 参照値出力 End Sub main 実行で Excel のシート上に以下の出力が得られます。 図 1: 出力 複素数や複素行列の型 (構造体) およびこれらに関連した関数は以下のソースで 与えられています (標準モジュール用)。 Type complex ’ 複素数の型 re As Double ’ 実部 im As Double ’ 虚部 End Type Type matrix ’ 複素行列の型 dim As Integer ’ 次元 ele(10, 10) As complex ’ 要素 End Type Function cn(a As Double, b As Double) As complex ’ 複素数の実表示 cn.re = a: cn.im = b End Function Function cplus(a As complex, b As complex) As complex ’ 複素数の和 cplus.re = a.re + b.re: cplus.im = a.im + b.im End Function Function cminus(a As complex, b As complex) As complex ’ 複素数の差 cminus.re = a.re - b.re: cminus.im = a.im - b.im End Function Function cproduct(a As complex, b As complex) As complex ’ 複素数の積 cproduct.re = a.re * b.re - a.im * b.im: cproduct.im = a.re * b.im + a.im * b.re End Function Function zeromatrix(d) As matrix ’ 零行列 zeromatrix.dim = d For i = 1 To d: For j = 1 To d zeromatrix.ele(i, j) = cn(0, 0) Next j: Next i End Function Function mplus(a As matrix, b As matrix) As matrix ’ 行列の和 mplus.dim = a.dim For i = 1 To a.dim: For j = 1 To a.dim mplus.ele(i, j) = cplus(a.ele(i, j), b.ele(i, j)) Next j: Next i End Function Function mminus(a As matrix, b As matrix) As matrix ’ 行列の差 mminus.dim = a.dim For i = 1 To a.dim: For j = 1 To a.dim mminus.ele(i, j) = cminus(a.ele(i, j), b.ele(i, j)) Next j: Next i End Function Function cmproduct(c As complex, a As matrix) As matrix ’ 複素数と行列の積 cmproduct.dim = a.dim For i = 1 To a.dim: For j = 1 To a.dim cmproduct.ele(i, j) = cproduct(c, a.ele(i, j)) Next j: Next i End Function Function mproduct(a As matrix, b As matrix) As matrix ’ 行列の積 Dim s As complex mproduct.dim = a.dim For i = 1 To a.dim: For j = 1 To a.dim s = cn(0, 0) For k = 1 To a.dim s = cplus(s, cproduct(a.ele(i, k), b.ele(k, j))) Next k mproduct.ele(i, j) = s Next j: Next i End Function Function trace(a As matrix) As complex ’ トレース Dim s As complex s = cn(0, 0) For i = 1 To a.dim s = cplus(s, a.ele(i, i)) Next i trace = s End Function Function commutator(a As matrix, b As matrix) As matrix ’ 交換子 commutator = mminus(mproduct(a, b), mproduct(b, a)) End Function 以上。
© Copyright 2024 ExpyDoc