truss-analysis 2.0.9__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.
- truss_analysis-2.0.9/LICENSE +21 -0
- truss_analysis-2.0.9/PKG-INFO +449 -0
- truss_analysis-2.0.9/README.md +411 -0
- truss_analysis-2.0.9/pyproject.toml +35 -0
- truss_analysis-2.0.9/setup.cfg +4 -0
- truss_analysis-2.0.9/src/truss_analysis/__init__.py +19 -0
- truss_analysis-2.0.9/src/truss_analysis/assembly.py +93 -0
- truss_analysis-2.0.9/src/truss_analysis/exceptions.py +25 -0
- truss_analysis-2.0.9/src/truss_analysis/fileio.py +45 -0
- truss_analysis-2.0.9/src/truss_analysis/i18n.py +30 -0
- truss_analysis-2.0.9/src/truss_analysis/logger.py +12 -0
- truss_analysis-2.0.9/src/truss_analysis/main.py +271 -0
- truss_analysis-2.0.9/src/truss_analysis/model.py +94 -0
- truss_analysis-2.0.9/src/truss_analysis/plotter.py +156 -0
- truss_analysis-2.0.9/src/truss_analysis/postprocess.py +254 -0
- truss_analysis-2.0.9/src/truss_analysis/report.py +120 -0
- truss_analysis-2.0.9/src/truss_analysis/solver.py +87 -0
- truss_analysis-2.0.9/src/truss_analysis/units.py +53 -0
- truss_analysis-2.0.9/src/truss_analysis.egg-info/PKG-INFO +449 -0
- truss_analysis-2.0.9/src/truss_analysis.egg-info/SOURCES.txt +37 -0
- truss_analysis-2.0.9/src/truss_analysis.egg-info/dependency_links.txt +1 -0
- truss_analysis-2.0.9/src/truss_analysis.egg-info/requires.txt +4 -0
- truss_analysis-2.0.9/src/truss_analysis.egg-info/top_level.txt +3 -0
- truss_analysis-2.0.9/src/utils/__init__.py +0 -0
- truss_analysis-2.0.9/src/utils/data_contract.py +30 -0
- truss_analysis-2.0.9/src/utils/font_loader.py +33 -0
- truss_analysis-2.0.9/tests/test_analytical.py +150 -0
- truss_analysis-2.0.9/tests/test_assembly.py +34 -0
- truss_analysis-2.0.9/tests/test_dof_mapping.py +16 -0
- truss_analysis-2.0.9/tests/test_e2e_cli.py +28 -0
- truss_analysis-2.0.9/tests/test_exceptions.py +21 -0
- truss_analysis-2.0.9/tests/test_fileio.py +33 -0
- truss_analysis-2.0.9/tests/test_golden.py +111 -0
- truss_analysis-2.0.9/tests/test_golden_phase3.py +180 -0
- truss_analysis-2.0.9/tests/test_model.py +31 -0
- truss_analysis-2.0.9/tests/test_phase2_cli_coverage.py +17 -0
- truss_analysis-2.0.9/tests/test_postprocess.py +49 -0
- truss_analysis-2.0.9/tests/test_solver.py +51 -0
- truss_analysis-2.0.9/tests/test_units.py +16 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Behnam Mohammadian
|
|
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,449 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: truss_analysis
|
|
3
|
+
Version: 2.0.9
|
|
4
|
+
Summary: 2D Truss Analysis Tool
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 Behnam Mohammadian
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Classifier: Programming Language :: Python :: 3
|
|
28
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
30
|
+
Requires-Python: >=3.9
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: numpy>=1.20
|
|
34
|
+
Requires-Dist: matplotlib
|
|
35
|
+
Requires-Dist: arabic-reshaper
|
|
36
|
+
Requires-Dist: python-bidi
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# 🏗️ تحلیل سازههای خرپایی دوبعدی (Truss Analysis 2D)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+

|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<div align="center">
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+

|
|
51
|
+

