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/wrapper.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
- Python 包装层
2
+ Python Wrapper Layer
3
3
 
4
- 提供圆柱/圆锥滚子轴承切片应力计算的高级 Python 接口。
5
- 封装底层 Fortran 计算核心(通过 f2py)。
4
+ Provides high-level Python interface for cylindrical/tapered roller bearing
5
+ slice stress calculation. Wraps the underlying Fortran computational core (via f2py).
6
6
  """
7
7
 
8
8
  from typing import Optional, Sequence, Callable, Tuple
@@ -17,7 +17,7 @@ from .models import (
17
17
  SliceResult,
18
18
  )
19
19
 
20
- # 尝试导入 f2py 编译的模块
20
+ # Try to import f2py compiled module
21
21
  _FORTRAN_AVAILABLE = False
22
22
  _taper_calculate: Optional[Callable[..., Tuple[
23
23
  NDArray[np.float64], NDArray[np.float64], NDArray[np.float64], float, float, float, int
@@ -30,8 +30,8 @@ try:
30
30
  except ImportError:
31
31
  import warnings
32
32
  warnings.warn(
33
- "Fortran 计算核心未编译,请运行 'python build.py' 编译模块。"
34
- "当前切片计算功能不可用。"
33
+ "Fortran core not compiled. Please run 'python build.py' to compile. "
34
+ "Slice calculation functionality is currently unavailable."
35
35
  )
36
36
 
37
37
 
@@ -41,73 +41,73 @@ def slice_stress(
41
41
  load: float,
42
42
  n_slice: int = 30,
43
43
  ) -> SliceResult:
44
- """计算滚子-滚道接触的切片应力分布
44
+ """Calculate slice stress distribution for roller-raceway contact.
45
45
 
46
- 使用影响系数法(Influence Coefficient Method)计算滚子与滚道
47
- 接触时各切片的应力分布,考虑凸度修形和滚子倾斜的影响。
46
+ Uses the Influence Coefficient Method to calculate stress distribution
47
+ across slices, considering crown modification and roller tilt effects.
48
48
 
49
49
  Args:
50
- roller: 滚子几何参数
51
- raceway: 滚道参数
52
- load: 滚子载荷 (N)
53
- n_slice: 切片数量 (1-50),默认 30
50
+ roller: Roller geometry parameters
51
+ raceway: Raceway parameters
52
+ load: Roller load (N)
53
+ n_slice: Number of slices (1-50), default 30
54
54
 
55
55
  Returns:
56
- SliceResult: 包含各切片应力、接触半宽度等计算结果
56
+ SliceResult: Contains stress, contact half-width, and other results for each slice
57
57
 
58
58
  Raises:
59
- RuntimeError: Fortran 模块未编译时抛出
60
- ValueError: 参数无效时抛出
59
+ RuntimeError: When Fortran module is not compiled
60
+ ValueError: When parameters are invalid
61
61
 
62
62
  Example:
63
- >>> from slice_wrapper import slice_stress, RollerParams, RacewayParams
64
- >>> from slice_wrapper import CrownType, RacewayType
63
+ >>> from bstart_trb import slice_stress, RollerParams, RacewayParams
64
+ >>> from bstart_trb import CrownType, RacewayType
65
65
  >>>
66
- >>> # 定义滚子参数
66
+ >>> # Define roller parameters
67
67
  >>> roller = RollerParams(
68
68
  ... d1=10.0, d2=10.0, length=9.6,
69
69
  ... crown_type=CrownType.LOGARITHMIC,
70
70
  ... curve_q=14100.0
71
71
  ... )
72
72
  >>>
73
- >>> # 定义外圈滚道参数(注意直径为负值)
73
+ >>> # Define outer ring raceway parameters (note negative diameter)
74
74
  >>> raceway = RacewayParams(
75
75
  ... diameter=-150.0,
76
76
  ... raceway_type=RacewayType.OUTER
77
77
  ... )
78
78
  >>>
79
- >>> # 计算切片应力
79
+ >>> # Calculate slice stress
80
80
  >>> result = slice_stress(roller, raceway, load=1340.0, n_slice=30)
81
- >>> print(f"最大应力: {result.max_stress:.0f} MPa")
82
- >>> print(f"应力均匀度: {result.stress_uniformity:.2%}")
81
+ >>> print(f"Max stress: {result.max_stress:.0f} MPa")
82
+ >>> print(f"Stress uniformity: {result.stress_uniformity:.2%}")
83
83
 
84
84
  Note:
85
- - 切片数 n_slice 最大支持 50
86
- - 对数凸度 (crown_type=2) load == curve_q 时可实现均匀应力分布
87
- - 外圈滚道的 diameter 应使用负值(Hertz 接触符号约定)
85
+ - Maximum n_slice is 50
86
+ - Logarithmic crown (crown_type=2) achieves uniform stress when load == curve_q
87
+ - Outer ring raceway diameter should be negative (Hertz contact sign convention)
88
88
 
89
89
  Theory:
90
- 该函数使用影响系数法求解滚子-滚道接触问题:
91
- 1. 将滚子沿轴向分成 n_slice 个切片
92
- 2. 建立切片间的弹性耦合关系(影响系数矩阵)
93
- 3. 使用高斯消元法求解线性方程组
94
- 4. 迭代收敛得到各切片的接触应力分布
90
+ This function uses the influence coefficient method to solve roller-raceway contact:
91
+ 1. Divides roller axially into n_slice slices
92
+ 2. Establishes elastic coupling between slices (influence coefficient matrix)
93
+ 3. Solves linear system using Gaussian elimination
94
+ 4. Iterates to convergence to obtain contact stress distribution
95
95
  """
