-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAedtRunner.py
187 lines (161 loc) · 6.14 KB
/
AedtRunner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import re
import os
def run(oProject, points, solutionData, currTime):
d1pInit = 2.4
d2pInit = 3.2
d1tInit = 4e-8
d2tInit = 5e-8
minPermittivity = 1.0
minTangentLoss = 1e-9
def fillMatrialProps(regionName, permittivity, tangent, pInit, tInit):
for point, temperatureValue in zip(
points[regionName], solutionData[regionName]["Temperature"]
):
x = point[0]
y = point[1]
z = point[2]
perm1 = pInit
loss1 = tInit
if temperatureValue >= 300.0 and temperatureValue <= 400.0:
perm1 = ((minPermittivity - pInit) / (400.0 - 300.0)) * (
temperatureValue - 300.0
) + pInit
loss1 = ((minTangentLoss - tInit) / (400.0 - 300.0)) * (
temperatureValue - 300.0
) + tInit
elif temperatureValue > 400.0:
perm1 = minPermittivity
loss1 = minTangentLoss
permittivity.append(["NAME:Point", x, y, z, perm1])
tangent.append(["NAME:Point", x, y, z, loss1])
def getNewDataSetValues():
dataSetValues = list()
dataSetValues.append("NAME:Coordinates")
dataSetValues.append(["NAME:DimUnits", "meter", "meter", "meter", ""])
return dataSetValues
dsDie1Perm = getNewDataSetValues()
dsDie1Tangent = getNewDataSetValues()
dsDie2Perm = getNewDataSetValues()
dsDie2Tangent = getNewDataSetValues()
fillMatrialProps("Die1", dsDie1Perm, dsDie1Tangent, pInit=d1pInit, tInit=d1tInit)
fillMatrialProps("Die2", dsDie2Perm, dsDie2Tangent, pInit=d2pInit, tInit=d2tInit)
def addDataSet(oProject, name, values):
dataSetToAdd = list()
dataSetToAdd.append(f"NAME:${name}")
dataSetToAdd.append(values)
oProject.AddDataset(dataSetToAdd)
die1PermDatasetName = "dsDie1Perm"
die1TangDatasetName = "dsDie1Tangent"
die2PermDatasetName = "dsDie2Perm"
die2TangDatasetName = "dsDie2Tangent"
addDataSet(oProject, die1PermDatasetName, dsDie1Perm)
addDataSet(oProject, die1TangDatasetName, dsDie1Tangent)
addDataSet(oProject, die2PermDatasetName, dsDie2Perm)
addDataSet(oProject, die2TangDatasetName, dsDie2Tangent)
def editMaterialCommon(oDefinitionManager, name, permittivityString, tangentString):
oDefinitionManager.EditMaterial(
f"{name}",
[
f"NAME:{name}",
"CoordinateSystemType:=",
"Cartesian",
"BulkOrSurfaceType:=",
1,
["NAME:PhysicsTypes", "set:=", ["Electromagnetic"]],
[
"NAME:ModifierData",
[
"NAME:SpatialModifierData",
"modifier_data:=",
"spatial_modifier_data",
["NAME:all_spatial_modifiers"],
],
],
"permittivity:=",
permittivityString,
"permeability:=",
"0.999991",
"conductivity:=",
"0.0",
"dielectric_loss_tangent:=",
tangentString,
"thermal_conductivity:=",
"237.5",
"mass_density:=",
"2689",
"specific_heat:=",
"951",
"youngs_modulus:=",
"69000000000",
"poissons_ratio:=",
"0.31",
"thermal_expansion_coefficient:=",
"2.33e-05",
],
)
def editMaterialUseConst(oDefinitionManager, name, permVal, tangVal):
editMaterialCommon(oDefinitionManager, name, f"{permVal}", f"{tangVal}")
def editMaterialUseDataset(oDefinitionManager, name, dsPermName, dsTangName):
editMaterialCommon(
oDefinitionManager,
name,
f"clp(${dsPermName},X,Y,Z)",
f"clp(${dsTangName},X,Y,Z)",
)
oDefinitionManager = oProject.GetDefinitionManager()
editMaterialUseDataset(
oDefinitionManager, "die1", die1PermDatasetName, die1TangDatasetName
)
editMaterialUseDataset(
oDefinitionManager, "die2", die2PermDatasetName, die2TangDatasetName
)
oDesign = oProject.SetActiveDesign("TeeModel")
oDesign.Analyze("Setup1")
oModule = oDesign.GetModule("FieldsReporter")
oModule.CopyNamedExprToStack("Volume_Loss_Density")
# fill outputs
def writeOutputs(oModule, regionName):
outputFileName = f"{regionName}.fld"
if os.path.exists(outputFileName):
os.remove(outputFileName)
oModule.ExportToFile(
outputFileName,
f"{regionName}.pts",
"Setup1 : LastAdaptive",
["Freq:=", "10GHz", "Phase:=", "0deg", "offset:=", "0in"],
[
"NAME:ExportOption",
"IncludePtInOutput:=",
True,
"RefCSName:=",
"Global",
"PtInSI:=",
True,
"FieldInRefCS:=",
False,
],
)
lossDensityArray = solutionData[regionName]["Loss Density"]
with open(outputFileName) as vldFile:
vldFile.readline() # skip first line
for index, line in enumerate(vldFile.readlines()):
# split by arbutrary number of contiguous white spaces
lineValues = re.split("\s+", line.strip())
vldValue = float(lineValues[3])
lossDensityArray[index] = vldValue
writeOutputs(oModule, "Die1")
writeOutputs(oModule, "Die2")
# delete datasets
# need to dereference the datasets first
editMaterialUseConst(oDefinitionManager, "die1", d1pInit, d1tInit)
editMaterialUseConst(oDefinitionManager, "die2", d2pInit, d2tInit)
# then, need to save the project
oProject.Save()
# now, can delete datasets
for datasetName in [
die1PermDatasetName,
die1TangDatasetName,
die2PermDatasetName,
die2TangDatasetName,
]:
oProject.DeleteDataset(f"${datasetName}")