API Reference¶

class
swat_em.datamodel.
datamodel
[source]¶ Provides a central place for all data. All analysis functions are connect with this class.

analyse_wdg
()[source]¶ Do a detailled analyses of the winding. This includes winding factors, detection of periodicity and symmetry, radial force modes and so on. Use the get_* functions for getting the results.

calc_num_basic_windings_t
()[source]¶ Calculates and returns the number of basic windings ‘t’ for the actual winding layout
 Returns
t – Periodicity for the winding layout
 Return type
integer

export_html_report
(fname=None)[source]¶ Returns a winding report.
 Parameters
fname (string) – file name for html file. If not given a file is created in the temp dir of the file system (the file name ist returned by this function)
 Returns
filnename – The file name of the htmlfile which is stored in tmp directory
 Return type
string

export_text_report
(fname)[source]¶ Export winding report as a text file.
 Parameters
fname (string) – file name

export_xlsx
(fname)[source]¶ Export the results to Excel xlsx file.
 Parameters
fname (string) – file name

genwdg
(Q, P, m, layers, w= 1, turns=1, empty_slots=0, analyse=True)[source]¶ Generates a winding layout and stores it in the datamodel
 Parameters
Q (integer) – number of slots
P (integer) – number of poles
m (integer) – number of phases
w (integer) – coil span (1 for tooth coils)
layers (integer) – number of coil sides per slot
turns (integer) – number of turns per coil
analyse (Bool) – If False the generated winding doesn’t get analysed
empty_slots (integer) –
Defines the number of empty slots (“dead coil winding”) 1: Choose number of empty slots automatically (the smallest
possible number is choosen)
0: No empty slots >0: Manual defined number of empty slots

get_MMF_harmonics
(threshold=False)[source]¶ Returns the harmonics of the MMF curve
 Parameters
threshold (float) – Relative threshold for cutting off small amplit>udes 0 < threshold <= 1.0
 Returns
nu (1D numpy array) – ordinal number (mechanical)
Cnu (1D numpy array) – amplitude corresponding to nu
phase (1D numpy array) – phaseangle of the harmonic corresponding to nu in range between pi and +pi

get_basic_characteristics
()[source]¶ Returns the basic charactericits of the winding as dictionary and a html string

get_double_linked_leakage
()[source]¶ Returns the coefficient of the double linkead leakage flux. This number is a measure of the harmonic content of the MMF in the airgap caused by the winding. As higher the number as higher the harmonics.
 Returns
sigma_d – coefficient of the double linkead leakage flux
 Return type
float

get_fundamental_windingfactor
()[source]¶ Returns the fundamental winding factors for each phase
 Returns
kw – windings factors, (one entry for each phase)
 Return type
list

get_is_symmetric
()[source]¶ Returns the symmetry of the winding
 Returns
is_symmetric – True if the winding is symmetric False if the winding is not symmetric
 Return type
Boolean

get_layers
()[source]¶ Returns the definition of the winding layout alternative to the ‘get_phases’ function. For every layer (with the length of the number of slots) there is a sublist which contains the phasenumber.
layers[0][0] contains the phase number for first layer and first slot layers[0][1] contains the phase number for first layer and second slot layers[0][Q1] contains the phase number for first layer and last slot layers[1][0] contains the phase number for second layer and first slot
 Returns
layers (numpy array) – winding layout
slayers (numpy array) – same as ‘layers’ but as string
layers_col (numpy array) – phase colors

get_lcmQP
()[source]¶ Returns the lowest common multiple of the slot number Q and the number of Poles. For permanentmagnet machines this value represents the first ordinal number for the cogging torque.
 Returns
lcmQP – Lowest common multiple lcm(Q, P)
 Return type
integer

get_num_phases
()[source]¶ Returns the number of phases m
 Returns
m – number of phases
 Return type
integer

get_num_polepairs
()[source]¶ Returns the number of polepairs p
 Returns
p – number of polepairs
 Return type
integer

get_num_series_turns
()[source]¶ Returns the number of turns in series per phase. If the number of coil sides per phase or number of turns per phase is not identically than a mean value of turns of all phases is returned.
 Returns
w – number of turns in series per phase
 Return type
number

get_num_slots
()[source]¶ Returns the number of slots Q
 Returns
Q – number of slots
 Return type
integer

get_parallel_connections
()[source]¶ Returns all possible parallel connections of the winding.
 Returns
a – Number of possible parallel connections
 Return type
list

get_periodicity_t
()[source]¶ Returns the periodicity of the winding. In most cases t = gcd(Q,p). For user defined windings this may be different.
 Returns
t – Number of periodic base windings
 Return type
integer

get_phasenames
()[source]¶ Returns the names of the phases as a series of characters ‘A’, ‘B’, ‘C’, … with length of the number of phases
 Returns
phasenames – names of the phases
 Return type
list
Examples
if there are m = 3 phases: >>> data.get_phasenames() [‘A’, ‘B’, ‘C’]

get_phases
(flatten=False)[source]¶ Returns the definition of the winding layout. For every phase there is a sublist which contains the slot number which are allocated to the phase. phases
phases[0] contains the slot numbers for the first phase phases[1] contains the slot numbers for the second phase phases[m1] contains the slot numbers for the last phase
 Returns
phases – winding layout
 Return type
list of lists

get_q
()[source]¶ Returns the number of slots per pole per phase.
 Returns
layers – number of slots per pole per phase
 Return type
Fraction

get_radial_force_modes
(num_modes=None)[source]¶ Returns the radial force modes caused by the winding. The results includes also the modes with a multiple of the phasenumber (which aren’t there if the machine is starconnected).
 Parameters
num_modes (integer) – Max. number of modes. If not given the default value from the config file is used
 Returns
MMK – radial force modes
 Return type
