bstart-trb 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bstart_trb/__init__.py +6 -6
- bstart_trb/models.py +118 -116
- bstart_trb/wrapper.py +51 -50
- bstart_trb-0.2.2.dist-info/METADATA +289 -0
- bstart_trb-0.2.2.dist-info/RECORD +11 -0
- bstart_trb-0.2.0.dist-info/METADATA +0 -949
- bstart_trb-0.2.0.dist-info/RECORD +0 -11
- {bstart_trb-0.2.0.dist-info → bstart_trb-0.2.2.dist-info}/WHEEL +0 -0
- {bstart_trb-0.2.0.dist-info → bstart_trb-0.2.2.dist-info}/licenses/LICENSE +0 -0
bstart_trb/__init__.py
CHANGED
|
@@ -11,8 +11,8 @@ Features:
|
|
|
11
11
|
- Dataclass wrapped results
|
|
12
12
|
|
|
13
13
|
Example:
|
|
14
|
-
>>> from
|
|
15
|
-
>>> from
|
|
14
|
+
>>> from bstart_trb import slice_stress, RollerParams, RacewayParams
|
|
15
|
+
>>> from bstart_trb import CrownType, RacewayType
|
|
16
16
|
>>>
|
|
17
17
|
>>> # Define cylindrical roller parameters
|
|
18
18
|
>>> roller = RollerParams(
|
|
@@ -47,17 +47,17 @@ from .wrapper import (
|
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
__all__ = [
|
|
50
|
-
#
|
|
50
|
+
# Enum types
|
|
51
51
|
"CrownType",
|
|
52
52
|
"RacewayType",
|
|
53
|
-
#
|
|
53
|
+
# Data types
|
|
54
54
|
"RollerParams",
|
|
55
55
|
"RacewayParams",
|
|
56
56
|
"SliceResult",
|
|
57
|
-
#
|
|
57
|
+
# Calculation functions
|
|
58
58
|
"slice_stress",
|
|
59
59
|
"batch_slice_stress",
|
|
60
60
|
"is_fortran_available",
|
|
61
61
|
]
|
|
62
62
|
|
|
63
|
-
__version__ = "0.2.
|
|
63
|
+
__version__ = "0.2.2"
|
bstart_trb/models.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Data Type Definitions
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Defines input parameter and output result data classes for
|
|
5
|
+
cylindrical/tapered roller bearing slice calculation.
|
|
6
|
+
All classes use the dataclass decorator with complete type hints.
|
|
6
7
|
"""
|
|
7
8
|
|
|
8
9
|
from dataclasses import dataclass
|
|
@@ -13,62 +14,63 @@ from numpy.typing import NDArray
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class CrownType(IntEnum):
|
|
16
|
-
"""
|
|
17
|
+
"""Crown modification type enumeration.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
Specifies the crown modification type for the roller.
|
|
19
20
|
|
|
20
21
|
Attributes:
|
|
21
|
-
STRAIGHT:
|
|
22
|
-
ARC:
|
|
23
|
-
LOGARITHMIC:
|
|
22
|
+
STRAIGHT: No modification (straight profile)
|
|
23
|
+
ARC: Circular arc crown
|
|
24
|
+
LOGARITHMIC: Logarithmic crown (recommended for optimal stress distribution)
|
|
24
25
|
"""
|
|
25
26
|
STRAIGHT = 0
|
|
26
|
-
"""
|
|
27
|
+
"""No modification (straight profile), high edge stress"""
|
|
27
28
|
|
|
28
29
|
ARC = 1
|
|
29
|
-
"""
|
|
30
|
+
"""Circular arc crown, requires arc radius specification"""
|
|
30
31
|
|
|
31
32
|
LOGARITHMIC = 2
|
|
32
|
-
"""
|
|
33
|
+
"""Logarithmic crown (recommended), theoretically achieves uniform stress distribution"""
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
class RacewayType(IntEnum):
|
|
36
|
-
"""
|
|
37
|
+
"""Raceway type enumeration.
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
Specifies the type of raceway in contact.
|
|
39
40
|
|
|
40
41
|
Attributes:
|
|
41
|
-
PLANE:
|
|
42
|
-
INNER:
|
|
43
|
-
OUTER:
|
|
42
|
+
PLANE: Flat surface contact
|
|
43
|
+
INNER: Inner ring raceway (convex surface)
|
|
44
|
+
OUTER: Outer ring raceway (concave surface)
|
|
44
45
|
"""
|
|
45
46
|
PLANE = 0
|
|
46
|
-
"""
|
|
47
|
+
"""Flat surface contact"""
|
|
47
48
|
|
|
48
49
|
INNER = 1
|
|
49
|
-
"""
|
|
50
|
+
"""Inner ring raceway (convex surface)"""
|
|
50
51
|
|
|
51
52
|
OUTER = 2
|
|
52
|
-
"""
|
|
53
|
+
"""Outer ring raceway (concave surface), note: use negative diameter value"""
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
@dataclass
|
|
56
57
|
class RollerParams:
|
|
57
|
-
"""
|
|
58
|
+
"""Roller geometry parameters.
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
Defines geometric dimensions and crown modification parameters
|
|
61
|
+
for cylindrical/tapered rollers.
|
|
60
62
|
|
|
61
63
|
Attributes:
|
|
62
|
-
d1:
|
|
63
|
-
d2:
|
|
64
|
-
length:
|
|
65
|
-
alfa:
|
|
66
|
-
tilt:
|
|
67
|
-
crown_type:
|
|
68
|
-
curve_q:
|
|
64
|
+
d1: Roller small end diameter (mm)
|
|
65
|
+
d2: Roller large end diameter (mm), d1=d2 for cylindrical rollers
|
|
66
|
+
length: Roller effective length (mm)
|
|
67
|
+
alfa: Roller half cone angle (degrees), alfa=0 for cylindrical rollers
|
|
68
|
+
tilt: Roller tilt angle (degrees), 0 means no tilt
|
|
69
|
+
crown_type: Crown modification type, see CrownType enum
|
|
70
|
+
curve_q: Design load (N), used for logarithmic crown calculation
|
|
69
71
|
|
|
70
72
|
Example:
|
|
71
|
-
>>> #
|
|
73
|
+
>>> # Cylindrical roller
|
|
72
74
|
>>> roller = RollerParams(
|
|
73
75
|
... d1=10.0, d2=10.0, length=9.6,
|
|
74
76
|
... alfa=0.0, tilt=0.0,
|
|
@@ -76,7 +78,7 @@ class RollerParams:
|
|
|
76
78
|
... curve_q=14100.0
|
|
77
79
|
... )
|
|
78
80
|
|
|
79
|
-
>>> #
|
|
81
|
+
>>> # Tapered roller
|
|
80
82
|
>>> taper_roller = RollerParams(
|
|
81
83
|
... d1=8.0, d2=10.0, length=12.0,
|
|
82
84
|
... alfa=10.0, tilt=0.0,
|
|
@@ -85,79 +87,79 @@ class RollerParams:
|
|
|
85
87
|
... )
|
|
86
88
|
|
|
87
89
|
Note:
|
|
88
|
-
-
|
|
89
|
-
- tilt > 0
|
|
90
|
+
- Logarithmic crown achieves uniform stress distribution when load == curve_q
|
|
91
|
+
- tilt > 0 causes stress concentration at one end, other end may lose contact
|
|
90
92
|
"""
|
|
91
93
|
d1: float
|
|
92
|
-
"""
|
|
94
|
+
"""Roller small end diameter (mm)"""
|
|
93
95
|
|
|
94
96
|
d2: float
|
|
95
|
-
"""
|
|
97
|
+
"""Roller large end diameter (mm), d1=d2 for cylindrical rollers"""
|
|
96
98
|
|
|
97
99
|
length: float
|
|
98
|
-
"""
|
|
100
|
+
"""Roller effective length (mm)"""
|
|
99
101
|
|
|
100
102
|
alfa: float = 0.0
|
|
101
|
-
"""
|
|
103
|
+
"""Roller half cone angle (degrees), alfa=0 for cylindrical rollers"""
|
|
102
104
|
|
|
103
105
|
tilt: float = 0.0
|
|
104
|
-
"""
|
|
106
|
+
"""Roller tilt angle (degrees)"""
|
|
105
107
|
|
|
106
108
|
crown_type: CrownType = CrownType.LOGARITHMIC
|
|
107
|
-
"""
|
|
109
|
+
"""Crown modification type"""
|
|
108
110
|
|
|
109
111
|
curve_q: float = 0.0
|
|
110
|
-
"""
|
|
112
|
+
"""Design load (N), used for logarithmic crown calculation, 0 means use actual load"""
|
|
111
113
|
|
|
112
114
|
def __post_init__(self):
|
|
113
|
-
"""
|
|
115
|
+
"""Parameter validation"""
|
|
114
116
|
if self.d1 <= 0:
|
|
115
|
-
raise ValueError(f"
|
|
117
|
+
raise ValueError(f"Roller small end diameter must be positive, got: {self.d1}")
|
|
116
118
|
if self.d2 <= 0:
|
|
117
|
-
raise ValueError(f"
|
|
119
|
+
raise ValueError(f"Roller large end diameter must be positive, got: {self.d2}")
|
|
118
120
|
if self.length <= 0:
|
|
119
|
-
raise ValueError(f"
|
|
121
|
+
raise ValueError(f"Roller effective length must be positive, got: {self.length}")
|
|
120
122
|
if self.d1 > self.d2:
|
|
121
123
|
import warnings
|
|
122
|
-
warnings.warn(f"
|
|
124
|
+
warnings.warn(f"Roller small end diameter d1={self.d1} is greater than large end diameter d2={self.d2}, please verify")
|
|
123
125
|
|
|
124
|
-
#
|
|
126
|
+
# Convert enum type
|
|
125
127
|
if isinstance(self.crown_type, int):
|
|
126
128
|
self.crown_type = CrownType(self.crown_type)
|
|
127
129
|
|
|
128
130
|
@property
|
|
129
131
|
def is_cylindrical(self) -> bool:
|
|
130
|
-
"""
|
|
132
|
+
"""Whether this is a cylindrical roller"""
|
|
131
133
|
return abs(self.d1 - self.d2) < 1e-6 and abs(self.alfa) < 1e-6
|
|
132
134
|
|
|
133
135
|
@property
|
|
134
136
|
def diameter(self) -> float:
|
|
135
|
-
"""
|
|
137
|
+
"""Roller diameter (cylindrical) or mean diameter (tapered)"""
|
|
136
138
|
return (self.d1 + self.d2) / 2.0
|
|
137
139
|
|
|
138
140
|
|
|
139
141
|
@dataclass
|
|
140
142
|
class RacewayParams:
|
|
141
|
-
"""
|
|
143
|
+
"""Raceway parameters.
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
Defines raceway geometric characteristics.
|
|
144
146
|
|
|
145
147
|
Attributes:
|
|
146
|
-
diameter:
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
raceway_type:
|
|
150
|
-
fai:
|
|
148
|
+
diameter: Raceway diameter (mm)
|
|
149
|
+
- Inner ring raceway: positive value
|
|
150
|
+
- Outer ring raceway: negative value (Hertz contact theory sign convention)
|
|
151
|
+
raceway_type: Raceway type, see RacewayType enum
|
|
152
|
+
fai: Raceway half cone angle (degrees), 0 for cylindrical roller bearings
|
|
151
153
|
|
|
152
154
|
Example:
|
|
153
|
-
>>> #
|
|
155
|
+
>>> # Inner ring raceway
|
|
154
156
|
>>> inner = RacewayParams(
|
|
155
157
|
... diameter=110.0,
|
|
156
158
|
... raceway_type=RacewayType.INNER,
|
|
157
159
|
... fai=0.0
|
|
158
160
|
... )
|
|
159
161
|
|
|
160
|
-
>>> #
|
|
162
|
+
>>> # Outer ring raceway (note negative sign)
|
|
161
163
|
>>> outer = RacewayParams(
|
|
162
164
|
... diameter=-150.0,
|
|
163
165
|
... raceway_type=RacewayType.OUTER,
|
|
@@ -165,111 +167,111 @@ class RacewayParams:
|
|
|
165
167
|
... )
|
|
166
168
|
|
|
167
169
|
Note:
|
|
168
|
-
|
|
169
|
-
-
|
|
170
|
-
-
|
|
170
|
+
Outer ring raceway diameter uses negative value per Hertz contact theory convention:
|
|
171
|
+
- Positive radius of curvature → convex surface (roller, inner ring)
|
|
172
|
+
- Negative radius of curvature → concave surface (outer ring)
|
|
171
173
|
"""
|
|
172
174
|
diameter: float
|
|
173
|
-
"""
|
|
175
|
+
"""Raceway diameter (mm), use negative value for outer ring"""
|
|
174
176
|
|
|
175
177
|
raceway_type: RacewayType = RacewayType.INNER
|
|
176
|
-
"""
|
|
178
|
+
"""Raceway type"""
|
|
177
179
|
|
|
178
180
|
fai: float = 0.0
|
|
179
|
-
"""
|
|
181
|
+
"""Raceway half cone angle (degrees)"""
|
|
180
182
|
|
|
181
183
|
def __post_init__(self):
|
|
182
|
-
"""
|
|
183
|
-
#
|
|
184
|
+
"""Parameter validation"""
|
|
185
|
+
# Convert enum type
|
|
184
186
|
if isinstance(self.raceway_type, int):
|
|
185
187
|
self.raceway_type = RacewayType(self.raceway_type)
|
|
186
188
|
|
|
187
|
-
#
|
|
189
|
+
# Check sign convention
|
|
188
190
|
if self.raceway_type == RacewayType.OUTER and self.diameter > 0:
|
|
189
191
|
import warnings
|
|
190
192
|
warnings.warn(
|
|
191
|
-
f"
|
|
192
|
-
"
|
|
193
|
+
f"Outer ring raceway diameter is typically negative (current value: {self.diameter}), "
|
|
194
|
+
"please verify if this is correct"
|
|
193
195
|
)
|
|
194
196
|
|
|
195
197
|
|
|
196
198
|
@dataclass
|
|
197
199
|
class SliceResult:
|
|
198
|
-
"""
|
|
200
|
+
"""Slice calculation result.
|
|
199
201
|
|
|
200
|
-
|
|
202
|
+
Contains results of roller-raceway contact slice stress distribution calculation.
|
|
201
203
|
|
|
202
204
|
Attributes:
|
|
203
|
-
n_slice:
|
|
204
|
-
stress:
|
|
205
|
-
half_width:
|
|
206
|
-
slice_force:
|
|
207
|
-
deflection:
|
|
208
|
-
equilibrium_load:
|
|
209
|
-
equilibrium_moment:
|
|
210
|
-
converged:
|
|
211
|
-
error_code:
|
|
205
|
+
n_slice: Number of slices
|
|
206
|
+
stress: Contact center stress for each slice (MPa)
|
|
207
|
+
half_width: Contact half-width for each slice (mm)
|
|
208
|
+
slice_force: Contact force for each slice (N)
|
|
209
|
+
deflection: Roller deformation (mm)
|
|
210
|
+
equilibrium_load: Equilibrium load (N)
|
|
211
|
+
equilibrium_moment: Equilibrium moment (N·mm)
|
|
212
|
+
converged: Whether calculation converged
|
|
213
|
+
error_code: Error code (0=success)
|
|
212
214
|
|
|
213
215
|
Example:
|
|
214
216
|
>>> result = slice_stress(roller, raceway, load=1340.0, n_slice=30)
|
|
215
|
-
>>> print(f"
|
|
216
|
-
>>> print(f"
|
|
217
|
-
>>> print(f"
|
|
217
|
+
>>> print(f"Max stress: {result.max_stress:.0f} MPa")
|
|
218
|
+
>>> print(f"Stress distribution: {result.stress}")
|
|
219
|
+
>>> print(f"Slice forces: {result.slice_force}")
|
|
218
220
|
"""
|
|
219
221
|
n_slice: int
|
|
220
|
-
"""
|
|
222
|
+
"""Number of slices"""
|
|
221
223
|
|
|
222
224
|
stress: NDArray[np.float64]
|
|
223
|
-
"""
|
|
225
|
+
"""Contact center stress for each slice (MPa)"""
|
|
224
226
|
|
|
225
227
|
half_width: NDArray[np.float64]
|
|
226
|
-
"""
|
|
228
|
+
"""Contact half-width for each slice (mm)"""
|
|
227
229
|
|
|
228
230
|
slice_force: NDArray[np.float64]
|
|
229
|
-
"""
|
|
231
|
+
"""Contact force for each slice (N)"""
|
|
230
232
|
|
|
231
233
|
deflection: float
|
|
232
|
-
"""
|
|
234
|
+
"""Roller deformation (mm)"""
|
|
233
235
|
|
|
234
236
|
equilibrium_load: float
|
|
235
|
-
"""
|
|
237
|
+
"""Equilibrium load (N), should be close to input load"""
|
|
236
238
|
|
|
237
239
|
equilibrium_moment: float
|
|
238
|
-
"""
|
|
240
|
+
"""Equilibrium moment (N·mm)"""
|
|
239
241
|
|
|
240
242
|
converged: bool = True
|
|
241
|
-
"""
|
|
243
|
+
"""Whether calculation converged"""
|
|
242
244
|
|
|
243
245
|
error_code: int = 0
|
|
244
|
-
"""
|
|
246
|
+
"""Error code: 0=success, 1=equation solve failed, 2=invalid n_slice, 3=invalid load"""
|
|
245
247
|
|
|
246
248
|
@property
|
|
247
249
|
def max_stress(self) -> float:
|
|
248
|
-
"""
|
|
250
|
+
"""Maximum contact stress (MPa)"""
|
|
249
251
|
return float(np.max(self.stress)) if len(self.stress) > 0 else 0.0
|
|
250
252
|
|
|
251
253
|
@property
|
|
252
254
|
def min_stress(self) -> float:
|
|
253
|
-
"""
|
|
255
|
+
"""Minimum contact stress (MPa), excluding 0 (non-contact zones)"""
|
|
254
256
|
nonzero = self.stress[self.stress > 0]
|
|
255
257
|
return float(np.min(nonzero)) if len(nonzero) > 0 else 0.0
|
|
256
258
|
|
|
257
259
|
@property
|
|
258
260
|
def mean_stress(self) -> float:
|
|
259
|
-
"""
|
|
261
|
+
"""Mean contact stress (MPa), calculated for contact zone only"""
|
|
260
262
|
nonzero = self.stress[self.stress > 0]
|
|
261
263
|
return float(np.mean(nonzero)) if len(nonzero) > 0 else 0.0
|
|
262
264
|
|
|
263
265
|
@property
|
|
264
266
|
def contact_slices(self) -> int:
|
|
265
|
-
"""
|
|
267
|
+
"""Number of slices in contact (stress > 0)"""
|
|
266
268
|
return int(np.sum(self.stress > 0))
|
|
267
269
|
|
|
268
270
|
@property
|
|
269
271
|
def stress_uniformity(self) -> float:
|
|
270
|
-
"""
|
|
272
|
+
"""Stress uniformity (0~1), 1 means perfectly uniform.
|
|
271
273
|
|
|
272
|
-
|
|
274
|
+
Defined as: 1 - (max_stress - min_stress) / mean_stress
|
|
273
275
|
"""
|
|
274
276
|
if self.mean_stress == 0:
|
|
275
277
|
return 0.0
|
|
@@ -277,54 +279,54 @@ class SliceResult:
|
|
|
277
279
|
return max(0.0, 1.0 - variation)
|
|
278
280
|
|
|
279
281
|
def get_slice_positions(self, roller_length: float) -> NDArray[np.float64]:
|
|
280
|
-
"""
|
|
282
|
+
"""Get center position of each slice.
|
|
281
283
|
|
|
282
284
|
Args:
|
|
283
|
-
roller_length:
|
|
285
|
+
roller_length: Roller effective length (mm)
|
|
284
286
|
|
|
285
287
|
Returns:
|
|
286
|
-
|
|
288
|
+
Center position of each slice, from 0 to roller_length
|
|
287
289
|
"""
|
|
288
|
-
h = roller_length / self.n_slice / 2 #
|
|
290
|
+
h = roller_length / self.n_slice / 2 # Half slice width
|
|
289
291
|
positions = np.array([h * (2 * i + 1) for i in range(self.n_slice)])
|
|
290
292
|
return positions
|
|
291
293
|
|
|
292
294
|
def get_slice_width(self, roller_length: float) -> float:
|
|
293
|
-
"""
|
|
295
|
+
"""Get slice width.
|
|
294
296
|
|
|
295
297
|
Args:
|
|
296
|
-
roller_length:
|
|
298
|
+
roller_length: Roller effective length (mm)
|
|
297
299
|
|
|
298
300
|
Returns:
|
|
299
|
-
|
|
301
|
+
Width of a single slice (mm)
|
|
300
302
|
"""
|
|
301
303
|
return roller_length / self.n_slice
|
|
302
304
|
|
|
303
305
|
def get_slice_spacing(self, roller_length: float) -> float:
|
|
304
|
-
"""
|
|
306
|
+
"""Get spacing between adjacent slice centers.
|
|
305
307
|
|
|
306
|
-
|
|
308
|
+
Note: Slice spacing = slice width = roller_length / n_slice
|
|
307
309
|
|
|
308
310
|
Args:
|
|
309
|
-
roller_length:
|
|
311
|
+
roller_length: Roller effective length (mm)
|
|
310
312
|
|
|
311
313
|
Returns:
|
|
312
|
-
|
|
314
|
+
Spacing between adjacent slice centers (mm)
|
|
313
315
|
"""
|
|
314
316
|
return roller_length / self.n_slice
|
|
315
317
|
|
|
316
318
|
def print_slice_info(self, roller_length: float) -> None:
|
|
317
|
-
"""
|
|
319
|
+
"""Print slice division information.
|
|
318
320
|
|
|
319
321
|
Args:
|
|
320
|
-
roller_length:
|
|
322
|
+
roller_length: Roller effective length (mm)
|
|
321
323
|
"""
|
|
322
324
|
width = self.get_slice_width(roller_length)
|
|
323
325
|
positions = self.get_slice_positions(roller_length)
|
|
324
|
-
print(f"
|
|
325
|
-
print(f"
|
|
326
|
-
print(f"
|
|
327
|
-
print(f"
|
|
328
|
-
print(f"
|
|
329
|
-
print(f"
|
|
330
|
-
print(f"
|
|
326
|
+
print(f"Slice division info:")
|
|
327
|
+
print(f" Roller effective length: {roller_length} mm")
|
|
328
|
+
print(f" Number of slices: {self.n_slice}")
|
|
329
|
+
print(f" Slice width: {width:.6f} mm")
|
|
330
|
+
print(f" Slice width × n_slice = {width * self.n_slice:.6f} mm")
|
|
331
|
+
print(f" First slice center position: {positions[0]:.6f} mm")
|
|
332
|
+
print(f" Last slice center position: {positions[-1]:.6f} mm")
|