之前介紹過在Command Window執行nexxim,速度快,缺點是sdf2csv只能轉出S parameter和時域資料。複雜一點的如Z parameter,眼圖統計等就沒辦法了。這邊的做法是將整個包含有netlist的AEDT檔案內容當成字串放在.py當中,修改字串當中的資料即可更改netlist設計或設定。將其輸出成.aedt檔再以ansysedt執行之後輸出所需資料即可。
run.bat
SET PATH=%PATH%;D:\Program Files\AnsysEM\AnsysEM21.1\Win64
ansysedt.exe -features=beta -ng -RunScriptAndExit .\run.py
run.py
text = r"""$begin 'AnsoftProject'
Created='Wed Jun 16 06:35:01 2021'
Product='ElectronicsDesktop'
FileOwnedByWorkbench=false
$begin 'Desktop'
Version(2021, 1)
InfrastructureVersion(1, 0)
$begin 'FactoryHeader'
$end 'FactoryHeader'
$end 'Desktop'
UsesAdvancedFeatures=false
NextUniqueID=0
MoveBackwards=false
$begin 'HFSSEnvironment'
Version(1, 0)
$end 'HFSSEnvironment'
$begin 'PlanarEMEnvironment'
Version(1, 0)
$end 'PlanarEMEnvironment'
$begin 'Q3DEnvironment'
Version(1, 0)
$end 'Q3DEnvironment'
$begin '2DExtractorEnvironment'
Version(1, 0)
$end '2DExtractorEnvironment'
$begin 'NexximEnvironment'
Version(1, 0)
$end 'NexximEnvironment'
$begin 'NexximNetlistEnvironment'
Version(1, 0)
$end 'NexximNetlistEnvironment'
$begin 'EmitEnvironment'
Version(1, 0)
$end 'EmitEnvironment'
$begin 'Maxwell3DEnvironment'
Version(1, 0)
$end 'Maxwell3DEnvironment'
$begin 'Maxwell2DEnvironment'
Version(1, 0)
$end 'Maxwell2DEnvironment'
$begin 'RMxprtEnvironment'
Version(1, 0)
$end 'RMxprtEnvironment'
$begin 'MaxCirEnvironment'
Version(1, 0)
$end 'MaxCirEnvironment'
$begin 'SimplorerEnvironment'
Version(1, 0)
$end 'SimplorerEnvironment'
$begin 'IcepakEnvironment'
Version(1, 0)
$end 'IcepakEnvironment'
$begin 'MechanicalEnvironment'
Version(1, 0)
$end 'MechanicalEnvironment'
$begin 'FilterDesignEnvironment'
$end 'FilterDesignEnvironment'
$begin 'SchematicEnvironment'
Version(1, 0)
$end 'SchematicEnvironment'
$begin 'geometry3deditor'
Version(1, 0)
$end 'geometry3deditor'
ReadVersion=8
$begin 'DesignMgrEnvironment'
CompInstCounter=1
GPortCounter=0
NetCounter=0
Alias('Ieee;Simplorer Elements\\Ieee', 'Std;Simplorer Elements\\Std', 'Basic_VHDLAMS;Simplorer Elements\\Basic Elements VHDLAMS\\Basic Elements VHDLAMS', 'Digital_Elements;Simplorer Elements\\Digital Elements\\Digital Elements', 'Transformations;Simplorer Elements\\Tools\\Transformations\\Transformations', 'HEV_VHDLAMS;Simplorer Elements\\HEV VHDLAMS\\HEV VHDLAMS', 'automotive_vda;Simplorer Elements\\VDALibs VHDLAMS\\automotive_vda', 'example_boardnet;Simplorer Elements\\VDALibs VHDLAMS\\example_boardnet', 'example_ecar;Simplorer Elements\\VDALibs VHDLAMS\\example_ecar', 'fundamentals_vda;Simplorer Elements\\VDALibs VHDLAMS\\fundamentals_vda', 'hybrid_emc_vda;Simplorer Elements\\VDALibs VHDLAMS\\hybrid_emc_vda', 'megma;Simplorer Elements\\VDALibs VHDLAMS\\megma', 'modelica_rotational;Simplorer Elements\\VDALibs VHDLAMS\\modelica_rotational', 'modelica_thermal;Simplorer Elements\\VDALibs VHDLAMS\\modelica_thermal', 'modelica_translational;Simplorer Elements\\VDALibs VHDLAMS\\modelica_translational', 'spice2vhd;Simplorer Elements\\VDALibs VHDLAMS\\spice2vhd', 'spice2vhd_devices;Simplorer Elements\\VDALibs VHDLAMS\\spice2vhd_devices', 'aircraft_electrical_vhdlams;Simplorer Elements\\Aircraft Electrical VHDLAMS\\Aircraft Electrical VHDLAMS', 'power_system_vhdlams;Simplorer Elements\\Power System VHDLAMS\\Power System VHDLAMS')
$end 'DesignMgrEnvironment'
$begin 'ProjectDatasets'
NextUniqueID=0
MoveBackwards=false
DatasetType='ProjectDatasetType'
$begin 'DatasetDefinitions'
$end 'DatasetDefinitions'
$end 'ProjectDatasets'
VariableOrders[0:]
$begin 'Definitions'
$begin 'Folders'
Definitions(1604, 10000, 1, 1, 0, false, false)
Materials(1604, 9500, 9, 2, 1, false, false)
'Surface Materials'(1604, 9501, 33503, 3, 1, false, false)
Scripts(1604, 9502, 33500, 4, 1, false, false)
Padstacks(1604, 9003, 12, 105, 1, false, false)
Symbols(1604, 9001, 10, 103, 1, false, false)
Footprints(1604, 9002, 11, 104, 1, false, false)
Bondwires(1604, 9006, 12, 108, 1, false, false)
Components(1604, 9000, 8, 102, 1, false, false)
Models(1604, 9004, 13, 106, 1, false, false)
Packages(1604, 9005, 33502, 107, 1, false, false)
$end 'Folders'
$begin 'Materials'
$end 'Materials'
$begin 'SurfaceMaterials'
$end 'SurfaceMaterials'
$begin 'Scripts'
$end 'Scripts'
$begin 'Symbols'
$begin 'CircuitNetlist1'
ModTime=1623796486
Library=''
ModSinceLib=false
LibLocation='Project'
HighestLevel=1
Normalize=true
InitialLevels(0, 1)
$begin 'Graphics'
Rect(0, 0, 0, 0, 0.00254, 0.00254, 0.00508, 0.00508, 0, 0, 0)
Rect(0, 1, 0, 0, 0.000423333333333333, 0.00254, 0.000423333333333333, 0.000423333333333334, 0, 0, 0)
$end 'Graphics'
$end 'CircuitNetlist1'
$end 'Symbols'
$begin 'DefInfo'
CircuitNetlist1(1002, 0, 17, 0, '', 1623796486, '', 'CircuitNetlist1', '', '', '', '', '', 'Design.bmp', '', 'Project', '', '', 1623796486, '', 0, 0)
$end 'DefInfo'
$begin 'Compdefs'
$begin 'CircuitNetlist1'
Library=''
CircuitEnv=0
Refbase='U'
NumParts=1
ModSinceLib=true
$begin 'Properties'
TextProp('Representation', 'SRD', '', 'CircuitNetlist1')
TextProp('Owner', 'SRD', '', 'Circuit Netlist')
$end 'Properties'
CompExtID=6
$end 'CircuitNetlist1'
$end 'Compdefs'
$end 'Definitions'
DesignIDServer=3
MoveBackwards=false
$begin 'NexximNetlist'
RepRewriteV2=true
Name='CircuitNetlist1'
DesignID=1
$begin 'DesignDatasets'
NextUniqueID=0
MoveBackwards=false
DatasetType='DesignDatasetType'
$begin 'DatasetDefinitions'
$end 'DatasetDefinitions'
$end 'DesignDatasets'
VariableOrders[0:]
Language='HSPICE'
$begin 'Netlist'
Text='* 0;Circuit1.sph\
**************************************************************************************************\
* Circuit Design netlist *\
* created by ANSYS Electronics Desktop *\
**************************************************************************************************\
\
.option PARHIER=\'local\'\
.option max_messages=1\
\
* begin toplevel circuit\
\
C1 Port1 Port2 1e-12\
RPort1 Port1 0 PORTNUM=1 RZ={0} IZ=0 \
.PORT Port1 0 1 RPort1 \
RPort2 Port2 0 PORTNUM=2 RZ={0} IZ=0 \
.PORT Port2 0 2 RPort2 \
\
* end toplevel circuit\
.LNA\
+ LIN 10 0 1000000000\
+ FLAG=\'LNA\'\
\
.end'
$end 'Netlist'
$begin 'OutputVariable'
NextUniqueID=0
MoveBackwards=false
$end 'OutputVariable'
$begin 'SolutionManager'
$begin 'SimDataExtractors'
$begin 'Version ID Map'
V=1
$end 'Version ID Map'
$end 'SimDataExtractors'
$begin 'Variations'
$end 'Variations'
$end 'SolutionManager'
IntegrationMethod='FFT'
InvisibleFlag=false
OwnerDesignInstance=0
OwnerSetup=''
OwnerSolutionID=0
DefaultSetupID=-1
$begin 'UserDefinedSolutionMgr'
NextUniqueID=1000000
MoveBackwards=false
$end 'UserDefinedSolutionMgr'
$begin 'DatasetSolutionMgr'
NextUniqueID=2000000
MoveBackwards=false
$end 'DatasetSolutionMgr'
Notes=$begin_cdata$ $end_cdata$
$begin 'AnimationSetups'
$end 'AnimationSetups'
CacheHeaderFile='HDR4E7B1498016237965015.tmp'
$end 'NexximNetlist'
$begin 'DataInstances'
DesignEditor='TopLevel'
Refdes('0', 'U1')
$begin 'CompInstances'
$begin 'Compinst'
ID='0'
Status='Status'
CompName='CircuitNetlist1'
GatesInUse()
$begin 'Properties'
TextProp('ID', 'SRID', '', '0')
$end 'Properties'
$end 'Compinst'
$end 'CompInstances'
$begin 'Instance'
DesignEditor='CircuitNetlist1'
ID='0'
$begin 'NexximNetlist'
DesignInstanceID=2
$begin 'WindowPosition'
$begin 'EditorWindow'
Netlist(Netlist(View(WindowPos(3, -1, -1, -9, -38, 32, 32, 1231, 390))))
$end 'EditorWindow'
$end 'WindowPosition'
$begin 'ReportSetup'
$begin 'ReportManager'
$begin 'Reports'
$end 'Reports'
NextUniqueID=0
MoveBackwards=false
$begin 'NextVersID'
NextUniqueID=0
MoveBackwards=false
$end 'NextVersID'
$end 'ReportManager'
$begin 'Reports'
$end 'Reports'
$begin 'ReportsWindowInfoList'
$end 'ReportsWindowInfoList'
$end 'ReportSetup'
$begin 'Properties'
$end 'Properties'
$begin 'UserDefinedDocument'
$begin 'Data'
$end 'Data'
$end 'UserDefinedDocument'
$end 'NexximNetlist'
$end 'Instance'
$begin 'SODInfo'
$end 'SODInfo'
$end 'DataInstances'
$begin 'WBSystemIDToDesignInstanceIDMap'
$end 'WBSystemIDToDesignInstanceIDMap'
$begin 'WBSysIDSysDetails'
$end 'WBSysIDSysDetails'
$begin 'WBConnIDConnDetails'
$end 'WBConnIDConnDetails'
$begin 'WBMaterialGuidDetails'
WBMaterialGuidMap()
$end 'WBMaterialGuidDetails'
$begin 'MinervaProjectSettingsBlk'
MinervaRemoteFilePath=''
FolderContainerString=''
$end 'MinervaProjectSettingsBlk'
$end 'AnsoftProject'
$begin 'AllReferencedFilesForProject'
$end 'AllReferencedFilesForProject'
$begin 'ProjectPreview'
IsEncrypted=false
Thumbnail64=''
$begin 'DesignInfo'
DesignName='CircuitNetlist1'
Notes=''
Factory='Circuit Netlist'
IsSolved=false
'Nominal Setups'[0:]
'Nominal Setup Types'[0:]
'Optimetrics Setups'[0:]
'Optimetrics Experiment Types'[0:]
Image64=''
$end 'DesignInfo'
$end 'ProjectPreview'
"""
with open('d:/demo/x5.aedt', 'w') as f:
f.write(text.format(50))
oDesktop.OpenProject("D:/demo/x5.aedt")
oProject = oDesktop.SetActiveProject("x5")
oDesign = oProject.SetActiveDesign("CircuitNetlist1")
oDesign.AnalyzeAll()
oModule = oDesign.GetModule("ReportSetup")
oModule.CreateReport("Z Parameter Plot 1", "Standard", "Rectangular Plot", "LNA",
[
"NAME:Context",
"SimValueContext:=" , [3,0,2,0,False,False,-1,1,0,1,1,"",0,0]
],
[
"Freq:=" , ["All"]
],
[
"X Component:=" , "Freq",
"Y Component:=" , ["dB(Z(1,1))","dB(Z(2,1))","dB(Z(1,2))","dB(Z(2,2))"]
])
oModule.ExportToFile("Z Parameter Plot 1", "D:/demo/sss.csv", False)