Eomys/pyleecan

input voltage

Opened this issue · 2 comments

Hello,
can someone explain to me why I get this error and what should I do if I want to use Input voltage instead of input current?
Best regards,
Faraz Mirali

from pyleecan.Classes.Simu1 import Simu1
from pyleecan.Classes.Electrical import Electrical
from pyleecan.Classes.EEC_PMSM import EEC_PMSM
from pyleecan.Classes.MagFEMM import MagFEMM

# Initialization of the Simulation
simu = Simu1(name="tuto_elec", machine=IPMSM_A)
# Definition of the Electrical Equivalent Circuit
eec = EEC_PMSM(  # No parameter enforced => compute all
    fluxlink=MagFEMM(is_periodicity_a=True, T_mag = 101, nb_worker=4), # Magnetic model to compute fluxlinkage
)
# The Electrical module is defined with the EEC
simu.elec = Electrical(eec=eec)
# Run only Electrical module
simu.mag = None
simu.force = None
simu.struct = None
from pyleecan.Classes.InputVoltage import InputVoltage
from pyleecan.Classes.OPdq import OPdq
from numpy import sqrt, exp, pi

# Definition of a sinusoidal current
simu.input = InputVoltage()

U0 = 11.13770284349565 # Maximum Voltage [Arms]
UPhi0 = 111.63408101717668*pi/180  # Maximum Torque Per Amp

simu.input.OP = OPdq(N0 = 4500)
simu.input.OP.set_U0_UPhi0(U0,UPhi0)

simu.input.Nt_tot = 500 # Number of time steps
simu.input.Na_tot = 2048 # Spatial discretization

(simu.input.OP.Ud_ref,simu.input.OP.Uq_ref)

out = simu.run()

[11:57:11] Starting running simulation tuto_elec (machine=IPMSM_OIL_PUMP_Final)
[11:57:11] Starting Electric module
[11:57:11] Starting running simulation tuto_elec_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM (machine=IPMSM_OIL_PUMP_Final)
[11:57:11] Starting Magnetic module[11:57:11] Starting running simulation tuto_elec (machine=IPMSM_OIL_PUMP_Final)
[11:57:11] Starting Electric module
[11:57:11] Starting running simulation tuto_elec_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM (machine=IPMSM_OIL_PUMP_Final)
[11:57:11] Starting Magnetic module
[11:57:13] Solving time steps: 0%
[11:57:13] Solving time steps: 0%
[11:57:13] Solving time steps: 0%
[11:57:13] Solving time steps: 0%
[11:57:34] Solving time steps: 25%
[11:57:34] Solving time steps: 25%
[11:57:34] Solving time steps: 25%
[11:57:40] Solving time steps: 25%
[11:57:50] Solving time steps: 50%
[11:57:51] Solving time steps: 50%
[11:57:51] Solving time steps: 50%
[11:57:57] Solving time steps: 50%
[11:58:09] Solving time steps: 75%
[11:58:11] Solving time steps: 75%
[11:58:11] Solving time steps: 75%
[11:58:17] Solving time steps: 75%
[11:58:26] Solving time step: 100%
[11:58:27] Solving time step: 100%
[11:58:28] Solving time step: 100%
[11:58:32] Solving time step: 100%
[11:58:32] End of simulation tuto_elec_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM_FluxLinkFEMM
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[28], line 1
----> 1 out = 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:29, in run_single(self)
     27 # Run the modules
     28 if self.elec is not None:
---> 29     self.elec.run()
     30 if self.mag is not None:
     31     self.mag.run()

File c:\users\faraz\appdata\local\programs\python\python38\lib\site-packages\pyleecan\Methods\Simulation\Electrical\run.py:63, in run(self)
     59     eec_out.comp_parameters()
     61 if output.elec.PWM is None:
     62     # Solve the electrical equivalent circuit for fundamental only
---> 63     out_dict = eec_out.solve()
     64 else:
     65     # Generate voltage signal (PWM signal generation is the only strategy for now)
     66     if output.elec.PWM.U0 is None:
     67         # Current driven mode
     68         # Solve the electrical equivalent circuit for fundamental current
     69         # to get fundamental phase voltage

File c:\users\faraz\appdata\local\programs\python\python38\lib\site-packages\pyleecan\Methods\Simulation\EEC_PMSM\solve.py:40, in solve(self)
     33 out_dict = dict()
     35 if self.OP.get_Ud_Uq()["Ud"] is not None:
     36     # Voltage driven
     37     # Impedance matrix
     38     XR = array(
     39         [
---> 40             [self.R1, -ws * self.Lq],
     41             [ws * self.Ld, self.R1],
     42         ]
     43     )
     44     # Back emf array
     45     if self.Phid_mag is not None:

TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

Dear all,
i will be grateful if someone explain me how i can compute line voltage when I have Ud and Uq in pyleecan
best regards,
faraz Mirali
@BonneelP

Hello,

Sorry for the late answer. The issue is Ld and Lq, for now we can only compute them if Id and Iq are set. If you want to set Ud Uq you will have to enforce Ld, Lq. There is an exemple here: Tests\Validation\Electrical\test_EEC_PWM.py

We are always looking for some help to work on the electrical module to add more flexibility to the models.

Best regards,
Pierre