python: adept to new CSXCAD API
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>python
parent
b45b615f7e
commit
d41830f090
|
@ -84,19 +84,19 @@ CSX.AddBox(patch, priority=10, start=start, stop=stop, edges2grid='all') # add a
|
|||
substrate = CSX.AddMaterial('substrate', epsilon=substrate_epsR, kappa=substrate_kappa )
|
||||
start = [patch_radius , -substr_ang_width/2, -substrate_length/2]
|
||||
stop = [patch_radius+substrate_thickness, substr_ang_width/2, substrate_length/2]
|
||||
CSX.AddBox(substrate, start=start, stop=stop, edges2grid='all')
|
||||
substrate.AddBox(start=start, stop=stop, edges2grid='all')
|
||||
|
||||
# save current density oon the patch
|
||||
jt_patch = CSX.AddDump('Jt_patch', dump_type=3, file_type=1)
|
||||
start = [patch_radius+substrate_thickness, -substr_ang_width/2, -substrate_length/2]
|
||||
stop = [patch_radius+substrate_thickness, +substr_ang_width/2, substrate_length/2]
|
||||
CSX.AddBox(jt_patch, start=start, stop=stop)
|
||||
jt_patch.AddBox(start=start, stop=stop)
|
||||
|
||||
# create ground
|
||||
gnd = CSX.AddMetal('gnd') # create a perfect electric conductor (PEC)
|
||||
start = [patch_radius, -substr_ang_width/2, -substrate_length/2]
|
||||
stop = [patch_radius, +substr_ang_width/2, +substrate_length/2]
|
||||
CSX.AddBox(gnd, priority=10, start=start, stop=stop, edges2grid='all')
|
||||
gnd.AddBox(priority=10, start=start, stop=stop, edges2grid='all')
|
||||
|
||||
# apply the excitation & resist as a current source
|
||||
start = [patch_radius , feed_angle, 0]
|
||||
|
|
|
@ -99,7 +99,7 @@ for n in range(Helix_turns-1):
|
|||
zpos = zpos + Helix_pitch
|
||||
|
||||
p = np.array([Helix_x, Helix_y, Helix_z])
|
||||
CSX.AddCurve(helix_metal, p)
|
||||
helix_metal.AddCurve(p)
|
||||
|
||||
# create ground circular ground
|
||||
gnd = CSX.AddMetal( 'gnd' ) # create a perfect electric conductor (PEC)
|
||||
|
@ -107,7 +107,7 @@ gnd = CSX.AddMetal( 'gnd' ) # create a perfect electric conductor (PEC)
|
|||
# add a box using cylindrical coordinates
|
||||
start = [0, 0, -0.1]
|
||||
stop = [0, 0, 0.1]
|
||||
CSX.AddCylinder(gnd, start, stop, radius=gnd_radius)
|
||||
gnd.AddCylinder(start, stop, radius=gnd_radius)
|
||||
|
||||
# apply the excitation & resist as a current source
|
||||
start = [Helix_radius, 0, 0]
|
||||
|
|
|
@ -74,7 +74,7 @@ mesh.SmoothMeshLines('z', resolution)
|
|||
substrate = CSX.AddMaterial( 'RO4350B', epsilon=substrate_epr)
|
||||
start = [-MSL_length, -15*MSL_width, 0]
|
||||
stop = [+MSL_length, +15*MSL_width+stub_length, substrate_thickness]
|
||||
CSX.AddBox(substrate, start, stop )
|
||||
substrate.AddBox(start, stop )
|
||||
|
||||
## MSL port setup
|
||||
port = [None, None]
|
||||
|
@ -90,7 +90,7 @@ port[1] = FDTD.AddMSLPort( 2, pec, portstart, portstop, 'x', 'z', MeasPlaneShift
|
|||
## Filter-Stub Definition
|
||||
start = [-MSL_width/2, MSL_width/2, substrate_thickness]
|
||||
stop = [ MSL_width/2, MSL_width/2+stub_length, substrate_thickness]
|
||||
box = CSX.AddBox( pec, start, stop, priority=10 )
|
||||
pec.AddBox(start, stop, priority=10 )
|
||||
|
||||
### Run the simulation
|
||||
if 0: # debugging only
|
||||
|
|
|
@ -80,7 +80,7 @@ mesh.SmoothMeshLines('all', mesh_res, ratio=1.4)
|
|||
Et = CSX.AddDump('Et', file_type=0, sub_sampling=[2,2,2])
|
||||
start = [0, 0, 0];
|
||||
stop = [a, b, length];
|
||||
CSX.AddBox(Et, start, stop);
|
||||
Et.AddBox(start, stop);
|
||||
|
||||
### Run the simulation
|
||||
if 0: # debugging only
|
||||
|
|
|
@ -16,7 +16,7 @@ from openEMS.physical_constants import *
|
|||
### General parameter setup
|
||||
Sim_Path = os.path.join(tempfile.gettempdir(), 'Simp_Patch')
|
||||
|
||||
post_proc_only = True
|
||||
post_proc_only = False
|
||||
|
||||
# patch width (resonant length) in x-direction
|
||||
patch_width = 32 #
|
||||
|
@ -66,14 +66,14 @@ mesh.AddLine('z', [-SimBox[2]/3, SimBox[2]*2/3] )
|
|||
patch = CSX.AddMetal( 'patch' ) # create a perfect electric conductor (PEC)
|
||||
start = [-patch_width/2, -patch_length/2, substrate_thickness]
|
||||
stop = [ patch_width/2 , patch_length/2, substrate_thickness]
|
||||
pb=CSX.AddBox(patch, priority=10, start=start, stop=stop) # add a box-primitive to the metal property 'patch'
|
||||
pb=patch.AddBox(priority=10, start=start, stop=stop) # add a box-primitive to the metal property 'patch'
|
||||
pb.AddEdges2Grid('xy', metal_edge_res=mesh_res/2)
|
||||
|
||||
# create substrate
|
||||
substrate = CSX.AddMaterial( 'substrate', epsilon=substrate_epsR, kappa=substrate_kappa)
|
||||
start = [-substrate_width/2, -substrate_length/2, 0]
|
||||
stop = [ substrate_width/2, substrate_length/2, substrate_thickness]
|
||||
sb=CSX.AddBox( substrate, priority=0, start=start, stop=stop )
|
||||
sb=substrate.AddBox( priority=0, start=start, stop=stop )
|
||||
|
||||
# add extra cells to discretize the substrate thickness
|
||||
mesh.AddLine('z', linspace(0,substrate_thickness,substrate_cells+1))
|
||||
|
@ -82,7 +82,7 @@ mesh.AddLine('z', linspace(0,substrate_thickness,substrate_cells+1))
|
|||
gnd = CSX.AddMetal( 'gnd' ) # create a perfect electric conductor (PEC)
|
||||
start[2]=0
|
||||
stop[2] =0
|
||||
gb=CSX.AddBox(gnd, start, stop, priority=10, edges2grid='all')
|
||||
gb=gnd.AddBox(start, stop, priority=10, edges2grid='all')
|
||||
|
||||
# apply the excitation & resist as a current source
|
||||
start = [feed_pos, 0, 0]
|
||||
|
|
|
@ -66,6 +66,9 @@ class nf2ff:
|
|||
del kw['frequency']
|
||||
self.dump_type = 10 # Ef/Hf
|
||||
|
||||
if np.isscalar(self.freq):
|
||||
self.freq = [self.freq]
|
||||
|
||||
self.e_file = '{}_E'.format(self.name)
|
||||
self.h_file = '{}_H'.format(self.name)
|
||||
|
||||
|
@ -82,14 +85,14 @@ class nf2ff:
|
|||
l_start = np.array(start)
|
||||
l_stop = np.array(stop)
|
||||
l_stop[ny] = l_start[ny]
|
||||
CSX.AddBox(self.e_dump, l_start, l_stop)
|
||||
CSX.AddBox(self.h_dump, l_start, l_stop)
|
||||
self.e_dump.AddBox(l_start, l_stop)
|
||||
self.h_dump.AddBox(l_start, l_stop)
|
||||
if self.directions[pos+1]:
|
||||
l_start = np.array(start)
|
||||
l_stop = np.array(stop)
|
||||
l_start[ny] = l_stop[ny]
|
||||
CSX.AddBox(self.e_dump, l_start, l_stop)
|
||||
CSX.AddBox(self.h_dump, l_start, l_stop)
|
||||
self.e_dump.AddBox(l_start, l_stop)
|
||||
self.h_dump.AddBox(l_start, l_stop)
|
||||
|
||||
def CalcNF2FF(self, sim_path, freq, theta, phi, center=[0,0,0], outfile=None, read_cached=True, verbose=0):
|
||||
""" CalcNF2FF(sim_path, freq, theta, phi, center=[0,0,0], outfile=None, read_cached=True, verbose=0):
|
||||
|
|
|
@ -26,7 +26,12 @@ from openEMS.physical_constants import *
|
|||
class UI_data:
|
||||
def __init__(self, fns, path, freq, signal_type='pulse', **kw):
|
||||
self.path = path
|
||||
if type(fns)==str:
|
||||
fns = [fns]
|
||||
self.fns = fns
|
||||
|
||||
if np.isscalar(freq):
|
||||
freq = [freq]
|
||||
self.freq = freq
|
||||
|
||||
self.ui_time = []
|
||||
|
@ -153,13 +158,13 @@ class LumpedPort(Port):
|
|||
elif self.R==0:
|
||||
lumped_R = CSX.AddMetal(self.lbl_temp.format('resist'))
|
||||
|
||||
CSX.AddBox(lumped_R, self.start, self.stop, priority=self.priority, edges2grid=kw.get('edges2grid', None))
|
||||
lumped_R.AddBox(self.start, self.stop, priority=self.priority, edges2grid=kw.get('edges2grid', None))
|
||||
|
||||
if excite!=0:
|
||||
exc_vec = np.zeros(3)
|
||||
exc_vec[self.exc_ny] = -1*self.direction*excite
|
||||
exc = CSX.AddExcitation(self.lbl_temp.format('excite'), exc_type=0, exc_val=exc_vec, delay=self.delay)
|
||||
CSX.AddBox(exc, self.start, self.stop, priority=self.priority)
|
||||
exc.AddBox(self.start, self.stop, priority=self.priority)
|
||||
|
||||
self.U_filenames = [self.lbl_temp.format('ut'), ]
|
||||
u_start = 0.5*(self.start+self.stop)
|
||||
|
@ -167,7 +172,7 @@ class LumpedPort(Port):
|
|||
u_stop = 0.5*(self.start+self.stop)
|
||||
u_stop[self.exc_ny] = self.stop[self.exc_ny]
|
||||
u_probe = CSX.AddProbe(self.U_filenames[0], p_type=0, weight=-1*self.direction)
|
||||
CSX.AddBox(u_probe, u_start, u_stop)
|
||||
u_probe.AddBox(u_start, u_stop)
|
||||
|
||||
self.I_filenames = [self.lbl_temp.format('it'), ]
|
||||
i_start = np.array(self.start)
|
||||
|
@ -175,7 +180,7 @@ class LumpedPort(Port):
|
|||
i_stop = np.array(self.stop)
|
||||
i_stop[self.exc_ny] = 0.5*(self.start[self.exc_ny]+self.stop[self.exc_ny])
|
||||
i_probe = CSX.AddProbe(self.I_filenames[0], p_type=1, weight=self.direction, norm_dir=self.exc_ny)
|
||||
CSX.AddBox(i_probe, i_start, i_stop)
|
||||
i_probe.AddBox(i_start, i_stop)
|
||||
|
||||
def CalcPort(self, sim_path, freq, ref_impedance=None, ref_plane_shift=None, signal_type='pulse'):
|
||||
if ref_impedance is None:
|
||||
|
@ -220,7 +225,7 @@ class MSLPort(Port):
|
|||
MSL_start = np.array(self.start)
|
||||
MSL_stop = np.array(self.stop)
|
||||
MSL_stop[self.exc_ny] = MSL_start[self.exc_ny]
|
||||
CSX.AddBox( metal_prop, MSL_start, MSL_stop, priority=self.priority )
|
||||
metal_prop.AddBox(MSL_start, MSL_stop, priority=self.priority )
|
||||
|
||||
mesh = CSX.GetGrid()
|
||||
prop_lines = mesh.GetLines(self.prop_ny)
|
||||
|
@ -248,7 +253,7 @@ class MSLPort(Port):
|
|||
u_name = self.lbl_temp.format('ut') + suffix[n]
|
||||
self.U_filenames.append(u_name)
|
||||
u_probe = CSX.AddProbe(u_name, p_type=0, weight=self.upside_down)
|
||||
CSX.AddBox(u_probe, u_start, u_stop)
|
||||
u_probe.AddBox(u_start, u_stop)
|
||||
|
||||
i_prope_pos = u_prope_pos[0:2] + np.diff(u_prope_pos)/2.0
|
||||
self.I_filenames = []
|
||||
|
@ -262,7 +267,7 @@ class MSLPort(Port):
|
|||
i_name = self.lbl_temp.format('it') + suffix[n]
|
||||
self.I_filenames.append(i_name)
|
||||
i_probe = CSX.AddProbe(i_name, p_type=1, weight=self.direction, norm_dir=self.prop_ny)
|
||||
CSX.AddBox(i_probe, i_start, i_stop)
|
||||
i_probe.AddBox(i_start, i_stop)
|
||||
|
||||
if excite!=0:
|
||||
excide_pos_idx = np.argmin(np.abs(prop_lines-(self.start[self.prop_ny] + self.feed_shift*self.direction)))
|
||||
|
@ -273,17 +278,17 @@ class MSLPort(Port):
|
|||
exc_vec = np.zeros(3)
|
||||
exc_vec[self.exc_ny] = -1*self.upside_down*excite
|
||||
exc = CSX.AddExcitation(self.lbl_temp.format('excite'), exc_type=0, exc_val=exc_vec, delay=self.delay)
|
||||
CSX.AddBox(exc, exc_start, exc_stop, priority=self.priority)
|
||||
exc.AddBox(exc_start, exc_stop, priority=self.priority)
|
||||
|
||||
if self.feed_R>=0 and not np.isinf(self.feed_R):
|
||||
R_start = np.array(self.start)
|
||||
R_stop = np.array(self.stop)
|
||||
R_stop [self.prop_ny] = R_start[self.prop_ny]
|
||||
if self.feed_R==0:
|
||||
CSX.AddBox(metal_prop, R_start, R_stop)
|
||||
metal_prop.AddBox(R_start, R_stop)
|
||||
else:
|
||||
lumped_R = CSX.AddLumpedElement(self.lbl_temp.format('resist'), ny=self.exc_ny, caps=True, R=self.feed_R)
|
||||
CSX.AddBox(lumped_R, R_start, R_stop)
|
||||
lumped_R.AddBox(R_start, R_stop)
|
||||
|
||||
def ReadUIData(self, sim_path, freq, signal_type ='pulse'):
|
||||
self.u_data = UI_data(self.U_filenames, sim_path, freq, signal_type )
|
||||
|
@ -335,7 +340,7 @@ class WaveguidePort(Port):
|
|||
e_vec = np.ones(3)
|
||||
e_vec[self.exc_ny]=0
|
||||
exc = CSX.AddExcitation(self.lbl_temp.format('excite'), exc_type=0, exc_val=e_vec, delay=self.delay)
|
||||
CSX.AddBox(exc, e_start, e_stop, priority=self.priority)
|
||||
exc.AddBox(e_start, e_stop, priority=self.priority)
|
||||
|
||||
# voltage/current planes
|
||||
m_start = np.array(start)
|
||||
|
@ -346,11 +351,11 @@ class WaveguidePort(Port):
|
|||
self.U_filenames = [self.lbl_temp.format('ut'), ]
|
||||
|
||||
u_probe = CSX.AddProbe(self.U_filenames[0], p_type=10, mode_function=self.E_func)
|
||||
CSX.AddBox(u_probe, m_start, m_stop)
|
||||
u_probe.AddBox(m_start, m_stop)
|
||||
|
||||
self.I_filenames = [self.lbl_temp.format('it'), ]
|
||||
i_probe = CSX.AddProbe(self.I_filenames[0], p_type=11, weight=self.direction, mode_function=self.H_func)
|
||||
CSX.AddBox(i_probe, m_start, m_stop)
|
||||
i_probe.AddBox(m_start, m_stop)
|
||||
|
||||
def InitMode(self, wg_mode):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue