예제 #1
0
def draw_guard_ring(distance, gap, radius, polarity, label_name, label_dict):
    '''Draw circular shape of guard ring in the problem and add a label.

    Args:
        distance (float): distance in r-plane from edge of PCB to edge of
        guard ring
        gap (float): distance in z-plane from edge of PCB to edge of guard ring
        radius (float): radius of the guard ring conductor
        polarity (int): attach the gaurd ring to high side or low side.
        Polarity higher than zero sets the guard ring to the upper side of the
        dielectric. Else the guard ring is set to lower side.
        label_name (str): name of this conductor that is stored in the label
        dictionary
        label_dict (dict): stores label coordinates
    '''

    max_angle = 1  # arc_section angle, affects finess of mesh.
    # high or low side?
    if polarity > 0:
        origin = label_dict['PCB_prim']
        origin = np.array((origin[2], origin[1]))
        point1 = origin + np.array((radius + distance, gap))
        point2 = point1 + np.array((0, 2 * radius))
        in_conductor = 'high'
    else:
        origin = label_dict['PCB_sec']
        origin = np.array((origin[2], origin[1]))
        point1 = origin + np.array((radius + distance, -gap))
        point2 = point1 + np.array((0, -2 * radius))
        in_conductor = 'zero'
    label_dict[label_name + 'surface'] = point1

    # ei_drawarc(x1,y1,x2,y2,angle,maxseg)
    # From manual: Adds nodes at (x1,y1) and (x2,y2) and adds an arc of the
    # specified angle and discretization connecting the nodes.
    femm.ei_drawarc(point1[0], point1[1], point2[0], point2[1], 180, max_angle)
    femm.ei_addarc(point2[0], point2[1], point1[0], point1[1], 180, max_angle)

    # Add label and block property to guard ring
    label_coord = np.average((point1, point2), axis=0)
    femm.ei_addblocklabel(*label_coord)
    femm.ei_selectlabel(*label_coord)
    femm.ei_setblockprop('<No Mesh>', 1, 0, 'guards')
    femm.ei_clearselected()
    label_dict[label_name] = label_coord

    # Set boundry based on coordinates
    # ei_setarcsegmentprop(maxsegdeg, ’propname’, hide, group, ’inconductor’)
    # From manual: Set the selected arc segments to:
    # Meshed with elements that span at most maxsegdeg degrees per element
    # Boundary property ’propname’
    # hide: 0 = not hidden in post-processor, 1 == hidden in post processor
    # A member of group number group
    # A member of the conductor specified by the string ’inconductor’. If the
    # segment is not part of a conductor, this parameter can be specified
    # as ’<None>’.
    femm.ei_selectarcsegment(label_coord[0] - radius, label_coord[1])
    femm.ei_selectarcsegment(label_coord[0] + radius, label_coord[1])
    femm.ei_setarcsegmentprop(max_angle, 'None', 0, 'None', in_conductor)
    femm.ei_clearselected()
예제 #2
0
def set_conductor_label(coords, label_name, label_dict):
    '''Set a block label inside a square conductor and set label properties.'''
    label_coord = (np.average(
        (coords[0], coords[2])), np.average((coords[1], coords[3])))
    femm.ei_addblocklabel(*label_coord)
    femm.ei_selectlabel(*label_coord)
    # No mesh is needed inside conductors
    femm.ei_setblockprop('<No Mesh>', 1, 0, 0)
    femm.ei_clearselected()
    label_dict[label_name] = label_coord
예제 #3
0
femm.ei_clearselected()

# Define the ground plane in both the geometry and the exterior region
femm.ei_addboundprop('ground', 0, 0, 0, 0, 0)
femm.ei_selectsegment(0, -20)
femm.ei_selectsegment(110, -20)
femm.ei_selectsegment(-110, -20)
femm.ei_selectsegment(110, 100)
femm.ei_setsegmentprop('ground', 0, 1, 0, 0, '<none>')
femm.ei_clearselected()

# Add block labels for each strip and mark them with "No Mesh"
for k in range(0, 4):
    femm.ei_addblocklabel(-36 + k * 24, 1)
for k in range(0, 4):
    femm.ei_selectlabel(-36 + k * 24, 1)
femm.ei_setblockprop('<No Mesh>', 0, 1, 0)
femm.ei_clearselected()

