コード例 #1
0
def build_geometry(self):
    """Compute the curve needed to plot the object.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW24
        A SlotW24 object

    Returns
    -------
    curve_list: list
        A list of 2 Segment and 1 Arc

    """
    (alpha_0, alpha_2) = self.comp_alphas()
    [Z1, Z2, Z3, Z4] = self._comp_point_coordinate()
    Zc = 0
    # Creation of curve
    curve_list = list()
    curve_list.append(Segment(Z1, Z2))
    curve_list.append(Arc2(Z2, Zc, alpha_2))
    curve_list.append(Segment(Z3, Z4))

    return curve_list
コード例 #2
0
def comp_magnetization_dict(self, is_north=True):
    """Compute the dictionary of the magnetization direction of the magnets (key=magnet_X, value=angle[rad])
    Mangetization angle with Hole centered on Ox axis

    Parameters
    ----------
    self : HoleM52
        a HoleM52 object
    is_north: True
        True: comp north magnetization, else add pi [rad]

    Returns
    -------
    mag_dict: dict
        magnetization dictionary (key=magnet_X, value=angle[rad])
    """

    # Comp magnet
    point_dict = self._comp_point_coordinate()

    mag_dict = dict()
    S0 = Segment(point_dict["Z4"], point_dict["Z6"])
    mag_dict["magnet_0"] = S0.comp_normal()

    if not is_north:
        mag_dict["magnet_0"] += pi

    if self.magnetization_dict_offset is not None:
        for key, value in self.magnetization_dict_offset:
            mag_dict[key] += value

    return mag_dict
コード例 #3
0
def gen_curve_list(point_list, RX, TY, st):
    """

    Parameters
    ----------
    point_list :

    RX :

    TY :

    st :


    Returns
    -------

    """
    curve_list = list()
    for ii in range(len(point_list) - 1):
        curve_list.append(Segment(point_list[ii], point_list[ii + 1]))
    curve_list.append(Segment(point_list[-1], point_list[0]))

    res = 0
    for Z in point_list:
        res += Z
    point_ref = res / len(point_list)
    surface = SurfLine(
        line_list=curve_list,
        label="Wind" + st + "_R" + RX + "_T" + TY + "_S0",
        point_ref=point_ref,
    )
    return surface
コード例 #4
0
def get_lines(self):
    """return the list of lines that delimits the PolarArc

    Parameters
    ----------
    self : PolarArc
        a PolarArc object

    Returns
    -------
    line_list: list
        List of line need to draw the slot (2 Segment + 2 Arc1)
    """
    # check if the PolarArc is correct
    self.check()

    Z_ref = self.point_ref
    center = Z_ref * exp(-1j * angle(Z_ref))
    H = self.height
    A = self.angle
    # the points of the PolarArc
    Z2 = (center - (H / 2)) * exp(1j * (-(A / 2))) * exp(1j * angle(Z_ref))
    Z3 = (center + (H / 2)) * exp(1j * (-(A / 2))) * exp(1j * angle(Z_ref))
    Z4 = (center + (H / 2)) * exp(1j * (A / 2)) * exp(1j * angle(Z_ref))
    Z1 = (center - (H / 2)) * exp(1j * (A / 2)) * exp(1j * angle(Z_ref))

    # Lines that delimit the PolarArc
    line1 = Arc1(Z1, Z2, -abs(Z1))
    line2 = Segment(Z2, Z3)
    line3 = Arc1(Z3, Z4, abs(Z3))
    line4 = Segment(Z4, Z1)

    return [line1, line2, line3, line4]
コード例 #5
0
def build_geometry(self):
    """Compute the curve (Line) needed to plot the Slot.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW16
        A SlotW16 object

    Returns
    -------
    curve_list: llist
        A list of 4 Segment and 5 Arc

    """

    Rbo = self.get_Rbo()

    [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8, Z9, Z10] = self._comp_point_coordinate()

    # Creation of curve
    curve_list = list()
    curve_list.append(Segment(Z1, Z2))
    curve_list.append(Arc1(Z2, Z3, -Rbo + self.H0, is_trigo_direction=False))
    curve_list.append(Arc1(Z3, Z4, -self.R1, is_trigo_direction=False))
    curve_list.append(Segment(Z4, Z5))
    curve_list.append(
        Arc1(Z5, Z6, Rbo - self.H0 - self.H2, is_trigo_direction=True))
    curve_list.append(Segment(Z6, Z7))
    curve_list.append(Arc1(Z7, Z8, -self.R1, is_trigo_direction=False))
    curve_list.append(Arc1(Z8, Z9, -Rbo + self.H0, is_trigo_direction=False))
    curve_list.append(Segment(Z9, Z10))

    return curve_list
