pyleecan.Classes.Machine module

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

class Machine(frame=- 1, shaft=- 1, name='default_machine', desc='', type_machine=1, logger_name='Pyleecan.Machine', init_dict=None, init_str=None)[source]

Bases: FrozenClass

Abstract class for machines

VERSION = 1
build_geometry(sym=1, alpha=0, delta=0)

Build the geometry of the machine

Parameters:
  • self (Machine) – Machine object

  • sym (int) – Symmetry factor (1= full machine, 2= half of the machine…)

  • alpha (float) – Angle for rotation [rad]

  • delta (complex) – Complex value for translation

Returns:

surf_list – list of surfaces needed to draw the lamination

Return type:

list

check()

Check that the Machine object is correct

Parameters:

self – A Machine object

Return type:

None

Raises:
comp_angle_rotor_initial()

Set rotor initial angle as 0

Parameters:

self (Machine) – A: Machine object

Returns:

angle_rotor_initial – rotor initial angle set to 0 [rad]

Return type:

float

comp_desc_dict()

Compute a dictionary with the main parameters/output of the machine

Parameters:

self (Machine) – A Machine object

Returns:

desc_dict – list of dictionary containing the main parameters of the machine

Return type:

list

comp_length_airgap_active()

Compute the airgap active length

Parameters:

self (Machine) – A Machine object

Returns:

Lgap – Airgap active length [m]

Return type:

float

comp_masses()

Compute the masses of the machine - Mmach : Mass total [kg] - Mfra : Mass of the Frame [kg] - Msha : Mass of the Shaft [kg] - Mrot : Mass dictionary of the rotor masses - Msta : Mass dictionary of the stator masses

Parameters:

self (Machine) – A Machine object

Returns:

M_dict – A dictionary of the Machine’s masses (Mmach, Msha, Mfra, Mrot, Msta) [kg]

Return type:

dict

comp_output_geo()

Compute the main geometry output

Parameters:

self (Machine) – A Machine object

Returns:

output – Main geometry output of the machine

Return type:

OutGeo

comp_Rgap_mec()

Returns the radius of the center of the mecanical airgap

Parameters:

self (Machine) – Machine object

Returns:

Rgap_mec – Radius of the center of the mecanical airgap [m]

Return type:

float

comp_periodicity_spatial()

Compute the (anti)-periodicities of the machine in space domain

Parameters:

self (Machine) – A Machine object

Returns:

  • pera (int) – Number of spatial periodicities of the machine over 2*pi

  • is_apera (bool) – True if an anti-periodicity is possible after the periodicities

comp_width_airgap_mag()

Compute the magnetic airgap (distance beetween the two Lamination)

Parameters:

self (Machine) – A Machine object

Returns:

mag_gap – The magnetic airgap [m]

Return type:

float

comp_width_airgap_mec()

Compute the mechanical airgap (mag_airgap - magnet or ring)

Parameters:

self (Machine) – Machine object

Returns:

mec_gap – The mechanical airgap [m]

Return type:

float

get_material_dict(path='self', is_unique=False)

Get the dict of materials contained in a Machine

Parameters:
  • self (Machine) – A Machine object

  • path (str) – prefix to use for material object path

  • is_unique (bool) – True each material will only one in the dict

Returns:

materials – dict of materials contained in the object (key=”obj path” like self.mat_type)

Return type:

dict

get_polar_eq()

Returns a polar equivalent of the machine

Parameters:

self (Machine) – Machine object

Returns:

polar_eq – The polar equivalent of the machine

Return type:

Machine

plot(fig=None, ax=None, sym=1, alpha=0, delta=0, is_edge_only=False, edgecolor=None, is_add_arrow=False, comp_machine=None, comp_legend=None, is_show_fig=True, save_path=None, win_title=None, fig_title=None, is_max_sym=False, is_clean_plot=False, is_winding_connection=False)

Plot the Machine in a matplotlib fig