96
96
  if not _FORTRAN_AVAILABLE or _taper_calculate is None:
97
97
  raise RuntimeError(
98
- "Fortran 计算核心未编译。请先运行 'python build.py' 编译模块。"
98
+ "Fortran core not compiled. Please run 'python build.py' first."
99
99
  )
100
100
 
101
- # 参数验证
101
+ # Parameter validation
102
102
  if load <= 0:
103
- raise ValueError(f"载荷必须为正数,当前值: {load}")
103
+ raise ValueError(f"Load must be positive, got: {load}")
104
104
  if not 1 <= n_slice <= 50:
105
- raise ValueError(f"切片数必须在 1-50 之间,当前值: {n_slice}")
105
+ raise ValueError(f"n_slice must be between 1-50, got: {n_slice}")
106
106
 
107
- # 确定设计载荷
107
+ # Determine design load
108
108
  curve_q = roller.curve_q if roller.curve_q > 0 else load
109
109
 
110
- # 调用 Fortran 计算(此时 _taper_calculate 已确保不为 None
110
+ # Call Fortran calculation (_taper_calculate is guaranteed non-None here)
111
111
  p, a, q_slice, dc, q1, qm, ierr = _taper_calculate(
112
112
  d1=roller.d1,
113
113
  d2=roller.d2,
@@ -123,7 +123,7 @@ def slice_stress(
123
123
  curveq=curve_q,
124
124
  )
125
125
 
126
- # 构建结果
126
+ # Build result
127
127
  return SliceResult(
128
128
  n_slice=n_slice,
129
129
  stress=np.array(p, dtype=np.float64),
@@ -143,25 +143,26 @@ def batch_slice_stress(
143
143
  loads: Sequence[float],
144
144
  n_slice: int = 30,
145
145
  ) -> list[SliceResult]:
146
- """批量计算多个载荷下的切片应力分布
146
+ """Batch calculate slice stress distribution for multiple loads.
147
147
 
148
- 对多个载荷值进行切片应力计算,适用于载荷分布已知的情况。
148
+ Calculates slice stress for multiple load values, suitable when
149
+ load distribution is known.
149
150
 
150
151
  Args:
151
- roller: 滚子几何参数
152
- raceway: 滚道参数
153
- loads: 载荷序列 (N),支持 list[int], list[float], NDArray
154
- n_slice: 切片数量,默认 30
152
+ roller: Roller geometry parameters
153
+ raceway: Raceway parameters
154
+ loads: Load sequence (N), supports list[int], list[float], NDArray, etc.
155
+ n_slice: Number of slices, default 30
155
156
 
156
157
  Returns:
157
- list[SliceResult]: 各载荷对应的计算结果列表
158
+ list[SliceResult]: List of calculation results for each load
158
159
 
159
160
  Example:
160
- >>> # 假设已知各滚子的载荷分布
161
+ >>> # Assuming known load distribution for each roller
161
162
  >>> loads = [1340.0, 1128.3, 689.2, 324.8]
162
163
  >>> results = batch_slice_stress(roller, raceway, loads)
163
164
  >>> for i, result in enumerate(results):
164
- ... print(f"载荷 {loads[i]:.1f}N: 最大应力 {result.max_stress:.0f} MPa")
165
+ ... print(f"Load {loads[i]:.1f}N: Max stress {result.max_stress:.0f} MPa")
165
166
  """
166
167
  results = []
167
168
  for load in loads:
@@ -169,7 +170,7 @@ def batch_slice_stress(
169
170
  result = slice_stress(roller, raceway, load, n_slice)
170
171
  results.append(result)
171
172
  else:
172
- # 无载荷,返回零结果
173
+ # Zero load, return zero result
173
174
  results.append(SliceResult(
174
175
  n_slice=n_slice,
175
176
  stress=np.zeros(n_slice),
@@ -185,9 +186,9 @@ def batch_slice_stress(
185
186
 
186
187
 
187
188
  def is_fortran_available() -> bool:
188
- """检查 Fortran 计算核心是否可用
189
+ """Check if Fortran computational core is available.
189
190
 
190
191
  Returns:
191
- bool: True 表示 Fortran 模块已编译可用
192
+ bool: True if Fortran module is compiled and available
192
193
  """
193
194
  return _FORTRAN_AVAILABLE
@@ -0,0 +1,289 @@
1
+ Metadata-Version: 2.4
2
+ Name: bstart-trb
3
+ Version: 0.2.2
4
+ Summary: Add your description here
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: numpy>=2.0.0
8
+ Provides-Extra: demo
9
+ Requires-Dist: openpyxl>=3.1.5; extra == 'demo'
10
+ Requires-Dist: pandas>=2.0.0; extra == 'demo'
11
+ Requires-Dist: plotly>=5.0.0; extra == 'demo'
12
+ Description-Content-Type: text/markdown
13
+
14
+ # BSTART-TRB
15
+
16
+ **Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module**
17
+
18
+ A high-performance Python package for calculating contact stress distribution in roller bearings using the slice method with Fortran computational core.
19
+
20
+ ## Features
21
+
22
+ - 🚀 **Fast Fortran Core**: Compiled Fortran code via f2py for optimal performance
23
+ - 📦 **Pre-compiled Binary**: No Fortran compiler required for installation
24
+ - 🎯 **Type-Safe**: Complete type hints and IDE support
25
+ - 🔬 **Accurate**: Uses influence coefficient method based on elastic contact theory
26
+ - 📊 **Flexible**: Supports various crown types (linear, circular, logarithmic)
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install bstart-trb
32
+ ```
33
+
34
+ **Note**: This package includes pre-compiled binaries for Windows (x64) + Python 3.11. Support for other platforms coming soon.
35
+
36
+ ## Quick Start
37
+
38
+ ```python
39
+ from bstart_trb import (
40
+ slice_stress,
41
+ RollerParams,
42
+ RacewayParams,
43
+ CrownType,
44
+ RacewayType,
45
+ )
46
+
47
+ # Define cylindrical roller parameters
48
+ roller = RollerParams(
49
+ d1=10.0, # Small end diameter (mm)
50
+ d2=10.0, # Large end diameter (mm)
51
+ length=9.6, # Effective length (mm)
52
+ alfa=0.0, # Half cone angle (degrees)
53
+ tilt=0.0, # Tilt angle (degrees)
54
+ crown_type=CrownType.LOGARITHMIC,
55
+ curve_q=14100.0, # Design load (N)
56
+ )
57
+
58
+ # Define outer ring raceway parameters
59
+ raceway = RacewayParams(
60
+ diameter=-150.0, # Negative for concave surface (mm)
61
+ raceway_type=RacewayType.OUTER,
62
+ fai=0.0, # Half cone angle (degrees)
63
+ )
64
+
65
+ # Calculate slice stress distribution
66
+ result = slice_stress(roller, raceway, load=1340.86, n_slice=30)
67
+
68
+ # Access scalar results
69
+ print(f"Converged: {result.converged}")
70
+ print(f"Max stress: {result.max_stress:.0f} MPa")
71
+ print(f"Mean stress: {result.mean_stress:.0f} MPa")
72
+ print(f"Contact deflection: {result.deflection:.6f} mm")
73
+ print(f"Stress uniformity: {result.stress_uniformity:.2%}")
74
+ print(f"Contact slices: {result.contact_slices}/{result.n_slice}")
75
+
76
+ # Access array results
77
+ print(f"Stress distribution: {result.stress}") # MPa per slice
78
+ print(f"Contact half-widths: {result.half_width}") # mm per slice
79
+ print(f"Slice forces: {result.slice_force}") # N per slice
80
+
81
+ # Get slice positions along roller length
82
+ positions = result.get_slice_positions(roller.length) # mm
83
+ print(f"Slice positions: {positions}")
84
+ ```
85
+
86
+ ## Return Value: `SliceResult`
87
+
88
+ The `slice_stress()` function returns a `SliceResult` object containing:
89
+
90
+ ### Array Attributes
91
+
92
+ | Attribute | Type | Unit | Description |
93
+ |-----------|------|------|-------------|
94
+ | `stress` | `NDArray[float64]` | MPa | Contact stress at each slice center |
95
+ | `half_width` | `NDArray[float64]` | mm | Contact half-width at each slice |
96
+ | `slice_force` | `NDArray[float64]` | N | Contact force at each slice |
97
+
98
+ ### Scalar Attributes
99
+
100
+ | Attribute | Type | Unit | Description |
101
+ |-----------|------|------|-------------|
102
+ | `n_slice` | `int` | - | Number of slices |
103
+ | `deflection` | `float` | mm | Roller deformation |
104
+ | `equilibrium_load` | `float` | N | Equilibrium load (should match input) |
105
+ | `equilibrium_moment` | `float` | N·mm | Equilibrium moment |
106
+ | `converged` | `bool` | - | Whether the iteration converged |
107
+ | `error_code` | `int` | - | 0=success, 1=solve failed, 2=invalid n_slice, 3=invalid load |
108
+
109
+ ### Computed Properties
110
+
111
+ | Property | Type | Unit | Description |
112
+ |----------|------|------|-------------|
113
+ | `max_stress` | `float` | MPa | Maximum contact stress |
114
+ | `min_stress` | `float` | MPa | Minimum contact stress (non-zero) |
115
+ | `mean_stress` | `float` | MPa | Mean contact stress (contact zone only) |
116
+ | `contact_slices` | `int` | - | Number of slices in contact (stress > 0) |
117
+ | `stress_uniformity` | `float` | 0~1 | Stress uniformity (1 = perfectly uniform) |
118
+
119
+ ### Methods
120
+
121
+ | Method | Returns | Description |
122
+ |--------|---------|-------------|
123
+ | `get_slice_positions(roller_length)` | `NDArray[float64]` | Center position of each slice (mm) |
124
+ | `get_slice_width(roller_length)` | `float` | Width of each slice (mm) |
125
+ | `get_slice_spacing(roller_length)` | `float` | Spacing between slice centers (mm) |
126
+
127
+ ## Other Functions
128
+
129
+ ### `batch_slice_stress()`
130
+
131
+ Calculate stress for multiple loads at once:
132
+
133
+ ```python
134
+ from bstart_trb import batch_slice_stress
135
+
136
+ loads = [1340.0, 1128.3, 689.2, 324.8]
137
+ results = batch_slice_stress(roller, raceway, loads, n_slice=30)
138
+
139
+ for i, result in enumerate(results):
140
+ print(f"Load {loads[i]:.1f}N: Max stress {result.max_stress:.0f} MPa")
141
+ ```
142
+
143
+ ### `is_fortran_available()`
144
+
145
+ Check if Fortran core is available:
146
+
147
+ ```python
148
+ from bstart_trb import is_fortran_available
149
+
150
+ if is_fortran_available():
151
+ print("Fortran core ready")
152
+ else:
153
+ print("Fortran core not compiled")
154
+ ```
155
+
156
+ ## Enum Types
157
+
158
+ ### `CrownType` - Crown Modification Types
159
+
160
+ | Value | Name | Description |
161
+ |-------|------|-------------|
162
+ | 0 | `STRAIGHT` | No crown modification - high edge stress |
163
+ | 1 | `ARC` | Circular crown - requires arc radius |
164
+ | 2 | `LOGARITHMIC` | Logarithmic crown (recommended) - optimal stress distribution |
165
+
166
+ ### `RacewayType` - Raceway Types
167
+
168
+ | Value | Name | Description |
169
+ |-------|------|-------------|
170
+ | 0 | `PLANE` | Flat surface contact |
171
+ | 1 | `INNER` | Inner ring raceway (convex surface) |
172
+ | 2 | `OUTER` | Outer ring raceway (concave surface) - use negative diameter |
173
+
174
+ ## Key Parameters Explained
175
+
176
+ ### Roller Parameters
177
+
178
+ | Parameter | Unit | Description |
179
+ |-----------|------|-------------|
180
+ | `d1` | mm | Roller small end diameter (equal to d2 for cylindrical) |
181
+ | `d2` | mm | Roller large end diameter |
182
+ | `length` | mm | Effective roller length |
183
+ | `alfa` | deg | Roller half cone angle (0 for cylindrical) |
184
+ | `tilt` | deg | Roller tilt angle (see below) |
185
+ | `crown_type` | - | Crown modification type (see enum) |
186
+ | `curve_q` | N | Design load for crown optimization (see below) |
187
+
188
+ ### Raceway Parameters
189
+
190
+ | Parameter | Unit | Description |
191
+ |-----------|------|-------------|
192
+ | `diameter` | mm | Raceway diameter (**negative for outer ring**) |
193
+ | `raceway_type` | - | Inner/Outer raceway type |
194
+ | `fai` | deg | Raceway half cone angle |
195
+
196
+ ### Calculation Parameters
197
+
198
+ | Parameter | Unit | Description |
199
+ |-----------|------|-------------|
200
+ | `load` | N | Applied load on roller |
201
+ | `n_slice` | - | Number of slices (default 30, max 50) |
202
+
203
+ ### Understanding `curve_q` (Design Load)
204
+
205
+ The `curve_q` parameter determines the logarithmic crown profile. It affects stress distribution:
206
+
207
+ | Condition | Stress Distribution |
208
+ |-----------|---------------------|
209
+ | `load == curve_q` | **Uniform** - optimal crown compensation |
210
+ | `load < curve_q` | Center high, edge low - edge may lose contact |
211
+ | `load > curve_q` | Edge high, center low - edge stress concentration |
212
+
213
+ **Tip**: Set `curve_q` to your most common operating load.
214
+
215
+ ### Understanding `tilt` (Tilt Angle)
216
+
217
+ Roller tilt causes asymmetric stress distribution:
218
+
219
+ ```
220
+ tilt = 0 (normal): tilt > 0 (tilted):
221
+ ┌──────────────────┐ ┌──────────────────┐
222
+ │ uniform stress │ │ high │ low │
223
+ └──────────────────┘ └──────────────────┘
224
+ ```
225
+
226
+ Sources of tilt: shaft deflection, mounting errors, housing deformation.
227
+
228
+ ### Why Outer Ring Uses Negative Diameter?
229
+
230
+ Hertz contact theory sign convention:
231
+ - **Positive curvature** → Convex surface (roller, inner ring)
232
+ - **Negative curvature** → Concave surface (outer ring)
233
+
234
+ Example: Outer ring with 150mm diameter → `diameter = -150.0`
235
+
236
+ ## What is Slice Calculation?
237
+
238
+ The slice method divides the roller-raceway contact into multiple slices along the roller length to accurately calculate stress distribution. This is essential for:
239
+
240
+ - Capturing edge stress concentration effects
241
+ - Analyzing the impact of crown modifications
242
+ - Predicting bearing life more accurately
243
+ - Understanding load distribution along roller length
244
+
245
+ ## Theory
246
+
247
+ This package implements the **influence coefficient method** based on elastic half-space contact theory:
248
+
249
+ 1. Discretizes roller into slices
250
+ 2. Calculates elastic coupling between slices (influence coefficient matrix)
251
+ 3. Solves linear system using Gaussian elimination
252
+ 4. Iterates to convergence for contact area and load balance
253
+
254
+ The method is more accurate than simplified Hertz formulas as it accounts for:
255
+ - Elastic coupling between slices
256
+ - Dynamic contact area determination
257
+ - Edge loading effects
258
+ - Crown modification influence
259
+
260
+ ## Requirements
261
+
262
+ - Python >= 3.11
263
+ - NumPy >= 2.0.0
264
+
265
+ ## Platform Support
266
+
267
+ | Platform | Status |
268
+ |----------|--------|
269
+ | Windows (x64) | ✅ Supported |
270
+ | Linux | 🚧 Coming soon |
271
+ | macOS | 🚧 Coming soon |
272
+
273
+ ## License
274
+
275
+ MIT License - See LICENSE file for details.
276
+
277
+ ## Author
278
+
279
+ Gu Lei
280
+
281
+ ## References
282
+
283
+ - Harris, T.A., Kotzalas, M.N. - *Rolling Bearing Analysis*, 5th Edition
284
+ - Johnson, K.L. - *Contact Mechanics*
285
+ - ISO/TS 16281:2008 - Rolling bearings calculation methods
286
+
287
+ ## Contributing
288
+
289
+ Contributions are welcome! Please feel free to submit issues or pull requests.
@@ -0,0 +1,11 @@
1
+ bstart_trb/__init__.py,sha256=32QmnLdTE53qkVgDvDZBH2Z1v3I-4qG8JlcVlQDcbU4,1560
2
+ bstart_trb/_taper_slice.pyi,sha256=X5xMWlbdGl46RQmunOaFbh9BFjeqTMP0Hp7b_waJuaA,4896
3
+ bstart_trb/libtaper_sl.J4R3HUMRYTOGZPKAVTEOISVEHZMIJTJT.gfortran-win_amd64.dll,sha256=9fWV89mKt1_6Q8f_votoG1vlvxsy4qgDVWXQAZ0vmUA,108562
4
+ bstart_trb/models.py,sha256=tRpkcJE50I9jL3y03EgITJ1iMv57gRFkr1tl6OeXDWw,11503
5
+ bstart_trb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ bstart_trb/wrapper.py,sha256=CadOcW31MVZ8WsTwG5Ksp_ZAacf_D96XJJ4gqYb70MM,6565
7
+ bstart_trb/_taper_slice.cp311-win_amd64.pyd,sha256=WDAXF_NTj7DRIEA6--kX1W3TMPGQD5u8JVRt-hR_9L4,64000
8
+ bstart_trb-0.2.2.dist-info/METADATA,sha256=jRClXe7c3JBUEWgsMsYT9vkUTWjldlM5aLma2y1ZogQ,9502
9
+ bstart_trb-0.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ bstart_trb-0.2.2.dist-info/licenses/LICENSE,sha256=YCXLtJfjUPyklZ7pN5gxOeMOr5QCAvip4Sdnl_xcCu8,1084
11
+ bstart_trb-0.2.2.dist-info/RECORD,,