MCPcopy Index your code
hub / github.com/MagedMohamedTurk/Turbomachinery-Rotors-Balancing

github.com/MagedMohamedTurk/Turbomachinery-Rotors-Balancing @v0.5.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.4 ↗ · + Follow
114 symbols 345 edges 15 files 77 documented · 68% updated 2y agov0.5.4 · 2022-02-25★ 38

Browse by type

Functions 105 Types & classes 9
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Turbomachinery-Flexible-Rotors-Balancing

Python Tools to Model and Solve the problem of High speed Rotor Balancing.

Introduction

The purpose of this project is to solve the problem of turbomachinery rotor balancing when more than critical speed are required and where there are a large number of bearings.

hsbalance Package:

Downloads License: MIT pic pic Generic badge Generic badge
Binder

HSBALANCE package is a python tool-kit that enables field engineer to do rotor balancing job on large number of measuring and balancing planes. It facilitates testing various scenarios through applying different optimization methods and applying different constraints. The package takes advantage of object oriented programming which makes it easier to build, extend and maintain.
The package also make it possible to easily use the code in a notebook which is a great advantage to work freely, try different method of optimization and splitting for your case, get to compare results and RMS errors and even plot charts and diagrams.

Binder

Use mybinder link to quickly navigate through examples with no installation required.

Installation

To quickly use the package: 1. Optional create an isolated environment for python 3.8. (for Anaconda users e.g. $ conda create -n myenv python=3.8) 2. $ pip install hsbalance 3. Take a look at the notebooks in 'examples\' attached in the repo to see hsbalance in action.

Quick Example

Script can be found in examples\example_script.py

Import package
import hsbalance as hs

