2021年5月12日 星期三

如何在HFSS當中快速設置差分對

在此範例當中,同一差分隊的同一側命名只有L跟H的差異,利用這一點可以使用腳本快速將所有符合規則的ports設置為differential pair。如果不是L跟H的差異,使用者可以修改腳本來適應命名規則。

DifferentialPairing.py

import ScriptEnv


ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oDesktop.ClearMessages("", "", 2)
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()


def setdiffpair(i, p, n):
result = [
"NAME:Pair1",
"PosBoundary:=" , p,
"NegBoundary:=" , n,
"CommonName:=" , "Comm_" + str(i),
"CommonRefZ:=" , "25ohm",
"DiffName:=" , "Diff_" + str(i),
"DiffRefZ:=" , "100ohm",
"IsActive:=" , True,
"UseMatched:=" , False
]
return result

oModule = oDesign.GetModule("BoundarySetup")
result = {}
for i in oModule.GetExcitations()[::2]:
key = i.lower().replace('_l_', '').replace('_h_', '')
if key not in result:
result[key] = [i]
else:
result[key] += [i]

pairs = []
n = 1
for i in sorted(result.keys()):
result[i].sort()
if len(result[i]) == 2:
pairs.append(setdiffpair(i, *result[i]))
n += 1
AddWarningMessage('{}, {}'.format(*result[i]))
else:
pass

oModule.EditDiffPairs(["NAME:EditDiffPairs" ,] + pairs)
AddInfoMessage("Differential pairing completed!")

(圖一) 自動差分對設置


沒有留言:

張貼留言