這一組掃描dipole antenna的範例程式從dipole建模,模擬設定,資料萃取到輸出圖,只用了40行程式碼,不用開AEDT GUI,就像是把AEDT當作一般的Python模組使用。減少繁複的操作及資料匯入匯出,大幅提高了工作效率。
import matplotlib.pyplot as plt
from pyaedt import Desktop, Hfss, constants
with Desktop("2021.2", non_graphical=True):
hfss = Hfss(designname='A1')
hfss['length'] = '50mm'
p = hfss.modeler.primitives
p.create_cylinder(constants.PLANE.XY, ('0mm', '0mm', '1mm'), '1mm', 'length', matname='copper')
p.create_cylinder(constants.PLANE.XY, ('0mm', '0mm', '-1mm'), '1mm', '-length', matname='copper')
p.create_rectangle(constants.PLANE.YZ, ('0mm', '-1mm', '-1mm'), ('2mm', '2mm'), name='sheet1')
hfss.create_lumped_port_to_sheet(sheet_name='sheet1', axisdir=constants.AXIS.Z)
setup1 = hfss.create_setup(setupname='setup1')
setup1.props['Frequency'] = '1GHz'
hfss.create_frequency_sweep('setup1', 'GHz', 1e-3, 3)
setup1.update()
hfss.create_open_region(Frequency='1GHz')
for l in ['40mm', '50mm', '60mm']:
hfss['length'] = l
hfss.analyze_all()
f, m = [], []
x = hfss.post.get_report_data("dB(S(1,1))")
for freq in x.solutions_data_mag['dB(S(1,1))']:
mag = x.solutions_data_mag['dB(S(1,1))'][freq]
f.append(freq[0])
m.append(-mag)
plt.plot(f, m)
plt.grid()
plt.xlabel('Freq')
plt.ylabel('mag(dB)')
plt.show()
沒有留言:
張貼留言