pyleecan.Classes.MagFEMM module

Method code available at https://github.com/Eomys/pyleecan/tree/master/pyleecan/Methods/Simulation/MagFEMM

class MagFEMM(Kmesh_fineness=1, Kgeo_fineness=1, type_calc_leakage=0, file_name='', FEMM_dict_enforced=- 1, is_get_meshsolution=False, is_save_meshsolution_as_file=False, is_sliding_band=True, transform_list=- 1, rotor_dxf=None, stator_dxf=None, import_file=None, is_close_femm=True, nb_worker=1, Rag_enforced=None, is_set_previous=True, is_fast_draw=True, is_calc_torque_energy=True, is_remove_slotS=False, is_remove_slotR=False, is_remove_ventS=False, is_remove_ventR=False, is_mmfs=True, is_mmfr=True, type_BH_stator=0, type_BH_rotor=0, is_periodicity_t=False, is_periodicity_a=False, angle_stator_shift=0, angle_rotor_shift=0, logger_name='Pyleecan.Magnetics', Slice_enforced=None, Nslices_enforced=None, type_distribution_enforced=None, is_current_harm=True, T_mag=20, is_periodicity_rotor=False, init_dict=None, init_str=None)[source]

Bases: Magnetics

Magnetic module: Finite Element model with FEMM

VERSION = 1
comp_flux_airgap(output, axes_dict, Is_val=None, Ir_val=None)

Build and solve FEMM model to calculate and store magnetic quantities

Parameters:
  • self (MagFEMM) – a MagFEMM object

  • output (Output) – an Output object

  • axes_dict ({Data}) – Dict of axes used for magnetic calculation

Returns:

out_dict

Dict containing the following quantities:
Brndarray

Airgap radial flux density (Nt,Na) [T]

Btndarray

Airgap tangential flux density (Nt,Na) [T]

Temndarray

Electromagnetic torque over time (Nt,) [Nm]

Phi_wind_statorndarray

Stator winding flux (qs,Nt) [Wb]

Phi_winddict

Dict of winding fluxlinkage with respect to Machine.get_lam_list_label (qs,Nt) [Wb]

meshsolution: MeshSolution

MeshSolution object containing magnetic quantities B, H, mu for each time step

Return type:

dict

get_path_save(output)

Return the path to save the FEMM simulation

Parameters:
  • self (MagFEMM) – a MagFEMM object

  • output (Output) –

    an Output object

    Returns

  • -------

  • save_path (str) – Path to save the FEMM simulation

solve_FEMM(femm, output, out_dict, FEMM_dict, sym, Nt, angle, Is, Ir, angle_rotor, is_close_femm, filename=None, start_t=0, end_t=None, Nmess=4)

Solve FEMM model to calculate airgap flux density, torque instantaneous/average/ripple values, flux induced in stator windings and flux density, field and permeability maps

Parameters:
  • self (MagFEMM) – A MagFEMM object

  • femm (_FEMMHandler) – Object to handle FEMM

  • output (Output) – An Output object

  • out_dict (dict) –

    Dict containing the following quantities to update for each time step:
    Brndarray

    Airgap radial flux density (Nt,Na) [T]

    Btndarray

    Airgap tangential flux density (Nt,Na) [T]

    Temndarray

    Electromagnetic torque over time (Nt,) [Nm]

    Phi_windlist of ndarray # TODO should it rather be a dict with lam label?

    List of winding flux with respect to Machine.get_lamlist (qs,Nt) [Wb]

  • FEMM_dict (dict) – Dict containing FEMM model parameters

  • sym (int) – Spatial symmetry factor

  • Nt (int) – Number of time steps for calculation

  • angle (ndarray) – Angle vector for calculation

  • Is (ndarray) – Stator current matrix (qs,Nt) [A]

  • Ir (ndarray) – Stator current matrix (qs,Nt) [A]

  • angle_rotor (ndarray) – Rotor angular position vector (Nt,)

  • is_close_femm (bool) – True to close FEMM handler in the end

  • filename (str) – Path to FEMM model to open

  • start_t (int) – Index of first time step (0 by default, used for parallelization)

  • end_t (int) – Index of last time step (Nt by default, used for parallelization)