コード例 #6
0
def build_geometry(self):
    """Compute the curve (Line) needed to plot the object.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : Slot19
        A Slot19 object

    Returns
    -------
    curve_list: list
        A list of 2 Segment and 1 Arc

    """

    [Z1, Z2, Z3, Z4] = self._comp_point_coordinate()

    # Creation of curve
    curve_list = list()
    curve_list.append(Segment(Z1, Z2))
    if self.W1 > 0:
        curve_list.append(Arc1(Z2, Z3, abs(Z3)))
    curve_list.append(Segment(Z3, Z4))

    return curve_list
コード例 #7
0
def build_geometry(self):
    """Compute the curve needed to plot the object.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW25
        A SlotW25 object

    Returns
    -------
    curve_list: list
        A list of 4 Segment and 3 Arc

    """
    [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8] = self._comp_point_coordinate()
    # Creation of curve
    curve_list = list()
    curve_list.append(Segment(Z8, Z7))
    curve_list.append(Arc1(Z7, Z6, -abs(Z2), is_trigo_direction=False))
    curve_list.append(Segment(Z6, Z5))
    curve_list.append(Arc1(Z5, Z4, abs(Z5)))
    curve_list.append(Segment(Z4, Z3))
    curve_list.append(Arc1(Z3, Z2, -abs(Z2), is_trigo_direction=False))
    curve_list.append(Segment(Z2, Z1))
    return curve_list
コード例 #8
0
ファイル: build_geometry.py プロジェクト: focus2010/pyleecan
def build_geometry(self):
    """Compute the curve (Line) needed to plot the object.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW28
        A SlotW28 object

    Returns
    -------
    curve_list: list
        A list of 4 Segment and 3 Arc1

    """

    [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8, rot_sign] = self._comp_point_coordinate()

    # Creation of curve
    curve_list = list()
    curve_list.append(Segment(Z1, Z2))
    curve_list.append(Arc1(Z2, Z3, rot_sign * self.R1, self.is_outwards()))
    curve_list.append(Segment(Z3, Z4))
    curve_list.append(Arc3(Z4, Z5, self.is_outwards()))
    curve_list.append(Segment(Z5, Z6))
    curve_list.append(Arc1(Z6, Z7, rot_sign * self.R1, self.is_outwards()))
    curve_list.append(Segment(Z7, Z8))

    return curve_list
コード例 #9
0
def get_lines(self):
    """Returns the Lines that delimit the Trapeze

    Parameters
    ----------
    self : Trapeze
        a Trapeze object


    Returns
    -------
    line_list : list
        list of 4 segments

    """
    # Check if the Trapeze is correct
    self.check()
    Z_ref = self.point_ref
    H = self.height
    W1 = self.W1
    W2 = self.W2

    # The 4 points of the Trapeze object
    Z1 = (complex(-H / 2, W1 / 2) * exp(1j * (angle(Z_ref)))) + Z_ref
    Z2 = (complex(-H / 2, -W1 / 2) * exp(1j * (angle(Z_ref)))) + Z_ref
    Z3 = (complex(H / 2, -W2 / 2) * exp(1j * (angle(Z_ref)))) + Z_ref
    Z4 = (complex(H / 2, W2 / 2) * exp(1j * (angle(Z_ref)))) + Z_ref

    # The lines that delimit the Trapeze
    line1 = Segment(Z1, Z2)
    line2 = Segment(Z2, Z3)
    line3 = Segment(Z3, Z4)
    line4 = Segment(Z4, Z1)

    return [line1, line2, line3, line4]
コード例 #10
0
    def test_split_half(self, test_dict):
        """Check that the segment split is correct
        """
        seg = Segment(begin=test_dict["begin"], end=test_dict["end"])
        seg.split_half(is_begin=test_dict["is_begin"])

        self.assertAlmostEqual(seg.begin, test_dict["N_begin"])
        self.assertAlmostEqual(seg.end, test_dict["N_end"])