The example is taken from B&K document (https://www.bksv.com/media/doc/17-227.pdf) Table 2 for example 6.

Trial Mass Sensor 1 Sensor 2
None 170 mm/s @ 112 deg 53 mm/s @ 78 deg
1.15 g on Plane 1 235 mm/s @ 94 deg 58 mm/s @ 68 deg
1.15 g on Plane 2 185 mm/s @ 115 deg 77 mm/s @ 104 deg
  1. Stating Problem Data
    Vibration can be expressed in hsbalance as string 'amplitude @ phase' where amplitude is in any desired unit (micro - mils - mm/sec) and phase in degrees as measured by tachometer.
    The following nomenclature are taken from Goodman's paper. A: Initial Condition Matrix should be input as nested column vector (a list of a list) --> shape M x 1 B: Trial masses Runs Matrix should be input as nested column vector (list of lists) --> shape M x N
    U: Trial masses vector should be input as nested column vector (a list) --> Shape N X 1 Where
    M : Number of measuring points (number of sensors x number of balancing speeds)
    N : Number of balancing planes
A = [['170@112'], ['53@78']]  # --> Initial vibration conditions First Row in Table  above.  
B = [['235@94', '185@115'],  # --> Vibration at sensor 1 when trial masses were added at plane 1&2 (First column for both trial runs)  
     ['58@68', '77@104']]  # Vibration at sensor 2 when trial masses were added at plane 1&2 (Second column for both trial runs)  
U = ['1.15@0', '1.15@0']  # Trial masses 2.5 g at plane 1 and 2 consequently
  1. Convert from mathematical expression into complex numbers:
    using convert_math_cart function
A = hs.convert_math_cart(A)
B = hs.convert_math_cart(B)
U = hs.convert_math_cart(U)
  1. Create Influence Coefficient Matrix Alpha
alpha = hs.Alpha()  # Instantiate Alpha class
alpha.add(A=A, B=B, U=U)
  1. Now we have alpha instance and initial condition A; we can create a model
model_LeastSquares = hs.LeastSquares(A=A, alpha=alpha)
w = model_LeastSquares.solve() #  Solve the model and get the correction weights vector
# Calculate Residual vibration vector
residual_vibration = hs.residual_vibration(alpha.value, w, A)
# Calculate Root mean square error for model
RMSE = hs.rmse(residual_vibration)
# Convert w back into mathematical expression 
w = hs.convert_cart_math(w)
# print results
print(model_LeastSquares.info())

Output:


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MODEL
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MODEL TYPE
==================================================
LeastSquares
==================================================
End of MODEL TYPE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFLUENCE COEFFICIENT MATRIX
==================================================

++++++++++++++++++++++++++++++++++++++++
Influence Coefficient Matrix
++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++
Coefficient Values
==============================
                Plane 1        Plane 2
Sensor 1  78.433 @ 58.4  15.34 @ 145.3
Sensor 2   9.462 @ 10.2  32.56 @ 142.4
==============================
End of Coefficient Values
++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++
Initial Vibration
==============================
              Vibration
Sensor 1  170.0 @ 112.0
Sensor 2    53.0 @ 78.0
==============================
End of Initial Vibration
++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++
Trial Runs Vibration
==============================
               Plane 1        Plane 2
Sensor 1  235.0 @ 94.0  185.0 @ 115.0
Sensor 2   58.0 @ 68.0   77.0 @ 104.0
==============================
End of Trial Runs Vibration
++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++
Trial Masses
==============================
               Mass
Plane 1  1.15 @ 0.0
Plane 2  1.15 @ 0.0
==============================
End of Trial Masses
++++++++++++++++++++++++++++++++++++++++


==================================================
End of INFLUENCE COEFFICIENT MATRIX
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INITIAL VIBRATION
==================================================
              Vibration
Sensor 1  170.0 @ 112.0
Sensor 2    53.0 @ 78.0
==================================================
End of INITIAL VIBRATION
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SOLUTION
==================================================
        Correction Masses
Plane 1     1.979 @ 236.2
Plane 2     1.071 @ 121.8
==================================================
End of SOLUTION
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
RMSE
==================================================
0.0
==================================================
End of RMSE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1. As expected for when M = N, we can have an exact solution of the model and residual vibration and rmse comes to zero.
    The Real problem arises when M > N which is quite normal in large machines where two proximity installed in each bearing and number of bearings is high. Moreover, the number of balancing speeds can be up to 3 or 4 speeds (large machinery usually exceeds their first critical speeds). Recall that M = Number of sensors x number of speeds.
  2. In this case there is no exact solution and we are seeking for optimized solution that minimized the error.
  3. hsbalace package provides (till now) Three types of optimization models:
    a. Least Squares model: Minimize the square errors, this is the traditional method where we can get the best least accumulated error. The main disadvantage of this model is that it is very sensitive to outliers. This means that any faulty sensor in the system will lead to enormous error. Secondly, the model tried too hard to minimized the sum of errors. This can lead to very low residual vibration at one sensor and high vibration at another (can reach the alarm limit even!)
    b. MinMax: This model tries to minimize the maximum residual_vibration. This is beneficial to level of the residual vibrations to be almost equal preventing too-low too-high phenomena in the previous model.
    c. LMI: Linear Matrix Inequality model which allows lazy constraints.
    Lazy constraints mean that the model tries to relax the solution at certain sensors in order to get the best results at critical planes. This can be practically useful where not all planes should be treated equally. Sometimes, journal bearings with small clearance should be treated as critical planes (usually with low alarm and trip vibration limit), other planes can be considered non critical like casing sensors using accelerometers which we need to only to get the vibration below the alarm limit.
    For more details take a tour over the notebooks in examples\.

Performance Test:

I tested the package against injected random Influence coefficient matrices (Alpha) with N x N size. The output can be summarized in the following plot. plot

The graph was a test for the Least Squares model. It shows a good time performance of 800 x 800 matrix under 3 minutes.
The hardware and software for the machine running the test can be found data/test_conditions.txt
The code below is to generate the previous plot.


import time
from scipy.interpolate import make_interp_spline
import numpy as np
import matplotlib.pyplot as plt
from hsbalance import Alpha, model, tools



def test_performance(n):
    '''
    Test the performance of model time_wise.
    Args:
      n : dimension of influence coefficient matrix nxn.
    Output:
      t : time elapsed in the test rounded to 2 decimal.
    '''
    # Generate alpha matrix nxn dimension
    alpha = Alpha()
    real = np.random.uniform(0, 10, [n, n])
    imag = np.random.uniform(0, 10, [n, n])
    alpha.add(real + imag * 1j)
    # Generate initial condition A matrix nx1
    real = np.random.uniform(0, 10, [n, 1])
    imag = np.random.uniform(0, 10, [n, 1])
    A= real + imag * 1j
    # start timing
    start = time.time()
    # building model LeastSquare.
    w =  model.LeastSquares(A, alpha).solve()
    # implement the model to get run time.
    error = tools.residual_vibration(alpha.value, w, A)
    t = time.time() - start
    return round(t, 2)
performance_time = []
N = [2, 10, 50, 100, 200, 400, 600, 800]
for n in N:
    performance_time.append(test_performance(n))
print(N, performance_time)
spline = make_interp_spline(N, performance_time)
x = np.linspace(min(N), max(N), 500)
y  = spline(x)
plt.plot(x, y, label="Performace Test")
plt.xlabel('N (dimension of a Squared Influence Coeffecient Matrix)')
plt.ylabel('Time (seconds)')
plt.title('Performance Test of LeastSquares model')
plt.show()

The Rotor Balancing Module

The original attempt by me was to create a single python module that takes user variables and give results in an easy way that the balancing personnel does not need heavy knowledge in programming or python language.
This module is still available in .\Rotor_Balance_Module\, in order to use it: 1. Clone the repo to your local machine.
$ git clone https://github.com/MagedMohamedTurk/Turbomachinery-Rotors-Balancing 2. $ cd Rotor_Balance_Module 3. Optional create an isolated environment for python 3.8. (for Anaconda users e.g. $ conda create -n myenv python=3.8) 4. Installed required packages (cvxpy - panadas - click)
$ pip install -r requirement.txt 5. Run the program: $ python -m Rotor_Balanceing

Describing the problem

Back to Basics

Balancing simply is to bring the center of mass of a rotating component to its center of rotation.

Every rotating component such as impellers, discs of a motor, turbine, or compressor has a center of gravity in which the mass is distributed, and it has a center of rotation which is the line between their bearings. At the manufacturing phase, they never coincide. But why?
Simple answer: it's too expensive to machine each component to have the same centreline of mass and rotation. Second, bearings and impellers are usually made by different manufacturers at different places. However, even though the equipment is produced by the same company, their installation setup impacts the balance and thus the center of rotation of the equipment.

Unbalance problem

Why should we be concerned about unbalanced rotors?
It generates large centrifugal forces on the rotor and bearings, resulting in high stresses on the bearings and other rotating parts of the machine. They lead to premature failure! Unplanned shutdowns happen, high-risk damages endanger lives and assets.

Flexible Rotors

To increase efficiency, larger machines are often designed with longer shafts and multiple stages, along with higher rotational speeds. As a result, machines are running above their first or second critical levels.
Failure may occur if the machine is run at a critical speed. We can all relate to the Tacoma Narrows Bridge incident.
Two measures are necessary to overcome such a problem. First, to pass the cr

Core symbols most depended-on inside this repo

Shape

Function 70
Method 35
Class 9

Languages

Python100%

Modules by API surface

src/hsbalance/model.py24 symbols
Rotor_Balance_module/Rotor_Balancing.py18 symbols
src/hsbalance/CI_matrix.py16 symbols
test/test_model.py15 symbols
src/hsbalance/tools.py15 symbols
test/test_ALPHA.py10 symbols
test/test_tools.py7 symbols
test/test_WLS.py5 symbols
test/test_splitting.py1 symbols
test/test_minmax.py1 symbols
test/test_LSE.py1 symbols
test/test_LMI.py1 symbols

For agents

$ claude mcp add Turbomachinery-Rotors-Balancing \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page