Returns:

  • B (ndarray) – 3D Magnetic flux density for all time steps and each element (Nt, Nelem, 3) [T]

  • H (ndarray) – 3D Magnetic field for all time steps and each element (Nt, Nelem, 3) [A/m]

  • mu (ndarray) – Magnetic relative permeability for all time steps and each element (Nt, Nelem) []

  • mesh (MeshMat) – Object containing magnetic mesh at first time step

  • groups (dict) – Dict whose values are group label and values are array of indices of related elements

get_meshsolution(femm, FEMM_dict, save_path, j_t0, id_worker=0, is_get_mesh=False)

Load the mesh data and solution data. FEMM must be working and a simulation must have been solved.

Parameters:
  • self (MagFEMM) – a MagFEMM object

  • femm (FEMMHandler) – client to send command to a FEMM instance

  • save_path (str) – Full path to folder in which to save results

  • j_t0 (int) – time step index

  • id_worker (int) – worker index

  • is_get_mesh (bool) – True to load and create the mesh or not

Returns:

  • mesh (MeshMat) – Object containing magnetic mesh

  • B (ndarray) – 3D Magnetic flux density for each element (Nelem, 3) [T]

  • H (ndarray) – 3D Magnetic field for each element (Nelem, 3) [A/m]

  • mu (ndarray) – Magnetic relative permeability for each element (Nelem,1) []

  • groups (dict) – Dict whose values are group label and values are array of indices of related elements

get_path_save_fem(output)

Return the path to save the FEMM simulation

Parameters:
  • self (MagFEMM) – a MagFEMM object

  • output (Output) –

    an Output object

    Returns

  • -------

  • save_path (str) – Path to save the .fem file

solve_FEMM_parallel(femm, output, out_dict, FEMM_dict, sym, Nt, angle, Is, Ir, angle_rotor, filename)

Same as solve_FEMM including parallelization on several workers

Parameters:
  • self (MagFEMM) – A MagFEMM object

  • femm (FEMMHandler) – Object to handle FEMM

  • output (Output) – An Output object

  • out_dict (dict) –

    Dict containing the following quantities to update for each time step:
    Brndarray

    Airgap radial flux density (Nt,Na) [T]

    Btndarray

    Airgap tangential flux density (Nt,Na) [T]

    Temndarray

    Electromagnetic torque over time (Nt,) [Nm]

    Phi_wind_statorndarray

    Stator winding flux (qs,Nt) [Wb]

  • FEMM_dict (dict) – Dict containing FEMM model parameters

  • sym (int) – Spatial symmetry factor

  • Nt (int) – Number of time steps for calculation

  • angle (ndarray) – Angle vector for calculation

  • Is (ndarray) – Stator current matrix (qs,Nt) [A]

  • Ir (ndarray) – Stator current matrix (qs,Nt) [A]

  • angle_rotor (ndarray) – Rotor angular position vector (Nt,)

  • filename (str) – Path to FEMM model to open

Returns:

  • B (ndarray) – 3D Magnetic flux density for all time steps and each element (Nt, Nelem, 3) [T]

  • H (ndarray) – 3D Magnetic field for all time steps and each element (Nt, Nelem, 3) [A/m]

  • mu (ndarray) – Magnetic relative permeability for all time steps and each element (Nt, Nelem) []

  • mesh (MeshMat) – Object containing magnetic mesh at first time step

  • groups (dict) – Dict whose values are group label and values are array of indices of related elements

build_MS_sliced(MS_sliced, MS, axes_dict, Nslices, ii)

Build and solve FEMM model to calculate and store magnetic quantities