# Add and assign the block labels for the air and dielectric regions
femm.ei_addmaterial('air', 1, 1, 0)
femm.ei_addmaterial('dielectric', 4, 4, 0)
femm.ei_addblocklabel(0, -10)
femm.ei_addblocklabel(0, 50)
femm.ei_addblocklabel(110, 95)
femm.ei_selectlabel(0, -10)
femm.ei_setblockprop('dielectric', 0, 1, 0)
femm.ei_clearselected()
femm.ei_selectlabel(0, 50)
femm.ei_selectlabel(110, 95)
femm.ei_setblockprop('air', 0, 1, 0)
def analyseCapacitor(flexPercent):

    # Create a new electrostatics problem
    femm.newdocument(1)

    # Draw the geometry
    femm.ei_probdef('centimeters', 'axi', 10**(-8), 30)
    femm.ei_drawrectangle(0, -SPACE, RADIUS,
                          -DISTANCE)  # bottom plate and dielectric
    # femm.ei_drawline(0,0,RADIUS,0) # top plate
    for i in range(0, NODECOUNT):
        femm.ei_drawline(i * dr, getPlateZ(flexPercent, i * dr), (i + 1) * dr,
                         getPlateZ(flexPercent, (i + 1) * dr))

    femm.ei_drawarc(0, -RADIUS * 5, 0, RADIUS * 5, 180, 2.5)  # arc boundary
    femm.ei_drawline(0, -RADIUS * 5, 0, RADIUS * 5)  # line boundary

    # Create and assign a "fixed voltage" boundary condition to curve
    femm.ei_addboundprop('Fixed Voltage', 0.5, 0, 0, 0, 0)
    femm.ei_selectarcsegment(0, -RADIUS * 5)
    femm.ei_setarcsegmentprop(2.5, 'Fixed Voltage', 0, 0, '<none>')
    femm.ei_clearselected()

    # Add and assign the block labels for the air and dielectric regions
    femm.ei_addmaterial('air', 1, 1, 0)
    femm.ei_addmaterial('dielectric', 3, 3, 0)

    femm.ei_addblocklabel(10, 10)
    femm.ei_selectlabel(10, 10)
    femm.ei_setblockprop('air', 0, 1, 0)
    femm.ei_clearselected()

    femm.ei_addblocklabel(RADIUS / 2, -DISTANCE + DI_WIDTH / 2)
    femm.ei_selectlabel(RADIUS / 2, -DISTANCE + DI_WIDTH / 2)
    femm.ei_setblockprop('dielectric', 0, 1, 0)
    femm.ei_clearselected()

    # Add a "Conductor Property" for each of the plates
    femm.ei_addconductorprop('anode', 1, 0, 1)
    femm.ei_addconductorprop('cathode', 0, 0, 1)

    # Assign the anode properties to all sides of the first strip
    # femm.ei_selectsegment(RADIUS/2,0)
    for i in range(0, NODECOUNT):
        femm.ei_selectsegment((i + 0.5) * dr,
                              getPlateZ(flexPercent, (i + 0.5) * dr))

    femm.ei_setsegmentprop('<None>', 0.25, 0, 0, 0, 'anode')
    femm.ei_clearselected()

    # Assign the cathode properties to all sides of the fourth strip
    femm.ei_selectsegment(RADIUS / 2, -DISTANCE)
    femm.ei_setsegmentprop('<None>', 0.25, 0, 0, 0, 'cathode')
    femm.ei_clearselected()

    femm.ei_zoomnatural()

    # Save the geometry to disk so we can analyze it
    femm.ei_saveas('capacitors/capacitorflex' + str(flexPercent) + '.fee')

    femm.ei_analyze()
    femm.ei_loadsolution()

    femm.eo_selectblock(10, 10)
    energy = femm.eo_blockintegral(0)[0]

    return energy