コード例 #11
0
def build_geometry(self):
    """Compute the curve (Line) needed to plot the object.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW12
        A SlotW12	object

    Returns
    -------
    curve_list: list
        A list of 4 Segment and 3 Arc3

    """

    Rbo = self.get_Rbo()

    # alpha is the angle to rotate Z0 so ||Z1,Z8|| = 2*R2
    alpha = float(arcsin(self.R2 / Rbo))

    # comp point coordinate (in complex)
    Z0 = Rbo * exp(1j * 0)
    Z1 = Z0 * exp(-1j * alpha)

    if self.is_outwards():
        Z2 = Z1 + self.H0
        Z3 = Z2 + self.R1 * 2
        Z4 = Z3 + self.H1
        rot_sign = True
    else:  # inward slot
        Z2 = Z1 - self.H0
        Z3 = Z2 - self.R1 * 2
        Z4 = Z3 - self.H1
        rot_sign = False

    # symetry
    Z5 = Z4.conjugate()
    Z6 = Z3.conjugate()
    Z7 = Z2.conjugate()
    Z8 = Z1.conjugate()

    # Creation of curve
    curve_list = list()
    curve_list.append(Segment(Z1, Z2))
    if self.R1 > 0:  # R1=0 => Z2==Z3
        curve_list.append(Arc3(Z2, Z3, rot_sign))
    if self.H1 > 0:  # H1=0 => Z3==Z4
        curve_list.append(Segment(Z3, Z4))
    curve_list.append(Arc3(Z4, Z5, rot_sign))
    if self.H1 > 0:  # H1=0 => Z5==Z6
        curve_list.append(Segment(Z5, Z6))
    if self.R1 > 0:  # R1=0 => Z6==Z7
        curve_list.append(Arc3(Z6, Z7, rot_sign))
    curve_list.append(Segment(Z7, Z8))

    return curve_list
コード例 #12
0
    def test_dicretize(self, test_dict):
        """Check that you can discretize a segment
        """
        segment = Segment(test_dict["begin"], test_dict["end"])

        result = segment.discretize(test_dict["nb_point"])

        self.assertEqual(result.size, test_dict["result"].size)
        for i in range(0, result.size):
            self.assertAlmostEqual(result[i],
                                   test_dict["result"][i],
                                   delta=DELTA)
コード例 #13
0
def build_geometry(self):
    """Compute the curve (Line) needed to plot the Slot.
    The ending point of a curve is always the starting point of the next
    curve in the list

    Parameters
    ----------
    self : SlotMPolar
        A SlotMPolar object

    Returns
    -------
    curve_list: list
        A list of 2 Segment and 1 Arc1

    """

    Rbo = self.get_Rbo()
    alpha = self.comp_angle_opening()
    alpha_mag = self.comp_angle_opening_magnet()

    # Point coordinate for a slot center on Ox
    Z1 = Rbo * exp(-1j * alpha_mag / 2)
    Z2 = Rbo * exp(1j * alpha_mag / 2)
    if self.is_outwards():
        Rbot = Rbo + self.H0
    else:
        Rbot = Rbo - self.H0
    Z3 = Rbot * exp(-1j * alpha_mag / 2)
    Z4 = Rbot * exp(1j * alpha_mag / 2)

    # Curve list of a single slot
    curve_list = list()
    if self.H0 > 0:
        curve_list.append(Segment(Z1, Z3))
    curve_list.append(Arc1(Z3, Z4, Rbot))
    if self.H0 > 0:
        curve_list.append(Segment(Z4, Z2))

    # Complete curve list for all the slots (for one pole)
    slot_list = list()
    for ii in range(len(self.magnet)):
        # Compute angle of the middle of the slot
        beta = -alpha / 2 + alpha_mag / 2 + ii * (self.W3 + alpha_mag)
        # Duplicate and rotate the slot + bore for each slot
        for line in curve_list:
            new_line = type(line)(init_dict=line.as_dict())
            new_line.rotate(beta)
            slot_list.append(new_line)
        if ii != len(self.magnet) - 1:  # Add the W3 except for the last slot
            slot_list.append(Arc2(slot_list[-1].get_end(), 0, self.W3))

    return slot_list
