QuanticParis / HFSSdrawpy

Draw HFSS designs using python
MIT License
17 stars 23 forks source link

draw_end_cable #33

Closed phelyx42 closed 3 years ago

phelyx42 commented 4 years ago

draw_end_cable: -setting the width of fillet for an 'open' to (track width)/2 will raise an error during unite operation.

e.g. draw_end_cable(body, width, gap, typeEnd='open', fillet=width/2, name='port_stop')

HFSS error messages: [error] Acis error: "Fail to make union.. Acis Error 21091 - Two or more vertices of one body mapped to a single entity of other body " (4:38:03 PM Oct 05, 2020) [error] Body could not be created for part because of invalid parameters to Unite operation. (4:38:03 PM Oct 05, 2020)

Here is the code:

from HFSSdrawpy import Modeler, Body
from HFSSdrawpy.libraries.base_elements import *
from drawpylib.parameters import TRACK, GAP, RLC, MESH
import drawpylib.cpw_elements as elt
import numpy as np

def draw_filter(fbody, pos, length, width, gap, wo, name):

    pos = [pos[0], pos[1]]
    with fbody([0, wo + gap],[0,1]):
        port_start, = elt.create_port(fbody, widths=[wo,
                                                    wo+2*gap],
                                               name='port_start')

##############################################################################
    with fbody([0,length -wo - gap],[0,1]):
        open_end, = elt.draw_end_cable(fbody, wo, gap, typeEnd='open', fillet=wo/2, name='port_stop')
##############################################################################

    fbody.draw_cable(port_start, open_end,
                     name =name+'cable_thru',to_meander=[-1, 0, 0],
                     meander_length='0um',
                     meander_offset='0um',fillet='30um')

    _filter = fbody.rect([pos[0]-width/2, pos[1]+0, 0],
                            [width, length],
                            layer=TRACK,
                            name=name+'_thru')

    _filter.subtract(fbody.entities[GAP])
    _filter.unite(fbody.entities[TRACK])

    return _filter

if(__name__=="__main__"):
    new_geometry = True
    pm = Modeler('hfss')

    main_body = Body(pm, 'main')
    chip_body = Body(pm, 'chip',ref_name='main')
    filter_body = Body(pm, 'filter_track',ref_name='main')
    cavity_body = Body(pm, 'cavity',ref_name='main')

    filter_length = pm.set_variable('4mm')      #filter length
    filter_width = pm.set_variable('325um')   #line width
    slot = pm.set_variable('15um')    #slot width
    wopen = pm.set_variable('20um')    #width open stub

    num_lines = 1       # number of lines

if (num_lines == 1):
    # origin
    offset = [0, 0]
    # filter
    filter_1 = draw_filter(filter_body, offset, filter_length,
                           filter_width, slot, wopen, 'filter_1')
    filter_1.assign_perfect_E()