예제 #5
0
def draw_guard_trench(tg, trench, label_name, label_dict):
    '''Draw a trench on the outside of turn closest to the dielectric.

    Args:
        tg (:obj:'TransformerGeometry'): contains all geometry information
        trench (:obj:'GuardTrench'): trench guard geometry
        label_name (str): label that identifies the guard in the dict
        label_dict (dict): stores label coordinates
    '''

    conductor_height = tg.height_copper
    conductor_width = tg.width_copper
    max_angle = 2
    elementsize = 0.05
    if trench.inner:
        sign = -1
        turns = 1
    else:
        sign = 1
        turns = tg.turns_primary

    # find starting point
    if trench.polarity:
        node0 = (np.array(label_dict['prim' + str(turns - 1)]) + np.array(
            (conductor_width[0] * sign, conductor_height)) / 2.0 + np.array(
                (trench.distance * sign, 0)))
        in_conductor = 'high'
        pm = 1  # polarity multiplier
    else:
        node0 = (np.array(label_dict['sec' + str(turns - 1)]) + np.array(
            (conductor_width[1] * sign, -conductor_height)) / 2.0 + np.array(
                (trench.distance * sign, 0)))
        in_conductor = 'zero'
        pm = -1  # polarity multiplier
    # draw four/five points and lines between points 1 to last to 0
    nodes = [(0, 0), (trench.width * sign, 0),
             (trench.width * sign, trench.depth * pm), (0, trench.depth * pm)]
    if trench.drill_angle > 90:
        alpha = (1.0 - trench.drill_angle / 180.) * pi
        depth_added = trench.width / (2.0 * np.tan(alpha))
        nodes.insert(-1, (trench.width / 2.0 * sign,
                          (trench.depth + depth_added) * pm))
    nodes = [node0 + np.array(n) for n in nodes]
    for idx, n in enumerate(nodes):
        femm.ei_addnode(*n)
        label_dict[label_name + 'node' + str(idx)] = n
    ind = range(1, len(nodes)) + [
        0,
    ]
    segment_gen = (np.concatenate((nodes[ind[idx]], nodes[ind[idx + 1]]))
                   for idx in range(len(nodes) - 1))
    for n in segment_gen:
        femm.ei_addsegment(*n)
        femm.ei_selectsegment(*(np.mean((n[:2], n[2:]), axis=0)))
    femm.ei_setsegmentprop('None', elementsize, 0, 0, 'None', in_conductor)
    femm.ei_clearselected()
    # remove existing segment of the PCB
    femm.ei_selectsegment(*(np.mean((nodes[0:2]), axis=0)))
    femm.ei_deleteselectedsegments()
    # draw circular top
    if (pm == 1 and sign == 1) or (pm == -1 and sign == -1):
        femm.ei_addarc(nodes[0][0], nodes[0][1], nodes[1][0], nodes[1][1],
                       trench.outer_angle, max_angle)
    else:
        femm.ei_addarc(nodes[1][0], nodes[1][1], nodes[0][0], nodes[0][1],
                       trench.outer_angle, max_angle)

    # set conductor properties on the boundries
    femm.ei_selectarcsegment(*(np.mean((nodes[0:2]), axis=0)))
    femm.ei_setarcsegmentprop(max_angle, 'None', 0, 'None', in_conductor)

    # add label and set material
    label_dict[label_name] = (nodes[0] + np.array(
        (trench.width / 2. * sign, trench.depth * pm / 2.)))
    femm.ei_addblocklabel(*label_dict[label_name])
    femm.ei_selectlabel(*label_dict[label_name])
    femm.ei_setblockprop(trench.material, 1, 0, 'None')
    femm.ei_clearselected()
예제 #6
0
def add_block_labels(tg, label_dict):
    '''Add block labels to pcbs, air, isolation disc, isolation gel/liquid.'''
    # Add block labels
    # ei seteditmode(editmode)
    # From manual: Sets the current editmode to:
    # – "nodes" - nodes
    # – "segments" - line segments
    # – "arcsegments" - arc segments
    # – "blocks" - block labels
    # – "group" - selected group
    femm.ei_seteditmode('blocks')

    # ei addblocklabel(x,y)
    # From manual: Add a new block label at (x,y)

    # labels for the PCBs
    coords = [2, tg.height_dielectric + tg.height_pcb_core / 2.]
    femm.ei_addblocklabel(*coords)
    label_dict['pcb_prim_label'] = coords

    coords = [2, -tg.height_pcb_core / 2.]
    femm.ei_addblocklabel(*coords)
    label_dict['pcb_sec_label'] = coords

    # label for the surrounding air
    coords = [2, tg.height_dielectric * 2 + tg.height_gel]
    femm.ei_addblocklabel(*coords)
    label_dict['air'] = coords

    # label for the dilectric gel or liquid surrounding the transformer
    coords = [tg.radius_pcb + 2, tg.height_dielectric + tg.height_gel / 2.]
    femm.ei_addblocklabel(*coords)
    label_dict['gel'] = coords

    # label for the isolation disc
    coords = [2, tg.height_dielectric / 2.]
    femm.ei_addblocklabel(*coords)
    label_dict['isolant'] = coords

    # Set material type for all blocks
    # ei setblockprop("blockname", automesh, meshsize, group) Set the selected
    # block labels to have the properties: Block property "blockname".
    # automesh: 0 = mesher defers to mesh size constraint defined in meshsize,
    # 1 = mesher automatically chooses the mesh density. meshsize: size
    # constraint on the mesh in the block marked by this label. A member of
    # group number group

    femm.ei_selectlabel(*label_dict['pcb_prim_label'])
    femm.ei_selectlabel(*label_dict['pcb_sec_label'])
    femm.ei_setblockprop('fr4', 1, 0, 'None')
    femm.ei_clearselected()

    femm.ei_selectlabel(*label_dict['air'])
    femm.ei_setblockprop('air', 1, 0, 'None')
    femm.ei_clearselected()

    femm.ei_selectlabel(*label_dict['gel'])
    femm.ei_setblockprop('midel', 1, 0, 'None')
    femm.ei_clearselected()

    femm.ei_selectlabel(*label_dict['isolant'])
    femm.ei_setblockprop(tg.material_dielectric.lower(), 1, 0, 'None')
    femm.ei_clearselected()