Parameters:
  • self (MagFEMM) – a MagFEMM object

  • output (Output) – an Output object

  • axes_dict ({Data}) – Dict of axes used for magnetic calculation

  • delta_xy (ndarray) – Rotor center position function of time

Returns:

out_dict

Dict containing the following quantities:
Brndarray

Airgap radial flux density (Nt,Na) [T]

Btndarray

Airgap tangential flux density (Nt,Na) [T]

Temndarray

Electromagnetic torque over time (Nt,) [Nm]

Phi_wind_statorndarray

Stator winding flux (qs,Nt) [Wb]

Phi_winddict

Dict of winding fluxlinkage with respect to Machine.get_lam_list_label (qs,Nt) [Wb]

meshsolution: MeshSolution

MeshSolution object containing magnetic quantities B, H, mu for each time step

Return type:

dict

save(save_path='', is_folder=False, type_handle_old=2, type_compression=0)

Save the object to the save_path

Parameters:
  • self – A pyleecan object

  • save_path (str) – path to the folder to save the object

  • is_folder (bool) – to split the object in different files: separate simulation machine and materials (json only)

  • type_handle_old (int) – How to handle old file in folder mode (0:Nothing, 1:Delete, 2:Move to “Backup” folder)

  • type_compression (int) – Available only for json, 0: no compression, 1: gzip

get_logger()

Get the object logger or its parent’s one

Parameters:

obj – A pyleecan object

Returns:

logger – Pyleecan object dedicated logger

Return type:

logging.Logger

compare(other, name='self', ignore_list=None, is_add_value=False)[source]

Compare two objects and return list of differences

as_dict(type_handle_ndarray=0, keep_function=False, **kwargs)[source]

Convert this object in a json serializable dict (can be use in __init__). type_handle_ndarray: int

How to handle ndarray (0: tolist, 1: copy, 2: nothing)

keep_functionbool

True to keep the function object, else return str

Optional keyword input parameter is for internal use only and may prevent json serializability.

copy()[source]

Creates a deepcopy of the object

property Kmesh_fineness

finner , < 1 : less fine)

Type:

float

Type:

global coefficient to adjust mesh fineness in FEMM (1

Type:

default , > 1

property Kgeo_fineness

finner , < 1 : less fine)

Type:

float

Type:

global coefficient to adjust geometry fineness in FEMM (1

Type:

default , > 1

property type_calc_leakage

0 no leakage calculation / 1 calculation using single slot

Type:

int

Min:

0

Max:

1

property file_name

Name of the file to save the FEMM model

Type:

str

property FEMM_dict_enforced

To enforce user-defined values for FEMM main parameters

Type:

dict

property is_get_meshsolution

To save FEA and mesh for latter post-procesing

Type:

bool

property is_save_meshsolution_as_file

To save FEA and mesh as h5 files to save memory

Type:

bool

property is_sliding_band

0 to desactivate the sliding band

Type:

bool

property transform_list

label (to select the surface), type (rotate or translate), value (alpha or delta)

Type:

list

Type:

List of dictionary to apply transformation on the machine surfaces. Key

property rotor_dxf

To use a dxf version of the rotor instead of build_geometry

Type:

DXFImport

property stator_dxf

To use a dxf version of the rotor instead of build_geometry

Type:

DXFImport

property import_file

To import an existing femm file

Type:

str

property is_close_femm

To close femm automatically after the simulation

Type:

bool

property nb_worker

To run FEMM in parallel (the parallelization is on the time loop)

Type:

int

property Rag_enforced

To enforce a different radius value for air-gap outputs

Type:

float

property is_set_previous

True set previous .ans result file in current .fem to use it as initialization and speed up calculation time

Type:

bool

property is_fast_draw

True to use the symetry of the lamination to draw the machine faster

Type:

bool

property is_calc_torque_energy

True to calculate torque from integration of energy derivate over rotor elements

Type:

bool