list

get_turns
()[source]¶ Returns the number of turns. If all coil sides has the same number of turns, the return value is a scalar. If every coil side has an individual number of turns, the return value consists of lists with the same shape as the winding layout (phases)
 Returns
turns – number of turns
 Return type
integer, float or list of lists

get_wdg_overhang
(optimize_overhang=False)[source]¶ Returns the winding overhang (connection of the coil sides).
 Parameters
optimize_overhang (Bool) – Optimize for short winding connection (experimental!)
 Returns
return – Winding connections for all phases, len = num_phases, format: [[(from_slot, to_slot), stepwidth, direction, (from_layer, to_layer)], [(), ()], …] from_to_slot: tuple of (from_slot (positive coil side), to_slot (negative coil side)) stepwidth: distance between from_slot to to_slot direction: winding direction (1: from left to right, 1: from right to left) layer: tuple of the layer of ‘from_slot’ and ‘to_slot’
 Return type
list

get_windingfactor_el
()[source]¶ Returns the windings factors with respect to the electrical ordinal numbers
 Returns
nu (numpy array) – ordinal numbers
kw (2D numpy array) – windings factors, (one column for each phase)

get_windingfactor_el_by_nu
(nu)[source]¶ Returns the windings factors with respect to the electrical ordinal numbers for the given ordinal number
 Parameters
nu (integer) – ordinal number
 Returns
kw – windings factors, (one column for each phase)
 Return type
1D numpy array

get_windingfactor_mech
()[source]¶ Returns the windings factors with respect to the mechanicl ordinal numbers
 Returns
nu (numpy array) – ordinal numbers
kw (2D numpy array) – windings factors, (one column for each phase)

get_windingfactor_mech_by_nu
(nu)[source]¶ Returns the windings factors with respect to the mechanical ordinal numbers for the given ordinal number
 Parameters
nu (integer) – ordinal number
 Returns
kw – windings factors, (one column for each phase)
 Return type
1D numpy array

load_from_file
(fname, idx_in_file=0)[source]¶ Load data from file.
 Parameters
fname (string) – file name

plot_MMK
(filename, res=None, phase=0, show=False)[source]¶ Generates a figure of the winding layout
 Parameters
filename (string) – filename with extension to save the figure
res (list) – Resolution for the figure in pixes for x and y direction example: res = [800, 600]
phase (float) – phase angle for the current system in electical degree in the range 0..360°
show (Bool) – If true the window pops up for interactive usage

plot_layout
(filename, res=None, show=False)[source]¶ Generates a figure of the winding layout
 Parameters
filename (string) – filename with extension to save the figure
res (list) – Resolution for the figure in pixes for x and y direction example: res = [800, 600]
show (Bool) – If true the window pops up for interactive usage

plot_overhang
(filename, res=None, show=False, optimize_overhang=False)[source]¶ Generates a figure of the winding layout
 Parameters
filename (string) – filename with extension to save the figure
res (list) – Resolution for the figure in pixes for x and y direction example: res = [800, 600]
show (Bool) – If true the window pops up for interactive usage
optimize_overhang (Bool) – If true swatem tries to identify shorter winding overhangs

plot_polar_layout
(filename, res=None, optimize_overhang=False, draw_poles=False, show=False)[source]¶ Generates a figure of the winding layout
 Parameters
filename (string) – filename with extension to save the figure
res (list) – Resolution for the figure in pixes for x and y direction example: res = [800, 600]
optimize_overhang (Bool) – If true swatem tries to identify shorter winding overhangs
draw_poles (Bool) – If true the poles of the rotor are drawn
show (Bool) – If true the window pops up for interactive usage

plot_star
(filename, res=None, ForceX=True, show=False)[source]¶ Generates a figure of the star voltage phasors
 Parameters
filename (string) – filename with extension to save the figure
res (list) – Resolution for the figure in pixes for x and y direction example: res = [800, 600]
ForceX (Bool) – If true the voltage phasors are rotated in such way, that the resulting phasor of the first phase matches the xaxis
show (Bool) – If true the window pops up for interactive usage

plot_windingfactor
(filename, res=None, mechanical=True, show=False)[source]¶ Generates a figure of the winding layout
 Parameters
filename (string) – filename with extension to save the figure
m (list) – Resolution for the figure in pixes for x and y direction example: res = [800, 600]
mechanical (Bool) – If true the winding factor is plotted with respect to the mechanical ordinal numbers. If false the electrical ordinal numbers are used
show (Bool) – If true the window pops up for interactive usage

set_machinedata
(Q=None, p=None, m=None, Qes=None)[source]¶ setting the machine data
 Parameters
Q (integer) – number of slots
p (integer) – number of pole pairs
m (integer) – number of phases

set_notes
(notes)[source]¶ Set additional notes for the winding
 Parameters
notes (string) – Some notes

set_num_polepairs
(p)[source]¶ Sets the number of pole pairs p
 Parameters
p (integer) – number of pole pairs

set_phases
(S, turns=1, w=None)[source]¶ setting the winding layout
 Parameters
S (list of lists) – winding layout for every phase, for example: S = [[1,2], [3,4], [5,6]]. This means there are 3 phases with phase 1 in in slot 1 and in slot 2 with negativ winding direction. For double layer windings there must be additional lists: S = [[[1, 4], [3, 6]], [[3, 6], [5, 2]], [[2, 5], [4, 1]]] Hint: [[[first layer], [second layer]], … ]
w (integer) – coil span (slots as unit)

set_turns
(turns)[source]¶ Sets the number of turns. If all coil sides has the same number of turns, the parameter should be an scalar. If every coil side has an individual number of turns, the parameter value have to consist of lists with the same shape as the winding layout (phases)
 Parameters
turns (integer, float or list of lists) – number of turns