Parameters:
  • self (Machine) – A Machine object

  • fig (Matplotlib.figure.Figure) – existing figure to use if None create a new one

  • ax (Matplotlib.axes.Axes object) – Axis on which to plot the data

  • sym (int) – Symmetry factor (1= full machine, 2= half of the machine…)

  • alpha (float) – Angle for rotation [rad]

  • delta (complex) – Complex value for translation

  • is_edge_only (bool) – To plot transparent Patches

  • edgecolor – Color of the edges if is_edge_only=True

  • comp_machine (Machine) – A machine to plot in transparency on top of the self machine

  • comp_legend (str) – Name of the compare machine to set in the legeng (comp_machine != None)

  • is_show_fig (bool) – To call show at the end of the method

  • save_path (str) – full path including folder, name and extension of the file to save if save_path is not None

  • win_title (str) – Name of the Window (default machine name)

  • fig_title (str) – Name of the figure (default machine name)

  • is_max_sym (bool) – True: overwrite sym parameter with max periodicity of the machine

  • is_clean_plot (bool) – True to remove title, legend, axis (only machine on plot with white background)

  • is_winding_connection (bool) – True to display winding connections

Returns:

  • fig (Matplotlib.figure.Figure) – Figure containing the plot

  • ax (Matplotlib.axes.Axes object) – Axis containing the plot

plot_anim_rotor(Nframe, Tanim, Nrot=1, is_loop=True)

Plot the machine with an animation of the rotor (Internal Rotor for now ?)

Parameters:
  • self (Machine) – Machine object

  • Nframe (int) – Number of frame for the animation

  • Tanim (float) – Duration of the animation [ms]

  • Nrot (float) – Number of rotation

  • is_loop (bool) – True to activate the loop animation

get_lam_list(is_int_to_ext=True, key=None)

Returns the ordered list of lamination of the machine

Parameters:
  • self (Machine) – Machine object

  • is_int_to_ext (bool) – true to order the list from the inner lamination to the extrenal one

  • key (string) – keyword to return only stator or rotor laminations, accepted values are “Stator” or “Rotor” default None to return all

Returns:

lam_list – Ordered lamination list, for abstract Machine objects list will be empty

Return type:

list

get_lam_list_label()

Returns the ordered (from internal to external) list of lamination labels corresponding to machine.get_lam_list(is_int_to_ext=True, key=None)

Parameters:

self (Machine) – Machine object

Returns:

label_list – Ordered lamination list, for abstract Machine objects list will be empty

Return type:

list

get_lam_by_label(label)

Returns the lamination by its labels. Accepted labels are ‘Stator-X’ and ‘Rotor-X’ with X the number of the lamination starting with 0. For convenience also ‘Stator’ or ‘Rotor’ are allowed here to get respective first stator or rotor lamination.

Parameters:
  • self (Machine) – Machine object

  • label (string) – label of the lamination to return

Returns:

lam – Lamination with the given label

Return type:

Lamination

get_lam_index(label)

Returns list index of the lamination with the given label corresponding to machine.get_lam_list(is_int_to_ext=True, key=None). For convenience label ‘Stator’ or ‘Rotor’ are allowed here to get respective first stator or rotor lamination.

Parameters:
  • self (Machine) – Machine object

  • label (str) – Label of the lamination

Returns:

index – List index of the lamination, if label doesn’t exists index is None

Return type:

int

get_pole_pair_number()

Returns the number of pole pairs of the machine

Parameters:

self (Machine) – Machine object

Returns:

p – Pole pair number of the machine

Return type:

int

set_pole_pair_number(p)

Set the number of pole pairs of the machine

Parameters:
  • self (Machine) – Machine object

  • p (int) – Pole pair number of the machine

comp_periodicity_time(slip=0)

Compute the (anti)-periodicities of the machine in time domain

Parameters:
  • self (Machine) – A Machine object

  • slip (float) – Rotor asynchronous slip

Returns:

  • pert_S (int) – Number of periodicities of the machine over time period (p/felec by default if Nrev is None) in static referential

  • is_apert_S (bool) – True if an anti-periodicity is possible after the periodicities (in static referential)

  • pert_R (int) – Number of periodicities of the machine over time period (p/felec by default if Nrev is None) in rotating referential

  • is_apert_R (bool) – True if an anti-periodicity is possible after the periodicities (in rotating referential)

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 frame

Machine’s Frame

Type:

Frame

property shaft

Machine’s Shaft

Type:

Shaft

property name

Name of the machine

Type:

str

property desc

Machine description

Type:

str

property type_machine

Integer to store the machine type (for the GUI, should be replaced by a test of the object type)

Type:

int

property logger_name

Name of the logger to use

Type:

str