Browse by type
Python Tools to Model and Solve the problem of High speed Rotor Balancing.
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: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.
Use mybinder link to quickly navigate through examples with no installation required.
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.
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 |
hsbalance as string 'amplitude @ phase' where amplitude is in any desired unit
(micro - mils - mm/sec) and phase in degrees as measured by tachometer.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
convert_math_cart functionA = hs.convert_math_cart(A)
B = hs.convert_math_cart(B)
U = hs.convert_math_cart(U)
alpha = hs.Alpha() # Instantiate Alpha class
alpha.add(A=A, B=B, U=U)
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())
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hsbalace package provides (till now) Three types of optimization models:examples\.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.
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 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
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.
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.
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
$ claude mcp add Turbomachinery-Rotors-Balancing \
-- python -m otcore.mcp_server <graph>