bstart-trb 0.1.0__tar.gz
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-0.1.0/.gitignore +30 -0
- bstart_trb-0.1.0/LICENSE +21 -0
- bstart_trb-0.1.0/PKG-INFO +165 -0
- bstart_trb-0.1.0/README_PYPI.md +140 -0
- bstart_trb-0.1.0/pyproject.toml +61 -0
- bstart_trb-0.1.0/slice_wrapper/__init__.py +63 -0
- bstart_trb-0.1.0/slice_wrapper/_taper_slice.cp312-win_amd64.pyd +0 -0
- bstart_trb-0.1.0/slice_wrapper/_taper_slice.pyi +140 -0
- bstart_trb-0.1.0/slice_wrapper/models.py +330 -0
- bstart_trb-0.1.0/slice_wrapper/py.typed +0 -0
- bstart_trb-0.1.0/slice_wrapper/wrapper.py +193 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Compiled extensions (built by CI)
|
|
13
|
+
*.so
|
|
14
|
+
*.dylib
|
|
15
|
+
|
|
16
|
+
# 注意:不再忽略 .pyd 文件,因为需要将预编译的二进制文件打包
|
|
17
|
+
# 如果需要排除特定的 .pyd 文件,请在下面明确列出
|
|
18
|
+
# *.pyd
|
|
19
|
+
|
|
20
|
+
# Build artifacts
|
|
21
|
+
*.mod
|
|
22
|
+
*.o
|
|
23
|
+
|
|
24
|
+
# IDE
|
|
25
|
+
.idea/
|
|
26
|
+
.vscode/
|
|
27
|
+
|
|
28
|
+
# Test outputs
|
|
29
|
+
*.html
|
|
30
|
+
*.json
|
bstart_trb-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Gu Lei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bstart-trb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module
|
|
5
|
+
Project-URL: Homepage, https://github.com/yourusername/bstart-trb
|
|
6
|
+
Project-URL: Repository, https://github.com/yourusername/bstart-trb
|
|
7
|
+
Project-URL: Documentation, https://github.com/yourusername/bstart-trb#readme
|
|
8
|
+
Author-email: Gu Lei <gulei@example.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: bearing,contact,f2py,fortran,hertz,roller,stress
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Manufacturing
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Programming Language :: Fortran
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Requires-Dist: numpy>=2.0.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# BSTART-TRB
|
|
27
|
+
|
|
28
|
+
**Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module**
|
|
29
|
+
|
|
30
|
+
A high-performance Python package for calculating contact stress distribution in roller bearings using the slice method with Fortran computational core.
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- 🚀 **Fast Fortran Core**: Compiled Fortran code via f2py for optimal performance
|
|
35
|
+
- 📦 **Pre-compiled Binary**: No Fortran compiler required for installation
|
|
36
|
+
- 🎯 **Type-Safe**: Complete type hints and IDE support
|
|
37
|
+
- 🔬 **Accurate**: Uses influence coefficient method based on elastic contact theory
|
|
38
|
+
- 📊 **Flexible**: Supports various crown types (linear, circular, logarithmic)
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install bstart-trb
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Note**: This package includes pre-compiled binaries for Windows (x64). Support for other platforms coming soon.
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from slice_wrapper import (
|
|
52
|
+
slice_stress,
|
|
53
|
+
RollerParams,
|
|
54
|
+
RacewayParams,
|
|
55
|
+
CrownType,
|
|
56
|
+
RacewayType,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Define cylindrical roller parameters
|
|
60
|
+
roller = RollerParams(
|
|
61
|
+
d1=10.0, # Small end diameter (mm)
|
|
62
|
+
d2=10.0, # Large end diameter (mm)
|
|
63
|
+
length=9.6, # Effective length (mm)
|
|
64
|
+
alfa=0.0, # Half cone angle (degrees)
|
|
65
|
+
tilt=0.0, # Tilt angle (degrees)
|
|
66
|
+
crown_type=CrownType.LOGARITHMIC,
|
|
67
|
+
curve_q=14100.0, # Design load (N)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Define outer ring raceway parameters
|
|
71
|
+
raceway = RacewayParams(
|
|
72
|
+
diameter=-150.0, # Negative for concave surface (mm)
|
|
73
|
+
raceway_type=RacewayType.OUTER,
|
|
74
|
+
fai=0.0, # Half cone angle (degrees)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Calculate slice stress distribution
|
|
78
|
+
result = slice_stress(roller, raceway, load=1340.86, n_slice=30)
|
|
79
|
+
|
|
80
|
+
# Access results
|
|
81
|
+
print(f"Max stress: {result.max_stress:.0f} MPa")
|
|
82
|
+
print(f"Contact deflection: {result.deflection:.6f} mm")
|
|
83
|
+
print(f"Stress uniformity: {result.stress_uniformity:.2%}")
|
|
84
|
+
print(f"Contact slices: {result.contact_slices}/{result.n_slice}")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## What is Slice Calculation?
|
|
88
|
+
|
|
89
|
+
The slice method divides the roller-raceway contact into multiple slices along the roller length to accurately calculate stress distribution. This is essential for:
|
|
90
|
+
|
|
91
|
+
- Capturing edge stress concentration effects
|
|
92
|
+
- Analyzing the impact of crown modifications
|
|
93
|
+
- Predicting bearing life more accurately
|
|
94
|
+
- Understanding load distribution along roller length
|
|
95
|
+
|
|
96
|
+
## Key Parameters
|
|
97
|
+
|
|
98
|
+
### Roller Parameters
|
|
99
|
+
|
|
100
|
+
- `d1`, `d2`: Roller diameters (mm) - equal for cylindrical rollers
|
|
101
|
+
- `length`: Effective roller length (mm)
|
|
102
|
+
- `alfa`: Half cone angle (degrees) - 0 for cylindrical rollers
|
|
103
|
+
- `tilt`: Roller tilt angle (degrees)
|
|
104
|
+
- `crown_type`: Crown modification type
|
|
105
|
+
- `STRAIGHT`: No crown modification
|
|
106
|
+
- `CIRCULAR`: Circular crown
|
|
107
|
+
- `LOGARITHMIC`: Logarithmic crown (recommended)
|
|
108
|
+
- `curve_q`: Design load (N) for optimal stress distribution
|
|
109
|
+
|
|
110
|
+
### Raceway Parameters
|
|
111
|
+
|
|
112
|
+
- `diameter`: Raceway diameter (mm) - negative for outer ring (concave)
|
|
113
|
+
- `raceway_type`: `INNER` or `OUTER`
|
|
114
|
+
- `fai`: Raceway cone angle (degrees)
|
|
115
|
+
|
|
116
|
+
### Calculation Parameters
|
|
117
|
+
|
|
118
|
+
- `load`: Applied load on roller (N)
|
|
119
|
+
- `n_slice`: Number of slices (default 30, max 50)
|
|
120
|
+
|
|
121
|
+
## Theory
|
|
122
|
+
|
|
123
|
+
This package implements the **influence coefficient method** based on elastic half-space contact theory:
|
|
124
|
+
|
|
125
|
+
1. Discretizes roller into slices
|
|
126
|
+
2. Calculates elastic coupling between slices (influence coefficient matrix)
|
|
127
|
+
3. Solves linear system using Gaussian elimination
|
|
128
|
+
4. Iterates to convergence for contact area and load balance
|
|
129
|
+
|
|
130
|
+
The method is more accurate than simplified Hertz formulas as it accounts for:
|
|
131
|
+
- Elastic coupling between slices
|
|
132
|
+
- Dynamic contact area determination
|
|
133
|
+
- Edge loading effects
|
|
134
|
+
- Crown modification influence
|
|
135
|
+
|
|
136
|
+
## Requirements
|
|
137
|
+
|
|
138
|
+
- Python >= 3.12
|
|
139
|
+
- NumPy >= 2.0.0
|
|
140
|
+
|
|
141
|
+
## Platform Support
|
|
142
|
+
|
|
143
|
+
| Platform | Status |
|
|
144
|
+
|----------|--------|
|
|
145
|
+
| Windows (x64) | ✅ Supported |
|
|
146
|
+
| Linux | 🚧 Coming soon |
|
|
147
|
+
| macOS | 🚧 Coming soon |
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT License - See LICENSE file for details.
|
|
152
|
+
|
|
153
|
+
## Author
|
|
154
|
+
|
|
155
|
+
Gu Lei
|
|
156
|
+
|
|
157
|
+
## References
|
|
158
|
+
|
|
159
|
+
- Harris, T.A., Kotzalas, M.N. - *Rolling Bearing Analysis*, 5th Edition
|
|
160
|
+
- Johnson, K.L. - *Contact Mechanics*
|
|
161
|
+
- ISO/TS 16281:2008 - Rolling bearings calculation methods
|
|
162
|
+
|
|
163
|
+
## Contributing
|
|
164
|
+
|
|
165
|
+
Contributions are welcome! Please feel free to submit issues or pull requests.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# BSTART-TRB
|
|
2
|
+
|
|
3
|
+
**Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module**
|
|
4
|
+
|
|
5
|
+
A high-performance Python package for calculating contact stress distribution in roller bearings using the slice method with Fortran computational core.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🚀 **Fast Fortran Core**: Compiled Fortran code via f2py for optimal performance
|
|
10
|
+
- 📦 **Pre-compiled Binary**: No Fortran compiler required for installation
|
|
11
|
+
- 🎯 **Type-Safe**: Complete type hints and IDE support
|
|
12
|
+
- 🔬 **Accurate**: Uses influence coefficient method based on elastic contact theory
|
|
13
|
+
- 📊 **Flexible**: Supports various crown types (linear, circular, logarithmic)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install bstart-trb
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Note**: This package includes pre-compiled binaries for Windows (x64). Support for other platforms coming soon.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from slice_wrapper import (
|
|
27
|
+
slice_stress,
|
|
28
|
+
RollerParams,
|
|
29
|
+
RacewayParams,
|
|
30
|
+
CrownType,
|
|
31
|
+
RacewayType,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Define cylindrical roller parameters
|
|
35
|
+
roller = RollerParams(
|
|
36
|
+
d1=10.0, # Small end diameter (mm)
|
|
37
|
+
d2=10.0, # Large end diameter (mm)
|
|
38
|
+
length=9.6, # Effective length (mm)
|
|
39
|
+
alfa=0.0, # Half cone angle (degrees)
|
|
40
|
+
tilt=0.0, # Tilt angle (degrees)
|
|
41
|
+
crown_type=CrownType.LOGARITHMIC,
|
|
42
|
+
curve_q=14100.0, # Design load (N)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Define outer ring raceway parameters
|
|
46
|
+
raceway = RacewayParams(
|
|
47
|
+
diameter=-150.0, # Negative for concave surface (mm)
|
|
48
|
+
raceway_type=RacewayType.OUTER,
|
|
49
|
+
fai=0.0, # Half cone angle (degrees)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Calculate slice stress distribution
|
|
53
|
+
result = slice_stress(roller, raceway, load=1340.86, n_slice=30)
|
|
54
|
+
|
|
55
|
+
# Access results
|
|
56
|
+
print(f"Max stress: {result.max_stress:.0f} MPa")
|
|
57
|
+
print(f"Contact deflection: {result.deflection:.6f} mm")
|
|
58
|
+
print(f"Stress uniformity: {result.stress_uniformity:.2%}")
|
|
59
|
+
print(f"Contact slices: {result.contact_slices}/{result.n_slice}")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## What is Slice Calculation?
|
|
63
|
+
|
|
64
|
+
The slice method divides the roller-raceway contact into multiple slices along the roller length to accurately calculate stress distribution. This is essential for:
|
|
65
|
+
|
|
66
|
+
- Capturing edge stress concentration effects
|
|
67
|
+
- Analyzing the impact of crown modifications
|
|
68
|
+
- Predicting bearing life more accurately
|
|
69
|
+
- Understanding load distribution along roller length
|
|
70
|
+
|
|
71
|
+
## Key Parameters
|
|
72
|
+
|
|
73
|
+
### Roller Parameters
|
|
74
|
+
|
|
75
|
+
- `d1`, `d2`: Roller diameters (mm) - equal for cylindrical rollers
|
|
76
|
+
- `length`: Effective roller length (mm)
|
|
77
|
+
- `alfa`: Half cone angle (degrees) - 0 for cylindrical rollers
|
|
78
|
+
- `tilt`: Roller tilt angle (degrees)
|
|
79
|
+
- `crown_type`: Crown modification type
|
|
80
|
+
- `STRAIGHT`: No crown modification
|
|
81
|
+
- `CIRCULAR`: Circular crown
|
|
82
|
+
- `LOGARITHMIC`: Logarithmic crown (recommended)
|
|
83
|
+
- `curve_q`: Design load (N) for optimal stress distribution
|
|
84
|
+
|
|
85
|
+
### Raceway Parameters
|
|
86
|
+
|
|
87
|
+
- `diameter`: Raceway diameter (mm) - negative for outer ring (concave)
|
|
88
|
+
- `raceway_type`: `INNER` or `OUTER`
|
|
89
|
+
- `fai`: Raceway cone angle (degrees)
|
|
90
|
+
|
|
91
|
+
### Calculation Parameters
|
|
92
|
+
|
|
93
|
+
- `load`: Applied load on roller (N)
|
|
94
|
+
- `n_slice`: Number of slices (default 30, max 50)
|
|
95
|
+
|
|
96
|
+
## Theory
|
|
97
|
+
|
|
98
|
+
This package implements the **influence coefficient method** based on elastic half-space contact theory:
|
|
99
|
+
|
|
100
|
+
1. Discretizes roller into slices
|
|
101
|
+
2. Calculates elastic coupling between slices (influence coefficient matrix)
|
|
102
|
+
3. Solves linear system using Gaussian elimination
|
|
103
|
+
4. Iterates to convergence for contact area and load balance
|
|
104
|
+
|
|
105
|
+
The method is more accurate than simplified Hertz formulas as it accounts for:
|
|
106
|
+
- Elastic coupling between slices
|
|
107
|
+
- Dynamic contact area determination
|
|
108
|
+
- Edge loading effects
|
|
109
|
+
- Crown modification influence
|
|
110
|
+
|
|
111
|
+
## Requirements
|
|
112
|
+
|
|
113
|
+
- Python >= 3.12
|
|
114
|
+
- NumPy >= 2.0.0
|
|
115
|
+
|
|
116
|
+
## Platform Support
|
|
117
|
+
|
|
118
|
+
| Platform | Status |
|
|
119
|
+
|----------|--------|
|
|
120
|
+
| Windows (x64) | ✅ Supported |
|
|
121
|
+
| Linux | 🚧 Coming soon |
|
|
122
|
+
| macOS | 🚧 Coming soon |
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT License - See LICENSE file for details.
|
|
127
|
+
|
|
128
|
+
## Author
|
|
129
|
+
|
|
130
|
+
Gu Lei
|
|
131
|
+
|
|
132
|
+
## References
|
|
133
|
+
|
|
134
|
+
- Harris, T.A., Kotzalas, M.N. - *Rolling Bearing Analysis*, 5th Edition
|
|
135
|
+
- Johnson, K.L. - *Contact Mechanics*
|
|
136
|
+
- ISO/TS 16281:2008 - Rolling bearings calculation methods
|
|
137
|
+
|
|
138
|
+
## Contributing
|
|
139
|
+
|
|
140
|
+
Contributions are welcome! Please feel free to submit issues or pull requests.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "bstart-trb"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module"
|
|
5
|
+
readme = "README_PYPI.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
license = {text = "MIT"}
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Gu Lei", email = "gulei@example.com"}
|
|
10
|
+
]
|
|
11
|
+
keywords = ["bearing", "roller", "stress", "contact", "hertz", "fortran", "f2py"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Science/Research",
|
|
15
|
+
"Intended Audience :: Manufacturing",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Fortran",
|
|
20
|
+
"Topic :: Scientific/Engineering",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"numpy>=2.0.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/yourusername/bstart-trb"
|
|
30
|
+
Repository = "https://github.com/yourusername/bstart-trb"
|
|
31
|
+
Documentation = "https://github.com/yourusername/bstart-trb#readme"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["hatchling"]
|
|
35
|
+
build-backend = "hatchling.build"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["slice_wrapper"]
|
|
39
|
+
artifacts = [
|
|
40
|
+
"slice_wrapper/*.pyd",
|
|
41
|
+
"slice_wrapper/*.so",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.sdist]
|
|
45
|
+
only-include = [
|
|
46
|
+
"slice_wrapper/__init__.py",
|
|
47
|
+
"slice_wrapper/models.py",
|
|
48
|
+
"slice_wrapper/wrapper.py",
|
|
49
|
+
"slice_wrapper/_taper_slice.pyi",
|
|
50
|
+
"slice_wrapper/py.typed",
|
|
51
|
+
"slice_wrapper/_taper_slice.cp312-win_amd64.pyd",
|
|
52
|
+
"README_PYPI.md",
|
|
53
|
+
"LICENSE",
|
|
54
|
+
"pyproject.toml",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[dependency-groups]
|
|
58
|
+
dev = [
|
|
59
|
+
"hatchling>=1.28.0",
|
|
60
|
+
"twine>=6.2.0",
|
|
61
|
+
]
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module
|
|
3
|
+
|
|
4
|
+
This module provides slice calculation for roller-raceway contact stress distribution,
|
|
5
|
+
using Fortran compiled core via f2py.
|
|
6
|
+
|
|
7
|
+
Features:
|
|
8
|
+
- No file I/O, direct memory transfer
|
|
9
|
+
- Complete type hints
|
|
10
|
+
- Native NumPy array support
|
|
11
|
+
- Dataclass wrapped results
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
>>> from slice_wrapper import slice_stress, RollerParams, RacewayParams
|
|
15
|
+
>>> from slice_wrapper import CrownType, RacewayType
|
|
16
|
+
>>>
|
|
17
|
+
>>> # Define cylindrical roller parameters
|
|
18
|
+
>>> roller = RollerParams(
|
|
19
|
+
... d1=10.0, d2=10.0, length=9.6,
|
|
20
|
+
... crown_type=CrownType.LOGARITHMIC,
|
|
21
|
+
... curve_q=14100.0
|
|
22
|
+
... )
|
|
23
|
+
>>>
|
|
24
|
+
>>> # Define outer ring raceway parameters
|
|
25
|
+
>>> raceway = RacewayParams(
|
|
26
|
+
... diameter=-150.0,
|
|
27
|
+
... raceway_type=RacewayType.OUTER
|
|
28
|
+
... )
|
|
29
|
+
>>>
|
|
30
|
+
>>> # Calculate slice stress
|
|
31
|
+
>>> result = slice_stress(roller, raceway, load=1340.0, n_slice=30)
|
|
32
|
+
>>> print(f"Max stress: {result.max_stress:.0f} MPa")
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from .models import (
|
|
36
|
+
CrownType,
|
|
37
|
+
RacewayType,
|
|
38
|
+
RollerParams,
|
|
39
|
+
RacewayParams,
|
|
40
|
+
SliceResult,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
from .wrapper import (
|
|
44
|
+
slice_stress,
|
|
45
|
+
batch_slice_stress,
|
|
46
|
+
is_fortran_available,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
__all__ = [
|
|
50
|
+
# 枚举类型
|
|
51
|
+
"CrownType",
|
|
52
|
+
"RacewayType",
|
|
53
|
+
# 数据类型
|
|
54
|
+
"RollerParams",
|
|
55
|
+
"RacewayParams",
|
|
56
|
+
"SliceResult",
|
|
57
|
+
# 计算函数
|
|
58
|
+
"slice_stress",
|
|
59
|
+
"batch_slice_stress",
|
|
60
|
+
"is_fortran_available",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
__version__ = "0.1.0"
|
|
Binary file
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Type stubs for _taper_slice Fortran extension module.
|
|
3
|
+
|
|
4
|
+
This module provides Python type hints for the f2py compiled Fortran module.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Tuple
|
|
8
|
+
import numpy as np
|
|
9
|
+
from numpy.typing import NDArray
|
|
10
|
+
|
|
11
|
+
def taper_calculate(
|
|
12
|
+
d1: float,
|
|
13
|
+
d2: float,
|
|
14
|
+
rl: float,
|
|
15
|
+
alfa: float,
|
|
16
|
+
q: float,
|
|
17
|
+
tilt: float,
|
|
18
|
+
m1: int,
|
|
19
|
+
n_slice: int,
|
|
20
|
+
m2: int,
|
|
21
|
+
dr1: float,
|
|
22
|
+
fai: float,
|
|
23
|
+
curveq: float,
|
|
24
|
+
) -> Tuple[
|
|
25
|
+
NDArray[np.float64], # p: Contact center stress for each slice (MPa)
|
|
26
|
+
NDArray[np.float64], # a: Contact half-width for each slice (mm)
|
|
27
|
+
NDArray[np.float64], # q_slice: Contact force for each slice (N)
|
|
28
|
+
float, # dc: Roller deflection (mm)
|
|
29
|
+
float, # q1: Equilibrium load (N)
|
|
30
|
+
float, # qm: Equilibrium moment (N·mm)
|
|
31
|
+
int, # ierr: Error code (0=success)
|
|
32
|
+
]:
|
|
33
|
+
"""Calculate slice stress distribution for roller-raceway contact
|
|
34
|
+
|
|
35
|
+
Uses the Influence Coefficient Method to calculate contact stress.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
d1: Roller small-end diameter (mm)
|
|
39
|
+
d2: Roller large-end diameter (mm), d1=d2 for cylindrical roller
|
|
40
|
+
rl: Roller effective length (mm)
|
|
41
|
+
alfa: Roller half-cone angle (deg), alfa=0 for cylindrical roller
|
|
42
|
+
q: Roller load (N)
|
|
43
|
+
tilt: Roller tilt angle (deg)
|
|
44
|
+
m1: Crown type - 0:straight, 1:arc, 2:logarithmic
|
|
45
|
+
n_slice: Number of slices (1-50)
|
|
46
|
+
m2: Raceway type - 0:plane, 1:inner, 2:outer
|
|
47
|
+
dr1: Raceway diameter (mm), use negative value for outer ring
|
|
48
|
+
fai: Raceway half-cone angle (deg)
|
|
49
|
+
curveq: Design load (N), for logarithmic crown calculation
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Tuple containing:
|
|
53
|
+
- p: Contact center stress array (MPa), shape=(n_slice,)
|
|
54
|
+
- a: Contact half-width array (mm), shape=(n_slice,)
|
|
55
|
+
- q_slice: Contact force array (N), shape=(n_slice,)
|
|
56
|
+
- dc: Roller deflection (mm)
|
|
57
|
+
- q1: Equilibrium load (N), should be close to input load q
|
|
58
|
+
- qm: Equilibrium moment (N·mm)
|
|
59
|
+
- ierr: Error code
|
|
60
|
+
- 0: Calculation successful
|
|
61
|
+
- 1: Equation solving failed
|
|
62
|
+
- 2: Invalid slice count (n_slice < 1 or > 50)
|
|
63
|
+
- 3: Invalid load (q <= 0)
|
|
64
|
+
|
|
65
|
+
Example:
|
|
66
|
+
>>> import _taper_slice
|
|
67
|
+
>>> p, a, q_slice, dc, q1, qm, ierr = _taper_slice.taper_calculate(
|
|
68
|
+
... d1=10.0, d2=10.0, rl=9.6, alfa=0.0,
|
|
69
|
+
... q=1340.86, tilt=0.0, m1=2, n_slice=30,
|
|
70
|
+
... m2=2, dr1=-150.0, fai=0.0, curveq=14100.0
|
|
71
|
+
... )
|
|
72
|
+
>>> print(f"Max stress: {max(p):.0f} MPa")
|
|
73
|
+
>>> print(f"Slice force sum: {sum(q_slice):.2f} N")
|
|
74
|
+
|
|
75
|
+
Note:
|
|
76
|
+
- Outer ring raceway (m2=2) dr1 should use negative value (Hertz contact sign convention)
|
|
77
|
+
- Logarithmic crown (m1=2) achieves uniform stress distribution when q=curveq
|
|
78
|
+
- Recommended n_slice >= 20 for sufficient accuracy
|
|
79
|
+
"""
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class taper_slice_mod:
|
|
84
|
+
"""Fortran module taper_slice_mod
|
|
85
|
+
|
|
86
|
+
Contains the core calculation subroutines for slice stress analysis.
|
|
87
|
+
Usually not called directly; use taper_calculate instead.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
# Module constants
|
|
91
|
+
POISSON: float
|
|
92
|
+
"""Poisson's ratio (default: 0.3)"""
|
|
93
|
+
|
|
94
|
+
ELASTIC_MOD: float
|
|
95
|
+
"""Elastic modulus in MPa (default: 2.06e5)"""
|
|
96
|
+
|
|
97
|
+
PI: float
|
|
98
|
+
"""Pi constant"""
|
|
99
|
+
|
|
100
|
+
DEG2RAD: float
|
|
101
|
+
"""Degree to radian conversion factor"""
|
|
102
|
+
|
|
103
|
+
MAX_SLICES: int
|
|
104
|
+
"""Maximum number of slices (50)"""
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def calculate_slice_stress(
|
|
108
|
+
d1: float,
|
|
109
|
+
d2: float,
|
|
110
|
+
rl: float,
|
|
111
|
+
alfa: float,
|
|
112
|
+
q: float,
|
|
113
|
+
tilt: float,
|
|
114
|
+
m1: int,
|
|
115
|
+
n_slice: int,
|
|
116
|
+
m2: int,
|
|
117
|
+
dr1: float,
|
|
118
|
+
fai: float,
|
|
119
|
+
curveq: float,
|
|
120
|
+
pl: float,
|
|
121
|
+
rc: float,
|
|
122
|
+
) -> Tuple[
|
|
123
|
+
NDArray[np.float64], # p: Contact center stress for each slice (MPa)
|
|
124
|
+
NDArray[np.float64], # a: Contact half-width for each slice (mm)
|
|
125
|
+
NDArray[np.float64], # q_slice: Contact force for each slice (N)
|
|
126
|
+
float, # dc: Roller deflection (mm)
|
|
127
|
+
float, # q1: Equilibrium load (N)
|
|
128
|
+
float, # qm: Equilibrium moment (N·mm)
|
|
129
|
+
int, # ierr: Error code (0=success)
|
|
130
|
+
]:
|
|
131
|
+
"""Full interface for slice stress calculation (includes arc crown params)
|
|
132
|
+
|
|
133
|
+
This is the full interface including arc crown parameters pl and rc.
|
|
134
|
+
For most use cases, use taper_calculate instead which provides defaults.
|
|
135
|
+
|
|
136
|
+
Additional Args:
|
|
137
|
+
pl: Parallel length (mm), only for arc crown (m1=1)
|
|
138
|
+
rc: Crown radius (mm), only for arc crown (m1=1)
|
|
139
|
+
"""
|
|
140
|
+
...
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"""
|
|
2
|
+
数据类型定义
|
|
3
|
+
|
|
4
|
+
定义圆柱/圆锥滚子轴承切片计算所需的输入参数和输出结果的数据类。
|
|
5
|
+
所有类都使用 dataclass 装饰器,支持完整的类型提示。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from enum import IntEnum
|
|
10
|
+
from typing import Optional
|
|
11
|
+
import numpy as np
|
|
12
|
+
from numpy.typing import NDArray
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CrownType(IntEnum):
|
|
16
|
+
"""凸度类型枚举
|
|
17
|
+
|
|
18
|
+
用于指定滚子的凸度修形类型。
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
STRAIGHT: 直线(无修形)
|
|
22
|
+
ARC: 圆弧凸度
|
|
23
|
+
LOGARITHMIC: 对数凸度(推荐,可实现最优应力分布)
|
|
24
|
+
"""
|
|
25
|
+
STRAIGHT = 0
|
|
26
|
+
"""直线(无修形),边缘应力高"""
|
|
27
|
+
|
|
28
|
+
ARC = 1
|
|
29
|
+
"""圆弧凸度,需要指定圆弧半径"""
|
|
30
|
+
|
|
31
|
+
LOGARITHMIC = 2
|
|
32
|
+
"""对数凸度(推荐),理论上可实现均匀应力分布"""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class RacewayType(IntEnum):
|
|
36
|
+
"""滚道类型枚举
|
|
37
|
+
|
|
38
|
+
用于指定接触的滚道类型。
|
|
39
|
+
|
|
40
|
+
Attributes:
|
|
41
|
+
PLANE: 平面接触
|
|
42
|
+
INNER: 内圈滚道(凸面)
|
|
43
|
+
OUTER: 外圈滚道(凹面)
|
|
44
|
+
"""
|
|
45
|
+
PLANE = 0
|
|
46
|
+
"""平面接触"""
|
|
47
|
+
|
|
48
|
+
INNER = 1
|
|
49
|
+
"""内圈滚道(凸面)"""
|
|
50
|
+
|
|
51
|
+
OUTER = 2
|
|
52
|
+
"""外圈滚道(凹面),注意 diameter 使用负值"""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class RollerParams:
|
|
57
|
+
"""滚子几何参数
|
|
58
|
+
|
|
59
|
+
定义圆柱/圆锥滚子的几何尺寸和修形参数。
|
|
60
|
+
|
|
61
|
+
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),用于计算对数凸度修形量
|
|
69
|
+
|
|
70
|
+
Example:
|
|
71
|
+
>>> # 圆柱滚子
|
|
72
|
+
>>> roller = RollerParams(
|
|
73
|
+
... d1=10.0, d2=10.0, length=9.6,
|
|
74
|
+
... alfa=0.0, tilt=0.0,
|
|
75
|
+
... crown_type=CrownType.LOGARITHMIC,
|
|
76
|
+
... curve_q=14100.0
|
|
77
|
+
... )
|
|
78
|
+
|
|
79
|
+
>>> # 圆锥滚子
|
|
80
|
+
>>> taper_roller = RollerParams(
|
|
81
|
+
... d1=8.0, d2=10.0, length=12.0,
|
|
82
|
+
... alfa=10.0, tilt=0.0,
|
|
83
|
+
... crown_type=CrownType.LOGARITHMIC,
|
|
84
|
+
... curve_q=20000.0
|
|
85
|
+
... )
|
|
86
|
+
|
|
87
|
+
Note:
|
|
88
|
+
- 对数凸度修形在 load == curve_q 时可实现均匀应力分布
|
|
89
|
+
- tilt > 0 会导致一端应力集中,另一端可能脱离接触
|
|
90
|
+
"""
|
|
91
|
+
d1: float
|
|
92
|
+
"""滚子小端直径 (mm)"""
|
|
93
|
+
|
|
94
|
+
d2: float
|
|
95
|
+
"""滚子大端直径 (mm),圆柱滚子 d1=d2"""
|
|
96
|
+
|
|
97
|
+
length: float
|
|
98
|
+
"""滚子有效长度 (mm)"""
|
|
99
|
+
|
|
100
|
+
alfa: float = 0.0
|
|
101
|
+
"""滚子半圆锥角 (度),圆柱滚子 alfa=0"""
|
|
102
|
+
|
|
103
|
+
tilt: float = 0.0
|
|
104
|
+
"""滚子倾斜角度 (度)"""
|
|
105
|
+
|
|
106
|
+
crown_type: CrownType = CrownType.LOGARITHMIC
|
|
107
|
+
"""凸度类型"""
|
|
108
|
+
|
|
109
|
+
curve_q: float = 0.0
|
|
110
|
+
"""设计载荷 (N),用于对数凸度计算,0 表示使用实际载荷"""
|
|
111
|
+
|
|
112
|
+
def __post_init__(self):
|
|
113
|
+
"""参数验证"""
|
|
114
|
+
if self.d1 <= 0:
|
|
115
|
+
raise ValueError(f"滚子小端直径必须为正数,当前值: {self.d1}")
|
|
116
|
+
if self.d2 <= 0:
|
|
117
|
+
raise ValueError(f"滚子大端直径必须为正数,当前值: {self.d2}")
|
|
118
|
+
if self.length <= 0:
|
|
119
|
+
raise ValueError(f"滚子有效长度必须为正数,当前值: {self.length}")
|
|
120
|
+
if self.d1 > self.d2:
|
|
121
|
+
import warnings
|
|
122
|
+
warnings.warn(f"滚子小端直径 d1={self.d1} 大于大端直径 d2={self.d2},请确认")
|
|
123
|
+
|
|
124
|
+
# 转换枚举类型
|
|
125
|
+
if isinstance(self.crown_type, int):
|
|
126
|
+
self.crown_type = CrownType(self.crown_type)
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def is_cylindrical(self) -> bool:
|
|
130
|
+
"""是否为圆柱滚子"""
|
|
131
|
+
return abs(self.d1 - self.d2) < 1e-6 and abs(self.alfa) < 1e-6
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def diameter(self) -> float:
|
|
135
|
+
"""滚子直径(圆柱滚子)或平均直径(圆锥滚子)"""
|
|
136
|
+
return (self.d1 + self.d2) / 2.0
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@dataclass
|
|
140
|
+
class RacewayParams:
|
|
141
|
+
"""滚道参数
|
|
142
|
+
|
|
143
|
+
定义滚道的几何特征。
|
|
144
|
+
|
|
145
|
+
Attributes:
|
|
146
|
+
diameter: 滚道直径 (mm)
|
|
147
|
+
- 内圈滚道:正值
|
|
148
|
+
- 外圈滚道:负值(Hertz 接触理论符号约定)
|
|
149
|
+
raceway_type: 滚道类型,见 RacewayType 枚举
|
|
150
|
+
fai: 滚道半圆锥角 (度),圆柱滚子轴承为 0
|
|
151
|
+
|
|
152
|
+
Example:
|
|
153
|
+
>>> # 内圈滚道
|
|
154
|
+
>>> inner = RacewayParams(
|
|
155
|
+
... diameter=110.0,
|
|
156
|
+
... raceway_type=RacewayType.INNER,
|
|
157
|
+
... fai=0.0
|
|
158
|
+
... )
|
|
159
|
+
|
|
160
|
+
>>> # 外圈滚道(注意负号)
|
|
161
|
+
>>> outer = RacewayParams(
|
|
162
|
+
... diameter=-150.0,
|
|
163
|
+
... raceway_type=RacewayType.OUTER,
|
|
164
|
+
... fai=0.0
|
|
165
|
+
... )
|
|
166
|
+
|
|
167
|
+
Note:
|
|
168
|
+
外圈滚道 diameter 使用负值是 Hertz 接触理论的符号约定:
|
|
169
|
+
- 正曲率半径 → 凸面(滚子、内圈)
|
|
170
|
+
- 负曲率半径 → 凹面(外圈)
|
|
171
|
+
"""
|
|
172
|
+
diameter: float
|
|
173
|
+
"""滚道直径 (mm),外圈使用负值"""
|
|
174
|
+
|
|
175
|
+
raceway_type: RacewayType = RacewayType.INNER
|
|
176
|
+
"""滚道类型"""
|
|
177
|
+
|
|
178
|
+
fai: float = 0.0
|
|
179
|
+
"""滚道半圆锥角 (度)"""
|
|
180
|
+
|
|
181
|
+
def __post_init__(self):
|
|
182
|
+
"""参数验证"""
|
|
183
|
+
# 转换枚举类型
|
|
184
|
+
if isinstance(self.raceway_type, int):
|
|
185
|
+
self.raceway_type = RacewayType(self.raceway_type)
|
|
186
|
+
|
|
187
|
+
# 检查符号约定
|
|
188
|
+
if self.raceway_type == RacewayType.OUTER and self.diameter > 0:
|
|
189
|
+
import warnings
|
|
190
|
+
warnings.warn(
|
|
191
|
+
f"外圈滚道 diameter 通常使用负值(当前值: {self.diameter}),"
|
|
192
|
+
"请确认是否正确"
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@dataclass
|
|
197
|
+
class SliceResult:
|
|
198
|
+
"""切片计算结果
|
|
199
|
+
|
|
200
|
+
包含滚子-滚道接触的切片应力分布计算结果。
|
|
201
|
+
|
|
202
|
+
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=成功)
|
|
212
|
+
|
|
213
|
+
Example:
|
|
214
|
+
>>> 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}")
|
|
218
|
+
"""
|
|
219
|
+
n_slice: int
|
|
220
|
+
"""切片数量"""
|
|
221
|
+
|
|
222
|
+
stress: NDArray[np.float64]
|
|
223
|
+
"""各切片接触中心应力 (MPa)"""
|
|
224
|
+
|
|
225
|
+
half_width: NDArray[np.float64]
|
|
226
|
+
"""各切片接触半宽度 (mm)"""
|
|
227
|
+
|
|
228
|
+
slice_force: NDArray[np.float64]
|
|
229
|
+
"""各切片接触力 (N)"""
|
|
230
|
+
|
|
231
|
+
deflection: float
|
|
232
|
+
"""滚子变形量 (mm)"""
|
|
233
|
+
|
|
234
|
+
equilibrium_load: float
|
|
235
|
+
"""平衡载荷 (N),应接近输入载荷"""
|
|
236
|
+
|
|
237
|
+
equilibrium_moment: float
|
|
238
|
+
"""平衡力矩 (N·mm)"""
|
|
239
|
+
|
|
240
|
+
converged: bool = True
|
|
241
|
+
"""是否收敛"""
|
|
242
|
+
|
|
243
|
+
error_code: int = 0
|
|
244
|
+
"""错误码: 0=成功, 1=方程求解失败, 2=切片数无效, 3=载荷无效"""
|
|
245
|
+
|
|
246
|
+
@property
|
|
247
|
+
def max_stress(self) -> float:
|
|
248
|
+
"""最大接触应力 (MPa)"""
|
|
249
|
+
return float(np.max(self.stress)) if len(self.stress) > 0 else 0.0
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def min_stress(self) -> float:
|
|
253
|
+
"""最小接触应力 (MPa),不包括 0(非接触区)"""
|
|
254
|
+
nonzero = self.stress[self.stress > 0]
|
|
255
|
+
return float(np.min(nonzero)) if len(nonzero) > 0 else 0.0
|
|
256
|
+
|
|
257
|
+
@property
|
|
258
|
+
def mean_stress(self) -> float:
|
|
259
|
+
"""平均接触应力 (MPa),仅计算接触区"""
|
|
260
|
+
nonzero = self.stress[self.stress > 0]
|
|
261
|
+
return float(np.mean(nonzero)) if len(nonzero) > 0 else 0.0
|
|
262
|
+
|
|
263
|
+
@property
|
|
264
|
+
def contact_slices(self) -> int:
|
|
265
|
+
"""接触切片数量(应力 > 0)"""
|
|
266
|
+
return int(np.sum(self.stress > 0))
|
|
267
|
+
|
|
268
|
+
@property
|
|
269
|
+
def stress_uniformity(self) -> float:
|
|
270
|
+
"""应力均匀度 (0~1),1 表示完全均匀
|
|
271
|
+
|
|
272
|
+
定义为: 1 - (最大应力 - 最小应力) / 平均应力
|
|
273
|
+
"""
|
|
274
|
+
if self.mean_stress == 0:
|
|
275
|
+
return 0.0
|
|
276
|
+
variation = (self.max_stress - self.min_stress) / self.mean_stress
|
|
277
|
+
return max(0.0, 1.0 - variation)
|
|
278
|
+
|
|
279
|
+
def get_slice_positions(self, roller_length: float) -> NDArray[np.float64]:
|
|
280
|
+
"""获取各切片的中心位置
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
roller_length: 滚子有效长度 (mm)
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
各切片中心位置,从 0 到 roller_length
|
|
287
|
+
"""
|
|
288
|
+
h = roller_length / self.n_slice / 2 # 半切片宽度
|
|
289
|
+
positions = np.array([h * (2 * i + 1) for i in range(self.n_slice)])
|
|
290
|
+
return positions
|
|
291
|
+
|
|
292
|
+
def get_slice_width(self, roller_length: float) -> float:
|
|
293
|
+
"""获取切片宽度
|
|
294
|
+
|
|
295
|
+
Args:
|
|
296
|
+
roller_length: 滚子有效长度 (mm)
|
|
297
|
+
|
|
298
|
+
Returns:
|
|
299
|
+
单个切片的宽度 (mm)
|
|
300
|
+
"""
|
|
301
|
+
return roller_length / self.n_slice
|
|
302
|
+
|
|
303
|
+
def get_slice_spacing(self, roller_length: float) -> float:
|
|
304
|
+
"""获取相邻切片中心之间的间距
|
|
305
|
+
|
|
306
|
+
注意:切片间距 = 切片宽度 = roller_length / n_slice
|
|
307
|
+
|
|
308
|
+
Args:
|
|
309
|
+
roller_length: 滚子有效长度 (mm)
|
|
310
|
+
|
|
311
|
+
Returns:
|
|
312
|
+
相邻切片中心之间的间距 (mm)
|
|
313
|
+
"""
|
|
314
|
+
return roller_length / self.n_slice
|
|
315
|
+
|
|
316
|
+
def print_slice_info(self, roller_length: float) -> None:
|
|
317
|
+
"""打印切片划分信息
|
|
318
|
+
|
|
319
|
+
Args:
|
|
320
|
+
roller_length: 滚子有效长度 (mm)
|
|
321
|
+
"""
|
|
322
|
+
width = self.get_slice_width(roller_length)
|
|
323
|
+
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")
|
|
File without changes
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Python 包装层
|
|
3
|
+
|
|
4
|
+
提供圆柱/圆锥滚子轴承切片应力计算的高级 Python 接口。
|
|
5
|
+
封装底层 Fortran 计算核心(通过 f2py)。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Optional, Sequence, Callable, Tuple
|
|
9
|
+
import numpy as np
|
|
10
|
+
from numpy.typing import NDArray
|
|
11
|
+
|
|
12
|
+
from .models import (
|
|
13
|
+
RollerParams,
|
|
14
|
+
RacewayParams,
|
|
15
|
+
CrownType,
|
|
16
|
+
RacewayType,
|
|
17
|
+
SliceResult,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# 尝试导入 f2py 编译的模块
|
|
21
|
+
_FORTRAN_AVAILABLE = False
|
|
22
|
+
_taper_calculate: Optional[Callable[..., Tuple[
|
|
23
|
+
NDArray[np.float64], NDArray[np.float64], NDArray[np.float64], float, float, float, int
|
|
24
|
+
]]] = None
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
from . import _taper_slice
|
|
28
|
+
_taper_calculate = _taper_slice.taper_calculate
|
|
29
|
+
_FORTRAN_AVAILABLE = True
|
|
30
|
+
except ImportError:
|
|
31
|
+
import warnings
|
|
32
|
+
warnings.warn(
|
|
33
|
+
"Fortran 计算核心未编译,请运行 'python build.py' 编译模块。"
|
|
34
|
+
"当前切片计算功能不可用。"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def slice_stress(
|
|
39
|
+
roller: RollerParams,
|
|
40
|
+
raceway: RacewayParams,
|
|
41
|
+
load: float,
|
|
42
|
+
n_slice: int = 30,
|
|
43
|
+
) -> SliceResult:
|
|
44
|
+
"""计算滚子-滚道接触的切片应力分布
|
|
45
|
+
|
|
46
|
+
使用影响系数法(Influence Coefficient Method)计算滚子与滚道
|
|
47
|
+
接触时各切片的应力分布,考虑凸度修形和滚子倾斜的影响。
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
roller: 滚子几何参数
|
|
51
|
+
raceway: 滚道参数
|
|
52
|
+
load: 滚子载荷 (N)
|
|
53
|
+
n_slice: 切片数量 (1-50),默认 30
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
SliceResult: 包含各切片应力、接触半宽度等计算结果
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
RuntimeError: Fortran 模块未编译时抛出
|
|
60
|
+
ValueError: 参数无效时抛出
|
|
61
|
+
|
|
62
|
+
Example:
|
|
63
|
+
>>> from slice_wrapper import slice_stress, RollerParams, RacewayParams
|
|
64
|
+
>>> from slice_wrapper import CrownType, RacewayType
|
|
65
|
+
>>>
|
|
66
|
+
>>> # 定义滚子参数
|
|
67
|
+
>>> roller = RollerParams(
|
|
68
|
+
... d1=10.0, d2=10.0, length=9.6,
|
|
69
|
+
... crown_type=CrownType.LOGARITHMIC,
|
|
70
|
+
... curve_q=14100.0
|
|
71
|
+
... )
|
|
72
|
+
>>>
|
|
73
|
+
>>> # 定义外圈滚道参数(注意直径为负值)
|
|
74
|
+
>>> raceway = RacewayParams(
|
|
75
|
+
... diameter=-150.0,
|
|
76
|
+
... raceway_type=RacewayType.OUTER
|
|
77
|
+
... )
|
|
78
|
+
>>>
|
|
79
|
+
>>> # 计算切片应力
|
|
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%}")
|
|
83
|
+
|
|
84
|
+
Note:
|
|
85
|
+
- 切片数 n_slice 最大支持 50
|
|
86
|
+
- 对数凸度 (crown_type=2) 在 load == curve_q 时可实现均匀应力分布
|
|
87
|
+
- 外圈滚道的 diameter 应使用负值(Hertz 接触符号约定)
|
|
88
|
+
|
|
89
|
+
Theory:
|
|
90
|
+
该函数使用影响系数法求解滚子-滚道接触问题:
|
|
91
|
+
1. 将滚子沿轴向分成 n_slice 个切片
|
|
92
|
+
2. 建立切片间的弹性耦合关系(影响系数矩阵)
|
|
93
|
+
3. 使用高斯消元法求解线性方程组
|
|
94
|
+
4. 迭代收敛得到各切片的接触应力分布
|
|
95
|
+
"""
|
|
96
|
+
if not _FORTRAN_AVAILABLE or _taper_calculate is None:
|
|
97
|
+
raise RuntimeError(
|
|
98
|
+
"Fortran 计算核心未编译。请先运行 'python build.py' 编译模块。"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# 参数验证
|
|
102
|
+
if load <= 0:
|
|
103
|
+
raise ValueError(f"载荷必须为正数,当前值: {load}")
|
|
104
|
+
if not 1 <= n_slice <= 50:
|
|
105
|
+
raise ValueError(f"切片数必须在 1-50 之间,当前值: {n_slice}")
|
|
106
|
+
|
|
107
|
+
# 确定设计载荷
|
|
108
|
+
curve_q = roller.curve_q if roller.curve_q > 0 else load
|
|
109
|
+
|
|
110
|
+
# 调用 Fortran 计算(此时 _taper_calculate 已确保不为 None)
|
|
111
|
+
p, a, q_slice, dc, q1, qm, ierr = _taper_calculate(
|
|
112
|
+
d1=roller.d1,
|
|
113
|
+
d2=roller.d2,
|
|
114
|
+
rl=roller.length,
|
|
115
|
+
alfa=roller.alfa,
|
|
116
|
+
q=load,
|
|
117
|
+
tilt=roller.tilt,
|
|
118
|
+
m1=int(roller.crown_type),
|
|
119
|
+
n_slice=n_slice,
|
|
120
|
+
m2=int(raceway.raceway_type),
|
|
121
|
+
dr1=raceway.diameter,
|
|
122
|
+
fai=raceway.fai,
|
|
123
|
+
curveq=curve_q,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# 构建结果
|
|
127
|
+
return SliceResult(
|
|
128
|
+
n_slice=n_slice,
|
|
129
|
+
stress=np.array(p, dtype=np.float64),
|
|
130
|
+
half_width=np.array(a, dtype=np.float64),
|
|
131
|
+
slice_force=np.array(q_slice, dtype=np.float64),
|
|
132
|
+
deflection=float(dc),
|
|
133
|
+
equilibrium_load=float(q1),
|
|
134
|
+
equilibrium_moment=float(qm),
|
|
135
|
+
converged=(ierr == 0),
|
|
136
|
+
error_code=int(ierr),
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def batch_slice_stress(
|
|
141
|
+
roller: RollerParams,
|
|
142
|
+
raceway: RacewayParams,
|
|
143
|
+
loads: Sequence[float],
|
|
144
|
+
n_slice: int = 30,
|
|
145
|
+
) -> list[SliceResult]:
|
|
146
|
+
"""批量计算多个载荷下的切片应力分布
|
|
147
|
+
|
|
148
|
+
对多个载荷值进行切片应力计算,适用于载荷分布已知的情况。
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
roller: 滚子几何参数
|
|
152
|
+
raceway: 滚道参数
|
|
153
|
+
loads: 载荷序列 (N),支持 list[int], list[float], NDArray 等
|
|
154
|
+
n_slice: 切片数量,默认 30
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
list[SliceResult]: 各载荷对应的计算结果列表
|
|
158
|
+
|
|
159
|
+
Example:
|
|
160
|
+
>>> # 假设已知各滚子的载荷分布
|
|
161
|
+
>>> loads = [1340.0, 1128.3, 689.2, 324.8]
|
|
162
|
+
>>> results = batch_slice_stress(roller, raceway, loads)
|
|
163
|
+
>>> for i, result in enumerate(results):
|
|
164
|
+
... print(f"载荷 {loads[i]:.1f}N: 最大应力 {result.max_stress:.0f} MPa")
|
|
165
|
+
"""
|
|
166
|
+
results = []
|
|
167
|
+
for load in loads:
|
|
168
|
+
if load > 0:
|
|
169
|
+
result = slice_stress(roller, raceway, load, n_slice)
|
|
170
|
+
results.append(result)
|
|
171
|
+
else:
|
|
172
|
+
# 无载荷,返回零结果
|
|
173
|
+
results.append(SliceResult(
|
|
174
|
+
n_slice=n_slice,
|
|
175
|
+
stress=np.zeros(n_slice),
|
|
176
|
+
half_width=np.zeros(n_slice),
|
|
177
|
+
slice_force=np.zeros(n_slice),
|
|
178
|
+
deflection=0.0,
|
|
179
|
+
equilibrium_load=0.0,
|
|
180
|
+
equilibrium_moment=0.0,
|
|
181
|
+
converged=True,
|
|
182
|
+
error_code=0,
|
|
183
|
+
))
|
|
184
|
+
return results
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def is_fortran_available() -> bool:
|
|
188
|
+
"""检查 Fortran 计算核心是否可用
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
bool: True 表示 Fortran 模块已编译可用
|
|
192
|
+
"""
|
|
193
|
+
return _FORTRAN_AVAILABLE
|