コード例 #14
0
def build_geometry(self):
    """Compute the curve (Segment) needed to plot the object.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW22
        A SlotW22 object

    Returns
    -------
    curve_list: llist
        A list of 5 Segment and 3 Arc2

    """
    Rbo = self.get_Rbo()

    # comp point coordinate (in complex)
    Z1 = Rbo * exp(-1j * self.W0 / 2)
    if self.is_outwards():
        R1 = Rbo + self.H0
        R2 = Rbo + self.H0 + self.H2
    else:  # inward slot
        R1 = Rbo - self.H0
        R2 = Rbo - self.H0 - self.H2
    Z2 = R1 * exp(-1j * self.W0 / 2.0)
    Z3 = R1 * exp(-1j * self.W2 / 2.0)
    Z4 = R2 * exp(-1j * self.W2 / 2.0)

    # symetry
    Z5 = Z4.conjugate()
    Z6 = Z3.conjugate()
    Z7 = Z2.conjugate()
    Z8 = Z1.conjugate()
    Zc = 0

    # Creation of curve
    curve_list = list()
    if self.H0 > 0:
        curve_list.append(Segment(Z1, Z2))
    if self.W2 != self.W0:
        curve_list.append(Arc2(Z2, Zc, -(self.W2 - self.W0) / 2))
    curve_list.append(Segment(Z3, Z4))
    curve_list.append(Arc2(Z4, Zc, self.W2))
    curve_list.append(Segment(Z5, Z6))
    if self.W2 != self.W0:
        curve_list.append(Arc2(Z6, Zc, -(self.W2 - self.W0) / 2))
    if self.H0 > 0:
        curve_list.append(Segment(Z7, Z8))

    return curve_list
コード例 #15
0
def build_geometry(self):
    """Compute the curve (Segment) needed to plot the Slot.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW14
        A SlotW14 object

    Returns
    -------
    curve_list: list
        A list of 8 Segment

    """

    [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8, Z9] = self._comp_point_coordinate()
    # Creation of curve
    curve_list = list()
    if self.H0 > 0:
        curve_list.append(Segment(Z1, Z2))
    curve_list.append(Segment(Z2, Z3))
    curve_list.append(Segment(Z3, Z4))
    curve_list.append(Segment(Z4, Z5))
    curve_list.append(Segment(Z5, Z6))
    curve_list.append(Segment(Z6, Z7))
    curve_list.append(Segment(Z7, Z8))
    if self.H0 > 0:
        curve_list.append(Segment(Z8, Z9))

    return curve_list
コード例 #16
0
def build_geometry(self):
    """Compute the curve (Line) needed to plot the Slot.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW60
        A SlotW60 object

    Returns
    -------
    curve_list: list
        A list of 8 Segment and 2 Arc1

    """

    [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8, Z9, Z10, Z11] = self._comp_point_coordinate()

    # Creation of curve
    curve_list = list()
    curve_list.append(Arc1(Z1, Z2, self.R1))
    curve_list.append(Segment(Z2, Z3))
    curve_list.append(Segment(Z3, Z4))
    curve_list.append(Segment(Z4, Z5))
    curve_list.append(Segment(Z5, Z6))
    curve_list.append(Segment(Z6, Z7))
    curve_list.append(Segment(Z7, Z8))
    curve_list.append(Segment(Z8, Z9))
    curve_list.append(Segment(Z9, Z10))
    curve_list.append(Arc1(Z10, Z11, self.R1))

    return curve_list
