def func(min_lines: int): sim = Simulation(freq=freq, unit=unit, reference_frequency=ref_freq, sim_dir=None) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), omit_copper=[0], ) Microstrip( pcb=pcb, position=Coordinate2(0, 0), length=pcb_len, width=trace_width, propagation_axis=Axis("x"), port_number=1, excite=True, ) Mesh( sim=sim, metal_res=1 / 80, nonmetal_res=1 / 10, smooth=(1.1, 1.5, 1.5), min_lines=min_lines, expand_bounds=((0, 0), (0, 0), (10, 40)), ) sim.run(csx=False) return sim.ports[0].impedance()
def z0_for_width(width: float) -> float: """ """ sim = Simulation(freq=freq, unit=1e-3, reference_frequency=ref_freq, sim_dir=None) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), omit_copper=[0], ) Microstrip( pcb=pcb, position=Coordinate2(0, 0), length=pcb_len, width=width, propagation_axis=Axis("x"), port_number=1, excite=True, ref_impedance=50, ) Mesh( sim=sim, metal_res=1 / 80, nonmetal_res=1 / 10, min_lines=5, expand_bounds=((0, 0), (0, 0), (10, 40)), ) sim.run(csx=False) return np.abs(sim.ports[0].impedance(freq=ref_freq))
def func(gnd_gap: float): sim = Simulation(freq=freq, unit=unit, reference_frequency=ref_freq, sim_dir=None) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), ) Microstrip( pcb=pcb, position=Coordinate2(0, 0), length=pcb_len, width=trace_width, propagation_axis=Axis("x"), gnd_gap=(gnd_gap, gnd_gap), port_number=1, excite=True, ref_impedance=50, ) Mesh( sim=sim, metal_res=1 / 80, nonmetal_res=1 / 10, min_lines=9, expand_bounds=((0, 0), (0, 0), (10, 40)), ) sim.run(csx=False) return np.abs(sim.ports[0].impedance(freq=ref_freq))
def gcpw(trace_width: float): """ """ sim = Simulation(freq=freq, unit=1e-3) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), ) box = Box2( Coordinate2(-pcb_len / 2, -trace_width / 2), Coordinate2(pcb_len / 2, trace_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, gnd_gap=(gap, gap), port_number=1, ref_impedance=50, excite=True, ) ViaWall( pcb=pcb, position=Coordinate2(0, trace_width / 2 + gap + via_gap), length=pcb_len, width=via_gap / 2, ) ViaWall( pcb=pcb, position=Coordinate2(0, -trace_width / 2 - gap - via_gap), length=pcb_len, width=via_gap / 2, ) Mesh( sim=sim, metal_res=1 / 120, nonmetal_res=1 / 40, smooth=(1.1, 1.5, 1.5), min_lines=25, expand_bounds=((0, 0), (24, 24), (24, 24)), ) sim.run(csx=False) return np.average(np.abs(np.abs(sim.ports[0].impedance()) - 50))
def gen_sim(width: float) -> Simulation: """ Create simulation objects to sweep over. :param width: Top layer trace width. This is the parameter we sweep over. """ sim = Simulation(freq=freq, unit=1e-3) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), ) box = Box2( Coordinate2(-pcb_len / 2, -width / 2), Coordinate2(pcb_len / 2, width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, gnd_gap=(gap, gap), port_number=1, feed_shift=0.3, ref_impedance=50, excite=True, ) Mesh( sim=sim, metal_res=1 / 80, nonmetal_res=1 / 40, smooth=(1.2, 1.5, 1.5), min_lines=25, expand_bounds=((0, 0), (8, 8), (8, 20)), ) return sim_impedance(sim)
pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), ) box = Box2( Coordinate2(-pcb_len / 2, -trace_width / 2), Coordinate2(pcb_len / 2, trace_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, gnd_gap=(gap, gap), port_number=1, ref_impedance=50, excite=True, ) ViaWall( pcb=pcb, position=Coordinate2(0, trace_width / 2 + gap + via_gap), length=pcb_len, width=via_gap / 2, ) ViaWall(
pcb_prop = common_pcbs["oshpark4"] pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), ) Microstrip( pcb=pcb, position=Coordinate2(-pcb_len / 4, 0), length=pcb_len / 2, width=trace_width, propagation_axis=Axis("x"), gnd_gap=(gap, gap), port_number=1, excite=True, ref_impedance=50, ) cap_0402 = common_smd_passives["0402C"] cap_0402.set_unit(unit) # values based on Murata GJM1555C1HR50BB01 (ESR at 12GHz) SMDPassive( pcb=pcb, position=Coordinate2(0, -cap_0402.length / 2), axis=Axis("y"), dimensions=cap_0402,
sim = Simulation(freq=freq, unit=unit, reference_frequency=5.6e9) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), omit_copper=[0], ) Microstrip( pcb=pcb, position=Coordinate2(0, 0), length=microstrip_discontinuity_length, width=microstrip_discontinuity_width, propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, ) box = Box2( Coordinate2(-pcb_len / 2, -trace_width / 2), Coordinate2(-microstrip_discontinuity_length / 2, trace_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=trace_width, propagation_axis=Axis("x"),
pcb_prop = common_pcbs["oshpark4"] pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), omit_copper=[0], ) Microstrip( pcb=pcb, position=Coordinate2(0, 0), length=pcb_len, width=trace_width, propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, port_number=1, ref_impedance=50, excite=True, ) # Mueller BU-1420701851 edge mount SMA pad = add_conducting_sheet( csx=sim.csx, name="pad", conductivity=pcb_prop.metal_conductivity(), thickness=pcb_prop.copper_thickness(0), ) construct_box( prop=pad,
via_fence_sep = via_sep * 2 sim = Simulation(freq=freq, unit=unit) pcb = PCB(sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width) box = Box2( Coordinate2(-pcb_len / 2, -gcpw_width / 2), Coordinate2(pcb_len / 4, gcpw_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, gnd_gap=(gcpw_gap, gcpw_gap), via_gap=(via_gap, via_gap), via=None, port_number=1, feed_shift=0.2, excite=True, ) Via( pcb=pcb, position=Coordinate2(pcb_len / 4, 0), drill=drill_diam, annular_ring=annular_width, antipad=antipad, noconnect_layers=[0, 1, 2, 3],
def func(params: List[float]): """ """ cutout_width = params[0] sim = Simulation(freq=freq, unit=unit, sim_dir=None) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), omit_copper=[0], ) box = Box2( Coordinate2(-pcb_len / 2, -trace_width / 2), Coordinate2(-(cap_dim.length / 2) - (pad_length / 2), trace_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, port_number=1, excite=True, feed_shift=0.35, ref_impedance=z0_ref, ) SMDPassive( pcb=pcb, position=Coordinate2(0, 0), axis=Axis("x"), dimensions=cap_dim, pad_width=pad_width, pad_length=pad_length, c=10e-12, pcb_layer=0, gnd_cutout_width=cutout_width, gnd_cutout_length=1, ) box = Box2( Coordinate2(pcb_len / 2, trace_width / 2), Coordinate2((cap_dim.length / 2) + (pad_length / 2), -trace_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x", direction=-1), trace_layer=0, gnd_layer=1, port_number=2, excite=False, ref_impedance=z0_ref, ) Mesh( sim=sim, metal_res=1 / 120, nonmetal_res=1 / 40, smooth=(1.2, 1.2, 1.2), min_lines=5, expand_bounds=((0, 0), (0, 0), (10, 20)), ) sim.run(csx=False) print_table( data=[sim.freq / 1e9, sim.s_param(1, 1), sim.s_param(2, 1)], col_names=["freq", "s11", "s21"], prec=[4, 4, 4], ) return np.sum(sim.s_param(1, 1))
sim = Simulation(freq=freq, unit=unit) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, omit_copper=[0, 3], ) box = Box2((-pcb_len / 2, -microstrip_width / 2), (0, microstrip_width / 2)) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, port_number=1, feed_shift=0.3, excite=True, ref_impedance=z0_ref, ) Via( pcb=pcb, position=(0, 0), drill=drill_diam, annular_ring=annular_width, antipad=antipad, noconnect_layers=[0, 1, 2, 3], )
trace_width=trace_width, trace_gap=trace_spacing, length=coupler_length, miter=None, ) coupler_port_positions = coupler.port_positions() port0_x = coupler_port_positions[0].x port0_y = coupler_port_positions[0].y Microstrip( pcb=pcb, position=Coordinate2(np.average([port0_x, -pcb_len / 2]), port0_y), length=port0_x + pcb_len / 2, width=trace_width, propagation_axis=Axis("x"), port_number=1, excite=True, ref_impedance=50, feed_shift=0.3, ) port1_x = coupler_port_positions[1].x Microstrip( pcb=pcb, position=Coordinate2(np.average([port1_x, pcb_len / 2]), port0_y), length=pcb_len / 2 - port1_x, width=trace_width, propagation_axis=Axis("x", direction=-1), port_number=2, excite=False,
def sim_func(cutout_width: float): """ """ sim = Simulation(freq=freq, unit=unit, reference_frequency=ref_freq) core_rad = (coax_core_diameter( 2 * coax_rad, coax_dielectric.epsr_at_freq(sim.reference_frequency)) / 2) pcb_prop = common_pcbs["oshpark4"] pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), omit_copper=[0], ) Microstrip( pcb=pcb, position=Coordinate2(0, 0), length=pcb_len, width=trace_width, propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, port_number=1, ref_impedance=50, excite=True, ) # Mueller BU-1420701851 edge mount SMA pad = sim.csx.AddConductingSheet( "pad", conductivity=pcb_prop.metal_conductivity(), thickness=pcb_prop.copper_thickness(0), ) pad.AddBox( priority=priorities["trace"], start=[pcb_len / 2 - sma_lead_len / 2, -sma_lead_width / 2, 0], stop=[pcb_len / 2, sma_lead_width / 2, 0], ) pad_cutout = sim.csx.AddMaterial( "gnd_cutout", epsilon=pcb_prop.substrate.epsr_at_freq(ref_freq), kappa=pcb_prop.substrate.kappa_at_freq(ref_freq), ) pad_cutout.AddBox( priority=priorities["keepout"], start=[ pcb_len / 2 - sma_lead_len / 2, -cutout_width / 2, pcb.copper_layer_elevation(1), ], stop=[pcb_len / 2, cutout_width / 2, pcb.copper_layer_elevation(1)], ) sma_box = sim.csx.AddMetal("sma_box") sma_box.AddBox( priority=priorities["ground"], start=[ pcb_len / 2, -sma_rect_width / 2, -sma_rect_height / 2 + sma_lead_height / 2, ], stop=[ pcb_len / 2 + sma_rect_length, sma_rect_width / 2, sma_rect_height / 2 + sma_lead_height / 2, ], ) sma_keepout = sim.csx.AddMaterial( "sma_keepout", epsilon=coax_dielectric.epsr_at_freq(ref_freq), kappa=coax_dielectric.kappa_at_freq(ref_freq), ) sma_keepout.AddCylinder( priority=priorities["keepout"], start=[pcb_len / 2, 0, sma_lead_height / 2], stop=[pcb_len / 2 + sma_rect_length, 0, sma_lead_height / 2], radius=coax_rad, ) for ypos in [ -sma_rect_width / 2, sma_rect_width / 2 - sma_gnd_prong_width, ]: # sma_box.AddBox( # priority=priorities["ground"], # start=[pcb_len / 2 - sma_gnd_prong_len, ypos, 0], # stop=[ # pcb_len / 2, # ypos + sma_gnd_prong_width, # sma_gnd_prong_height # ], # ) # sma_box.AddBox( # priority=priorities["ground"], # start=[ # pcb_len / 2 - sma_gnd_prong_len, # ypos, # pcb.copper_layer_elevation(1) # ], # stop=[ # pcb_len / 2, # ypos + sma_gnd_prong_width, # pcb.copper_layer_elevation(1) - sma_gnd_prong_height, # ], # ) sma_box.AddBox( priority=priorities["ground"], start=[ pcb_len / 2 - sma_gnd_prong_len, ypos, pcb.copper_layer_elevation(1) - sma_gnd_prong_height, ], stop=[ pcb_len / 2, ypos + sma_gnd_prong_width, sma_gnd_prong_height, ], ) lead = sim.csx.AddMetal("lead") lead.AddBox( priority=priorities["trace"], start=[pcb_len / 2 - sma_lead_len / 2, -sma_lead_width / 2, 0], stop=[ pcb_len / 2 + sma_rect_length, sma_lead_width / 2, sma_lead_height, ], ) # coax port Coax( sim=sim, position=Coordinate3( pcb_len / 2 + sma_rect_length + coax_len / 2, 0, sma_lead_height / 2, ), length=coax_len, radius=coax_rad, core_radius=core_rad, shield_thickness=mil_to_mm(5), dielectric=coax_dielectric, propagation_axis=Axis("x", direction=-1), port_number=2, ref_impedance=50, ) mesh = Mesh( sim=sim, metal_res=1 / 120, nonmetal_res=1 / 10, min_lines=5, expand_bounds=((0, 0), (0, 0), (10, 10)), ) box = mesh.sim_box(include_pml=False) sim.run(csx=False) s11 = sim.s_param(1, 1) s21 = sim.s_param(2, 1) print("cutout width: {}".format(cutout_width)) print_table( data=[sim.freq / 1e9, s11, s21], col_names=["freq", "s11", "s21"], prec=[4, 4, 4], ) return np.sum(s11)
pcb = PCB(sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_len, layers=range(3)) box = Box2( Coordinate2(-pcb_len / 2, pcb_len / 4 - (trace_width / 2)), Coordinate2(pcb_len / 4, pcb_len / 4 + (trace_width / 2)), ) Microstrip( pcb=pcb, position=box.center(), length=box.max_corner.x - box.min_corner.x, width=trace_width, propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, gnd_gap=(gap, gap), port_number=1, feed_shift=0.4, excite=True, ) box = Box2( Coordinate2(pcb_len / 4 - trace_width, pcb_len / 4 + (trace_width / 2)), Coordinate2(pcb_len / 4, -pcb_len / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.min_corner.y - box.max_corner.y,
def sim_func(taper_angle: float): """ :param taper_angle: Linear taper angle in degrees. """ angle_rad = taper_angle * np.pi / 180 dy = np.abs(trace_width - microstrip_discontinuity_width) / 2 dx = dy / np.tan(angle_rad) taper_middle = microstrip_discontinuity_length / 2 + dx / 2 taper_end = microstrip_discontinuity_length / 2 + dx sim = Simulation(freq=freq, unit=unit, sim_dir=None) pcb = PCB( sim=sim, pcb_prop=pcb_prop, length=pcb_len, width=pcb_width, layers=range(3), omit_copper=[0], ) Microstrip( pcb=pcb, position=Coordinate2(0, 0), length=microstrip_discontinuity_length, width=microstrip_discontinuity_width, propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, ) Taper( pcb=pcb, position=Coordinate2(-taper_middle, 0), pcb_layer=0, width1=trace_width, width2=microstrip_discontinuity_width, length=dx, ) Taper( pcb=pcb, position=Coordinate2(taper_middle, 0), pcb_layer=0, width1=microstrip_discontinuity_width, width2=trace_width, length=dx, ) box = Box2( Coordinate2(-pcb_len / 2, -trace_width / 2), Coordinate2(-taper_end, trace_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=trace_width, propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, port_number=1, excite=True, feed_shift=0.35, ref_impedance=50, ) box = Box2( Coordinate2(taper_end, -trace_width / 2), Coordinate2(pcb_len / 2, trace_width / 2), ) Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=trace_width, propagation_axis=Axis("x", direction=-1), trace_layer=0, gnd_layer=1, port_number=2, ref_impedance=50, ) Mesh( sim=sim, metal_res=1 / 120, nonmetal_res=1 / 40, min_lines=5, expand_bounds=((0, 0), (0, 0), (10, 40)), ) # sim.run(csx=False) sim.run() return sim.s_param(1, 1)
pcb_layer=0, gnd_layer=1, trace_width=trace_width, gap=gap, ) print("miter: {:.4f}mm ({:.2f}%)".format( miter.miter, 100 * miter.miter / (trace_width * np.sqrt(2)))) Microstrip( pcb=pcb, position=box.center(), length=box.max_corner.x - box.min_corner.x, width=trace_width, propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, gnd_gap=(gap, gap), via_gap=(via_gap, via_gap), via=None, shorten_via_wall=(0, gap + via_gap - miter.inset_length()), port_number=1, feed_shift=0.4, excite=True, ) end_pos = miter.end_point() box = Box2( Coordinate2(end_pos.x - (trace_width / 2), end_pos.y), Coordinate2(end_pos.x + (trace_width / 2), -pcb_len / 2), ) Microstrip(
layers=range(3), omit_copper=[0], ) box = Box2( Coordinate2(-pcb_len / 2, -trace_width / 2), Coordinate2(-(cap_dim.length / 2) - (pad_length / 2), trace_width / 2), ) microstrip1 = Microstrip( pcb=pcb, position=box.center(), length=box.length(), width=box.width(), propagation_axis=Axis("x"), trace_layer=0, gnd_layer=1, # gnd_gap=(gap, gap), # via_gap=(via_gap, via_gap), # via=None, port_number=1, excite=True, feed_shift=0.3, ) # ViaWall( # pcb=pcb, # position=Coordinate2(0, trace_width / 2 + gap + via_gap), # length=pcb_len, # width=via_gap / 2, # )