17
17
# ***************************************************************************
18
18
19
19
import numpy as np
20
- from scipy import optimize as opt
21
20
22
21
23
22
def compute_shifted_gears (m , alpha , t1 , t2 , x1 , x2 ):
@@ -34,31 +33,32 @@ def compute_shifted_gears(m, alpha, t1, t2, x1, x2):
34
33
Returns:
35
34
(float, float): distance between gears [length], pressure angle of the assembly [rad]
36
35
"""
37
- def inv (x ): return np . tan ( x ) - x
38
- inv_alpha_w = inv ( alpha ) + 2 * np .tan (alpha ) * ( x1 + x2 ) / ( t1 + t2 )
36
+ def inv (x ):
37
+ return np .tan (x ) - x
39
38
40
- def root_inv (x ): return inv (x ) - inv_alpha_w
41
- alpha_w = opt .fsolve (root_inv , 0. )
42
- dist = m * (t1 + t2 ) / 2 * np .cos (alpha ) / np .cos (alpha_w )
43
- return dist , alpha_w
39
+ inv_alpha_w = inv (alpha ) + 2 * np .tan (alpha ) * (x1 + x2 ) / (t1 + t2 )
44
40
41
+ def root_inv (x ):
42
+ return inv (x ) - inv_alpha_w
45
43
46
- def shifted_pitch_diameter ( m , alpha , t1 , x1 ):
47
- """Summary
44
+ def d_root_inv ( x ):
45
+ return 1. / np . cos ( x ) - 1
48
46
49
- Args:
50
- m (float): common module of both gears [length]
51
- alpha (float): pressure-angle [rad]
52
- t1 (int): number of teeth of gear1
53
- x1 (float): relative profile-shift of gear1
47
+ alpha_w = find_root (alpha , root_inv , d_root_inv )
48
+ dist = m * (t1 + t2 ) / 2 * np .cos (alpha ) / np .cos (alpha_w )
49
+ return dist , alpha_w
54
50
55
- Returns:
56
- (float, float): distance between gears [length], pressure angle of the assembly [rad]
57
- """
58
- def inv (x ): return np .tan (x ) - x
59
- inv_alpha_w = inv (alpha ) + 2 * np .tan (alpha ) * x1 / t1
60
51
61
- def root_inv (x ): return inv (x ) - inv_alpha_w
62
- alpha_w = opt .fsolve (root_inv , 0. )
63
- pitch_diameter = m * t1 * np .cos (alpha ) / np .cos (alpha_w )
64
- return pitch_diameter , alpha_w
52
+ def find_root (x0 , f , df , epsilon = 2e-10 , max_iter = 100 ):
53
+ x_n = x0
54
+ for i in range (max_iter ):
55
+ f_xn = f (x_n )
56
+ if abs (f_xn ) < epsilon :
57
+ return x_n
58
+ else :
59
+ df_xn = df (x_n )
60
+ if df_xn == 0 :
61
+ return None
62
+ else :
63
+ x_n = x_n - f_xn / df_xn / 2 # adding (/ 2) to avoid oscillation
64
+ return None
0 commit comments