コード例 #17
0
    def test_build_geometry(self):
        """check that curve_list is correct"""
        test_obj = SlotW22(W0=pi / 10, H0=0.1, W2=pi / 5, H2=0.1)
        lam = LamSlot(is_internal=False, slot=test_obj, Rint=1)

        Z1 = cos(pi / 20) + 1j * sin(pi / 20)
        Z2 = 1.1 * (cos(pi / 20) + 1j * sin(pi / 20))
        Z3 = 1.1 * (cos(pi / 10) + 1j * sin(pi / 10))
        Z4 = 1.2 * (cos(pi / 10) + 1j * sin(pi / 10))
        Z5 = 1.2 * (cos(pi / 10) - 1j * sin(pi / 10))
        Z6 = 1.1 * (cos(pi / 10) - 1j * sin(pi / 10))
        Z7 = 1.1 * (cos(pi / 20) - 1j * sin(pi / 20))
        Z8 = cos(pi / 20) - 1j * sin(pi / 20)
        [Z8, Z7, Z6, Z5, Z4, Z3, Z2, Z1] = [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8]

        # Creation of curve
        curve_list = list()
        Zc = 0  # center
        curve_list.append(Segment(Z1, Z2))
        curve_list.append(Arc2(Z2, Zc, -pi / 20))
        curve_list.append(Segment(Z3, Z4))
        curve_list.append(Arc2(Z4, Zc, pi / 5))
        curve_list.append(Segment(Z5, Z6))
        curve_list.append(Arc2(Z6, Zc, -pi / 20))
        curve_list.append(Segment(Z7, Z8))

        result = test_obj.build_geometry()
        self.assertEqual(len(result), len(curve_list))
        for i in range(0, len(result)):
            if isinstance(result[i], Segment):
                a = result[i].begin
                b = curve_list[i].begin
                self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

                a = result[i].end
                b = curve_list[i].end
                self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
            else:  # Arc2
                a = result[i].begin
                b = curve_list[i].begin
                self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

                a = result[i].center
                b = curve_list[i].center
                self.assertAlmostEqual(a, b)

                a = result[i].angle
                b = curve_list[i].angle
                self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
コード例 #18
0
ファイル: build_geometry.py プロジェクト: focus2010/pyleecan
def build_geometry(self):
    """Compute the curve (Line) needed to plot the object.
    The ending point of a curve is the starting point of the next curve
    in the list

    Parameters
    ----------
    self : SlotUD
        A SlotUD object

    Returns
    -------
    curve_list: list
        A list of Segments

    """

    # Apply symmetry if needed
    point_list = self.point_list.copy()
    if self.is_sym:
        for point in self.point_list[::-1]:
            point_list.append(point.conjugate())

    # Creation of curve
    curve_list = list()
    for ii in range(len(point_list) - 1):
        curve_list.append(Segment(point_list[ii], point_list[ii + 1]))

    return curve_list
コード例 #19
0
    def test_intersect(self, test_dict):
        """Check that the intersection is computed correctly
        """
        seg = Segment(test_dict["begin"], test_dict["end"])

        # Check intersection
        result = seg.intersect_line(test_dict["Z1"], test_dict["Z2"])
        self.assertEqual(len(result), len(test_dict["Zi"]))
        msg = ("Wrong intersection: returned " + str(result) + ", expected: " +
               str(test_dict["Zi"]))
        for ii in range(len(result)):
            self.assertAlmostEqual(abs(result[ii] - test_dict["Zi"][ii]),
                                   0,
                                   msg=msg)

        # Check split_line is_top=True
        seg2 = seg.split_line(test_dict["Z1"], test_dict["Z2"], is_top=True)
        if seg2 is not None:
            msg = ("Wrong begin with is_top: returned " + str(seg2.begin) +
                   ", expected: " + str(test_dict["Zb_top"]))
            self.assertAlmostEqual(abs(seg2.begin - test_dict["Zb_top"]),
                                   0,
                                   msg=msg)
            msg = ("Wrong end with is_top: returned " + str(seg2.end) +
                   ", expected: " + str(test_dict["Ze_top"]))
            self.assertAlmostEqual(abs(seg2.end - test_dict["Ze_top"]),
                                   0,
                                   msg=msg)
        else:  # No intersection
            self.assertIsNone(test_dict["Zb_top"])

        # Check split_line is_top=False
        seg3 = seg.split_line(test_dict["Z1"], test_dict["Z2"], is_top=False)
        if seg3 is not None:
            msg = ("Wrong begin with not is_top: returned " + str(seg3.begin) +
                   ", expected: " + str(test_dict["Zb_bot"]))
            self.assertAlmostEqual(abs(seg3.begin - test_dict["Zb_bot"]),
                                   0,
                                   msg=msg)
            msg = ("Wrong end with not is_top: returned " + str(seg3.end) +
                   ", expected: " + str(test_dict["Ze_bot"]))
            self.assertAlmostEqual(abs(seg3.end - test_dict["Ze_bot"]),
                                   0,
                                   msg=msg)
        else:  # No intersection
            self.assertIsNone(test_dict["Zb_bot"])
