def construct_box( prop: CSProperties, box: Box3, priority: int, transform: CSTransform = None, ) -> CSPrimitives: """ """ if transform is None: box = _add_box( prop=prop, priority=priority, start=box.start(), stop=box.stop() ) return box if box.has_zero_dim(): fp_warning(construct_box) box = _add_box( prop=prop, priority=priority, start=box.origin_start(), stop=box.origin_stop(), ) apply_transform(box, transform) translate = CSTransform() translate.AddTransform("Translate", box.center().coordinate_list()) apply_transform(box, translate) return box
def test_corner(): box = Box3(Coordinate3(0, 0, 0), Coordinate3(1, 1, 1)) corners = box.corners() corners = [corner.coordinate_list() for corner in corners] assert corners == [ Coordinate3(0, 0, 0).coordinate_list(), Coordinate3(0, 1, 0).coordinate_list(), Coordinate3(1, 0, 0).coordinate_list(), Coordinate3(1, 1, 0).coordinate_list(), Coordinate3(0, 0, 1).coordinate_list(), Coordinate3(0, 1, 1).coordinate_list(), Coordinate3(1, 0, 1).coordinate_list(), Coordinate3(1, 1, 1).coordinate_list(), ]
def _box_coords(box: CSPrimBox) -> List[Coordinate3]: """ """ start = box.GetStart() stop = box.GetStop() box3 = Box3(tuple(start), tuple(stop)) corners = box3.corners() new_corners = [] for corner in corners: transform = box.GetTransform() if transform is not None: corner = corner.transform(transform) corner = corner.round_prec(PREC) new_corners.append(corner) return _remove_prim_coord_dups(new_corners)
def func(width: float): sim = Simulation(freq=freq, unit=unit, reference_frequency=ref_freq, sim_dir=None) 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], ) DifferentialMicrostrip( pcb=pcb, position=Coordinate2(0, 0), length=pcb_len, width=width, gap=trace_gap, 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=9, expand_bounds=((0, 0), (0, 0), (10, 40)), ) FieldDump( sim=sim, box=Box3( Coordinate3(-pcb_len / 2, -pcb_width / 2, 0), Coordinate3(pcb_len / 2, pcb_width / 2, 0), ), dump_type=DumpType.current_density_time, ) sim.run(csx=False) return np.abs(sim.ports[0].impedance(freq=ref_freq))
def test_corner(): box = Box3(Coordinate3(0, 0, 0), Coordinate3(1, 1, 1)) corners = box.corners() corners = np.array([corner.coordinate_list() for corner in corners]) assert np.array_equal( corners, np.array([ Coordinate3(0, 0, 0).coordinate_list(), Coordinate3(0, 1, 0).coordinate_list(), Coordinate3(1, 0, 0).coordinate_list(), Coordinate3(1, 1, 0).coordinate_list(), Coordinate3(0, 0, 1).coordinate_list(), Coordinate3(0, 1, 1).coordinate_list(), Coordinate3(1, 0, 1).coordinate_list(), Coordinate3(1, 1, 1).coordinate_list(), ]), )
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, ) dump = FieldDump( sim=sim, box=Box3( Coordinate3(-pcb_len / 2, -pcb_width / 2, 0), Coordinate3(pcb_len / 2, pcb_width / 2, 0), ), ) mesh = 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)), ) if os.getenv("_PYEMS_PYTEST"): sys.exit(0)
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, box=Box3( (pcb_len / 2 - sma_lead_len / 2, -sma_lead_width / 2, 0), (pcb_len / 2, sma_lead_width / 2, 0), ), priority=priorities["trace"], ) pad_keepout = add_material( csx=sim.csx, name="pad_keepout", epsilon=pcb_prop.substrate.epsr_at_freq(ref_freq), kappa=pcb_prop.substrate.kappa_at_freq(ref_freq), color=colors["soldermask"], ) sma_box = add_metal(csx=sim.csx, name="sma_box") construct_box( prop=sma_box,
unit = 1e-3 freq = np.linspace(5.3e9, 5.9e9, 501) sim = Simulation(freq=freq, unit=unit) metal = sim.csx.AddMetal("metal") stl = metal.AddPolyhedronReader(filename=os.path.abspath("horn-antenna.stl")) stl.ReadFile() wg = standard_waveguides["WR159"] wg.set_unit(unit) wg_len = 40 port = RectWaveguidePort( sim=sim, box=Box3( Coordinate3(-wg.a / 2, -wg.b / 2, -wg_len), Coordinate3(wg.a / 2, wg.b / 2, 0), ), propagation_axis=Axis("z"), excite=True, ) port.add_metal_shell(thickness=5) mesh = Mesh( sim=sim, metal_res=1 / 20, nonmetal_res=1 / 10, smooth=(1.5, 1.5, 1.5), min_lines=5, expand_bounds=((16, 16), (16, 16), (8, 24)), ) field_dump = FieldDump(sim=sim, box=mesh.sim_box(include_pml=False))