def draw_FEMM(self, nodeprop=None, maxseg=None, propname=None, hide=False, group=None): """Draw the Arc object in FEMM and assign the property Parameters ---------- nodeprop : Nodal property (Default value = None) maxseg : Meshed with elements that span at most maxsegdeg degrees per element (Default value = None) propname : Boundary property ’propname’ (Default value = None) hide : 0 = not hidden in post-processor, 1 == hidden in post processor (Default value = False) group : the group the Arc1 object belongs (Default value = None) Returns ------- None """ # Get BC (if any) if self.label in boundary_prop: propname = boundary_prop[self.label] # Create the nodes begin = self.get_begin() end = self.get_end() X1, Y1 = begin.real, begin.imag X2, Y2 = end.real, end.imag femm.mi_addnode(X1, Y1) femm.mi_selectnode(X1, Y1) femm.mi_setnodeprop(nodeprop, group) femm.mi_clearselected() femm.mi_addnode(X2, Y2) femm.mi_selectnode(X2, Y2) femm.mi_setnodeprop(nodeprop, group) femm.mi_clearselected() # Create the arc angle = self.get_angle(is_deg=True) if angle > 0: femm.mi_addarc(X1, Y1, X2, Y2, angle, 2) else: femm.mi_addarc(X2, Y2, X1, Y1, -angle, 2) # Set Arc properties Zm = self.get_middle() femm.mi_selectarcsegment(Zm.real, Zm.imag) femm.mi_setarcsegmentprop(maxseg, propname, hide, group) femm.mi_clearselected()
def addArc(r1, phi1, r2, phi2, group=-1): if group == -1: group = femmgroupmode n1 = cmath.rect(r1, rad(phi1)) n2 = cmath.rect(r2, rad(phi2)) femm.mi_addarc(n1.real, n1.imag, n2.real, n2.imag, abs(phi1 - phi2), 10) # select middle of arc for adding group # todo: better guess at point on arc (unpredictable if r1 != r2) n = cmath.rect((r1 + r2) / 2., rad((phi1 + phi2) / 2.)) femm.mi_selectarcsegment(n.real, n.imag) femm.mi_setgroup(group) femm.mi_clearselected()
def addArcZZ(n1, n2, group=-1): if group == -1: group = femmgroupmode r1, phi1 = cmath.polar(n1) r2, phi2 = cmath.polar(n2) femm.mi_addarc(n1.real, n1.imag, n2.real, n2.imag, deg(abs(phi1 - phi2)), 10) # select middle of arc for adding group # todo: better guess at point on arc (unpredictable if r1 != r2) n = cmath.rect((r1 + r2) / 2., (phi1 + phi2) / 2.) femm.mi_selectarcsegment(n.real, n.imag) femm.mi_setgroup(group) femm.mi_clearselected()
def drawroundedcorner_box(femm, group, width, length, x_center, y_center, corner_radius, one_sided): x1 = x_center - width / 2 y1 = y_center - length / 2 x2 = x1 + width y2 = y1 + length # mc = .02 * inches mc = corner_radius # first create nodes at the 4 corners # because they will be joined by an arc segment c1_x = x1 c1_y = y1 c2_x = x2 c2_y = y1 c3_x = x2 c3_y = y2 c4_x = x1 c4_y = y2 # now make blunted edge magnet based on it n1x = c1_x n1y = c1_y + mc n2x = c1_x + mc n2y = c1_y n3x = c2_x - mc n3y = c2_y n4x = c2_x n4y = c2_y + mc n5x = c3_x n5y = c3_y - mc n6x = c3_x - mc n6y = c3_y n7x = c4_x + mc n7y = c4_y n8x = c4_x n8y = c4_y - mc # If drawing all 4 corners if (one_sided == 0): femm.mi_addnode(n1x, n1y) femm.mi_addnode(n2x, n2y) femm.mi_addnode(n3x, n3y) femm.mi_addnode(n4x, n4y) femm.mi_addnode(n5x, n5y) femm.mi_addnode(n6x, n6y) femm.mi_addnode(n7x, n7y) femm.mi_addnode(n8x, n8y) femm.mi_addarc(n1x, n1y, n2x, n2y, 90, 3) femm.mi_addsegment(n2x, n2y, n3x, n3y) femm.mi_addarc(n3x, n3y, n4x, n4y, 90, 3) femm.mi_addsegment(n4x, n4y, n5x, n5y) femm.mi_addarc(n5x, n5y, n6x, n6y, 90, 3) femm.mi_addsegment(n6x, n6y, n7x, n7y) femm.mi_addarc(n7x, n7y, n8x, n8y, 90, 3) femm.mi_addsegment(n8x, n8y, n1x, n1y) femm.mi_clearselected() # femm.mi_drawrectangle(x1, mag_y1, mag_x2, mag_y2) # femm.mi_selectrectangle(x1, mag_y1, mag_x2, mag_y2,0) femm.mi_selectsegment(c1_x, c1_y) femm.mi_setgroup(group) femm.mi_selectsegment(c1_x + width / 4, c1_y) femm.mi_setgroup(group) femm.mi_selectsegment(c2_x, c2_y) femm.mi_setgroup(group) femm.mi_selectsegment(c3_x, c3_y + length / 2) femm.mi_setgroup(group) femm.mi_selectsegment(c3_x, c3_y) femm.mi_setgroup(group) femm.mi_selectsegment(c3_x - width / 4, c3_y) femm.mi_setgroup(group) femm.mi_selectsegment(c4_x, c4_y) femm.mi_setgroup(group) femm.mi_selectsegment(c4_x, c4_y - length / 2) femm.mi_setgroup(group) #femm.mi_clearselected() # if drawing only rounded corners on far side # because location is on axis. if (one_sided == 1): femm.mi_addnode(c1_x, c1_y) femm.mi_addnode(n3x, n3y) femm.mi_addnode(n4x, n4y) femm.mi_addnode(n5x, n5y) femm.mi_addnode(n6x, n6y) femm.mi_addnode(c4_x, c4_y) femm.mi_addsegment(c4_x, c4_y, c1_x, c1_y) femm.mi_addsegment(c1_x, c1_y, n3x, n3y) femm.mi_addarc(n3x, n3y, n4x, n4y, 90, 3) femm.mi_addsegment(n4x, n4y, n5x, n5y) femm.mi_addarc(n5x, n5y, n6x, n6y, 90, 3) femm.mi_addsegment(n6x, n6y, c4_x, c4_y) femm.mi_clearselected() femm.mi_selectsegment(c1_x, c1_y + length / 2) femm.mi_setgroup(group) femm.mi_selectsegment(c1_x + width / 2, c1_y) femm.mi_setgroup(group) femm.mi_selectsegment(c2_x, c2_y) femm.mi_setgroup(group) femm.mi_selectsegment(c2_x, c2_y + length / 2) femm.mi_setgroup(group) femm.mi_selectsegment(c3_x, c3_y) femm.mi_setgroup(group) femm.mi_selectsegment(c3_x - width / 2, c3_y) femm.mi_setgroup(group)
femm.mi_selectlabel(wall_radius / 2, (wall_distance + wall_thickness / 2)) femm.mi_setblockprop('magnet', automesh, meshsize, 0, 270, 0, 0) femm.mi_clearselected() #draw and label spiral cross section while (r < outer_radius): if (r == inner_radius): pass else: r = r + wire_spacing inner_edge = r outer_edge = r + wire_thickness femm.mi_drawarc(inner_edge, 0, outer_edge, 0, 180, EXPERIMENT) #mi_drawarc(x1,y1,x2,y2,angle,maxseg) femm.mi_addarc(outer_edge, 0, inner_edge, 0, 180, EXPERIMENT) #other half of circle femm.mi_addblocklabel(((inner_edge + outer_edge) / 2), 0) femm.mi_selectlabel(((inner_edge + outer_edge) / 2), 0) femm.mi_setblockprop('36awgcopper', automesh, meshsize, 'spiral', 0, 0, 1) femm.mi_clearselected() r = outer_edge #define the air femm.mi_addblocklabel((wall_radius / 2), (wall_distance / 2)) femm.mi_selectlabel((wall_radius / 2), (wall_distance / 2)) femm.mi_setblockprop('air', automesh, meshsize, 0) femm.mi_clearselected() femm.mi_makeABC(1, ((wall_distance + outer_radius + wall_radius) * 2), 0, 0, 0)
def draw(self): R1 = self.OR - (self.dm + self.dri) #inner radius of rotor R2 = self.OR - self.dm #radius to inside of PM R3 = self.OR - self.dmp #radius to outside of steel rotor self.hollow = R1 > self.threshold num_magnets = 2 * self.p theta = 360 / num_magnets #span between magnet centers in deg c = np.cos(self.alpha_m / 2) s = np.sin(self.alpha_m / 2) #bottom 3 points p1 = [R2 * c, -R2 * s] p2 = [R3 * c, -R3 * s] p3 = [self.OR * c, -self.OR * s] #top 3 points p4 = [self.OR * c, self.OR * s] p5 = [R3 * c, R3 * s] p6 = [R2 * c, R2 * s] nominal_coords = [p1, p2, p3, p4, p5, p6] #draw each of the magnets for i in range(num_magnets): angle = i * theta rotated_coords = [ rotate(*coord, angle) for coord in nominal_coords ] for coord in rotated_coords: fe.mi_addnode(*coord) c1, c2, c3, c4, c5, c6 = rotated_coords #add segments in clockwise fashion fe.mi_addsegment(*c1, *c2) fe.mi_addsegment(*c2, *c3) fe.mi_addarc(*c3, *c4, self.alpha_m_deg, 1) fe.mi_addsegment(*c4, *c5) fe.mi_addsegment(*c5, *c6) fe.mi_addarc(*c1, *c6, self.alpha_m_deg, 1) #connect between magnets alpha_between = 360 / num_magnets - self.alpha_m_deg for i in range(num_magnets): start = rotate(*p5, theta * i) stop = rotate(*p2, theta * (i + 1)) fe.mi_addarc(*start, *stop, alpha_between, 1) if self.hollow: fe.mi_addnode(0, R1) fe.mi_addnode(0, -R1) fe.mi_addarc(0, R1, 0, -R1, 180, 1) fe.mi_addarc(0, -R1, 0, R1, 180, 1) self.is_drawn = True
def draw_FEMM(self, nodeprop=None, maxseg=None, propname=None, hide=False, group=None): """Draw the Arc object in FEMM and assign the property Parameters ---------- nodeprop : Nodal property (Default value = None) maxseg : Meshed with elements that span at most maxsegdeg degrees per element (Default value = None) propname : Boundary property ’propname’ (Default value = None) hide : 0 = not hidden in post-processor, 1 == hidden in post processor (Default value = False) group : the group the Arc1 object belongs (Default value = None) Returns ------- None """ # Get BC (if any) for bound_label in boundary_prop: if bound_label in self.label: propname = boundary_prop[bound_label] # split if arc angle > 180 angle = self.get_angle(is_deg=True) # Create the nodes begin = self.get_begin() mid = self.get_middle() end = self.get_end() X1, Y1 = begin.real, begin.imag X2, Y2 = mid.real, mid.imag X3, Y3 = end.real, end.imag femm.mi_addnode(X1, Y1) femm.mi_selectnode(X1, Y1) femm.mi_setnodeprop(nodeprop, group) femm.mi_clearselected() femm.mi_addnode(X3, Y3) femm.mi_selectnode(X3, Y3) femm.mi_setnodeprop(nodeprop, group) femm.mi_clearselected() if abs(angle) > 180: femm.mi_addnode(X2, Y2) femm.mi_selectnode(X2, Y2) femm.mi_setnodeprop(nodeprop, group) femm.mi_clearselected() # invert the nodes if angle < 0: angle = -angle X1, Y1, X3, Y3 = X3, Y3, X1, Y1 if angle > 180: femm.mi_addarc(X1, Y1, X2, Y2, angle / 2, 2) femm.mi_addarc(X2, Y2, X3, Y3, angle / 2, 2) else: femm.mi_addarc(X1, Y1, X3, Y3, angle, 2) # Set Arc properties if angle > 180: cent = self.get_center() mid1 = cent + (mid - cent) * exp(1j * angle / 4) mid2 = cent + (mid - cent) * exp(-1j * angle / 4) femm.mi_selectarcsegment(mid1.real, mid1.imag) femm.mi_selectarcsegment(mid2.real, mid1.imag) else: femm.mi_selectarcsegment(X2, Y2) femm.mi_setarcsegmentprop(maxseg, propname, hide, group) femm.mi_clearselected()