コード例 #20
0
 def test_comp_length(self):
     """Check that you can compute the length of the polar arc
     """
     surface = PolarArc(label="test", point_ref=1, angle=pi / 4, height=2)
     surface.get_lines = MagicMock(return_value=[Segment(begin=0, end=1)])
     length = surface.comp_length()
     expected = 1
     self.assertAlmostEqual(abs(length - expected), 0)
コード例 #21
0
    def test_build_geometry(self):
        """Check if the curve_list is correct"""
        test_obj = SlotW27(
            Zs=6, H0=0.05, W0=30e-3, H1=0.125, W1=0.06, H2=0.05, W2=0.09, W3=0.04
        )
        lam = LamSlot(is_internal=False, slot=test_obj, Rint=1)

        Z1 = exp(1j * float(arcsin(30e-3 / 2.0)))
        Z2 = Z1 + 0.05
        Z3 = Z2 + ((0.06 - 30e-3) / 2.0) * 1j
        Z4 = Z3 + 0.125 + ((0.09 - 0.06) / 2.0) * 1j
        Z5 = Z4 + 0.05 + ((0.04 - 0.09) / 2.0) * 1j
        Z6 = Z5.conjugate()
        Z7 = Z4.conjugate()
        Z8 = Z3.conjugate()
        Z9 = Z2.conjugate()
        Z10 = Z1.conjugate()

        [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8, Z9, Z10] = [
            Z10,
            Z9,
            Z8,
            Z7,
            Z6,
            Z5,
            Z4,
            Z3,
            Z2,
            Z1,
        ]
        curve_list = list()
        curve_list.append(Segment(Z1, Z2))
        curve_list.append(Segment(Z2, Z3))
        curve_list.append(Segment(Z3, Z4))
        curve_list.append(Segment(Z4, Z5))
        curve_list.append(Segment(Z5, Z6))
        curve_list.append(Segment(Z6, Z7))
        curve_list.append(Segment(Z7, Z8))
        curve_list.append(Segment(Z8, Z9))
        curve_list.append(Segment(Z9, Z10))

        result = test_obj.build_geometry()
        self.assertEqual(len(result), len(curve_list))
        for i in range(0, len(result)):
            a = result[i].begin
            b = curve_list[i].begin
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

            a = result[i].end
            b = curve_list[i].end
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
コード例 #22
0
 def test_comp_length(self):
     """Check that you can compute the length of the trapeze
     """
     surface = Trapeze(point_ref=1j, label="test", height=6, W2=6, W1=3)
     surface.get_lines = MagicMock(return_value=[Segment(begin=0, end=1)])
     length = surface.comp_length()
     expected = 1
     self.assertEqual(length, expected)
コード例 #23
0
def get_surface_tooth(self):
    """Returns the surface delimiting the tooth (including yoke part)

    Parameters
    ----------
    self : Slot
        A Slot object

    Returns
    -------
    surface: SurfLine
        A SurfLine object representing the slot

    """

    if self.parent is not None:
        Ryoke = self.parent.get_Ryoke()
    else:
        raise ParentMissingError("Error: The slot is not inside a Lamination")

    curve_list = list()
    # tooth lines
    top_list = self.build_geometry_half_tooth(is_top=True)
    bot_list = self.build_geometry_half_tooth(is_top=False)
    # Yoke lines
    Z1 = Ryoke * exp(1j * pi / self.Zs)
    Z2 = Ryoke * exp(-1j * pi / self.Zs)
    curve_list.append(
        Segment(top_list[-1].get_end(), Z1, label="Tooth_Yoke_Side"))
    if Ryoke > 0:
        curve_list.append(
            Arc1(
                begin=Z1,
                end=Z2,
                radius=-Ryoke,
                is_trigo_direction=False,
                label="Tooth_Yoke_Arc",
            ))
    curve_list.append(
        Segment(Z2, bot_list[0].get_begin(), label="Tooth_Yoke_Side"))
    # Second half of the tooth
    curve_list.extend(bot_list)
    curve_list.extend(top_list)

    return SurfLine(line_list=curve_list, label="Tooth")
