Eomys/pyleecan

losses and rotor hole type 52

Closed this issue · 1 comments

hello,
thank you for your help in advance,
I simulate my machine with DXF file for the rotor hole and there wasn't any error but when I want to use the rotor Hole from pyleecan( HOLE TYPE 52) and simulate the losses I got a strange error; the other simulations( magnetic and electrical) don't have any error.
can you help me please as soon as you have time?

[14:59:32] Starting running simulation test_FEMM_Loss_IPMSM (machine=IPMSM_OIL_PUMP_Final_2)
[14:59:32] Starting Magnetic module
[14:59:33] Solving time steps: 0%
[14:59:33] Solving time steps: 0%
[14:59:33] Solving time steps: 0%
[14:59:33] Solving time steps: 0%
[15:00:06] Solving time steps: 25%
[15:00:07] Solving time steps: 25%
[15:00:07] Solving time steps: 25%
[15:00:07] Solving time steps: 25%
[15:00:37] Solving time steps: 50%
[15:00:37] Solving time steps: 50%
[15:00:38] Solving time steps: 50%
[15:00:38] Solving time steps: 50%
[15:01:07] Solving time steps: 75%
[15:01:08] Solving time steps: 75%
[15:01:09] Solving time steps: 75%
[15:01:09] Solving time steps: 75%
[15:01:39] Solving time step: 100%
[15:01:39] Solving time step: 100%
[15:01:40] Solving time step: 100%
[15:01:44] Solving time step: 100%
[15:01:44] Running Loss module
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[5], line 1
----> 1 out2 = simu.run()

File c:\users\faraz\appdata\local\programs\python\python38\lib\site-packages\pyleecan\Methods\Simulation\Simulation\run.py:52, in run(self)
     49     self.init_logger(results)
     51     # Compute the simulation
---> 52     self.run_single()
     54 if self.index is None and self.layer == 0:
     55     msg = "End of simulation"

File c:\users\faraz\appdata\local\programs\python\python38\lib\site-packages\pyleecan\Methods\Simulation\Simu1\run_single.py:43, in run_single(self)
     39 # if self.ac is not None:
     40 #     self.ac.run()
     42 if self.loss is not None:
---> 43     self.loss.run()
     44 # Running postprocessings
     46 if self.postproc_list:

File c:\users\faraz\appdata\local\programs\python\python38\lib\site-packages\pyleecan\Methods\Loss\Loss\run.py:24, in run(self)
     22 axes_dict = self.comp_axes(output)
     23 # Comp and store in output
---> 24 self.comp_all_losses(axes_dict)

File c:\users\faraz\appdata\local\programs\python\python38\lib\site-packages\pyleecan\Methods\Loss\Loss\comp_all_losses.py:40, in comp_all_losses(self, axes_dict)
     37 out_loss.loss_dict = dict()
     38 for key, model in self.model_dict.items():
     39     # Compute losses for each model
---> 40     P_density, f_array = model.comp_loss()
     41     if self.is_get_meshsolution:
     42         loss_density = np.zeros((freqs.size, Nelem))

File c:\users\faraz\appdata\local\programs\python\python38\lib\site-packages\pyleecan\Methods\Loss\LossModelMagnet\comp_loss.py:92, in comp_loss(self)
     87 L1 = machine.rotor.L1
     89 # Calculate segmentation coefficient from:
     90 # "Effect of Eddy-Current Loss Reduction by Magnet Segmentation in Synchronous Motors With Concentrated Windings"
     91 # Katsumi Yamazaki, Member, IEEE, and Yu Fukushima, Equation (9)
---> 92 if magnet.Lmag is None or magnet.Nseg is None or Wmag is None or magnet.Nseg == 1:
     93     kseg = 1
     94 else:

UnboundLocalError: local variable 'Wmag' referenced before assignment

Best regards,
Faraz Mirali

Hello,

In fact there was a typo in pyleecan\Methods\Loss\LossModelMagnet\comp_loss that affect only HoleM52!
I have push a bug correction directly on master.
Thank you for spotting that !

Best regards,
Pierre