2021年9月24日 星期五

結合PyAEDT抓取HFSS設定並輸出到網頁上

在一個python檔案當中,呼叫pyaedt及Streamlit模組,用少量的程式碼便可以將多個aedt當中的模擬設定參數顯示到網頁上面。

run.bat

set PATH=C:\Users\mlin\AppData\Local\Programs\Python\Python38\Scripts;%PATH%

streamlit run example.py
pause

example.py

import threading
import streamlit as st
import os
import pyaedt

projects = [r"D:\demo\bp_filter.aedt",
r"D:\demo\coaxbend.aedt",
r"D:\demo\corporate_feed.aedt"]

props = []
for p in projects:
app = pyaedt.Hfss(p,
'HFSSDesign1',
non_graphical=True,
new_desktop_session=True,
close_on_exit=True,
student_version=False)

props.append(app.get_setup('Setup1'))

app.close_desktop()

for pj, c, pr in zip(projects, st.columns(len(props)), props):
with c:
st.subheader(pj)
st.write(pr.props)


(圖一)顯示在網頁上的HFSS模擬設定

如何利用PyAEDT抓取HFSS已模擬完成的結果

利用PyAEDT抓取資料

import pyaedt
import matplotlib.pyplot as plt
app = pyaedt.Hfss("D:/demo_pyaedt/OptimTee.aedt",
'TeeModel',
non_graphical=True,
new_desktop_session=True,
close_on_exit=True,
student_version=False)
try:
f, m = [], []
x = app.post.get_report_data("dB(S(2,1))")

except:
pass
finally:
app.close_desktop()

for freq in x.solutions_data_mag['dB(S(2,1))']:
mag = x.solutions_data_mag['dB(S(2,1))'][freq]
f.append(freq[0])
m.append(-mag)
plt.plot(f, m)
plt.grid()
plt.xlabel('Freq')
plt.ylabel('mag')
plt.show()

 

(圖一) HFSS當中的S21
(圖二)PyAEDT抓取S21並繪圖


2021年9月23日 星期四

如何呼叫API查詢函式

PyAEDT的查詢功能較AEDT內建的API而言,較不容易使用。因為API查詢函數一般不需要下太多參數,我們可以在PyAEDT當中調用API的查詢函數,如下:

import pyaedt

app = pyaedt.Hfss3dLayout("D:/demo_pyaedt/Galileo_G87173_2042.aedt",
'Galileo_G87173_204',
non_graphical=True,
new_desktop_session=True,
close_on_exit=True,
student_version=False)
try:
modeler = app.modeler

oEditor = modeler.oeditor
print(oEditor.GetNets())
print(oEditor.FindObjects('Type', 'poly'))
print(oEditor.GetStackupLayerNames())
for i in oEditor.GetStackupLayerNames():
print(oEditor.GetLayerInfo(i))
except:
pass
finally:
app.close_desktop()
(圖一)查詢結果輸出


輸出EDB資料

 

from pyaedt import Edb

myedb = Edb("D:/demo_pyaedt/Galileo_G87173_2042.aedb", 'Galileo_G87173_204')

x = myedb.core_nets.nets
print(x.keys())

x = [i.PartName for i in myedb.core_components.get_component_list()]
print(x)

x = myedb.core_stackup.stackup_layers.layers
print(x.keys())

x = myedb.core_padstack.padstacks
print(x.keys())

x = myedb.core_primitives.polygons
y = ([(i.GetNet().GetName(), i.GetLayer().GetName()) for i in x])
print(y)

myedb.close_edb()

EDB建立PinGroup

為U2A5建立GND PinGroup,儲存之後匯入EDB from pyaedt import Edb edb = Edb(edbpath= r"D:\demo\Galileo_G87173_20454.aedb" , edbversion= '20...