-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMicrostripExample.py
More file actions
161 lines (133 loc) · 4.25 KB
/
MicrostripExample.py
File metadata and controls
161 lines (133 loc) · 4.25 KB
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
import win32com.client
from matplotlib import pyplot as plt
from Home.CstMeshInitiator import *
from Home.CstDefineBackroundMaterial import *
from Home.CstDefaultUnits import *
from Home.CstSaveAsProject import *
from Home.CstQuitProject import *
from Materials.CstCopperAnnealedLossy import *
from Materials.CstFR4lossy import *
from Modeling.Cstbrick import *
from Modeling.CstSubtract import *
from Modeling.CstAdd import *
from Modeling.CstPickFace import *
from Simulation.CstDefineFrequencyRange import *
from Simulation.CstDefineOpenBoundary import *
from Simulation.CstWaveguidePort import *
from Simulation.CstDefineHfieldMonitor import *
from Simulation.CstDefineEfieldMonitor import *
from Simulation.CstDefineFarfieldMonitor import *
from Simulation.CstDefineTimedomainSolver import *
from PostProcessing.CstResultParameters import *
from PostProcessing.CstExportTouchstone import *
#cst = win32com.client.Dispatch("CSTStudio.Application")
#mws = cst.NewMWS()
cst = win32com.client.dynamic.Dispatch("CSTStudio.Application")
cst.SetQuietMode(True)
new_mws = cst.NewMWS()
mws = cst.Active3D()
CstDefaultUnits(mws)
CstDefineFrequencyRange(mws, 1.5, 3.5)
CstMeshInitiator(mws)
Xmin = 'expanded open'
Xmax = 'expanded open'
Ymin = 'expanded open'
Ymax = 'expanded open'
Zmin = 'expanded open'
Zmax = 'expanded open'
minfrequency = 1.5
CstDefineOpenBoundary(mws, minfrequency, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax)
XminSpace = 0
XmaxSpace = 0
YminSpace = 0
YmaxSpace = 0
ZminSpace = 0
ZmaxSpace = 0
CstDefineBackroundMaterial(mws, XminSpace, XmaxSpace, YminSpace, YmaxSpace, ZminSpace, ZmaxSpace)
CstCopperAnnealedLossy(mws)
CstFR4lossy(mws)
W = 28.45
L = 28.45
Fi = 9
Wf = 1.137
Gpf = 1
Lg = 2 * L
Wg = 2 * W
Ht = 0.035
Hs = 1.6
Name = 'Groundplane'
component = 'component1'
material = 'Copper (annealed)'
Xrange = [-0.5 * Wg, 0.5 * Wg]
Yrange = [-0.5 * Lg, 0.5 * Lg]
Zrange = [0, Ht]
Cstbrick(mws, Name, component, material, Xrange, Yrange, Zrange)
Name = 'Substrate'
component = 'component1'
material = 'FR-4 (lossy)'
Xrange = [-0.5 * Wg, 0.5 * Wg]
Yrange = [-0.5 * Lg, 0.5 * Lg]
Zrange = [Ht, Ht + Hs]
Cstbrick(mws, Name, component, material, Xrange, Yrange, Zrange)
Name = 'Patch'
component = 'component1'
material = 'Copper (annealed)'
Xrange = [-W / 2, W / 2]
Yrange = [-L / 2, L / 2]
Zrange = [Ht + Hs, Ht + Hs + Ht]
Cstbrick(mws, Name, component, material, Xrange, Yrange, Zrange)
Name = 'Empty space'
component = 'component1'
material = 'Copper (annealed)'
Xrange = [-((Wf / 2) + Gpf), ((Wf / 2) + Gpf)]
Yrange = [-L / 2 + Fi, -L / 2]
Zrange = [Ht + Hs, Ht + Hs + Ht]
Cstbrick(mws, Name, component, material, Xrange, Yrange, Zrange)
component1 = 'component1:Patch'
component2 = 'component1:Empty space'
CstSubtract(mws, component1, component2)
Name = 'FeedLine'
component = 'component1'
material = 'Copper (annealed)'
Xrange = [-Wf / 2, Wf / 2]
Yrange = [-L / 2 + Fi, -Lg / 2]
Zrange = [Ht + Hs, Ht + Hs + Ht]
Cstbrick(mws, Name, component, material, Xrange, Yrange, Zrange)
component1 = 'component1:Patch'
component2 = 'component1:FeedLine'
CstAdd(mws, component1, component2)
Name = 'Substrate'
face_id = 3
CstPickFace(mws, 'component1', Name, face_id)
PortNumber = 1
Xrange = [-36, 36]
Yrange = [-36, -36]
Zrange = [0.035, 1.635]
XrangeAdd = [3 * Wf, 3 * Wf]
YrangeAdd = [0, 0]
ZrangeAdd = [Ht + Hs, 4 * Hs]
Coordinates = 'Picks'
Orientation = 'positive'
CstWaveguidePort(mws, PortNumber, Xrange, Yrange, Zrange, XrangeAdd, YrangeAdd, ZrangeAdd, Coordinates, Orientation)
CstDefineEfieldMonitor(mws, ('e-field' + '2.45'), 2.45)
CstDefineHfieldMonitor(mws, ('h-field' + '2.45'), 2.45)
CstDefineFarfieldMonitor(mws, ('farfield' + '2.45'), 2.45)
CstSaveAsProject(mws, 'E:\\demo\\demo_result\\MicrostripAntenna')
CstDefineTimedomainSolver(mws, -40)
frequencies_list, [y_real, y_imag], y_list, [x_label, y_label, plot_title] = CstResultParameters(mws, parent_path=r'1D Results\S-Parameters', run_id=0, result_id=0)
plt.figure(dpi=300)
plt.plot(frequencies_list, y_real)
plt.plot(frequencies_list, y_imag)
plt.xlabel(x_label)
plt.ylabel(y_label)
plt.title(plot_title)
plt.show()
plt.figure(dpi=300)
plt.plot(frequencies_list, y_list)
plt.xlabel(x_label)
plt.ylabel(y_label)
plt.title(plot_title)
plt.show()
export_file_path = 'E:\\demo\\microstrip_demo.txt'
CstExportTouchstone(mws, export_file_path)
cst.Quit()