hsbalance package

IC_matrix module

class hsbalance.IC_matrix.Alpha(name: string = '')

Bases: object

Alpha: Influence Coefficient Matrix

Influence coefficient matrix is a representation of the change of vibration vector in a measuring point when putting a unit weight on a balancing plane.

add(direct_matrix: Optional[array] = None, A: Optional[array] = None, B: Optional[array] = None, U: Optional[array] = None, keep_trial: bool = False, name: str = '') None

Alpha Method to add new values for Alpha instance

Important: either the direct_matrix is needed or ALL of (A, B, U)

Parameters:
  • direct_matrix (Numpy ndarray) –

    M x N matrix rows where:

    M: Number of rows representing the measuring points

    N: Number of columns -> balancing planes

  • A (Numpy ndarray M x 1) – Initial vibration column vector

  • B (Numpy ndarray M) – Trial Mass Matrix

  • U – Trial weight row vector

  • keep_trial (bool, optional) – defaults to False true: Keeps the previous trial weight in every succeeding trials, It means the trial weights are not removed after their run.

  • name (str, optional) – Describes the Alpha matrix with a name, defaults to None

Raises:
  • IndexError – if direct_matrix is single dimensional.

  • CustomError – if direct_matrix rows is less than columns.

  • ValueError – if both direct_matrix and (A, B, U) were given.

  • CustomError – if A is not a column matrix.

  • CustomError – if U is not a row vector.

  • CustomError – if B dimensions does not match A and U

  • CustomError – if either direct_matrix or (A, B, U) were not passed as Numpy ndArray.

check(ill_condition_remove=False)
Method to check the alpha value
  • check the symmetrical of the matrix (check for square matrix only,

for square matrix it should be symmetric obeying the reciprocity law) * check for ill conditioned planes:

if for any reason two or more planes has independent readings for example [[1, 2 , 3], [2, 4, 6]] this is named as ill-conditioned planes as they does not carry new information from the system and considering them cause solution infiltration.

ill_condition_remove = True : remove the ill_condition planes after the check

load(file: str)

Method to load influence coefficient value

save(file: str)

Method to save influence coefficient values

property shape

returns shape of Influence coefficient matrix (no. Measuring Points, no. Balancing Planes)

class hsbalance.IC_matrix.Condition(name: string = '')

Bases: object

Docstring for conditions. Condition is defined as speed or load or operating condition that is concerned in the balancing process. Conditions class is meant to be used for creating multispeed-multi_condition It is designed to arrange the conditions speeds and loads in explicit way.

add(alpha: Alpha instance, A: initial_vibration numpy.array)

Method to add a new condition Args:

alpha: Alpha class instance A: Initial vibration column array -> numpy array

load(file: str)

Method to load condition instance.

save(file: str)

Method to save condition instance.

model module

class hsbalance.model.LMI(A: ~numpy.array, alpha: instance of Alpha class, conditions=None, weight_const={}, critical_planes={}, V_max=None, name='')

Bases: _Model

subclass of model solving using linear matrix inequality this is mainly to insert ‘lazy constraints’ Lazy constraints will relax the solution at certain planes (not to exceed certain vibration limit)

solve(solver=None)

solving the LMI model returns solution matrix W

class hsbalance.model.LeastSquares(A: ~numpy.array = None, alpha: instance of Alpha class = None, conditions=None, C=array([0.]), name='')

Bases: _Model

subclass of Model solving the model using Least squares method, The objective function is to minimize the least squares of residual vibration.

solve(solver='OLE')

Method to solve the model Args:

solver:’OLE’ Ordinary Least Squares method ‘Huber’: Uses Huber smoother to down estimate the outliers.

class hsbalance.model.Min_max(A: ~numpy.array, alpha: instance of Alpha class, conditions=None, weight_const={}, name='')

Bases: _Model

subclass of model: Solving the model using Minmax optimization method to minimize the maximum of residual_vibration.

solve(solver=None)

Method to solve the Minmax model

tools module

exception hsbalance.tools.CustomError

Bases: Exception

The class is used to raise custom expections

class hsbalance.tools.InfoFormatter(name: str, info_parameters: Iterable, level: int = 1)

Bases: object

Class to format info method of every class.

info()

return generator with the strings to be printed

hsbalance.tools.convert_matrix_to_cart(ALPHA_math)

docs: Convert influence coeffecient matrix ALPHA from mathematical expression form to cartesian form.

ALPHA_math:

list of lists with polar mathmematical expression ex . [[90@58, 21@140]

Returns:

np.dnarray with cartesian form

hsbalance.tools.convert_matrix_to_math(matrix)

inverse of convert_matrix_to_cart

hsbalance.tools.convert_to_cartesian(polar)

docs: Convert number from polar form to cartesian complex number. :inputs: polar: Complex number in polar form (modulus, phase in degrees)

ex.(12, 90) -> <class ‘tuple’>

output: Complex number in cartesian number ex. 12+23j

-> <class ‘complex’>

hsbalance.tools.convert_to_polar(cart)
docs: Convert complex number in the cartesian form

into polar form.

Inputs:

cart: Complex number in cartesian number ex. 12+23j

-> <class ‘complex’>

output: Complex number in polar form (modulus, phase in degrees)

ex.(12, 90) -> <class ‘tuple’>

hsbalance.tools.ill_condition(alpha)
hsbalance.tools.residual_vibration(ALPHA, W, A)

Calculate the residual vibration between ALPHA matrix and solution W with intial vibration A Args:

ALPHA : Influence coefficient matrix -> np.array A : Initial vibration column array -> np.array W : Solution balancing weight row vector -> np.array

Return:

residual_vibration column array -> np.array

hsbalance.tools.rmse(residual_vibration)

Calculate the root mean square error for residual_vibration column matrix subtract each residual vibration from zero and taking the square root of the summation, rounding the result to the fourth decimal point Args:

residual_vibration: numpy array

Return: RMSE deviated from 0