Electric Motors

Electric Motor Base Class

class gym_electric_motor.physical_systems.electric_motors.ElectricMotor(motor_parameter=None, nominal_values=None, limit_values=None, motor_initializer=None, initial_limits=None)[source]

Base class for all technical electrical motor models.

A motor consists of the ode-state. These are the dynamic quantities of its ODE. For example:

ODE-State of a DC-shunt motor: `` [i_a, i_e ] ``
  • i_a: Anchor circuit current

  • i_e: Exciting circuit current

Each electric motor can be parametrized by a dictionary of motor parameters, the nominal state dictionary and the limit dictionary.

Initialization is given by initializer(dict). It can be constant state value or random value in given interval. dict should be like: { ‘states’(dict): with state names and initital values

‘interval’(array like): boundaries for each state

(only for random init), shape(num states, 2)

‘random_init’(str): ‘uniform’ or ‘normal’ ‘random_params(tuple): mue(float), sigma(int)

Example initializer(dict) for constant initialization:

{ ‘states’: {‘omega’: 16.0}}

Example initializer(dict) for random initialization:

{ ‘random_init’: ‘normal’}

Parameters:
  • motor_parameter – Motor parameter dictionary. Contents specified for each motor.

  • nominal_values – Nominal values for the motor quantities.

  • limit_values – Limits for the motor quantities.

  • motor_initializer

    Initial motor states (currents) (‘constant’, ‘uniform’, ‘gaussian’ sampled from

    given interval or out of nominal motor values)

  • initial_limits – limits for of the initial state-value

CURRENTS = []

List of the motor currents names

Type:

CURRENTS(list(str))

CURRENTS_IDX = []

Indices for accessing all motor currents.

Type:

CURRENTS_IDX(list(int))

HAS_JACOBIAN = False

Parameter indicating if the class is implementing the optional jacobian function

VOLTAGES = []

List of the motor input voltages names

Type:

VOLTAGES(list(str))

electrical_jacobian(state, u_in, omega, *_)[source]

Calculation of the jacobian of each motor ODE for the given inputs / The motors ODE-System.

Overriding this method is optional for each subclass. If it is overridden, the parameter HAS_JACOBIAN must also be set to True. Otherwise, the jacobian will not be called.

Parameters:
  • state (ndarray(float)) – The motors state.

  • u_in (list(float)) – The motors input voltages.

  • omega (float) – Angular velocity of the motor

Returns:

[0]: Derivatives of all electrical motor states over all electrical motor states shape:(states x states) [1]: Derivatives of all electrical motor states over omega shape:(states,) [2]: Derivative of Torque over all motor states shape:(states,)

Return type:

Tuple(ndarray, ndarray, ndarray)

electrical_ode(state, u_in, omega, *_)[source]

Calculation of the derivatives of each motor state variable for the given inputs / The motors ODE-System.

Parameters:
  • state (ndarray(float)) – The motors state.

  • u_in (list(float)) – The motors input voltages.

  • omega (float) – Angular velocity of the motor

Returns:

Derivatives of the motors ODE-system for the given inputs.

Return type:

ndarray(float)

i_in(state)[source]
Parameters:

state (ndarray(float)) – ODE state of the motor

Returns:

List of all currents flowing into the motor.

Return type:

list(float)

property initial_limits

Returns: dict: nominal motor limits for choosing initial values

initialize(state_space, state_positions, **__)[source]

Initializes given state values. Values can be given as a constant or sampled random out of a statistical distribution. Initial value is in range of the nominal values or a given interval. Values are written in initial_states attribute

Parameters:
  • state_space (gymnasium.Box) – normalized state space boundaries (given by physical system)

  • state_positions (dict) – indices of system states (given by physical system)

property initializer

Returns: dict: Motor initial state and additional initializer parameter

property limits

Readonly motors limit state array. Entries are set to the maximum physical possible values in case of unspecified limits.

Returns:

Limits of the motor.

Return type:

dict(float)

property motor_parameter

Returns: dict(float): The motors parameter dictionary

property nominal_values

Readonly motors nominal values.

Returns:

Current nominal values of the motor.

Return type:

dict(float)

reset(state_space, state_positions, **__)[source]

Reset the motors state to a new initial state. (Default 0)

Parameters:
  • state_space (gymnasium.Box) – normalized state space boundaries

  • state_positions (dict) – indexes of system states

Returns:

The initial motor states.

Return type:

numpy.ndarray(float)