pymgrit.induction_machine package

Submodules

pymgrit.induction_machine.grid_transfer_machine module

Grid Transfer class for the induction machine model “im_3kW”. (https://gitlab.onelab.info/doc/models/-/wikis/Electric-machines)

For more details see: https://arxiv.org/abs/1912.03106

Interpolation: standard finite element interpolation Restriction: injection

class pymgrit.induction_machine.grid_transfer_machine.GridTransferMachine(coarse_grid, fine_grid, path_meshes)

Bases: pymgrit.core.grid_transfer.GridTransfer

Grid Transfer class for the induction machine im_3kW Interpolation: standard finite element interpolation Restriction: injection

interpolation(u: pymgrit.induction_machine.vector_machine.VectorMachine) pymgrit.induction_machine.vector_machine.VectorMachine

Interpolation

Parameters

u – approximate solution vector

Returns

input solution vector u interpolated to a fine grid

restriction(u: pymgrit.induction_machine.vector_machine.VectorMachine) pymgrit.induction_machine.vector_machine.VectorMachine

Restriction

Parameters

u – approximate solution vector

Returns

input solution vector u restricted to a coarse grid

pymgrit.induction_machine.helper module

Helper functions for the induction machine model “im_3kW”. (https://gitlab.onelab.info/doc/models/-/wikis/Electric-machines)

pymgrit.induction_machine.helper.cart2pol(x: numpy.ndarray, y: numpy.ndarray) numpy.ndarray

Transform Cartesian coordinates to polar

Parameters
  • x – x-coordinates

  • y – y-coordinates

Returns

polar coordinates

pymgrit.induction_machine.helper.check_version(msh_file: str)
pymgrit.induction_machine.helper.compute_data(pre: str, msh: str, new_unknown_start: int, inner_r: float = 0.04568666666666668) Dict

Compute grid information

Parameters
  • pre – Pre file of mesh

  • msh – Mesh

  • new_unknown_start

  • inner_r – Radius machine

Returns

pymgrit.induction_machine.helper.compute_mesh_transfer(values: numpy.ndarray, vtx: numpy.ndarray, wts: numpy.ndarray, dif: int, dif2: int, fill_value: float = nan) numpy.ndarray

Compute mesh transfer

Parameters
  • values – vector to transform

  • vtx – vertices

  • wts – weights

  • dif – difference for boundary conditions

  • dif2 – difference for boundary conditions

  • fill_value – fill value

Returns

input values transfered to another grid

pymgrit.induction_machine.helper.get_arrays(nodes_dict: Dict, lines_dict: Dict, elements_dict: Dict, inner_r: float, unknown_to_cor: Dict, boundary: List, new_start: int = 0) Dict

Compute mapping between grids

Parameters
  • nodes_dict – grid points

  • lines_dict – lines

  • elements_dict – elements

  • inner_r – radius machine

  • unknown_to_cor – mapping between unknown and grid points

  • boundary – boundary elements

  • new_start – new unknowns

Returns

grid information

pymgrit.induction_machine.helper.get_elements(file: str) Tuple[Dict, Dict, Dict, Dict]

Get elements from file

Parameters

file – mesh file

Returns

elements

pymgrit.induction_machine.helper.get_nodes(file: str) Tuple[Dict, Dict]

Get nodes from file

Parameters

file – Mesh file

Returns

Grid points

pymgrit.induction_machine.helper.get_preresolution(file: str) int

Read pre file and returns number of unknowns

Parameters

file – pre file

Returns

number of unknowns

pymgrit.induction_machine.helper.get_values_from(file: str) numpy.ndarray

Read values from file

Parameters

file – result file

Returns

result value(s)

pymgrit.induction_machine.helper.getdp_read_resolution(file: str, num_dofs: int) Tuple[numpy.ndarray, numpy.ndarray]

Read unknown values from file

Parameters
  • file – result file

  • num_dofs – number of unknowns

Returns

timepoint(s) and value(s)

pymgrit.induction_machine.helper.interp_weights(xyz: numpy.ndarray, uvw: numpy.ndarray, d: int = 2, tol: float = 0.1) Tuple[numpy.ndarray, numpy.ndarray]

Interpolation between two grids

Parameters
  • xyz – coarse grid points

  • uvw – fine grid points

  • d – dimensions

  • tol – tolerance

Returns

vertices and weights

pymgrit.induction_machine.helper.interpolation_factors(data_coarse: Dict, data_fine: Dict) Dict

Compute the interpolation factor for each point by two given grids

Parameters
  • data_coarse

  • data_fine

Returns

pymgrit.induction_machine.helper.is_numeric(obj) bool

Test if obj is numeric

Parameters

obj – test object

Returns

is numeric

pymgrit.induction_machine.helper.pre_file(file: str) Tuple[Dict, Dict, List]

Read pre file and return mapping between nodes

Parameters

file – pre file

Returns

mapping between unknowns and grid points

pymgrit.induction_machine.helper.set_resolution(file: str, t_start: float, u_start: numpy.ndarray, num_dofs: int) None

Create resolution file

Parameters
  • file – file

  • t_start – time associated with the input approximate solution u_start

  • u_start – approximate solution for the input time t_start

  • num_dofs – number of unknowns

pymgrit.induction_machine.induction_machine module

Application class for the model ‘im_3_kW’ of an induction machine https://gitlab.onelab.info/doc/models/-/wikis/Electric-machines

class pymgrit.induction_machine.induction_machine.InductionMachine(*args, **kwargs)

Bases: pymgrit.core.application.Application

Simulating an induction machine using the model ‘im_3_kW’ from https://gitlab.onelab.info/doc/models/-/wikis/Electric-machines

run_getdp(u_start: numpy.ndarray, t_start: float, t_stop: float) Dict

Calls getdp

Parameters
  • u_start – approximate solution for the input time t_start

  • t_start – time associated with the input approximate solution u_start

  • t_stop – time to evolve the input approximate solution to

Returns

approximate solution at input time t_stop

step(u_start: pymgrit.induction_machine.vector_machine.VectorMachine, t_start: float, t_stop: float) pymgrit.induction_machine.vector_machine.VectorMachine

Time integration routine

Parameters
  • u_start – approximate solution for the input time t_start

  • t_start – time associated with the input approximate solution u_start

  • t_stop – time to evolve the input approximate solution to

Returns

approximate solution at input time t_stop

pymgrit.induction_machine.mgrit_machine module

MGRIT optimized for the induction machine model “im_3kW”. (https://gitlab.onelab.info/doc/models/-/wikis/Electric-machines)

class pymgrit.induction_machine.mgrit_machine.MgritMachine(*args, **kwargs)

Bases: pymgrit.core.mgrit.Mgrit

MGRIT optimized for the getdp induction machine

nested_iteration() None

Generates an initial approximation on the finest grid by solving the problem on the coarsest grid and interpolating the approximation to the finest level.

Performs nested iterations with a sin rhs

pymgrit.induction_machine.mgrit_machine_conv_jl module

MGRIT optimized for the induction machine model “im_3kW”. (https://gitlab.onelab.info/doc/models/-/wikis/Electric-machines) Using joule losses as stopping criteria

class pymgrit.induction_machine.mgrit_machine_conv_jl.MgritMachineConvJl(compute_f_after_convergence: bool, *args, **kwargs)

Bases: pymgrit.core.mgrit.Mgrit

MGRIT optimized for the getdp induction machine

convergence_criteria(iteration: int) None

Maximum norm of all C-points

Parameters

iteration – iteration number

iteration(lvl: int, cycle_type: str, iteration: int, first_f: bool)

MGRIT iteration on level lvl

Parameters
  • lvl – MGRIT level

  • cycle_type – Cycle type

  • iteration – Number of current iteration

  • first_f – F-relaxation at the beginning

nested_iteration() None

Generates an initial approximation on the finest grid by solving the problem on the coarsest grid and interpolating the approximation to the finest level.

Performs nested iterations with a sin rhs

solve() dict

Driver function for solving the problem using MGRIT.

Performs MGRIT iterations until a stopping criterion is fulfilled or the maximum number of iterations is reached.

Post operation for computing solution at F-points

Returns

dictionary with residual history, setup time, and solve time

pymgrit.induction_machine.vector_machine module

Vector for the induction machine model “im_3kW”. (https://gitlab.onelab.info/doc/models/-/wikis/Electric-machines)

class pymgrit.induction_machine.vector_machine.VectorMachine(u_front_size: int, u_middle_size: int, u_back_size: int)

Bases: pymgrit.core.vector.Vector

Vector for the induction machine im_3kW

clone()

Initial solution vector with all zeros :rtype: object

clone_rand() pymgrit.induction_machine.vector_machine.VectorMachine

Initialize vector object with random values

Return type

vector object with random values

clone_zero() pymgrit.induction_machine.vector_machine.VectorMachine

Initialize vector object with zeros

Return type

vector object with zero values

get_values() numpy.ndarray

Get vector data

Returns

values of vector object

norm() float

Norm of a vector object

Returns

2-norm of vector object

pack() List

Pack data

Returns

values of vector object

set_values(values: numpy.ndarray, jl: float, ia: float, ib: float, ic: float, ua: float, ub: float, uc: float, tr: float) None

Set vector data

unpack(values: List) None

Unpack and set data

Parameters

values – values for vector object

Module contents