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 CHANGED
@@ -11,8 +11,8 @@ Features:
11
11
  - Dataclass wrapped results
12
12
 
13
13
  Example:
14
- >>> from slice_wrapper import slice_stress, RollerParams, RacewayParams
15
- >>> from slice_wrapper import CrownType, RacewayType
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.0"
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
- 所有类都使用 dataclass 装饰器,支持完整的类型提示。
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
- """外圈滚道(凹面),注意 diameter 使用负值"""
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: 滚子小端直径 (mm)
63
- d2: 滚子大端直径 (mm),圆柱滚子 d1=d2
64
- length: 滚子有效长度 (mm)
65
- alfa: 滚子半圆锥角 (),圆柱滚子 alfa=0
66
- tilt: 滚子倾斜角度 ()0 表示无倾斜
67
- crown_type: 凸度类型,见 CrownType 枚举
68
- curve_q: 设计载荷 (N),用于计算对数凸度修形量
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
- - 对数凸度修形在 load == curve_q 时可实现均匀应力分布
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
- """滚子小端直径 (mm)"""
94
+ """Roller small end diameter (mm)"""
93
95
 
94
96
  d2: float
95
- """滚子大端直径 (mm),圆柱滚子 d1=d2"""
97
+ """Roller large end diameter (mm), d1=d2 for cylindrical rollers"""
96
98
 
97
99
  length: float
98
- """滚子有效长度 (mm)"""
100
+ """Roller effective length (mm)"""
99
101
 
100
102
  alfa: float = 0.0
101
- """滚子半圆锥角 (),圆柱滚子 alfa=0"""
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
- """设计载荷 (N),用于对数凸度计算,0 表示使用实际载荷"""
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"滚子小端直径必须为正数,当前值: {self.d1}")
117
+ raise ValueError(f"Roller small end diameter must be positive, got: {self.d1}")
116
118
  if self.d2 <= 0:
117
- raise ValueError(f"滚子大端直径必须为正数,当前值: {self.d2}")
119
+ raise ValueError(f"Roller large end diameter must be positive, got: {self.d2}")
118
120
  if self.length <= 0:
119
- raise ValueError(f"滚子有效长度必须为正数,当前值: {self.length}")
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"滚子小端直径 d1={self.d1} 大于大端直径 d2={self.d2},请确认")
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: 滚道直径 (mm)
147
- - 内圈滚道:正值
148
- - 外圈滚道:负值(Hertz 接触理论符号约定)
149
- raceway_type: 滚道类型,见 RacewayType 枚举
150
- fai: 滚道半圆锥角 (),圆柱滚子轴承为 0
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
- 外圈滚道 diameter 使用负值是 Hertz 接触理论的符号约定:
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
- """滚道直径 (mm),外圈使用负值"""
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"外圈滚道 diameter 通常使用负值(当前值: {self.diameter}),"
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: 各切片接触中心应力 (MPa)
205
- half_width: 各切片接触半宽度 (mm)
206
- slice_force: 各切片接触力 (N)
207
- deflection: 滚子变形量 (mm)
208
- equilibrium_load: 平衡载荷 (N)
209
- equilibrium_moment: 平衡力矩 (N·mm)
210
- converged: 是否收敛
211
- error_code: 错误码 (0=成功)
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"最大应力: {result.max_stress:.0f} MPa")
216
- >>> print(f"应力分布: {result.stress}")
217
- >>> print(f"各切片力: {result.slice_force}")
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
- """各切片接触中心应力 (MPa)"""
225
+ """Contact center stress for each slice (MPa)"""
224
226
 
225
227
  half_width: NDArray[np.float64]
226
- """各切片接触半宽度 (mm)"""
228
+ """Contact half-width for each slice (mm)"""
227
229
 
228
230
  slice_force: NDArray[np.float64]
229
- """各切片接触力 (N)"""
231
+ """Contact force for each slice (N)"""
230
232
 
231
233
  deflection: float
232
- """滚子变形量 (mm)"""
234
+ """Roller deformation (mm)"""
233
235
 
234
236
  equilibrium_load: float
235
- """平衡载荷 (N),应接近输入载荷"""
237
+ """Equilibrium load (N), should be close to input load"""
236
238
 
237
239
  equilibrium_moment: float
238
- """平衡力矩 (N·mm)"""
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
- """错误码: 0=成功, 1=方程求解失败, 2=切片数无效, 3=载荷无效"""
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
- """最大接触应力 (MPa)"""
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
- """最小接触应力 (MPa),不包括 0(非接触区)"""
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
- """平均接触应力 (MPa),仅计算接触区"""
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
- """接触切片数量(应力 > 0"""
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
- """应力均匀度 (0~1)1 表示完全均匀
272
+ """Stress uniformity (0~1), 1 means perfectly uniform.
271
273
 
272
- 定义为: 1 - (最大应力 - 最小应力) / 平均应力
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: 滚子有效长度 (mm)
285
+ roller_length: Roller effective length (mm)
284
286
 
285
287
  Returns:
286
- 各切片中心位置,从 0 roller_length
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: 滚子有效长度 (mm)
298
+ roller_length: Roller effective length (mm)
297
299
 
298
300
  Returns:
299
- 单个切片的宽度 (mm)
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
- 注意:切片间距 = 切片宽度 = roller_length / n_slice
308
+ Note: Slice spacing = slice width = roller_length / n_slice
307
309
 
308
310
  Args:
309
- roller_length: 滚子有效长度 (mm)
311
+ roller_length: Roller effective length (mm)
310
312
 
311
313
  Returns:
312
- 相邻切片中心之间的间距 (mm)
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: 滚子有效长度 (mm)
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" 滚子有效长度: {roller_length} mm")
326
- print(f" 切片数量: {self.n_slice}")
327
- print(f" 切片宽度: {width:.6f} mm")
328
- print(f" 切片宽度 × 切片数 = {width * self.n_slice:.6f} mm")
329
- print(f" 第一片中心位置: {positions[0]:.6f} mm")
330
- print(f" 最后片中心位置: {positions[-1]:.6f} mm")
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")