|
|
52
|
+
[](https://github.com/bmhmdyan279-png/truss-analysis-2d/actions)
|
|
53
|
+
|
|
54
|
+
**یک ابزار تحلیل خرپای دوبعدی کاملاً پایتون، با معماری استاندارد، اعتبارسنجی ترمودینامیکی تعمیمیافته و پایداری سینماتیکی تضمینشده**
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 📋 فهرست مطالب
|
|
61
|
+
|
|
62
|
+
- [ویژگیهای کلیدی](#-ویژگیهای-کلیدی)
|
|
63
|
+
- [معماری](#-معماری)
|
|
64
|
+
- [نصب](#-نصب)
|
|
65
|
+
- [استفاده سریع](#-استفاده-سریع)
|
|
66
|
+
- [مثال کامل](#-مثال-کامل)
|
|
67
|
+
- [سیستم واحد](#-سیستم-واحد)
|
|
68
|
+
- [اعتبارسنجی ترمودینامیکی](#-اعتبارسنجی-ترمودینامیکی)
|
|
69
|
+
- [تستها](#-تستها)
|
|
70
|
+
- [ساختار پروژه](#-ساختار-پروژه)
|
|
71
|
+
- [تغییرات نسخه](#-تغییرات-نسخه)
|
|
72
|
+
- [مجوز](#-مجوز)
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## ✨ ویژگیهای کلیدی
|
|
77
|
+
|
|
78
|
+
### 🎯 معماری استاندارد
|
|
79
|
+
- **Pure DTO Architecture**: جداسازی کامل داده (`model.py`)، اسمبل (`assembly.py`) و حل (`solver.py`)
|
|
80
|
+
- **Centralized Exceptions**: سلسلهمراتب متمرکز `TrussError` در `exceptions.py`
|
|
81
|
+
- **Fail-Fast Validation**: تشخیص فوری خطاهای هندسی، ماتریسهای تکین و ناپایداری سینماتیکی
|
|
82
|
+
|
|
83
|
+
### 🔧 قابلیتهای فنی پیشرفته
|
|
84
|
+
- **Thermodynamic Consistency**: تفکیک بردارهای نیرو (`F_ext` vs `F_mechanical`) برای محاسبه صحیح تعادل انرژی در حضور بارهای حرارتی
|
|
85
|
+
- **Prestress Work Tracking**: محاسبه کار پیشتنیدگی (`W_prestress = Σ k·ΔL_thermal·ΔL_mech`) برای قضیه کلپیرون تعمیمیافته
|
|
86
|
+
- **Kinematic Stability**: اعتبارسنجی پایداری سینماتیکی تکیهگاهها (جلوگیری از مکانیزمهای ناپایدار)
|
|
87
|
+
- **Roller Support**: شرایط مرزی مستقل در X و Y
|
|
88
|
+
- **Thermal + Fabrication**: پشتیبانی همزمان از `α·ΔT` و `delta_L_free`
|
|
89
|
+
|
|
90
|
+
### 🛡️ ایمنی و قابلیت اطمینان
|
|
91
|
+
- **Fail-Fast Rank Check**: تشخیص صریح ماتریسهای تکین (`SingularMatrixError`)
|
|
92
|
+
- **Zero-Length Element Detection**: `AssemblyError` برای المانهای با طول صفر
|
|
93
|
+
- **Strict JSON Schema Validation**: اعتبارسنجی ساختار فایل ورودی و فیلد `loads`
|
|
94
|
+
- **Division-by-Zero Guards**: محافظت در برابر مسائل خودمتعادل (`abs(W) < 1e-12`)
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 🏛️ معماری
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
102
|
+
│ main.py │
|
|
103
|
+
│ (JSON → Units → Assemble → Solve → Postprocess → Energy) │
|
|
104
|
+
└─────────────────────────────────────────────────────────────┘
|
|
105
|
+
↓
|
|
106
|
+
┌───────────────────┼───────────────────┐
|
|
107
|
+
↓ ↓ ↓
|
|
108
|
+
┌──────────┐ ┌──────────────┐ ┌────────────┐
|
|
109
|
+
│ fileio.py │ │ assembly.py │ │ solver.py │
|
|
110
|
+
│(Schema✓) │ │ (K,F_ext,F_mech) │ (KU=F + Energy) │
|
|
111
|
+
└──────────┘ └──────────────┘ └────────────┘
|
|
112
|
+
↓ ↓ ↓
|
|
113
|
+
┌──────────────────────────────────────────────────┐
|
|
114
|
+
│ model.py (Pure DTOs) │
|
|
115
|
+
│ @dataclass Node: id, x, y, support_dx, support_dy │
|
|
116
|
+
│ @dataclass Element: id, node_i, node_j, E, A, ... │
|
|
117
|
+
└──────────────────────────────────────────────────┘
|
|
118
|
+
↓ ↓ ↓
|
|
119
|
+
┌──────────┐ ┌──────────────┐ ┌────────────────┐
|
|
120
|
+
│ units.py │ │postprocess.py│ │ exceptions.py │
|
|
121
|
+
│(SI↔Imperial)│ │ (forces, energy,│ │ (TrussError │
|
|
122
|
+
│ 5/9 ✓ │ │ prestress) │ │ hierarchy) │
|
|
123
|
+
└──────────┘ └──────────────┘ └────────────────┘
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### اصول طراحی
|
|
127
|
+
|
|
128
|
+
1. **Single Responsibility**: هر ماژول فقط یک مسئولیت دارد
|
|
129
|
+
2. **Pure Functions**: توابع بدون side-effect، قابل تست و پیشبینی
|
|
130
|
+
3. **Fail-Fast**: خطاها در اولین فرصت گزارش میشوند
|
|
131
|
+
4. **Type Safety**: `@dataclass` و Type Hints کامل
|
|
132
|
+
5. **Thermodynamic Consistency**: فرمولهای صحیح انرژی حتی در حضور بارهای حرارتی
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 📦 نصب
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# نصب از سورس
|
|
140
|
+
git clone https://github.com/bmhmdyan279-png/truss-analysis-2d.git
|
|
141
|
+
cd truss-analysis-2d
|
|
142
|
+
pip install .
|
|
143
|
+
|
|
144
|
+
# نصب برای توسعه
|
|
145
|
+
pip install -e ".[dev]"
|
|
146
|
+
pre-commit install
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### وابستگیها
|
|
150
|
+
- `numpy>=1.20`: محاسبات برداری و ماتریسی (تنها وابستگی)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 🚀 استفاده سریع
|
|
155
|
+
|
|
156
|
+
### از خط فرمان
|
|
157
|
+
```bash
|
|
158
|
+
python -m truss_analysis.main examples/example1.json SI
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### از کد پایتون
|
|
162
|
+
```python
|
|
163
|
+
from truss_analysis import solve, Node, Element
|
|
164
|
+
from truss_analysis.assembly import assemble_global_matrices
|
|
165
|
+
from truss_analysis.postprocess import calculate_element_forces
|
|
166
|
+
from truss_analysis.solver import check_energy
|
|
167
|
+
|
|
168
|
+
# تعریف گرهها
|
|
169
|
+
nodes = [
|
|
170
|
+
Node(id="1", x=0.0, y=0.0, is_support=True, support_dx=True, support_dy=True),
|
|
171
|
+
Node(id="2", x=3.0, y=0.0, is_support=False),
|
|
172
|
+
Node(id="3", x=0.0, y=4.0, is_support=True, support_dx=True, support_dy=True),
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
# تعریف المانها (با اثر حرارتی)
|
|
176
|
+
elements = [
|
|
177
|
+
Element(id="1", node_i="1", node_j="2", E=200e9, A=0.001, alpha=1.2e-5, delta_T=50),
|
|
178
|
+
Element(id="2", node_i="2", node_j="3", E=200e9, A=0.002),
|
|
179
|
+
Element(id="3", node_i="1", node_j="3", E=200e9, A=0.0015),
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
# اسمبل ماتریسها - API جدید: 4 خروجی
|
|
183
|
+
K, F_ext, F_mech, fixed_dofs = assemble_global_matrices(nodes, elements)
|
|
184
|
+
|
|
185
|
+
# اعمال بار مکانیکی به هر دو بردار
|
|
186
|
+
F_ext[2] += 10000.0
|
|
187
|
+
F_mech[2] += 10000.0
|
|
188
|
+
|
|
189
|
+
# حل
|
|
190
|
+
U = solve(K, F_ext, fixed_dofs)
|
|
191
|
+
|
|
192
|
+
# محاسبه نیروها + انرژی + کار پیشتنیدگی
|
|
193
|
+
results, strain_energy, prestress_work = calculate_element_forces(nodes, elements, U)
|
|
194
|
+
|
|
195
|
+
# اعتبارسنجی ترمودینامیکی با فرمول تعمیمیافته
|
|
196
|
+
check_energy(U, F_mech, strain_energy, prestress_work)
|
|
197
|
+
|
|
198
|
+
for r in results:
|
|
199
|
+
print(f"Element {r['element']}: Force = {r['force']:.2f} N")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 📝 مثال کامل
|
|
205
|
+
|
|
206
|
+
### فایل ورودی (`examples/example1.json`)
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"nodes": [
|
|
210
|
+
{"id": "1", "x": 0.0, "y": 0.0, "is_support": true, "support_dx": true, "support_dy": true},
|
|
211
|
+
{"id": "2", "x": 3.0, "y": 0.0, "is_support": false},
|
|
212
|
+
{"id": "3", "x": 0.0, "y": 4.0, "is_support": true, "support_dx": true, "support_dy": true}
|
|
213
|
+
],
|
|
214
|
+
"elements": [
|
|
215
|
+
{"id": "1", "node_i": "1", "node_j": "2", "E": 200e9, "A": 0.001,
|
|
216
|
+
"alpha": 1.2e-5, "delta_T": 50},
|
|
217
|
+
{"id": "2", "node_i": "2", "node_j": "3", "E": 200e9, "A": 0.002},
|
|
218
|
+
{"id": "3", "node_i": "1", "node_j": "3", "E": 200e9, "A": 0.0015}
|
|
219
|
+
],
|
|
220
|
+
"loads": [
|
|
221
|
+
{"node_id": "2", "Fx": 10000.0, "Fy": -5000.0}
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### توضیحات
|
|
227
|
+
- **گره ۱**: تکیهگاه مفصلی کامل
|
|
228
|
+
- **گره ۲**: گره آزاد
|
|
229
|
+
- **گره ۳**: تکیهگاه مفصلی (پایداری سینماتیکی تضمینشده)
|
|
230
|
+
- **المان ۱**: دارای اثر حرارتی (α=1.2e-5, ΔT=50°C)
|
|
231
|
+
- **بارگذاری**: ۱۰ kN در X و -۵ kN در Y روی گره ۲
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 📏 سیستم واحد
|
|
236
|
+
|
|
237
|
+
| کمیت | SI | Imperial |
|
|
238
|
+
|------|-----|----------|
|
|
239
|
+
| طول (L) | متر | فوت |
|
|
240
|
+
| مساحت (A) | متر² | فوت² |
|
|
241
|
+
| مدول الاستیسیته (E) | پاسکال | psi |
|
|
242
|
+
| نیرو (F) | نیوتن | پوند-نیرو |
|
|
243
|
+
| ضریب انبساط حرارتی (α) | ۱/°C | ۱/°F |
|
|
244
|
+
| تغییر دما (ΔT) | °C | °F |
|
|
245
|
+
|
|
246
|
+
**نکته مهم**: ضریب تبدیل `delta_T` از °F به °C برابر با `5/9 ≈ 0.5556` است (نه 1.0)، و `alpha` برابر با `1.8` است (چرا که `1/°F = 1.8 × 1/°C`). این دو ضریب مکمل یکدیگرند و از نظر فیزیکی صحیح هستند.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## ⚡ اعتبارسنجی ترمودینامیکی
|
|
251
|
+
|
|
252
|
+
### قضیه کلپیرون تعمیمیافته
|
|
253
|
+
|
|
254
|
+
در حضور بارهای حرارتی، فرمول ساده `W = U_strain` دیگر برقرار نیست. این پروژه از فرمول تعمیمیافته استفاده میکند:
|
|
255
|
+
|
|
256
|
+
```text
|
|
257
|
+
W_mech = U_strain + W_prestress
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
که:
|
|
261
|
+
- **`W_mech = ½·Uᵀ·F_mechanical`**: کار بارهای خارجی مکانیکی (نه حرارتی)
|
|
262
|
+
- **`U_strain = Σ (½·k·ΔL_mech²)`**: انرژی کرنشی مکانیکی
|
|
263
|
+
- **`W_prestress = Σ (k·ΔL_thermal·ΔL_mech)`**: کار پیشتنیدگی حرارتی
|
|
264
|
+
|
|
265
|
+
### پیادهسازی
|
|
266
|
+
```python
|
|
267
|
+
from truss_analysis.solver import check_energy
|
|
268
|
+
|
|
269
|
+
# بررسی تعادل انرژی ترمودینامیکی
|
|
270
|
+
check_energy(U, F_mech, strain_energy, prestress_work, tol=0.01)
|
|
271
|
+
|
|
272
|
+
# در صورت عدم تعادل:
|
|
273
|
+
# EnergyValidationError: W_mech=..., U_strain=..., W_prestress=..., Error ...%
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### مزایا
|
|
277
|
+
- **تشخیص باگهای Double-Counting**: اگر اثر حرارتی دو بار محاسبه شود، تعادل انرژی برقرار نخواهد شد
|
|
278
|
+
- **حفاظت از مسائل خودمتعادل**: Guard در برابر `abs(W) < 1e-12`
|
|
279
|
+
- **اعتبارسنجی خودکار هر تحلیل**: هر run به صورت خودکار بررسی میشود
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 🧪 تستها
|
|
284
|
+
|
|
285
|
+
### اجرای تستها
|
|
286
|
+
```bash
|
|
287
|
+
# تمام تستها (29 تست)
|
|
288
|
+
pytest tests/
|
|
289
|
+
|
|
290
|
+
# با پوشش کد
|
|
291
|
+
pytest --cov=truss_analysis --cov-report=term-missing
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### انواع تستها
|
|
295
|
+
|
|
296
|
+
| تست | هدف |
|
|
297
|
+
|-----|------|
|
|
298
|
+
| `test_assembly.py` | اسمبل، شرایط مرزی، نیروهای حرارتی |
|
|
299
|
+
| `test_golden.py` | پایداری سینماتیکی، انبساط آزاد، حالت مقید |
|
|
300
|
+
| `test_solver.py` | حل، ماتریس تکین، تعادل انرژی ترمودینامیکی |
|
|
301
|
+
| `test_postprocess.py` | نیروها، انرژی، درصدها، Scale Factor |
|
|
302
|
+
| `test_model.py` | DTOها، `validate_inputs` |
|
|
303
|
+
| `test_fileio.py` | Schema validation برای JSON |
|
|
304
|
+
| `test_exceptions.py` | سلسلهمراتب `TrussError` |
|
|
305
|
+
| `test_units.py` | تبدیل واحدها، `None` guard |
|
|
306
|
+
| `test_dof_mapping.py` | نگاشت صحیح درجات آزادی |
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## 📁 ساختار پروژه
|
|
311
|
+
|
|
312
|
+
```text
|
|
313
|
+
truss-analysis-2d/
|
|
314
|
+
├── src/truss_analysis/
|
|
315
|
+
│ ├── __init__.py # Public API
|
|
316
|
+
│ ├── model.py # Pure DTOs (Node, Element)
|
|
317
|
+
│ ├── assembly.py # Assembly (K, F_ext, F_mech)
|
|
318
|
+
│ ├── solver.py # KU=F + Energy check
|
|
319
|
+
│ ├── postprocess.py # Forces, energy, prestress
|
|
320
|
+
│ ├── units.py # SI ↔ Imperial (5/9 for ΔT)
|
|
321
|
+
│ ├── fileio.py # JSON loader + schema
|
|
322
|
+
│ ├── exceptions.py # TrussError hierarchy
|
|
323
|
+
│ ├── main.py # CLI entry
|
|
324
|
+
│ └── logger.py # Lazy logging
|
|
325
|
+
├── tests/ # 29 comprehensive tests
|
|
326
|
+
├── examples/ # JSON inputs
|
|
327
|
+
├── pyproject.toml # Python ≥3.9, numpy only
|
|
328
|
+
├── CHANGELOG.md # Version history
|
|
329
|
+
└── README.md # This file
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## 📊 تغییرات نسخه
|
|
335
|
+
|
|
336
|
+
### نسخه ۲.۰.۹ (۲۰۲۶-۰۸-۰۷) - پایدار Release
|
|
337
|
+
#### 🎯 تثبیت نهایی
|
|
338
|
+
- همگامسازی کامل مستندات با معماری استاندارد
|
|
339
|
+
- پوشش کامل تمام دستاوردهای v2.0.5 تا v2.0.7 در مستندات
|
|
340
|
+
|
|
341
|
+
### نسخه ۲.۰.۷ (۲۰۲۶-۰۸-۰۷) - Kinematic Stability
|
|
342
|
+
#### 🔧 اصلاحات
|
|
343
|
+
- **test_golden_simple_truss**: گره ۳ به تکیهگاه مفصلی تبدیل شد (جلوگیری از مکانیزم ناشی از المان عمودی)
|
|
344
|
+
- **test_golden_thermal_loading**: گره ۲ در Y مقید شد (جلوگیری از مود چرخشی جسم صلب)
|
|
345
|
+
- تمام ۲۹ تست با ماتریسهای سختی پایدار ریاضی پاس میشوند
|
|
346
|
+
|
|
347
|
+
### نسخه ۲.۰.۶ (۲۰۲۶-۰۸-۰۷) - API Alignment
|
|
348
|
+
#### 🔧 اصلاحات
|
|
349
|
+
- **test_dof_mapping**: بهروزرسانی برای unpack چهار خروجی `assemble_global_matrices`
|
|
350
|
+
- رفع ناسازگاریهای باقیمانده در suite تست
|
|
351
|
+
|
|
352
|
+
### نسخه ۲.۰.۵ (۲۰۲۶-۰۸-۰۷) - Thermodynamic Consistency
|
|
353
|
+
#### 🚀 دستاورد بزرگ
|
|
354
|
+
- **رفع باگ Double-Counting حرارتی**: قضیه کلپیرون تعمیمیافته
|
|
355
|
+
- **تفکیک بردارهای نیرو**: `F_ext` (کل) در برابر `F_mechanical` (خارجی مکانیکی)
|
|
356
|
+
- **محاسبه `W_prestress`**: کار پیشتنیدگی حرارتی در `postprocess.py`
|
|
357
|
+
- **فرمول جدید `check_energy`**: `W_mech = U_strain + W_prestress`
|
|
358
|
+
- **تست جدید**: `test_golden_thermal_constrained` برای میله مقید
|
|
359
|
+
- **تست جدید**: `test_check_energy_pass_with_thermal` برای اثبات درستی فرمول
|
|
360
|
+
|
|
361
|
+
### نسخه ۲.۰.۴ (۲۰۲۶-۰۸-۰۷) - Documentation Sync
|
|
362
|
+
- همگامسازی README با معماری v2.0.9
|
|
363
|
+
- اصلاح ساختار JSON مثال (`loads` به صورت flat list)
|
|
364
|
+
- بهروزرسانی Badgeها و دیاگرام معماری
|
|
365
|
+
|
|
366
|
+
### نسخه ۲.۰.۹ (۲۰۲۶-۰۸-۰۷) - استاندارد Architecture
|
|
367
|
+
- یکپارچگی مطلق API (list-based)
|
|
368
|
+
- مدیریت خطای متمرکز (`exceptions.py`)
|
|
369
|
+
- اعتبارسنجی Schema برای `loads`
|
|
370
|
+
- اصلاح Imperial `delta_T` به `5/9`
|
|
371
|
+
- حذف `scipy` و `use_sparse`
|
|
372
|
+
- ارتقا به Python `>=3.9` + Ruff در CI
|
|
373
|
+
- اصلاح متغیر مبهم `I` به `I_sec`
|
|
374
|
+
- حذف side-effect در `logger.py`
|
|
375
|
+
|
|
376
|
+
### نسخه ۲.۰.۱ (۲۰۲۶-۰۸-۰۶)
|
|
377
|
+
- معماری Pure DTO
|
|
378
|
+
- Fail-Fast Rank Check
|
|
379
|
+
- پشتیبانی از Roller Support
|
|
380
|
+
- Zero-Length Element Detection
|
|
381
|
+
|
|
382
|
+
برای تاریخچه کامل، [CHANGELOG.md](CHANGELOG.md) را مشاهده کنید.
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## 🤝 مشارکت
|
|
387
|
+
|
|
388
|
+
مشارکتها خوشآمد هستند!
|
|
389
|
+
1. Fork کنید
|
|
390
|
+
2. Branch ویژگی بسازید (`git checkout -b feature/...`)
|
|
391
|
+
3. Commit کنید (`git commit -m 'feat: ...'`)
|
|
392
|
+
4. Push کنید
|
|
393
|
+
5. Pull Request باز کنید
|
|
394
|
+
|
|
395
|
+
#
|
|
396
|
+
## 💻 Advanced CLI Usage
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
# Basic analysis
|
|
400
|
+
python main.py examples/simple_truss.json
|
|
401
|
+
|
|
402
|
+
# Show interactive plots
|
|
403
|
+
python main.py examples/simple_truss.json --plot
|
|
404
|
+
|
|
405
|
+
# Save plots and all output formats
|
|
406
|
+
python main.py examples/simple_truss.json --save-plots --output results --format all
|
|
407
|
+
|
|
408
|
+
# Custom deformation scale
|
|
409
|
+
python main.py examples/simple_truss.json --plot --scale 50
|
|
410
|
+
|
|
411
|
+
# Check buckling warnings
|
|
412
|
+
python main.py examples/simple_truss.json --check-buckling
|
|
413
|
+
|
|
414
|
+
# Imperial units
|
|
415
|
+
python main.py examples/simple_truss.json Imperial
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## 📊 Output Formats
|
|
419
|
+
|
|
420
|
+
The tool generates structured outputs in multiple formats:
|
|
421
|
+
|
|
422
|
+
- **JSON**: Complete results with displacements, forces, and reactions
|
|
423
|
+
- **CSV**: Separate files for nodes, members, and reactions (Excel-friendly)
|
|
424
|
+
- **Markdown**: Human-readable report with Persian support
|
|
425
|
+
- **PNG**: Deformed truss and axial force diagrams with color-coded tension/compression
|
|
426
|
+
|
|
427
|
+
## 🎨 Visualization Features
|
|
428
|
+
|
|
429
|
+
- **Original vs Deformed**: Side-by-side comparison with adjustable scale factor
|
|
430
|
+
- **Axial Force Diagram**: Blue for tension, red for compression
|
|
431
|
+
- **Persian Labels**: Full RTL support with Vazirmatn font
|
|
432
|
+
- **Support Indicators**: Visual representation of pin and roller supports
|
|
433
|
+
|
|
434
|
+
## دستورالعملها
|
|
435
|
+
- از `ruff` برای linting استفاده کنید
|
|
436
|
+
- تست بنویسید (`pytest`)
|
|
437
|
+
- Type hints اضافه کنید
|
|
438
|
+
- Docstring بنویسید
|
|
439
|
+
- تمام ۲۹ تست باید پاس شوند
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
<div align="center">
|
|
444
|
+
|
|
445
|
+
**اگر این پروژه برای شما مفید بود، لطفاً ⭐ بدهید!**
|
|
446
|
+
|
|
447
|
+
[](https://github.com/bmhmdyan279-png/truss-analysis-2d/stargazers)
|
|
448
|
+
|
|
449
|
+
</div>
|