/
BearingMaster.py
1434 lines (1348 loc) · 52.2 KB
/
BearingMaster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
.::::.
.::::::::.
:::::::::::
..:::::::::::'
'::::::::::::'
.::::::::::
'::::::::::::::..
..::::::::::::.
``::::::::::::::::
::::``:::::::::' .:::.
::::' ':::::' .::::::::.
.::::' :::: .:::::::'::::.
.:::' ::::: .:::::::::' ':::::.
.::' :::::.:::::::::' ':::::.
.::' ::::::::::::::' ``::::.
...::: ::::::::::::' ``::.
````':. ':::::::::' ::::..
'.:::::' ':'````..
"""
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018-10-21 16:50
# @Author : Peter.Wong
# @File : BearingStrength.py
import os
import sys
import time
from math import cos, acos, sin, tan, asin
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox, QFileDialog
from matplotlib import pyplot as plt
from numpy import arange, array, lexsort, zeros, append
from scipy.optimize import fsolve
from scipy.special import ellipk, ellipe
from pandas import read_excel
from QT import MasterMain
MasterWindow = MasterMain.Ui_MainWindow
def cal_cp(Dw, alpha0, Dpw, ri, re, Ep, ve, tol=0.001):
"""
calculation of the spring constant cp, acc. to ISO 16218 Function 11.
Args:
tol: tolerance for convergence
Dw: diameter of the ball
alpha0: initial contact angle
Dpw: pitch diameter of the bearing
ri: cross-sectional raceway groove radius, inner
re: cross-sectional raceway groove radius, outer
Ep: modulus of elasticity
ve: poisson's ratio
Returns:
cp: float
"""
gamma = Dw * cos(alpha0) / Dpw
# 内外圈曲率和
rho_i = 2 / Dw * (2 + gamma / (1 - gamma) - Dw / 2 / ri)
rho_e = 2 / Dw * (2 - gamma / (1 + gamma) - Dw / 2 / re)
# 内外圈曲率差
Fip = (gamma / (1 - gamma) + Dw / 2 / ri) / (2 + gamma / (1 - gamma) - Dw / 2 / ri)
Fep = (-gamma / (1 + gamma) + Dw / 2 / re) / (2 - gamma / (1 + gamma) - Dw / 2 / ri)
for k in arange(0, 1, 0.001): # 内圈迭代求解
if k == 0:
chi = float("inf")
else:
chi = 1 / k
M = 1 - 1 / chi ** 2
# 第一类和第二类椭圆积分
Ki = ellipk(M)
Ei = ellipe(M)
Fp = 1 - 2 / (chi ** 2 - 1) * (Ki / Ei - 1)
if abs((Fp - Fip) / Fp) < tol:
chi_i = chi
break
else:
pass
for k in arange(0, 1, 0.001): # 外圈迭代求解
if k == 0:
chi = float("inf")
else:
chi = 1 / k
M = 1 - 1 / chi ** 2
# 第一类和第二类椭圆积分
Ke = ellipk(M)
Ee = ellipe(M)
Fp = 1 - 2 / (chi ** 2 - 1) * (Ke / Ee - 1)
if abs((Fp - Fep) / Fp) < tol:
chi_e = chi
break
else:
pass
return (
1.48
* Ep
/ (1 - ve ** 2)
* (
(
Ki * (rho_i / chi_i ** 2 / Ei) ** (1 / 3)
+ Ke * (rho_e / chi_e ** 2 / Ee) ** (1 / 3)
)
)
** (-1.5)
)
def cal_fc(index, alpha):
"""
calculation of the fc acc. to ISO 281 Table 4.
# only supports interpolation calculation at the same angle,
the interpolation for angel between 45 and 60 need to be updated.
# no error check functions.
Args:
index: float, Dw*cos(alpha)/Dpw
alpha: float, initial contact angel.
Returns:
fc, float.
if error occurred, return 'None'
"""
arges = arange(0.01, 0.32, 0.01)
a_45 = (
42.1,
51.7,
58.2,
63.3,
67.3,
70.7,
73.5,
75.9,
78,
79.7,
81.1,
82.3,
83.3,
84.1,
84.7,
85.1,
85.4,
85.5,
85.5,
85.4,
85.2,
84.9,
84.5,
84,
83.4,
82.8,
82,
81.3,
80.4,
79.6,
)
a_60 = (
39.2,
48.1,
54.2,
58.9,
62.6,
65.8,
68.4,
70.7,
72.6,
74.2,
75.5,
76.6,
77.5,
78.3,
78.8,
79.2,
79.5,
79.6,
79.6,
79.5,
)
a_75 = (37.3, 45.9, 51.7, 56.1, 59.7, 62.7, 65.2, 67.3, 69.2, 70.7)
for i, k in enumerate(arges):
if k <= index < arges[i + 1]:
if alpha == acos(-1) / 4:
return (index - k) * (a_45[i + 1] - a_45[i]) / (
arges[i + 1] - arges[i]
) + a_45[i]
elif alpha == acos(-1) / 3:
return (index - k) * (a_60[i + 1] - a_60[i]) / (
arges[i + 1] - arges[i]
) + a_60[i]
elif alpha == 75 * acos(-1) / 180:
return (index - k) * (a_75[i + 1] - a_75[i]) / (
arges[i + 1] - arges[i]
) + a_75[i]
else:
with open("ErrorLog.txt", "a") as f:
f.write(
time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()))
+ "\n"
)
f.write(
"Errors occurred during the calculation of coefficient fc, check please."
)
f.close()
return None
else:
pass
with open("ErrorLog.txt", "a") as f:
f.write(time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())) + "\n")
f.write(
"Errors occurred during the calculation of coefficient fc, check please."
)
f.close()
return None
def cal_ca(alpha, Z, Dw, gamma, bm=1.3):
"""
calculation of the basic dynamic axial load rating according to ISO281 chapter 6.1.
pares:
fc: float
alpha: float, initial contact angel
Z: int, number of rolling elements
Dw: float, nominal ball diameter
return:
Ca: float, basic dynamic axial load rating
"""
fc = cal_fc(gamma, alpha)
if Dw <= 25.4:
return [
bm * fc * Z ** (2 / 3) * Dw ** 1.8
if alpha == 90
else bm * fc * Z ** (2 / 3) * Dw ** 1.8 * cos(alpha) ** 0.7 * tan(alpha)
][0]
else:
return [
3.647 * bm * fc * Z ** (2 / 3) * Dw ** 1.4
if alpha == acos(-1) / 2
else 3.647
* bm
* fc
* Z ** (2 / 3)
* Dw ** 1.4
* cos(alpha) ** 0.7
* tan(alpha)
][0]
def cal_load_fre(arrays):
"""
calculation of the equivalent load and frequency
Args:
arrays: [64,2], component and rad of the load
Returns:
array: Mx Fre_Mx -Mx Fre_-Mx N
"""
pi = acos(-1)
# 将数组从小(负)到大排序
# array_sorted = arrays.T[lexsort(arrays[::-1, :])].T
array_sorted = arrays.T[lexsort(arrays[::-1, :])]
load = array_sorted[0]
rad = array_sorted[1]
# 统计载荷值中为负的个数
neg_pin = 0
for i in load:
if i < 0:
neg_pin += 1
n = [x / (2 * pi) for x in rad] # 对应参考文献[1]中的'n'
N_neg = sum(n[:neg_pin]) # 对应参考文献[1]中的'负N'
N_pos = sum(n[neg_pin:]) # 对应参考文献[1]中的'正N'
N = N_neg + N_pos
sum_frequency_neg = N_neg / N # 对应参考文献[1]中的'负frequency'
sum_frequency_pos = N_pos / N # 对应参考文献[1]中的'正frequency'
load_3_n = [(load[x] ** 3) * n[x] for x in range(64)] # 对应参考文献[1]中的'Mx^3*n'等
sum_load_3_n_neg = sum(load_3_n[:neg_pin]) # 对应参考文献[1]中的'sum(Mx^3*n)'等
sum_load_3_n_pos = sum(load_3_n[neg_pin:])
eqv_load_neg = -(
(-sum_load_3_n_neg / N_neg) ** (1 / 3)
) # sum_load_3_n_neg为负值,python中无法直接为负值进行开根号并返回浮点数(返回复数)
eqv_load_pos = (sum_load_3_n_pos / N_pos) ** (1 / 3)
return [
eqv_load_pos,
eqv_load_neg,
sum_frequency_pos,
sum_frequency_neg,
N,
]
class Main(QtWidgets.QMainWindow, MasterWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
MasterWindow.__init__(self)
self.setupUi(self)
self.setWindowIcon(
QtGui.QIcon(r"D:\OneDrive\Code\BearingMaster\Data\bearing.ico")
)
png = QtGui.QPixmap(r"D:\OneDrive\Code\BearingMaster\Data\PB.png")
self.label_pic.setPixmap(png)
self.cwd = os.getcwd() # current file location
self.fileName_choose = "" # Lrd fatigue load
self.pares = {} # bearing parameters
self.loads = {} # extreme loads
self.phi_ball = [] # position of the roller elements, in deg.
self.pi = acos(-1)
self.N = 1 # design life, total rotation in rad.
# 创建用于储存输出文件的文件夹
folder = self.cwd + "\\result_output"
if not os.path.exists(folder):
os.makedirs(folder)
# signal
self.buttom_ult.clicked.connect(self.cal_static)
self.buttom_fat.clicked.connect(self.cal_life)
self.buttom_plot.clicked.connect(self.plot_qj)
self.buttom_read_fat_file.clicked.connect(self.open_lrd)
# self.buttom_read_fat_file.clicked.connect(self.cal_equivalent_load)
# self.buttom_read_FEM_file.clicked.connect(self.slot_btn_chooseFile_FEM)
# self.buttom_fat_FEM.clicked.connect(self.cal_life_FEM)
# timenow = time.strftime('%Y-%m-%d')
# if timenow < '2019-05-01':
# pass
# else:
# exit()
def read_pares(self):
"""
read the parameters of bearings.
if errors occurred in reading the parameters, return {}
Returns:
pares: dict
"""
self.pares = {}
try:
self.pares["dpw"] = float(self.line_dpw.text())
self.pares["dc"] = float(self.line_dc.text())
self.pares["fi"] = float(self.line_fi.text())
self.pares["fe"] = float(self.line_fe.text())
self.pares["z0"] = float(self.line_z0.text())
self.pares["nz"] = float(self.line_nz.text())
self.pares["z1"] = float(self.line_z1.text())
self.pares["z2"] = float(self.line_z2.text())
self.pares["alpha"] = (
float(self.line_alpha.text()) * self.pi / 180
) # set unit of angle to rad.
self.pares["ep"] = float(self.line_ep.text())
self.pares["nu"] = float(self.line_nu.text())
self.pares["dw"] = float(self.line_dw.text())
self.pares["gap"] = float(self.line_gap.text())
self.pares["gr"] = float(self.line_gr.text())
except ValueError:
with open("ErrorLog.txt", "a") as f:
f.write(
time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())) + "\n"
)
f.write("Error reading bearing parameters.\n")
f.close()
QMessageBox.warning(
self,
"Error",
"<span style=' font-size:12pt;'>Error reading bearing parameters!",
)
return self.pares
return self.pares
def read_load_ult(self):
"""
read the extreme loads Fr Fa M in KN and KNm
if errors occurred in reading the loads, return {}.
Returns:
loads: dict
"""
self.loads = {}
try:
self.loads["fxy"] = float(self.line_fz.text())
self.loads["fz"] = float(self.line_fxy.text())
self.loads["mxy"] = float(self.line_mxy.text())
except ValueError:
with open("ErrorLog.txt", "a") as f:
f.write(
time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())) + "\n"
)
f.write("Errors in reading static loads.\n")
f.close()
QMessageBox.warning(
self,
"Error",
'<span style="font-size:12pt;">Error reading extreme loads!',
)
return self.loads
return self.loads
def cal_static(self):
"""
calculation of the maximum contact force and contact pressure base on the Fr, Fa, M
acc. to:
"Wind Turbine Design Guideline DG03: Yaw and Pitch Rolling Bearing Life"
"ISO 281-2007 chapter-6, Appendix B"
### only calculation for ball bearing supported.
:return:
qmax: float, maximum contact force
smax: float, maximum contact pressure
"""
# read parameters and loads
pares = self.read_pares()
if not pares == {}:
f = pares["fi"] # 内圈滚道曲率系数
d = pares["dw"] # 钢球直径
z = pares["z0"] # 单排钢球数量
nz = pares["nz"] # 滚道排数
dm = pares["dpw"] # 钢球节圆直径
a = pares["alpha"] # 初始接触角
else:
return
loads = self.read_load_ult()
if not loads == {}:
f_radial = loads["fxy"] # 变桨轴承承受的径向力,单位为kN
f_axial = loads["fz"] # 变桨轴承承受的轴向力,单位为kN
mxy = loads["mxy"] # 变桨轴承承受的弯矩,单位为kNm
else:
return
gamma = d * cos(a) / dm # 中间变量
# for ball bearing
# # body a 参数
# ra1 = 2 / d # 较小曲率半径
# ra2 = 2 / d # 较大曲率半径
# # body b 参数
# rb1 = 2 / (d * (1 - gamma) / gamma) # 较大曲率半径(内圈)
# rb2 = -1 / (f * d) # 较小曲率半径
# r_sum = ra1 + ra2 + rb1 + rb2 # 曲率和
# r_dif = (ra1 - ra2 + rb1 - rb2) / r_sum # 曲率差
# for cylindrical cross roller bearing
# ra = 2/d
# rb = 2/d/((1-gamma)/gamma)
# r_sum = ra + rb
# r_dif = 0
r_sum = 4 / d - 1 / f / d + 2 / d * gamma / (1 - gamma)
r_dif = (1 / f + 2 * gamma / (1 - gamma)) / (
4 - 1 / f + 2 * gamma / (1 - gamma)
)
# calculation of the long and short axis, a* and b*, according to DG03, table 10.
fr = [
0,
0.1075,
0.3204,
0.4795,
0.5916,
0.6716,
0.7332,
0.7948,
0.83495,
0.87366,
0.90999,
0.93657,
0.95738,
0.9729,
0.983797,
0.990902,
0.995112,
0.9973,
0.9981847,
0.9989156,
0.9994785,
0.9998527,
1,
]
aa = [
1,
1.076,
1.2623,
1.4556,
1.644,
1.8258,
2.011,
2.265,
2.494,
2.8,
3.233,
3.738,
4.395,
5.267,
6.448,
8.062,
10.222,
12.789,
14.839,
17.974,
23.55,
37.38,
float("inf"),
]
bb = [
1,
0.9318,
0.8114,
0.7278,
0.6687,
0.6245,
0.5881,
0.548,
0.5186,
0.4863,
0.4499,
0.4166,
0.383,
0.349,
0.315,
0.2814,
0.2497,
0.2232,
0.2072,
0.18822,
0.16442,
0.1305,
0,
]
loc = 1
for i in range(len(fr)):
if r_dif >= fr[i]:
loc = i
aa1 = (aa[loc + 1] - aa[loc]) * (r_dif - fr[loc]) / (
fr[loc + 1] - fr[loc]
) + aa[loc]
bb1 = (bb[loc + 1] - bb[loc]) * (r_dif - fr[loc]) / (
fr[loc + 1] - fr[loc]
) + bb[loc]
"""
load splitting for multi-row bearings, but only support double row bearing now.
Acc. to DG03 Appendix B.
A 55%/45% thrust load sharing of the two rows is considered the best possible load distribution ratio because
of tolerances and variation of internal dimensions between the bearing rows.
"""
if nz == 1:
ldf = 1
elif nz == 2:
ldf = 0.55
else:
QMessageBox.warning(
self,
"Error",
"<span style=' font-size:12pt;'>Support up to double row bearing calculation,\n"
" please check the input parameter Z0!",
)
return
qmax = ldf * (
2 * f_radial * 1000 / (z * cos(a))
+ f_axial * 1000 / (z * sin(a))
+ 4 * mxy * 1000000 / (dm * z * sin(a))
) # unit in N and Nmm
cc = 0.0236 * aa1 * (qmax / r_sum) ** (1 / 3) # 椭圆长半轴
dd = 0.0236 * bb1 * (qmax / r_sum) ** (1 / 3) # 椭圆短半轴
smax = 1.5 * qmax / (self.pi * cc * dd) # 滚动体最大接触应力
self.result_qmax.setText("%.2f" % float(qmax / 1000)) # in KN
self.result_smax.setText("%.2f" % float(smax)) # in MPa KN/mm2
QMessageBox.information(self, "Done", '<span style=" font-size:12pt;">接触力计算完成!')
return qmax, smax
def cal_qj(self, pares, loads, show=True):
"""
calculation of the contact force and contact angel for each roller element.
Args:
pares: {}, bearing parameters
loads: {}, static loads
show: bool, show the message box after calculation.
Return:
Q: array, contact force, in N.
a: array, contact angel, in deg.
"""
def fx(x):
"""
牛顿迭代法待求解函数,通过迭代输入变量[a, r, theta]解方程,使径向力、轴向力、弯矩与输入载荷匹配。
Args:
x: array, [a, r, theta]
a: float, 外圈轴向位移
r: float, 外圈径向位置
theta: float, 角位移
Returns:
deviation: list, calculated [Fa, Fr, M0] according to 'x' minus the true [Fa. Fr, M0].
"""
Fa0, Fr0, M0 = [], [], [] # initialize the [Fa, Fr, M0] for each roller
faa, frr, ftheta = x[0], x[1], x[2] # initialize the inputs
for ii in arange(1, Z + 1, 1):
fphi = self.pi * 2 / Z * ii
fA1 = (
(A * sin(alpha0) + faa + Ri * ftheta * cos(fphi)) ** 2
+ (
A * cos(alpha0)
+ frr * cos(fphi)
- 0.5 * dc * ftheta * cos(fphi)
)
** 2
) ** 0.5
fA2 = (
(A * sin(alpha0) - faa - Ri * ftheta * cos(fphi)) ** 2
+ (
A * cos(alpha0)
+ frr * cos(fphi)
- 0.5 * dc * ftheta * cos(fphi)
)
** 2
) ** 0.5
fA3 = (
(A * sin(alpha0) + faa + Ri * ftheta * cos(fphi)) ** 2
+ (
A * cos(alpha0)
+ frr * cos(fphi)
+ 0.5 * dc * ftheta * cos(fphi)
)
** 2
) ** 0.5
fA4 = (
(A * sin(alpha0) - faa - Ri * ftheta * cos(fphi)) ** 2
+ (
A * cos(alpha0)
+ frr * cos(fphi)
+ 0.5 * dc * ftheta * cos(fphi)
)
** 2
) ** 0.5
# 在接触对ii处,钢球与沟道总的弹性变形
fx1 = fA1 - A0
fx2 = fA2 - A0
fx3 = fA3 - A0
fx4 = fA4 - A0
# 内外圈发生位移后在接触对i在位置角Phi处的接触角
sina1 = (A * sin(alpha0) + faa + Ri * ftheta * cos(fphi)) / fA1
cosa1 = (
A * cos(alpha0) + frr * cos(fphi) - 0.5 * dc * ftheta * cos(fphi)
) / fA1
sina2 = (A * sin(alpha0) - faa - Ri * ftheta * cos(fphi)) / fA2
cosa2 = (
A * cos(alpha0) + frr * cos(fphi) - 0.5 * dc * ftheta * cos(fphi)
) / fA2
sina3 = (A * sin(alpha0) + faa + Ri * ftheta * cos(fphi)) / fA3
cosa3 = (
A * cos(alpha0) + frr * cos(fphi) + 0.5 * dc * ftheta * cos(fphi)
) / fA3
sina4 = (A * sin(alpha0) - faa - Ri * ftheta * cos(fphi)) / fA4
cosa4 = (
A * cos(alpha0) + frr * cos(fphi) + 0.5 * dc * ftheta * cos(fphi)
) / fA4
# Hertz接触理论,轴向载荷与接触变形关系
fQ1 = Kn * ((abs(fx1) + fx1) / 2) ** 1.5
fQ2 = Kn * ((abs(fx2) + fx2) / 2) ** 1.5
fQ3 = Kn * ((abs(fx3) + fx3) / 2) ** 1.5
fQ4 = Kn * ((abs(fx4) + fx4) / 2) ** 1.5
#
Fa0.append((fQ1 * sina1 - fQ2 * sina2 + fQ3 * sina3 - fQ4 * sina4))
Fr0.append(
(fQ1 * cosa1 + fQ2 * cosa2 + fQ3 * cosa3 + fQ4 * cosa4) * cos(fphi)
)
M0.append(
1
/ 2
* Dpw
* (fQ1 * sina1 - fQ2 * sina2 + fQ3 * sina3 - fQ4 * sina4)
* cos(fphi)
)
return [Fa - sum(Fa0), Fr - sum(Fr0), Mxy - sum(M0)]
if not pares == {}:
alpha0 = pares["alpha"]
Dpw = pares["dpw"]
Dw = pares["dw"]
dc = pares["dc"]
fi = pares["fi"]
fe = pares["fe"]
ri = fi * Dw
re = fe * Dw
Z = pares["z0"]
ve = pares["nu"]
Ep = pares["ep"]
Gr = pares["gr"]
else:
return # pares is {}
if not loads == {}:
Fa = loads["fxy"] * 1000
Fr = loads["fz"] * 1000
Mxy = loads["mxy"] * 1000000
else:
return # loads is {}
# 原始沟心距
A = (fi + fe - 1) * Dw - Gr * cos(alpha0) / 2
A0 = (fi + fe - 1) * Dw
Ri = Dpw / 2 + (ri - 0.5) * Dw * cos(alpha0) - Gr * (cos(alpha0)) ** 2 / 4
# calculation of the spring constant cp
Kn = cal_cp(Dw, alpha0, Dpw, ri, re, Ep, ve)
# calculation of the a, r, theta
try:
r_initial = fsolve(fx, array([0.1, 0.1, 0.1]))
except Exception as e:
with open("ErrorLog.txt", "a") as f:
f.write(
time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())) + "\n"
)
f.write(repr(e))
f.close()
QMessageBox.warning(
self,
"Error",
"<span style=’font-size:12pt;‘>Errors occurred during calculation of the initial contact condition.",
)
return None
Q11, Q22, Q33, Q44 = [], [], [], []
a11, a22, a33, a44 = [], [], [], []
aa, rr, theta = r_initial[0], r_initial[1], r_initial[2]
self.phi_ball = []
for i in arange(1, Z + 1, 1):
phi = self.pi * 2 / Z * i
self.phi_ball.append(phi / self.pi * 180)
A1 = (
(A * sin(alpha0) + aa + Ri * theta * cos(phi)) ** 2
+ (A * cos(alpha0) + rr * cos(phi) - 0.5 * dc * theta * cos(phi)) ** 2
) ** 0.5
A2 = (
(A * sin(alpha0) - aa - Ri * theta * cos(phi)) ** 2
+ (A * cos(alpha0) + rr * cos(phi) - 0.5 * dc * theta * cos(phi)) ** 2
) ** 0.5
A3 = (
(A * sin(alpha0) + aa + Ri * theta * cos(phi)) ** 2
+ (A * cos(alpha0) + rr * cos(phi) + 0.5 * dc * theta * cos(phi)) ** 2
) ** 0.5
A4 = (
(A * sin(alpha0) - aa - Ri * theta * cos(phi)) ** 2
+ (A * cos(alpha0) + rr * cos(phi) + 0.5 * dc * theta * cos(phi)) ** 2
) ** 0.5
# 在接触对i处,钢球与沟道总的弹性变形delta_phi
x1 = A1 - A0
x2 = A2 - A0
x3 = A3 - A0
x4 = A4 - A0
# 内外圈发生位移后在接触对i在位置角Phi处的接触角alpha_1phi
sina1 = (A * sin(alpha0) + aa + Ri * theta * cos(phi)) / A1
# cosa1 = (A * cos(alpha0) + rr * cos(phi) - 0.5 * dc * theta * cos(phi)) / A1
sina2 = (A * sin(alpha0) - aa - Ri * theta * cos(phi)) / A2
# cosa2 = (A * cos(alpha0) + rr * cos(phi) - 0.5 * dc * theta * cos(phi)) / A2
sina3 = (A * sin(alpha0) + aa + Ri * theta * cos(phi)) / A3
# cosa3 = (A * cos(alpha0) + rr * cos(phi) + 0.5 * dc * theta * cos(phi)) / A3
sina4 = (A * sin(alpha0) - aa - Ri * theta * cos(phi)) / A4
# cosa4 = (A * cos(alpha0) + rr * cos(phi) + 0.5 * dc * theta * cos(phi)) / A4
# Hertz接触理论,轴向载荷与接触变形关系
Q1 = Kn * ((abs(x1) + x1) / 2) ** 1.5
Q2 = Kn * ((abs(x2) + x2) / 2) ** 1.5
Q3 = Kn * ((abs(x3) + x3) / 2) ** 1.5
Q4 = Kn * ((abs(x4) + x4) / 2) ** 1.5
a11.append(asin(sina1) / self.pi * 180)
a22.append(asin(sina2) / self.pi * 180)
a33.append(asin(sina3) / self.pi * 180)
a44.append(asin(sina4) / self.pi * 180)
Q11.append(Q1)
Q22.append(Q2)
Q33.append(Q3)
Q44.append(Q4)
if show:
QMessageBox.information(
self, "Done", '<span style=" font-size:12pt;">接触力、接触角计算完成!'
)
return Q11, Q22, Q33, Q44, a11, a22, a33, a44
def plot_qj(self):
"""
plot the contact force vs position of the roller elements.
Returns:
figure
"""
try:
Q11, Q22, Q33, Q44, a11, a22, a33, a44 = self.cal_qj(
self.read_pares(), self.read_load_ult()
)
except TypeError: # errors in calculation of the contact force.
return
# result saved to txt file
with open(self.cwd + "\\result_output\\Contact_load_and_Angle.txt", "a") as f:
f.writelines(
"{:>10}{:>10}{:>10}{:>10}{:>10}{:>10}{:>10}{:>10}{:>10}\n".format(
"Angel/deg",
"Q11/KN",
"Q22/KN",
"Q33/KN",
"Q44/KN",
"a11/deg",
"a22/deg",
"a33/deg",
"a33/deg",
)
)
for i in range(len(Q11)):
f.writelines(
"{:>10.1f}{:>10.2f}{:>10.2f}{:>10.2f}{:>10.2f}{:>10.2f}{:>10.2f}{:>10.2f}{:>10.2f}\n".format(
self.phi_ball[i],
Q11[i],
Q22[i],
Q33[i],
Q44[i],
a11[i],
a22[i],
a33[i],
a44[i],
)
)
f.close()
plt.figure() # 创建画布
plt.plot(
self.phi_ball, [x / 1000 for x in Q11], color="r", label=r"Contact 1"
) # 将接触力转换为kN
plt.plot(self.phi_ball, [x / 1000 for x in Q22], color="b", label=r"Contact 2")
plt.plot(self.phi_ball, [x / 1000 for x in Q33], color="g", label=r"Contact 3")
plt.plot(self.phi_ball, [x / 1000 for x in Q44], color="y", label=r"Contact 4")
plt.xlabel(r"Angle / deg")
plt.ylabel(r"Contact load / kN")
plt.legend(loc="upper right")
plt.show()
plt.figure() # 创建画布
plt.plot(
self.phi_ball, [x for x in a11], color="r", label=r"Contact 1"
) # 将接触力转换为kN
plt.plot(self.phi_ball, [x for x in a22], color="b", label=r"Contact 2")
plt.plot(self.phi_ball, [x for x in a33], color="g", label=r"Contact 3")
plt.plot(self.phi_ball, [x for x in a44], color="y", label=r"Contact 4")
plt.xlabel(r"Angle / deg")
plt.ylabel(r"Contact angle / deg")
plt.legend(loc="upper right")
plt.show()
return
def open_lrd(self):
"""
open the load file.
Returns:
fileName_choose: string, file name and location
"""
self.fileName_choose, file_type = QFileDialog.getOpenFileName(
self, "选取文件", self.cwd, "Excel Files (*.xlsx;*.xls);;All Files (*)" # 起始路径
) # 设置文件扩展名过滤,用双分号间隔
if self.fileName_choose == "":
return
self.line_fat_file_dir.setText(self.fileName_choose)
return
# def slot_btn_chooseFile_FEM(self):
# # QFileDialog.getOpenFileNames得到的fileName_choose是一个列表,相对地getOpenFileName得到的直接是一个字符串
# fileName_choose, filetype = QFileDialog.getOpenFileNames(
# self, "选取文件", self.cwd, "excel Files (*.txt);;All Files (*)" # 起始路径
# ) # 设置文件扩展名过滤,用双分号间隔
#
# if fileName_choose == "":
# print("\n取消选择")
# return
#
# print("\n你选择的文件为:")
# print(fileName_choose)
#
# self.line_FEM_file_dir.setText(str(fileName_choose))
# QMessageBox.information(self, "选择的文件为", str(fileName_choose))
#
# self.FEM_file_dir = fileName_choose
#
# def read_FEM_file(self, dir_file):
# """
#
# :param dir_file: 传入一个文件的绝对路径,然后读取四个接触点的接触力和接触角的数据
# :return:
# """
# self.Q11 = []
# self.Q22 = []
# self.Q33 = []
# self.Q44 = []
# self.alpha11 = []
# self.alpha22 = []
# self.alpha33 = []
# self.alpha44 = []
# pi = acos(-1)
# try:
# file = open(dir_file, mode="r")
# for line in file:
# line_list = line.split()
# self.Q11.append(float(line_list[0]))
# self.Q22.append(float(line_list[2]))
# self.Q33.append(float(line_list[4]))
# self.Q44.append(float(line_list[6]))
# self.alpha11.append(float(line_list[1]) * pi / 180)
# self.alpha22.append(float(line_list[3]) * pi / 180)
# self.alpha33.append(float(line_list[5]) * pi / 180)
# self.alpha44.append(float(line_list[7]) * pi / 180)
# except Exception as e:
# with open("ErrorLog.txt", "a") as f:
# f.write(
# time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())) + "\n"
# )
# f.write(repr(e))
# f.close()
# QMessageBox.warning(
# self,
# "Error",
# "结果文件有问题,请对应检查以下项目:\n" "数据格式共8列-- 4个接触点,每个接触点包括接触力和接触角数据,共8列",
# )
def cal_equivalent_load(self):
"""
calculation of the equivalent lrd load.
1, read the initial lrd load cases
2, divide the load into positive and negative parts
3, combine all the load components and calculate the possibility
Returns:
combined load components and possibility, [mxy, fxy, fz, possibility]
"""
if self.fileName_choose == "":
self.open_lrd()
try: # read the LRD loads into array, mixed with component and frequency
lrd_load = read_excel(
self.fileName_choose, sheet_name="叶根LRD,LDD载荷", nrows=64
).fillna(0)
except Exception as e:
with open("ErrorLog.txt", "a") as f:
f.write(
time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())) + "\n"
)
f.write("Error reading lrd loads: %s\n" % repr(e))
f.close()
QMessageBox.warning(
self,
"Error",
"Error reading lrd loads, please check the format:\n"
"1 sheet name: “叶根LRD,LDD载荷”;\n"
"2 first row:“Blade 1 Mx [kNm] Time at level Revs[rad] Revs at level per bin[deg/s]...”",
)
return
# sort and combine
components, frequencies = (0, 5, 15, 20, 25), (2, 7, 17, 22, 27)
component_possibility = zeros([2, 10])
for i in range(5):
l_p, n_p, l_n, n_n = 0, 0, 0, 0
for j in range(64):
if lrd_load.iloc[j, components[i]] < 0:
l_n += (
lrd_load.iloc[j, components[i]] ** 3
* lrd_load.iloc[j, frequencies[i]]
/ 2
/ self.pi
)
n_n += lrd_load.iloc[j, frequencies[i]] / 2 / self.pi
else:
l_p += (
lrd_load.iloc[j, components[i]] ** 3
* lrd_load.iloc[j, frequencies[i]]
/ 2
/ self.pi
)
n_p += lrd_load.iloc[j, frequencies[i]] / 2 / self.pi
component_possibility[0, 2 * i] = -((-l_n / n_n) ** (1 / 3))
component_possibility[0, 2 * i + 1] = n_n / (n_n + n_p)
component_possibility[1, 2 * i] = (l_p / n_p) ** (1 / 3)
component_possibility[1, 2 * i + 1] = n_p / (n_n + n_p)
# 许用寿命,总圈数
self.N = n_n + n_p
# 排列组合工况表
load_combine = [] # 对应参考文献[1]中的'等效疲劳载荷'的下表
for mx in range(2):
for my in range(2):
for fx in range(2):
for fy in range(2):
for fz in range(2):
load_combine = append(
load_combine,
[
component_possibility[mx, 0],
component_possibility[my, 2],
component_possibility[fx, 4],
component_possibility[fy, 6],
component_possibility[fz, 8],
component_possibility[mx, 1]
* component_possibility[my, 3]
* component_possibility[fx, 5]