def test_Lam_Hole_54_plot(self): """Test machine plot hole 54""" plt.close("all") test_obj = Machine() test_obj.rotor = LamHole(is_internal=True, Rint=0.1, Rext=0.2, is_stator=False, L1=0.7) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM54(Zh=8, W0=pi / 4, H0=50e-3, H1=10e-3, R1=100e-3)) test_obj.rotor.hole.append( HoleM54(Zh=8, W0=pi / 6, H0=25e-3, H1=10e-3, R1=100e-3)) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Hole_s54-Rotor.png")) self.assertEqual(len(fig.axes[0].patches), 18) test_obj.rotor.hole[0].plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Hole_s54-Rotor hole.png")) self.assertEqual(len(fig.axes[0].patches), 1)
def test_Lam_Mag_10_surface(self): """Test machine plot with Magnet 10 surface""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=200e-3, is_internal=True, is_stator=False, L1=0.5, Nrvd=0, Wrvd=0.05, ) magnet = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.08)] test_obj.rotor.slot = SlotMFlat(Zs=8, H0=0, W0=2 * pi / 10, W0_is_rad=True, magnet=magnet) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.stator = Lamination( Rint=230e-3, Rext=0.3, is_internal=False, is_stator=True, L1=0.5, Nrvd=0, Wrvd=0.05, ) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 15) fig.savefig(join(save_path, "test_Lam_Mag_10s_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_10s_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 2) fig.savefig(join(save_path, "test_Lam_Mag_10s_3-Stator.png")) magnet2 = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)] test_obj.rotor.slot = SlotMFlat(Zs=8, W0=0.04, W0_is_rad=False, magnet=magnet2) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Mag_10s_5-Rotor 2.png"))
def test_Lam_Mag_11_surface(self): """Test machine plot with Magnet 11 surface""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=90e-3, is_internal=True, is_stator=False, L1=0.45, Nrvd=1, Wrvd=0.05, ) magnet = [MagnetType11(Lmag=0.5, Hmag=0.01, Wmag=pi / 8)] test_obj.rotor.slot = SlotMPolar(Zs=8, W0=pi / 8, magnet=magnet) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.stator = LamSlotMag( Rint=115e-3, Rext=200e-3, is_internal=False, is_stator=True, L1=0.45, Nrvd=1, Wrvd=0.05, ) magnet2 = [MagnetType11(Lmag=0.5, Hmag=0.01, Wmag=pi / 4)] test_obj.stator.slot = SlotMPolar(Zs=4, W0=pi / 4, magnet=magnet2) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=200e-3, Lfra=0.5) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 17) fig.savefig(join(save_path, "test_Lam_Mag_11s_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_11s_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() patches = fig.axes[0].patches self.assertEqual(len(patches), 6) self.assertTrue(isinstance(patches[0], Circle)) self.assertEqual(patches[0].get_radius(), 200e-3) self.assertEqual(patches[0].get_facecolor(), (0.0, 0.0, 1.0, 1.0)) # Blue for i in range(1, 6): self.assertTrue(isinstance(patches[i], Polygon)) if i == 1: # Lamination inner self.assertEqual(patches[i].get_facecolor(), (1.0, 1.0, 1.0, 1.0)) # White else: # Magnet self.assertEqual(patches[i].get_facecolor(), (0.75, 0.75, 0.75, 1.0)) # Gray fig.savefig(join(save_path, "test_Lam_Mag_11s_3-Stator.png"))
def test_Lam_Wind_28_wind_rad_tan(self): """Test machine plot with Slot 28 and winding rad=1, tan=2 and rad=2 and tan=1 """ print("\nTest plot Slot 28") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=35e-3, Rext=84e-3, is_internal=True, is_stator=False, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.rotor.axial_vent = [ VentilationCirc(Zh=6, Alpha0=pi / 6, D0=15e-3, H0=0.045) ] test_obj.rotor.slot = SlotW28( Zs=42, W0=3.5e-3, H0=0.45e-3, R1=3.5e-3, H3=14e-3, W3=5e-3 ) test_obj.rotor.winding = WindingCW2LT(qs=3, p=3) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=85e-3, Rext=0.2, is_internal=False, is_stator=True, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.stator.slot = SlotW28( Zs=18, W0=7e-3, R1=10e-3, H0=5e-3, H3=30e-3, W3=5e-3 ) test_obj.stator.winding = WindingDW2L(qs=3, p=3, Lewout=60e-3) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.2, Rext=0.25, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_1-Machine.png")) # Rotor + stator + 2 for frame + 1 for Shaft self.assertEqual(len(fig.axes[0].patches), 133) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_2-Rotor.png")) # 2 for lam + Zs*2 for wind + 6 vent self.assertEqual(len(fig.axes[0].patches), 92) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_3-Stator.png")) # 2 for lam, 2*Zs for wind self.assertEqual(len(fig.axes[0].patches), 38)
def __init__(self, name="", desc="", machine=-1, input=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["name", "desc", "machine", "input"]) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument # Call Simulation init super(Simu1, self).__init__(name=name, desc=desc, machine=machine, input=input)
def test_Lam_Wind_24_wind_22(self): """Test machine plot with Slot 24 and winding rad=2, tan=2 """ print("\nTest plot Slot 24") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.8, Nrvd=4, Wrvd=0.05, ) test_obj.rotor.slot = SlotW24(Zs=6, W3=100e-3, H2=150e-3) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=120e-3) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.8, Nrvd=4, Wrvd=0.05, ) test_obj.stator.slot = SlotW24(Zs=18, W3=50e-3, H2=200e-3) test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.stator.winding.Lewout = 120e-3 test_obj.frame = Frame(Rint=0.8, Rext=0.8, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s24_1-Machine.png")) # Rotor + Stator + 0 for frame + 1 for shaft self.assertEqual(len(fig.axes[0].patches), 65) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s24_2-Rotor.png")) # 2 for lam + 4*Zs for wind self.assertEqual(len(fig.axes[0].patches), 26) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s24_3-Stator.png")) # 2 for lam + 2*Zs for wind self.assertEqual(len(fig.axes[0].patches), 38)
def __init__( self, mag=-1, struct=-1, name="", desc="", machine=-1, input=-1, init_dict=None ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mag == -1: mag = Magnetics() if struct == -1: struct = Structural() if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["mag", "struct", "name", "desc", "machine", "input"] ) # Overwrite default value with init_dict content if "mag" in list(init_dict.keys()): mag = init_dict["mag"] if "struct" in list(init_dict.keys()): struct = init_dict["struct"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument # mag can be None, a Magnetics object or a dict if isinstance(mag, dict): # Check that the type is correct (including daughter) class_name = mag.get("__class__") if class_name not in ["Magnetics", "MagFEMM"]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for mag" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.mag = class_obj(init_dict=mag) else: self.mag = mag # struct can be None, a Structural object or a dict if isinstance(struct, dict): self.struct = Structural(init_dict=struct) else: self.struct = struct # Call Simulation init super(Simu1, self).__init__(name=name, desc=desc, machine=machine, input=input)
def __init__( self, mag=-1, struct=-1, name="", desc="", machine=-1, input=-1, init_dict=None ): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if mag == -1: mag = Magnetics() if struct == -1: struct = Structural() if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict( init_dict, ["mag", "struct", "name", "desc", "machine", "input"] ) # Overwrite default value with init_dict content if "mag" in list(init_dict.keys()): mag = init_dict["mag"] if "struct" in list(init_dict.keys()): struct = init_dict["struct"] if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument # mag can be None, a Magnetics object or a dict if isinstance(mag, dict): # Call the correct constructor according to the dict load_dict = {"MagFEMM": MagFEMM, "Magnetics": Magnetics} obj_class = mag.get("__class__") if obj_class is None: self.mag = Magnetics(init_dict=mag) elif obj_class in list(load_dict.keys()): self.mag = load_dict[obj_class](init_dict=mag) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError("Unknow class name in init_dict for mag") else: self.mag = mag # struct can be None, a Structural object or a dict if isinstance(struct, dict): self.struct = Structural(init_dict=struct) else: self.struct = struct # Call Simulation init super(Simu1, self).__init__(name=name, desc=desc, machine=machine, input=input)
def test_Lam_Mag_13_inset(self): """Test machine plot with Magnet 12 inset""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=90e-3, is_internal=True, is_stator=False, L1=0.42, Nrvd=4, Wrvd=0.02, ) magnet = [MagnetType13(Lmag=0.5, Hmag=0.02, Wmag=0.04, Rtop=0.04)] test_obj.rotor.slot = SlotMFlat(Zs=8, W0=0.04, H0=0.02, W3=2 * pi / 64, magnet=magnet) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.stator = LamSlotMag( Rint=110e-3, Rext=200e-3, is_internal=False, is_stator=True, L1=0.42, Nrvd=4, Wrvd=0.02, ) magnet2 = [MagnetType13(Lmag=0.5, Hmag=0.02, Wmag=0.04, Rtop=0.04)] test_obj.stator.slot = SlotMFlat(Zs=4, W0=0.04, H0=0.025, W3=2 * pi / 64, magnet=magnet2) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 19) fig.savefig(join(save_path, "test_Lam_Mag_13i_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_13i_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 6) fig.savefig(join(save_path, "test_Lam_Mag_13i_3-Stator.png"))
def test_Lam_Wind_61(self): """Test machine plot with Slot 61 """ print("\nTest plot Slot 61") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind(Rint=0, Rext=0.1325, is_internal=True, is_stator=False, L1=0.9) test_obj.rotor.slot = SlotW61( Zs=12, W0=15e-3, W1=35e-3, W2=12.5e-3, H0=15e-3, H1=20e-3, H2=25e-3, H3=1e-3, H4=2e-3, W3=3e-3, ) test_obj.rotor.winding = WindingCW2LT(qs=3, p=3, Lewout=60e-3) plt.close("all") test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s61_1-Rotor.png")) # 1 for Lam, Zs*2 for wind self.assertEqual(len(fig.axes[0].patches), 25) test_obj.rotor.slot.W3 = 0 test_obj.rotor.slot.H3 = 0 test_obj.rotor.slot.H4 = 0 test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s61_2-Rotor Wind.png")) # 1 for Lam, Zs*2 for wind self.assertEqual(len(fig.axes[0].patches), 25) tooth = test_obj.rotor.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s61_Tooth_in.png"))
def test_Lam_Wind_28_wind_22(self): """Test machine plot with Slot 28 and winding rad=2, tan=2 """ plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.01, Rext=0.129, is_internal=True, is_stator=False, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.rotor.slot = SlotW28( Zs=6, W0=20e-3, R1=25e-3, H0=10e-3, H3=50e-3, W3=15e-3 ) test_obj.rotor.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.13, Rext=0.4, is_internal=False, is_stator=True, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.stator.axial_vent = [ VentilationCirc(Zh=6, Alpha0=pi / 6, D0=60e-3, H0=0.25) ] test_obj.stator.slot = SlotW28( Zs=6, W0=40e-3, R1=50e-3, H0=10e-3, H3=70e-3, W3=85e-3 ) test_obj.stator.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_4-Machine.png")) # Rotor + stator + 0 for frame + 1 for shaft self.assertEqual(len(fig.axes[0].patches), 59) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_5-Rotor.png")) # 2 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 26) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_6-Stator.png")) # 2 for lam, 4*Zs for wind + 6 vents self.assertEqual(len(fig.axes[0].patches), 32)
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = Machine() test_obj.rotor = LamHole(Rint=45e-3 / 2, Rext=81.5e-3, is_stator=False, is_internal=True, L1=0.9) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM51( Zh=8, W0=0.016, W1=pi / 6, W2=0.004, W3=0.01, W4=0.002, W5=0.01, W6=0.002, W7=0.01, H0=0.01096, H1=0.0015, H2=0.0055, )) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1.2) test_obj.stator = Lamination(Rint=0.09, Rext=0.12, is_internal=False, is_stator=True, L1=0.9) test_obj.frame = Frame(Rint=0.12, Rext=0.12, Lfra=0.7) self.test_obj = test_obj
def test_Lam_Mag_14_inset(self): """Test machine plot with Magnet 14 inset""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=90e-3, is_internal=True, is_stator=False, L1=0.4, Nrvd=5, Wrvd=0.02, ) magnet = [MagnetType14(Lmag=0.5, Hmag=0.02, Wmag=0.628, Rtop=0.04)] test_obj.rotor.slot = SlotMPolar(Zs=4, W0=0.628, H0=0.02, magnet=magnet) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.stator = Lamination( Rint=130e-3, Rext=0.2, is_internal=False, is_stator=True, L1=0.4, Nrvd=5, Wrvd=0.02, ) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 11) fig.savefig(join(save_path, "test_Lam_Mag_14i_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 6) fig.savefig(join(save_path, "test_Lam_Mag_14i_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 2) fig.savefig(join(save_path, "test_Lam_Mag_14i_3-Stator.png"))
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = Machine() test_obj.rotor = LamHole( is_internal=True, Rint=0.1, Rext=0.2, is_stator=False, L1=0.7 ) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM53( Zh=8, W1=15e-3, W2=10e-3, W3=40e-3, W4=pi / 4, H0=75e-3, H1=5e-3, H2=20e-3, H3=5e-3, ) ) self.test_obj = test_obj
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = Machine() test_obj.rotor = LamHole(is_internal=True, Rint=0.021, Rext=0.075, is_stator=False, L1=0.7) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM50( Zh=8, W0=50e-3, W1=2e-3, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, H4=0, )) test_obj.rotor.axial_vent = list() test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=0, D0=5e-3, H0=40e-3)) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=pi / 8, D0=7e-3, H0=40e-3)) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1.2) test_obj.stator = Lamination(Rint=0.078, Rext=0.104, is_internal=False, is_stator=True, L1=0.8) test_obj.stator.axial_vent.append( VentilationPolar(Zh=8, H0=0.08, D0=0.01, W1=pi / 8, Alpha0=pi / 8)) test_obj.stator.axial_vent.append( VentilationPolar(Zh=8, H0=0.092, D0=0.01, W1=pi / 8, Alpha0=0)) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.104, Rext=0.114, Lfra=1) self.test_obj = test_obj
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = Machine(type_machine=6) # SPMSM # For comp_output compatibility self.test_obj.stator = LamSlotWind(Rint=0.95, Rext=0.99) self.test_obj.rotor = LamSlotMag(Rint=0.1, Rext=0.9) self.test_obj.rotor.slot = SlotMFlat(Zs=8, W0=10e-3, H0=0e-3) self.test_obj.rotor.slot.magnet = [ MagnetType13(Wmag=10e-3, Hmag=3e-3, Rtop=12e-3) ] self.test_obj.rotor.slot.magnet[0].mat_type.name = "test2" self.matlib = list() self.matlib.append(Material(name="test1")) self.matlib[-1].elec.rho = 0.31 self.matlib.append(Material(name="test2")) self.matlib[-1].elec.rho = 0.32 self.matlib.append(Material(name="test3")) self.matlib[-1].elec.rho = 0.33 self.widget = SMagnet(machine=self.test_obj, matlib=self.matlib, is_stator=False)
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = Machine() test_obj.rotor = LamHole( Rint=45e-3 / 2, Rext=81.5e-3, is_stator=False, is_internal=True, L1=0.9 ) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM52(Zh=8, W0=27e-3, W3=16.2e-3, H0=1e-3, H1=5e-3, H2=1e-3) ) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1.2) test_obj.stator = Lamination( Rint=0.09, Rext=0.12, is_internal=False, is_stator=True, L1=0.9 ) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.12, Rext=0.12, Lfra=0.7) self.test_obj = test_obj
def test_Lam_Wind_27_wind_22(self): """Test machine plot with Slot 27 and winding rad=2, tan=2 """ print("\nTest plot Slot 27") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.rotor.axial_vent = [ VentilationCirc(Zh=6, Alpha0=pi / 6, D0=60e-3, H0=0.35) ] test_obj.rotor.slot = SlotW27(Zs=6, H0=0.05, W0=30e-3, H1=0.125, W1=0.06, H2=0.05, W2=0.09, W3=0.04) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.stator.slot = SlotW27(Zs=18, H0=0.05, W0=30e-3, H1=0.07, W1=0.05, H2=0.15, W2=0.1, W3=0.05) test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.winding.Lewout = 60e-3 test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.8, Rext=0.9, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s27_1-Machine.png")) # Rotor + Stator + 2 for frame + 1 for shaft self.assertEqual(len(fig.axes[0].patches), 73) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s27_2-Rotor.png")) # 2 for lam + 4*Zs for wind + 6 vent self.assertEqual(len(fig.axes[0].patches), 32) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s27_3-Stator.png")) # 2 for lam + 2*Zs for wind self.assertEqual(len(fig.axes[0].patches), 38)
def test_Lam_Mag_10_inset(self): """Test machine plot with Magnet 10 inset""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=100e-3, is_internal=True, is_stator=False, L1=0.45, Nrvd=1, Wrvd=0.05, ) magnet = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)] test_obj.rotor.slot = SlotMFlat(Zs=4, W0=0.04, H0=0.02, magnet=magnet) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=4, Alpha0=0, D0=2.5e-3, H0=50e-3)) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=0, D0=5e-3, H0=60e-3)) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=12, Alpha0=0, D0=10e-3, H0=70e-3)) test_obj.stator = LamSlotMag( Rint=110e-3, Rext=200e-3, is_internal=False, is_stator=True, L1=0.45, Nrvd=1, Wrvd=0.05, ) magnet2 = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)] test_obj.stator.slot = SlotMFlat(Zs=8, W0=0.04, W3=2 * pi / 64, H0=0.02, magnet=magnet2) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.stator.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=10e-3, W2=20e-3, D0=0.02, H0=0.140)) test_obj.stator.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=20e-3, W2=40e-3, D0=0.02, H0=0.170)) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 55) fig.savefig(join(save_path, "test_Lam_Mag_10i_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 30) fig.savefig(join(save_path, "test_Lam_Mag_10i_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 22) fig.savefig(join(save_path, "test_Lam_Mag_10i_3-Stator.png"))
def test_Lam_Wind_22_wind_22(self): """Test machine plot with Slot 22 and winding rad=2, tan=2 """ print("\nTest plot Slot 22") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0, Rext=0.5, is_internal=True, is_stator=False, L1=0.8, Nrvd=4, Wrvd=0.05, ) test_obj.rotor.slot = SlotW22(Zs=6, W0=pi / 20, W2=pi / 10, H0=20e-3, H2=150e-3) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.8, Nrvd=4, Wrvd=0.05, ) test_obj.stator.slot = SlotW22(Zs=18, W0=pi / 20, W2=pi / 10, H0=20e-3, H2=150e-3) test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.stator.winding.Lewout = 60e-3 test_obj.frame = Frame(Rint=0.8, Rext=0.8, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_1-Machine.png")) # Rotor + Stator + 0 for frame + 0 for shaft self.assertEqual(len(fig.axes[0].patches), 63) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_2-Rotor.png")) # 1 for lam + 4*Zs for wind self.assertEqual(len(fig.axes[0].patches), 25) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_3-Stator.png")) # 2 for lam + Zs*2 for wind self.assertEqual(len(fig.axes[0].patches), 38) tooth = test_obj.rotor.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_Tooth_in.png")) tooth = test_obj.stator.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_Tooth_out.png"))
from numpy import array, pi, zeros from pyleecan.Classes.Machine import Machine from pyleecan.Classes.Lamination import Lamination from pyleecan.Classes.LamHole import LamHole from pyleecan.Classes.VentilationCirc import VentilationCirc from pyleecan.Classes.VentilationPolar import VentilationPolar from pyleecan.Classes.HoleM50 import HoleM50 from pyleecan.Classes.Frame import Frame from pyleecan.Classes.Shaft import Shaft # For AlmostEqual DELTA = 1e-4 M_test = list() test_obj = Machine() test_obj.rotor = LamHole(is_internal=True, Rint=0.021, Rext=0.075, is_stator=False, L1=0.7, Nrvd=0, Kf1=0.95) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM50( Zh=8, W0=50e-3, W1=2e-3, W2=1e-3, W3=1e-3,
def test_Lam_Wind_21_wind_22(self): """Test machine plot with Slot 21 and winding rad=2, tan=2 """ print("\nTest plot Slot 21") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.85, Nrvd=3, Wrvd=0.05, ) test_obj.rotor.slot = SlotW21( Zs=6, W0=40e-3, W1=60e-3, W2=40e-3, H0=20e-3, H1=0, H2=130e-3, H1_is_rad=False, ) test_obj.rotor.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=30e-3, W2=60e-3, D0=0.05, H0=0.3)) test_obj.rotor.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=60e-3, W2=90e-3, D0=0.05, H0=0.4)) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.85, Nrvd=3, Wrvd=0.05, ) test_obj.stator.slot = SlotW21( Zs=18, W0=40e-3, W1=60e-3, W2=90e-3, H0=15e-3, H1=35e-3, H2=140e-3, H1_is_rad=False, ) test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.axial_vent.append( VentilationCirc(Zh=12, Alpha0=pi / 6, D0=50e-3, H0=0.75)) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.stator.winding.Lewout = 60e-3 test_obj.frame = Frame(Rint=0.8, Rext=1, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s21_1-Machine.png")) # Rotor + Stator + 2 for frame + 1 for shaft self.assertEqual(len(fig.axes[0].patches), 91) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s21_2-Rotor.png")) # 2 for lam + 4*Zs for wind + 6 vents + 6 vents self.assertEqual(len(fig.axes[0].patches), 38) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s21_3-Stator.png")) # 2 for lam + Zs*2 for wind + 12 vents self.assertEqual(len(fig.axes[0].patches), 50) tooth = test_obj.rotor.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s21_Tooth_in.png")) tooth = test_obj.stator.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s21_Tooth_out.png"))
class Simulation(FrozenClass): """Abstract class for the simulation""" VERSION = 1 # save method is available in all object save = save def __init__(self, name="", desc="", machine=-1, input=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["name", "desc", "machine", "input"]) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument self.parent = None self.name = name self.desc = desc # machine can be None, a Machine object or a dict if isinstance(machine, dict): # Call the correct constructor according to the dict load_dict = { "MachineSync": MachineSync, "MachineAsync": MachineAsync, "MachineSCIM": MachineSCIM, "MachineDFIM": MachineDFIM, "MachineSIPMSM": MachineSIPMSM, "MachineIPMSM": MachineIPMSM, "MachineWRSM": MachineWRSM, "MachineSyRM": MachineSyRM, "Machine": Machine, } obj_class = machine.get("__class__") if obj_class is None: self.machine = Machine(init_dict=machine) elif obj_class in list(load_dict.keys()): self.machine = load_dict[obj_class](init_dict=machine) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for machine") else: self.machine = machine # input can be None, a Input object or a dict if isinstance(input, dict): # Call the correct constructor according to the dict load_dict = {"InCurrent": InCurrent, "Input": Input} obj_class = input.get("__class__") if obj_class is None: self.input = Input(init_dict=input) elif obj_class in list(load_dict.keys()): self.input = load_dict[obj_class](init_dict=input) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for input") else: self.input = input # The class is frozen, for now it's impossible to add new properties self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Simulation_str = "" if self.parent is None: Simulation_str += "parent = None " + linesep else: Simulation_str += "parent = " + str(type( self.parent)) + " object" + linesep Simulation_str += 'name = "' + str(self.name) + '"' + linesep Simulation_str += 'desc = "' + str(self.desc) + '"' + linesep Simulation_str += "machine = " + str( self.machine.as_dict()) + linesep + linesep Simulation_str += "input = " + str(self.input.as_dict()) return Simulation_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False if other.name != self.name: return False if other.desc != self.desc: return False if other.machine != self.machine: return False if other.input != self.input: return False return True def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Simulation_dict = dict() Simulation_dict["name"] = self.name Simulation_dict["desc"] = self.desc if self.machine is None: Simulation_dict["machine"] = None else: Simulation_dict["machine"] = self.machine.as_dict() if self.input is None: Simulation_dict["input"] = None else: Simulation_dict["input"] = self.input.as_dict() # The class name is added to the dict fordeserialisation purpose Simulation_dict["__class__"] = "Simulation" return Simulation_dict def _set_None(self): """Set all the properties to None (except pyleecan object)""" self.name = None self.desc = None if self.machine is not None: self.machine._set_None() if self.input is not None: self.input._set_None() def _get_name(self): """getter of name""" return self._name def _set_name(self, value): """setter of name""" check_var("name", value, "str") self._name = value # Name of the simulation # Type : str name = property(fget=_get_name, fset=_set_name, doc=u"""Name of the simulation""") def _get_desc(self): """getter of desc""" return self._desc def _set_desc(self, value): """setter of desc""" check_var("desc", value, "str") self._desc = value # Simulation description # Type : str desc = property(fget=_get_desc, fset=_set_desc, doc=u"""Simulation description""") def _get_machine(self): """getter of machine""" return self._machine def _set_machine(self, value): """setter of machine""" check_var("machine", value, "Machine") self._machine = value if self._machine is not None: self._machine.parent = self # Machine to simulate # Type : Machine machine = property(fget=_get_machine, fset=_set_machine, doc=u"""Machine to simulate""") def _get_input(self): """getter of input""" return self._input def _set_input(self, value): """setter of input""" check_var("input", value, "Input") self._input = value if self._input is not None: self._input.parent = self # Input of the simulation # Type : Input input = property(fget=_get_input, fset=_set_input, doc=u"""Input of the simulation""")
def test_Lam_Wind_12_wind_22(self): """Test machine plot with Slot 12 and winding rad=2, tan=2 """ print("\nTest plot Slot 12") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.rotor.axial_vent = [ VentilationPolar(Zh=6, Alpha0=pi / 6, W1=pi / 6, D0=100e-3, H0=0.3) ] test_obj.rotor.slot = SlotW12(Zs=6, R2=35e-3, H0=20e-3, R1=17e-3, H1=130e-3) test_obj.rotor.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.stator.slot = SlotW12(Zs=18, R2=25e-3, H0=30e-3, R1=0, H1=150e-3) test_obj.stator.winding.Lewout = 60e-3 test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.8, Rext=0.9, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s12_1-Machine.png")) # Rotor + Stator + 2 for frame + 1 for Shaft self.assertEqual(len(fig.axes[0].patches), 73) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s12_2-Rotor.png")) # 2 for lam + Zs*4 for wind + 6 vents self.assertEqual(len(fig.axes[0].patches), 32) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s12_3-Stator.png")) # 2 for lam + Zs*2 for wind self.assertEqual(len(fig.axes[0].patches), 38) tooth = test_obj.rotor.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s12_Tooth_in.png")) tooth = test_obj.stator.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s12_Tooth_out.png"))
def test_Lam_Wind_23_wind_22(self): """Test machine plot with Slot 23 and winding rad=2, tan=2 """ print("\nTest plot Slot 23") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0, Rext=0.5, is_internal=True, is_stator=False, L1=0.9, Nrvd=5, Wrvd=0.02, ) test_obj.rotor.slot = SlotW23(Zs=6, W0=50e-3, W1=90e-3, W2=100e-3, H0=20e-3, H1=35e-3, H2=130e-3) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.9, Nrvd=5, Wrvd=0.02, ) test_obj.stator.slot = SlotW23(Zs=18, W0=50e-3, W1=80e-3, W2=50e-3, H0=15e-3, H1=0, H2=170e-3) test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.stator.winding.Lewout = 60e-3 test_obj.frame = Frame(Rint=0.8, Rext=1, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s23_1-Machine.png")) # Rotor + Stator + 2 for frame + 0 shaft self.assertEqual(len(fig.axes[0].patches), 65) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s23_2-Rotor.png")) # 1 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 25) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s23_3-Stator.png")) # 2 for lam + Zs *2 for wind self.assertEqual(len(fig.axes[0].patches), 38)
def test_Lam_Wind_11_wind_22(self): """Test machine plot with Slot 11 and winding rad=2, tan=2 """ print("\nTest plot Slot 11") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.rotor.axial_vent = [ VentilationCirc(Zh=6, Alpha0=pi / 6, D0=60e-3, H0=0.35) ] test_obj.rotor.slot = SlotW11( Zs=6, W0=50e-3, W1=60e-3, W2=70e-3, H0=20e-3, H1=35e-3, H2=130e-3, H1_is_rad=False, R1=10e-3, ) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.stator.slot = SlotW11( Zs=18, W0=40e-3, W1=60e-3, W2=90e-3, H0=15e-3, H1=35e-3, H2=140e-3, H1_is_rad=False, R1=40e-3, ) test_obj.stator.winding.Lewout = 60e-3 test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.8, Rext=0.9, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s11_1-Machine.png")) # Rotor + Stator + 2 for frame + 1 for Shaft self.assertEqual(len(fig.axes[0].patches), 73) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s11_2-Rotor.png")) # 2 for lam + Zs*4 for wind + 6 vents self.assertEqual(len(fig.axes[0].patches), 32) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s11_3-Stator.png")) # 2 for lam + Zs*2 for wind self.assertEqual(len(fig.axes[0].patches), 38)
def test_Lam_Wind_10_wind_22(self): """Test machine plot with Slot 10 and winding rad=2, tan=2 """ print("\nTest plot Slot 10") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.95, Nrvd=1, Wrvd=0.05, ) test_obj.rotor.slot = SlotW10( Zs=6, W0=50e-3, W1=90e-3, W2=100e-3, H0=20e-3, H1=35e-3, H2=130e-3, H1_is_rad=False, ) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.shaft.mat_type.name = "M270_35A" test_obj.shaft.mat_type.magnetics = None test_obj.rotor.mat_type.name = "Load_M400" test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.95, Nrvd=1, Wrvd=0.05, ) test_obj.stator.slot = SlotW10( Zs=6, W0=50e-3, W1=80e-3, W2=50e-3, H0=15e-3, H1=25e-3, H2=140e-3, H1_is_rad=False, ) test_obj.stator.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.stator.mat_type.name = "Param" test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) BH = BHCurveParam(Bmax=1.5, mur_0=8585, mur_1=21.79, a=0.25575) test_obj.stator.mat_type.magnetics.BH_curve = BH test_obj.frame = Frame(Rint=0.8, Rext=0.9, Lfra=1) test_obj.frame.mat_type.name = "M330_35A" test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_1-Machine.png")) # Rotor + Stator + 2 for frame + 1 for Shaft self.assertEqual(len(fig.axes[0].patches), 55) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 26) fig.savefig(join(save_path, "test_Lam_Wind_s10_2-Rotor.png")) # 2 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 26) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_3-Stator.png")) # 2 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 26)
def test_Lam_Wind_10_wind_22(self): """Test machine plot with Slot 10 and winding rad=2, tan=2 """ print("\nTest plot Slot 10") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.95, Nrvd=1, Wrvd=0.05, ) test_obj.rotor.slot = SlotW10( Zs=6, W0=50e-3, W1=90e-3, W2=100e-3, H0=20e-3, H1=35e-3, H2=130e-3, H1_is_rad=False, ) test_obj.rotor.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.95, Nrvd=1, Wrvd=0.05, ) test_obj.stator.slot = SlotW10( Zs=6, W0=50e-3, W1=80e-3, W2=50e-3, H0=15e-3, H1=25e-3, H2=140e-3, H1_is_rad=False, ) test_obj.stator.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.frame = Frame(Rint=0.8, Rext=0.9, Lfra=1) test_obj.frame.mat_type.name = "M330_35A" test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_1-Machine.png")) # Rotor + Stator + 2 for frame + 1 for Shaft self.assertEqual(len(fig.axes[0].patches), 55) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 26) fig.savefig(join(save_path, "test_Lam_Wind_s10_2-Rotor.png")) # 2 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 26) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_3-Stator.png")) # 2 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 26) lines = test_obj.stator.slot.build_geometry_half_tooth(is_top=False) surf = SurfLine(line_list=lines) surf.plot_lines() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_bottom_out.png")) lines = test_obj.stator.slot.build_geometry_half_tooth(is_top=True) surf = SurfLine(line_list=lines) surf.plot_lines() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_top_out.png")) lines = test_obj.rotor.slot.build_geometry_half_tooth(is_top=False) surf = SurfLine(line_list=lines) surf.plot_lines() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_bottom_in.png")) lines = test_obj.rotor.slot.build_geometry_half_tooth(is_top=True) surf = SurfLine(line_list=lines) surf.plot_lines() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_top_in.png")) tooth = test_obj.rotor.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_in.png")) tooth = test_obj.stator.slot.get_surface_tooth() tooth.plot(color="r") fig = plt.gcf() mesh_dict = tooth.comp_mesh_dict(5e-3) for line in tooth.get_lines(): mid = line.get_middle() plt.text(mid.real, mid.imag, str(mesh_dict[line.label])) fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_out.png"))
def __init__(self, name="", desc="", machine=-1, input=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["name", "desc", "machine", "input"]) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument self.parent = None self.name = name self.desc = desc # machine can be None, a Machine object or a dict if isinstance(machine, dict): # Call the correct constructor according to the dict load_dict = { "MachineSync": MachineSync, "MachineAsync": MachineAsync, "MachineSCIM": MachineSCIM, "MachineDFIM": MachineDFIM, "MachineSIPMSM": MachineSIPMSM, "MachineIPMSM": MachineIPMSM, "MachineWRSM": MachineWRSM, "MachineSyRM": MachineSyRM, "Machine": Machine, } obj_class = machine.get("__class__") if obj_class is None: self.machine = Machine(init_dict=machine) elif obj_class in list(load_dict.keys()): self.machine = load_dict[obj_class](init_dict=machine) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for machine") else: self.machine = machine # input can be None, a Input object or a dict if isinstance(input, dict): # Call the correct constructor according to the dict load_dict = {"InCurrent": InCurrent, "Input": Input} obj_class = input.get("__class__") if obj_class is None: self.input = Input(init_dict=input) elif obj_class in list(load_dict.keys()): self.input = load_dict[obj_class](init_dict=input) else: # Avoid generation error or wrong modification in json raise InitUnKnowClassError( "Unknow class name in init_dict for input") else: self.input = input # The class is frozen, for now it's impossible to add new properties self._freeze()
def __init__(self, name="", desc="", machine=-1, input=-1, init_dict=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if machine == -1: machine = Machine() if input == -1: input = Input() if init_dict is not None: # Initialisation by dict check_init_dict(init_dict, ["name", "desc", "machine", "input"]) # Overwrite default value with init_dict content if "name" in list(init_dict.keys()): name = init_dict["name"] if "desc" in list(init_dict.keys()): desc = init_dict["desc"] if "machine" in list(init_dict.keys()): machine = init_dict["machine"] if "input" in list(init_dict.keys()): input = init_dict["input"] # Initialisation by argument self.parent = None self.name = name self.desc = desc # machine can be None, a Machine object or a dict if isinstance(machine, dict): # Check that the type is correct (including daughter) class_name = machine.get("__class__") if class_name not in [ "Machine", "MachineAsync", "MachineDFIM", "MachineIPMSM", "MachineSCIM", "MachineSIPMSM", "MachineSRM", "MachineSyRM", "MachineSync", "MachineWRSM", ]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for machine" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.machine = class_obj(init_dict=machine) else: self.machine = machine # input can be None, a Input object or a dict if isinstance(input, dict): # Check that the type is correct (including daughter) class_name = input.get("__class__") if class_name not in ["Input", "InCurrent", "InFlux", "InForce"]: raise InitUnKnowClassError( "Unknow class name " + class_name + " in init_dict for input" ) # Dynamic import to call the correct constructor module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name]) class_obj = getattr(module, class_name) self.input = class_obj(init_dict=input) else: self.input = input # The class is frozen, for now it's impossible to add new properties self._freeze()