MagFEMM (class)

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_mesh=False, is_save_FEA=False, is_sliding_band=True, transform_list=-1, rotor_dxf=None, stator_dxf=None, import_file=None, is_close_femm=True, nb_worker=1, is_remove_slotS=False, is_remove_slotR=False, is_remove_vent=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, init_dict=None, init_str=None)[source]

Bases: pyleecan.Classes.Magnetics.Magnetics

Magnetic module: Finite Element model with FEMM

VERSION = 1
comp_flux_airgap(output, axes_dict)

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]

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)

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_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,)

  • 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, 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

build_meshsolution(Nt, meshFEMM, Time, B, H, mu, groups)

Build the MeshSolution objets from FEMM outputs.

Parameters
  • self (MagFEMM) – a MagFEMM object

  • is_get_mesh (bool) – 1 to load the mesh and solution into the simulation

  • is_save_FEA (bool) – 1 to save the mesh and solution into a .json file

  • j_t0 (int) – Targeted time step

Returns

meshsol – a MeshSolution object with FEMM outputs at every time step

Return type

MeshSolution

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

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,)

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

save(save_path='', is_folder=False)

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

copy()

Return a copy of the class

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

as_dict()[source]

Convert this object in a json seriable dict (can be use in __init__)

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_mesh

To save FEA mesh for latter post-procesing

Type

bool

property is_save_FEA

To save FEA mesh and solution in .dat file

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 dictionnary 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