コード例 #24
0
    def test_comp_length(self):
        """Check that you can compute the length of the Surface
        """
        line1 = Arc1(begin=1, end=1j, radius=1)
        line1.comp_length = MagicMock(return_value=1)
        line2 = Arc2(begin=1, center=0, angle=pi / 2)
        line2.comp_length = MagicMock(return_value=1)
        line3 = Segment(begin=1j, end=0)
        line3.comp_length = MagicMock(return_value=1)

        surface = SurfLine(line_list=[line1, line2, line3],
                           label="test",
                           point_ref=0)
        length = surface.comp_length()
        line1.comp_length.assert_called_once()
        line2.comp_length.assert_called_once()
        line3.comp_length.assert_called_once()
        self.assertAlmostEqual(abs(length - 3), 0)
コード例 #25
0
def build_geometry(self, sym=1, alpha=0, delta=0):
    """Build the geometry of the shaft

    Parameters
    ----------
    self : Shaft
        Shaft Object
    sym : int
        Symmetry factor (1= full machine, 2= half of the machine...)
    alpha : float
        Angle for rotation [rad]
    delta : complex
        Complex value for translation

    Returns
    -------
    surf_list : list
        list of surfaces needed to draw the lamination
    
    """
    surf_list = list()

    if sym == 1:
        surf_list.append(
            Circle(radius=self.Drsh / 2, label="Shaft", center=0, point_ref=0))
    else:
        begin = self.Drsh / 2
        end = begin * exp(1j * 2 * pi / sym)
        surface = SurfLine(
            line_list=[
                Segment(0, begin),
                Arc1(begin, end, self.Drsh / 2),
                Segment(end, 0),
            ],
            label="Shaft",
            point_ref=0,
        )
        surf_list.append(surface)
    for surf in surf_list:
        surf.rotate(alpha)
        surf.translate(delta)
    return surf_list
コード例 #26
0
def comp_magnetization_dict(self, is_north=True):
    """Compute the dictionary of the magnetization direction of the magnets (key=magnet_X, value=angle[rad])
    Mangetization angle with Hole centered on Ox axis

    Parameters
    ----------
    self : HoleMLSRPM
        a HoleMLSRPM object
    is_north: True
        True: comp north magnetization, else add pi [rad]

    Returns
    -------
    mag_dict: dict
        magnetization dictionary (key=magnet_X, value=angle[rad])
    """

    # Comp magnet
    point_dict = self._comp_point_coordinate()

    mag_dict = dict()
    Z3 = point_dict["Z3"]
    Z4 = point_dict["Z4"]
    Z7 = point_dict["Z7"]
    Z8 = point_dict["Z8"]

    Zch = (Z3 + Z4) / 2
    Zcl = (Z7 + Z8) / 2
    S0 = Segment(Zch, Zcl)
    mag_dict["magnet_0"] = S0.comp_normal()

    ####Comp_normal direction?

    if not is_north:
        mag_dict["magnet_0"] += pi

    if self.magnetization_dict_offset is not None:
        for key, value in self.magnetization_dict_offset:
            mag_dict[key] += value

    return mag_dict
コード例 #27
0
    def test_build_geometry_out(self):
        """check that curve_list is correct (outwards magnet)
        """

        lam = LamSlotMag(
            Rint=1,
            Rext=0.09,
            is_internal=False,
            is_stator=False,
            L1=0.45,
            Nrvd=1,
            Wrvd=0.05,
        )
        lam.slot = SlotMFlat(Zs=8,
                             W0=0.6,
                             H0=0.2,
                             magnet=[MagnetType10(Wmag=0.6, Hmag=0.2)])
        test_obj = lam.slot.magnet[0]
        alpha = lam.slot.comp_angle_opening_magnet()
        Z1 = 1 * exp(-1j * alpha / 2) + 0.2
        Z2 = 1 * exp(1j * alpha / 2) + 0.2
        Z3 = Z1 - 0.2
        Z4 = Z2 - 0.2

        # Creation of curve
        curve_list = list()
        curve_list.append(Segment(Z1, Z3))
        curve_list.append(Segment(Z3, Z4))
        curve_list.append(Segment(Z4, Z2))
        curve_list.append(Segment(Z2, Z1))

        surface = test_obj.build_geometry()
        result = surface[0].get_lines()
        for i in range(0, len(result)):
            a = result[i].begin
            b = curve_list[i].begin
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

            a = result[i].end
            b = curve_list[i].end
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
コード例 #28
0
def build_geometry(self):
    """Compute the curve (Line) needed to plot the object.
    The ending point of a curve is the starting point of the next curve in
    the list

    Parameters
    ----------
    self : SlotW23
        A SlotW23 object

    Returns
    -------
    curve_list: list
        A list of 6 Segment and 1 Arc

    """

    [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8] = self._comp_point_coordinate()
    Zc = 0
    # Creation of curve
    curve_list = list()
    curve_list.append(Segment(Z1, Z2))
    curve_list.append(Segment(Z2, Z3))
    curve_list.append(Segment(Z3, Z4))
    curve_list.append(Arc1(Z4, Z5, abs(Z5)))
    curve_list.append(Segment(Z5, Z6))
    curve_list.append(Segment(Z6, Z7))
    curve_list.append(Segment(Z7, Z8))

    return curve_list
