def series(oEditor, cpw_filter, x0=0, y0=0, var_x=0.5, var_y=0.5, l2=0.02, l3=0.3, d=0.001, W=0.003, W1=0.001, W2=0.002, n=8): l1 = (var_y - l2 - l3 - l2 - 2 * d) / 2 rect = hfss.create_rectangle(oEditor, i_s(x0 - var_x / 2), i_s(y0), 0, i_s(var_x), i_s(var_y)) cl = [ hfss.create_rectangle(oEditor, i_s(x0 - W / 2), i_s(y0), 0, i_s(W), i_s(l1)), hfss.create_rectangle(oEditor, i_s(x0 - (n - 1 / 2) * W1 - (n - 1) * W2), i_s(y0 + l1), 0, i_s((2 * n - 1) * W1 + 2 * (n - 1) * W2), i_s(l2)) ] for i in range(n): cl.append( hfss.create_rectangle( oEditor, i_s(x0 - (n - 1 / 2) * W1 - (n - 1) * W2 + i * 2 * (W1 + W2)), i_s(y0 + l1 + l2), 0, i_s(W1), i_s(d + l3))) for i in range(n - 1): cl.append( hfss.create_rectangle( oEditor, i_s(x0 - (n - 1 / 2) * W1 - (n - 1) * W2 + i * 2 * (W1 + W2) + (W1 + W2)), i_s(y0 + l1 + l2 + d), 0, i_s(W1), i_s(d + l3))) cl.append( hfss.create_rectangle(oEditor, i_s(x0 - (n - 1 / 2) * W1 - (n - 1) * W2), i_s(y0 + l1 + l2 + l3 + 2 * d), 0, i_s((2 * n - 1) * W1 + 2 * (n - 1) * W2), i_s(l2))) cl.append( hfss.create_rectangle(oEditor, i_s(x0 - W / 2), i_s(y0 + l1 + l2 + l3 + l2 + 2 * d), 0, i_s(W), i_s(l1))) finger = hfss.unite(oEditor, cl) cpw_filter = hfss.subtract(oEditor, [cpw_filter], [rect]) cpw_filter = hfss.unite(oEditor, [cpw_filter, finger]) return cpw_filter
def shunt(oEditor, cpw_filter, x0=0, y0=0, var_x=0.5, l2=0.02, l3=0.447, d=0.001, W=0.003, W1=0.0011, W2=0.0017, n=8): l1 = (var_x - l2 - l3 - l2 - 2 * d) / 2 cl = [ hfss.create_rectangle(oEditor, i_s(x0), i_s(y0 - W / 2), 0, i_s(l1), i_s(W)), hfss.create_rectangle(oEditor, i_s(x0 + l1), i_s(y0 - (n - 1 / 2) * W1 - (n - 1) * W2), 0, i_s(l2), i_s((2 * n - 1) * W1 + 2 * (n - 1) * W2)) ] for i in range(n): cl.append( hfss.create_rectangle( oEditor, i_s(x0 + l1 + l2), i_s(y0 - (n - 1 / 2) * W1 - (n - 1) * W2 + i * 2 * (W1 + W2)), 0, i_s(d + l3), i_s(W1))) for i in range(n - 1): cl.append( hfss.create_rectangle( oEditor, i_s(x0 + l1 + l2 + d), i_s(y0 - (n - 1 / 2) * W1 - (n - 1) * W2 + i * 2 * (W1 + W2) + (W1 + W2)), 0, i_s(d + l3), i_s(W1))) cl.append( hfss.create_rectangle(oEditor, i_s(x0 + l1 + l2 + l3 + 2 * d), i_s(y0 - (n - 1 / 2) * W1 - (n - 1) * W2), 0, i_s(l2), i_s((2 * n - 1) * W1 + 2 * (n - 1) * W2))) cl.append( hfss.create_rectangle(oEditor, i_s(x0 + l1 + l2 + l3 + l2 + 2 * d), i_s(y0 - W / 2), 0, i_s(l1), i_s(W))) finger = hfss.unite(oEditor, cl) cpw_filter = hfss.unite(oEditor, [cpw_filter, finger]) return cpw_filter
MaterialValue='\"sapphire\"') cpw_filter = hfss.create_rectangle(oEditor, 0, 0, 0, 'a', 'b', Color=(255, 128, 64)) cpw_filter = hfss.subtract(oEditor, [cpw_filter], [ hfss.create_rectangle(oEditor, 'a/2-var_x/2', 'b/2-var_x/2', 0, 'var_x', 'var_x') ]) line1 = hfss.create_rectangle(oEditor, 'a/2-W/2', 'd0', 0, 'W', 'l0') cpw_filter = hfss.unite(oEditor, [cpw_filter, line1]) line2 = hfss.create_rectangle(oEditor, 'a/2-W/2', 'd0+l0', 0, 'W', 'W1') cpw_filter = hfss.unite(oEditor, [cpw_filter, line2]) line3 = hfss.create_rectangle(oEditor, 'a/2-W/2', 'd0+l0+W1', 0, 'W', 'l0') cpw_filter = hfss.unite(oEditor, [cpw_filter, line3]) line4 = hfss.create_rectangle(oEditor, 'a/2+W/2', 'd0+l0', 0, 'd1', 'W1') cpw_filter = hfss.unite(oEditor, [cpw_filter, line4]) line5 = hfss.create_rectangle(oEditor, 'a/2-W/2-d1', 'd0+l0', 0, 'd1', 'W1') cpw_filter = hfss.unite(oEditor, [cpw_filter, line5]) cpw_filter = capacitor.shunt(oEditor, cpw_filter,
sph1 = hfss.create_sphere(oEditor, hfss.Expression("0m"), hfss.Expression("0m"), hfss.Expression("1m"), hfss.Expression("0.5m")) sph2 = hfss.create_sphere(oEditor, hfss.Expression("0m"), hfss.Expression("0m"), hfss.Expression("-1m"), hfss.Expression("0.5m")) raw_input('Press "Enter" to unite the spheres.>') objname = hfss.unite(oEditor, [sph1, sph2]) raw_input('Press "Enter" to separate the two lumps.>') lumps = hfss.separate_body(oEditor, [objname]) print('lumps: ' + str(lumps)) raw_input('Press "Enter" to quit HFSS.>') hfss.quit_application(oDesktop) del oEditor del oDesign del oProject del oDesktop
oEditor = hfss.set_active_editor(oDesign) raw_input('Press "Enter" to draw two spheres.>') sph1 = hfss.create_sphere(oEditor, hfss.Expression("0m"), hfss.Expression("0m"), hfss.Expression("1m"), hfss.Expression("2m")) sph2 = hfss.create_sphere(oEditor, hfss.Expression("0m"), hfss.Expression("0m"), hfss.Expression("-1m"), hfss.Expression("2m")) raw_input('Press "Enter" to unite the spheres.>') hfss.unite(oEditor, [sph1, sph2]) raw_input('Press "Enter" to quit HFSS.>') hfss.quit_application(oDesktop) del oEditor del oDesign del oProject del oDesktop del oAnsoftApp
def shunt(oEditor, cpw_filter, x0=0, y0=0, var_x=0.5, l4=0.01, W3=0.003, r0=0.0024, r1=0.0024, n=4): l3 = var_x / 2 - r0 - n * r1 if (l3 <= 0): print "Parametrics<0" exit() d3 = var_x / 2 - W3 / 2 - r0 - r1 - l4 if (d3 <= 0): print "Parametrics<0" exit() rect = hfss.create_rectangle(oEditor, i_s(x0), i_s(y0 - var_x / 2), 0, i_s(var_x), i_s(var_x)) cl = [ hfss.create_polyline( oEditor, [i_s(x0), i_s(x0 + l3)], [i_s(y0), i_s(y0)], [0, 0], IsPolylineCovered=False, ), hfss.create_EQbasedcurve( oEditor, i_s(x0 + l3) + '+' + i_s(r0) + '*sin(_t)', i_s(y0 + r0) + '-' + i_s(r0) + '*cos(_t)', '0', 0, 'pi/2', 0, ) ] for i in range(n - 1): if i % 2 == 0: cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + i * 2 * r1), i_s(x0 + l3 + r0 + i * 2 * r1) ], [i_s(y0 + r0), i_s(y0 + r0 + l4)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_EQbasedcurve( oEditor, i_s(x0 + l3 + r0 + r1 + i * 2 * r1) + '-' + i_s(r1) + '*cos(_t)', i_s(y0 + r0 + l4) + '+' + i_s(r1) + '*sin(_t)', '0', 0, 'pi', 0)) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1), i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1) ], [i_s(y0 + r0 + l4), i_s(y0 + r0)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1), i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1) ], [i_s(y0 + r0), i_s(y0 - r0)], [0, 0], IsPolylineCovered=False)) else: cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + i * 2 * r1), i_s(x0 + l3 + r0 + i * 2 * r1) ], [i_s(y0 - r0), i_s(y0 - r0 - l4)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_EQbasedcurve( oEditor, i_s(x0 + l3 + r0 + r1 + i * 2 * r1) + '-' + i_s(r1) + '*cos(_t)', i_s(y0 - r0 - l4) + '-' + i_s(r1) + '*sin(_t)', '0', 0, 'pi', 0)) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1), i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1) ], [i_s(y0 - r0 - l4), i_s(y0 - r0)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1), i_s(x0 + l3 + r0 + 2 * r1 + i * 2 * r1) ], [i_s(y0 - r0), i_s(y0 + r0)], [0, 0], IsPolylineCovered=False)) if n % 2 == 0: cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + (n - 1) * 2 * r1), i_s(x0 + l3 + r0 + (n - 1) * 2 * r1) ], [i_s(y0 - r0), i_s(y0 - r0 - l4)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_EQbasedcurve( oEditor, i_s(x0 + l3 + r0 + r1 + (n - 1) * 2 * r1) + '-' + i_s(r1) + '*cos(_t)', i_s(y0 - r0 - l4) + '-' + i_s(r1) + '*sin(_t)', '0', 0, 'pi', 0)) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + 2 * r1 + (n - 1) * 2 * r1), i_s(x0 + l3 + r0 + 2 * r1 + (n - 1) * 2 * r1) ], [i_s(y0 - r0 - l4), i_s(y0 - r0)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_EQbasedcurve(oEditor, i_s(x0 + l3 + r0 + n * 2 * r1 + r0) + '-' + i_s(r0) + '*cos(_t)', i_s(y0 - r0) + '+' + i_s(r0) + '*sin(_t)', '0', 0, 'pi/2', 0, Name='Quarter_Line')) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + n * 2 * r1 + r0), i_s(x0 + l3 + r0 + n * 2 * r1 + r0 + l3) ], [i_s(y0), i_s(y0)], [0, 0], IsPolylineCovered=False)) else: cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + (n - 1) * 2 * r1), i_s(x0 + l3 + r0 + (n - 1) * 2 * r1) ], [i_s(y0 + r0), i_s(y0 + r0 + l4)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_EQbasedcurve( oEditor, i_s(x0 + l3 + r0 + r1 + (n - 1) * 2 * r1) + '-' + i_s(r1) + '*cos(_t)', i_s(y0 + r0 + l4) + '+' + i_s(r1) + '*sin(_t)', '0', 0, 'pi', 0)) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + 2 * r1 + (n - 1) * 2 * r1), i_s(x0 + l3 + r0 + 2 * r1 + (n - 1) * 2 * r1) ], [i_s(y0 + r0 + l4), i_s(y0 + r0)], [0, 0], IsPolylineCovered=False)) cl.append( hfss.create_EQbasedcurve(oEditor, i_s(x0 + l3 + r0 + n * 2 * r1 + r0) + '-' + i_s(r0) + '*cos(_t)', i_s(y0 + r0) + '-' + i_s(r0) + '*sin(_t)', '0', 0, 'pi/2', 0, Name='Quarter_Line')) cl.append( hfss.create_polyline(oEditor, [ i_s(x0 + l3 + r0 + n * 2 * r1 + r0), i_s(x0 + l3 + r0 + n * 2 * r1 + r0 + l3) ], [i_s(y0), i_s(y0)], [0, 0], IsPolylineCovered=False)) cl = hfss.unite(oEditor, cl) temp_l = hfss.create_polyline( oEditor, [i_s(x0), i_s(x0)], [i_s(y0 - W3 / 2), i_s(y0 + W3 / 2)], [0, 0], IsPolylineClosed=False) meander = hfss.sweep_along_path(oEditor, [temp_l], [cl]) cpw_filter = hfss.subtract(oEditor, [cpw_filter], [rect]) cpw_filter = hfss.unite(oEditor, [cpw_filter, meander[0]]) return cpw_filter
[0, 0], [0, 0], Name='Path', Color="(255 0 0)", IsPolylineCovered=False, IsPolylineClosed=False) objname2 = hfss.create_circle(oEditor, 0, 0, 0, 4, WhichAxis='X') objname3 = hfss.create_cylinder(oEditor, 0, 0, 0, 10, 30, WhichAxis='Z') objname4 = hfss.create_sphere(oEditor, 0, 0, 0, 3) hfss.sweep_along_path(oEditor,[objname2, objname1]) hfss.subtract(oEditor, [objname3], [objname4], KeepOriginals=False) merge1 = hfss.get_matched_object_name(oEditor, "Cyl*") merge2 = hfss.get_matched_object_name(oEditor, "Cir*") hfss.unite(oEditor, merge1 + merge2) raw_input('Press "Enter" to quit HFSS.>') hfss.close_current_project(oDesktop) hfss.quit_application(oDesktop) del oEditor del oDesign del oProject del oDesktop del oAnsoftApp