コード例 #29
0
    def test_build_geometry(self):
        """check that curve_list is correct"""
        test_obj = SlotW10(W0=0.2,
                           H0=0.1,
                           W1=0.4,
                           H1=0.1,
                           H1_is_rad=False,
                           H2=0.1,
                           W2=0.6)
        lam = LamSlot(is_internal=False, slot=test_obj, Rint=1)

        # Rbo=1
        Z10 = exp(1j * float(arcsin(0.1)))
        Z9 = Z10 + 0.1
        Z8 = Z10 + 0.1j + 0.2
        Z7 = Z10 + 0.2
        Z6 = Z10 + 0.2j + 0.3
        Z5 = Z10 - 0.4j + 0.3
        Z4 = Z10 - 0.2j + 0.2
        Z3 = Z10 - 0.3j + 0.2
        Z2 = Z10 - 0.2j + 0.1
        Z1 = Z10 - 0.2j

        # Creation of curve
        curve_list = list()
        curve_list.append(Segment(Z1, Z2))
        curve_list.append(Segment(Z2, Z3))
        curve_list.append(Segment(Z3, Z4))
        curve_list.append(Segment(Z4, Z5))
        curve_list.append(Segment(Z5, Z6))
        curve_list.append(Segment(Z6, Z7))
        curve_list.append(Segment(Z7, Z8))
        curve_list.append(Segment(Z8, Z9))
        curve_list.append(Segment(Z9, Z10))

        result = test_obj.build_geometry()
        self.assertEqual(len(result), len(curve_list))
        for i in range(0, len(result)):
            a = result[i].begin
            b = curve_list[i].begin
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

            a = result[i].end
            b = curve_list[i].end
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
コード例 #30
0
    def test_build_geometry_out(self):
        """check that curve_list is correct (outwards magnet)"""
        lam = LamSlotMag(
            Rint=40e-3,
            Rext=90e-3,
            is_internal=False,
            is_stator=False,
            L1=0.45,
            Nrvd=1,
            Wrvd=0.05,
        )
        magnet = [MagnetType11(Wmag=pi / 10, Hmag=0.2)]
        lam.slot = SlotMPolar(Zs=8, W0=pi / 10, H0=0.2, magnet=magnet)
        test_obj = lam.slot.magnet[0]
        Z1 = (40e-3 + 0.2) * exp(-1j * pi / 10 / 2)
        Z2 = (40e-3 + 0.2) * exp(1j * pi / 10 / 2)

        Z = abs(Z1)

        Z3 = (Z - 0.2) * exp(1j * angle(Z1))
        Z4 = (Z - 0.2) * exp(1j * angle(Z2))

        # # Creation of curve
        curve_list = list()
        curve_list.append(Segment(Z1, Z3))
        curve_list.append(Arc1(Z3, Z4, abs(Z3)))
        curve_list.append(Segment(Z4, Z2))
        curve_list.append(Arc1(Z2, Z1, -abs(Z2)))

        surface = test_obj.build_geometry()
        result = surface[0].get_lines()
        for i in range(0, len(result)):
            a = result[i].begin
            b = curve_list[i].begin
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

            a = result[i].end
            b = curve_list[i].end
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)