mechlab 0.0.1__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.
mechlab-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sewak Sunar
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.
mechlab-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.4
2
+ Name: mechlab
3
+ Version: 0.0.1
4
+ Summary: Computational Mechanical Engineering Toolkit
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: mechanical-engineering,thermodynamics,fluid-mechanics,control-systems,engineering,scientific-computing
8
+ Author: Sewak Sunar
9
+ Author-email: sewaksunar@hotmail.com
10
+ Requires-Python: >=3.14
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Intended Audience :: Education
14
+ Classifier: Topic :: Scientific/Engineering
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Dist: colorama (==0.4.6)
20
+ Requires-Dist: contourpy (==1.3.3)
21
+ Requires-Dist: control (==0.10.2)
22
+ Requires-Dist: coolprop (==7.2.0)
23
+ Requires-Dist: cycler (==0.12.1)
24
+ Requires-Dist: flexcache (==0.3)
25
+ Requires-Dist: flexparser (==0.4)
26
+ Requires-Dist: fluids (==1.3.0)
27
+ Requires-Dist: fonttools (==4.61.1)
28
+ Requires-Dist: furo (>=2025.12.19,<2026.0.0)
29
+ Requires-Dist: iniconfig (==2.3.0)
30
+ Requires-Dist: kiwisolver (==1.4.9)
31
+ Requires-Dist: matplotlib (==3.10.8)
32
+ Requires-Dist: mpmath (==1.3.0)
33
+ Requires-Dist: myst-parser (>=5.0.0,<6.0.0)
34
+ Requires-Dist: numpy (==2.4.1)
35
+ Requires-Dist: packaging (==26.0)
36
+ Requires-Dist: pillow (==12.1.0)
37
+ Requires-Dist: pint (==0.25.2)
38
+ Requires-Dist: platformdirs (==4.5.1)
39
+ Requires-Dist: pluggy (==1.6.0)
40
+ Requires-Dist: pygments (==2.19.2)
41
+ Requires-Dist: pyparsing (==3.3.2)
42
+ Requires-Dist: pytest (==9.0.2)
43
+ Requires-Dist: python-dateutil (==2.9.0.post0)
44
+ Requires-Dist: scipy (==1.17.0)
45
+ Requires-Dist: six (==1.17.0)
46
+ Requires-Dist: sphinx-autobuild (>=2025.8.25,<2026.0.0)
47
+ Requires-Dist: sphinx-copybutton (>=0.5.2,<0.6.0)
48
+ Requires-Dist: sphinx-design (>=0.7.0,<0.8.0)
49
+ Requires-Dist: sympy (==1.14.0)
50
+ Requires-Dist: typing-extensions (==4.15.0)
51
+ Description-Content-Type: text/markdown
52
+
53
+ ![PyPI](https://img.shields.io/pypi/v/mechlab)
54
+ ![License](https://img.shields.io/pypi/l/mechlab)
55
+ ![Python](https://img.shields.io/pypi/pyversions/mechlab)
56
+ # MechLab 🔧📘
57
+
58
+ **MechLab** is an open‑source Python library for **mechanical engineering computations**, designed to provide a unified, modular, and extensible toolkit for students, researchers, and practicing engineers.
59
+
60
+ It brings together commonly used scientific libraries under a clean, engineering‑focused API for **thermodynamics, fluid mechanics, control systems, and numerical analysis**.
61
+
62
+ ---
63
+
64
+ ## ✨ Features
65
+
66
+ * 🔥 Thermodynamics utilities (properties, processes, cycles)
67
+ * 🌊 Fluid mechanics calculations (dimensionless numbers, flow relations)
68
+ * 🎛️ Control systems support
69
+ * 🧮 Symbolic & numerical computation
70
+ * 📐 Unit‑safe calculations (planned)
71
+ * 🧱 Modular structure (easy to extend)
72
+
73
+ ---
74
+
75
+ ## 📦 Installation
76
+
77
+ Install directly from **PyPI**:
78
+
79
+ ```bash
80
+ pip install mechlab
81
+ ```
82
+
83
+ Or using **Poetry**:
84
+
85
+ ```bash
86
+ poetry add mechlab
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 🚀 Quick Start
92
+
93
+ ```python
94
+ from mechlab.thermodynamics import enthalpy_TP
95
+
96
+ h = enthalpy_TP(
97
+ fluid="Water",
98
+ T=500, # Temperature in K
99
+ P=3e6 # Pressure in Pa
100
+ )
101
+
102
+ print(f"Enthalpy: {h:.2f} J/kg")
103
+ ```
104
+
105
+ ---
106
+
107
+ ## 📂 Package Structure
108
+
109
+ ```text
110
+ mechlab/
111
+
112
+ ├── thermodynamics/
113
+ │ ├── __init__.py
114
+ │ ├── properties.py
115
+ │ └── cycles.py
116
+
117
+ ├── fluid_mechanics/
118
+ │ ├── __init__.py
119
+ │ └── dimensionless.py
120
+
121
+ ├── control_systems/
122
+ │ ├── __init__.py
123
+ │ └── linear.py
124
+
125
+ ├── utils/
126
+ │ ├── __init__.py
127
+ │ └── constants.py
128
+
129
+ └── __init__.py
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 🔬 Dependencies
135
+
136
+ MechLab is built on top of proven scientific libraries:
137
+
138
+ * `numpy`
139
+ * `scipy`
140
+ * `sympy`
141
+ * `control`
142
+ * `fluids`
143
+ * `CoolProp`
144
+ * `pint`
145
+ * `matplotlib`
146
+
147
+ These are installed automatically with MechLab.
148
+
149
+ ---
150
+
151
+ ## 🧠 Design Philosophy
152
+
153
+ * **Engineering‑first API** (clear variable names, physical meaning)
154
+ * **Readable code** over premature optimization
155
+ * **Modular** – each subject area is independent
156
+ * **Extensible** – easy to add new models & correlations
157
+
158
+ ---
159
+
160
+ ## 📈 Roadmap
161
+
162
+ * [ ] Rankine, Otto, Diesel cycles
163
+ * [ ] Pipe flow & heat exchanger modules
164
+ * [ ] Full unit‑aware API using Pint
165
+ * [ ] Validation against textbook examples
166
+ * [ ] Interactive Jupyter examples
167
+ * [ ] Documentation website
168
+
169
+ ---
170
+
171
+ ## 🧪 Development Setup
172
+
173
+ Clone the repository:
174
+
175
+ ```bash
176
+ git clone https://github.com/sewaksunar/mechlab.git
177
+ cd mechlab
178
+ ```
179
+
180
+ Install dependencies with Poetry:
181
+
182
+ ```bash
183
+ poetry install
184
+ poetry shell
185
+ ```
186
+
187
+ Run tests:
188
+
189
+ ```bash
190
+ pytest
191
+ ```
192
+
193
+ ---
194
+
195
+ ## 🤝 Contributing
196
+
197
+ Contributions are welcome!
198
+
199
+ 1. Fork the repository
200
+ 2. Create a feature branch
201
+ 3. Commit your changes
202
+ 4. Open a Pull Request
203
+
204
+ Please follow:
205
+
206
+ * PEP‑8 style
207
+ * Clear docstrings
208
+ * Basic tests for new features
209
+
210
+ ---
211
+
212
+ ## 📜 License
213
+
214
+ This project is licensed under the **MIT License**.
215
+
216
+ ---
217
+
218
+ ## 👤 Author
219
+
220
+ **Sewak Sunar**
221
+ Mechanical Engineering Enthusiast & Python Developer
222
+
223
+ * GitHub: [https://github.com/sewaksunar](https://github.com/sewaksunar)
224
+
225
+ ---
226
+
227
+ ## ⭐ Acknowledgements
228
+
229
+ Inspired by mechanical engineering textbooks and the open‑source scientific Python ecosystem.
230
+
231
+ If you find MechLab useful, please ⭐ the repository on GitHub!
232
+
@@ -0,0 +1,179 @@
1
+ ![PyPI](https://img.shields.io/pypi/v/mechlab)
2
+ ![License](https://img.shields.io/pypi/l/mechlab)
3
+ ![Python](https://img.shields.io/pypi/pyversions/mechlab)
4
+ # MechLab 🔧📘
5
+
6
+ **MechLab** is an open‑source Python library for **mechanical engineering computations**, designed to provide a unified, modular, and extensible toolkit for students, researchers, and practicing engineers.
7
+
8
+ It brings together commonly used scientific libraries under a clean, engineering‑focused API for **thermodynamics, fluid mechanics, control systems, and numerical analysis**.
9
+
10
+ ---
11
+
12
+ ## ✨ Features
13
+
14
+ * 🔥 Thermodynamics utilities (properties, processes, cycles)
15
+ * 🌊 Fluid mechanics calculations (dimensionless numbers, flow relations)
16
+ * 🎛️ Control systems support
17
+ * 🧮 Symbolic & numerical computation
18
+ * 📐 Unit‑safe calculations (planned)
19
+ * 🧱 Modular structure (easy to extend)
20
+
21
+ ---
22
+
23
+ ## 📦 Installation
24
+
25
+ Install directly from **PyPI**:
26
+
27
+ ```bash
28
+ pip install mechlab
29
+ ```
30
+
31
+ Or using **Poetry**:
32
+
33
+ ```bash
34
+ poetry add mechlab
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 🚀 Quick Start
40
+
41
+ ```python
42
+ from mechlab.thermodynamics import enthalpy_TP
43
+
44
+ h = enthalpy_TP(
45
+ fluid="Water",
46
+ T=500, # Temperature in K
47
+ P=3e6 # Pressure in Pa
48
+ )
49
+
50
+ print(f"Enthalpy: {h:.2f} J/kg")
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 📂 Package Structure
56
+
57
+ ```text
58
+ mechlab/
59
+
60
+ ├── thermodynamics/
61
+ │ ├── __init__.py
62
+ │ ├── properties.py
63
+ │ └── cycles.py
64
+
65
+ ├── fluid_mechanics/
66
+ │ ├── __init__.py
67
+ │ └── dimensionless.py
68
+
69
+ ├── control_systems/
70
+ │ ├── __init__.py
71
+ │ └── linear.py
72
+
73
+ ├── utils/
74
+ │ ├── __init__.py
75
+ │ └── constants.py
76
+
77
+ └── __init__.py
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 🔬 Dependencies
83
+
84
+ MechLab is built on top of proven scientific libraries:
85
+
86
+ * `numpy`
87
+ * `scipy`
88
+ * `sympy`
89
+ * `control`
90
+ * `fluids`
91
+ * `CoolProp`
92
+ * `pint`
93
+ * `matplotlib`
94
+
95
+ These are installed automatically with MechLab.
96
+
97
+ ---
98
+
99
+ ## 🧠 Design Philosophy
100
+
101
+ * **Engineering‑first API** (clear variable names, physical meaning)
102
+ * **Readable code** over premature optimization
103
+ * **Modular** – each subject area is independent
104
+ * **Extensible** – easy to add new models & correlations
105
+
106
+ ---
107
+
108
+ ## 📈 Roadmap
109
+
110
+ * [ ] Rankine, Otto, Diesel cycles
111
+ * [ ] Pipe flow & heat exchanger modules
112
+ * [ ] Full unit‑aware API using Pint
113
+ * [ ] Validation against textbook examples
114
+ * [ ] Interactive Jupyter examples
115
+ * [ ] Documentation website
116
+
117
+ ---
118
+
119
+ ## 🧪 Development Setup
120
+
121
+ Clone the repository:
122
+
123
+ ```bash
124
+ git clone https://github.com/sewaksunar/mechlab.git
125
+ cd mechlab
126
+ ```
127
+
128
+ Install dependencies with Poetry:
129
+
130
+ ```bash
131
+ poetry install
132
+ poetry shell
133
+ ```
134
+
135
+ Run tests:
136
+
137
+ ```bash
138
+ pytest
139
+ ```
140
+
141
+ ---
142
+
143
+ ## 🤝 Contributing
144
+
145
+ Contributions are welcome!
146
+
147
+ 1. Fork the repository
148
+ 2. Create a feature branch
149
+ 3. Commit your changes
150
+ 4. Open a Pull Request
151
+
152
+ Please follow:
153
+
154
+ * PEP‑8 style
155
+ * Clear docstrings
156
+ * Basic tests for new features
157
+
158
+ ---
159
+
160
+ ## 📜 License
161
+
162
+ This project is licensed under the **MIT License**.
163
+
164
+ ---
165
+
166
+ ## 👤 Author
167
+
168
+ **Sewak Sunar**
169
+ Mechanical Engineering Enthusiast & Python Developer
170
+
171
+ * GitHub: [https://github.com/sewaksunar](https://github.com/sewaksunar)
172
+
173
+ ---
174
+
175
+ ## ⭐ Acknowledgements
176
+
177
+ Inspired by mechanical engineering textbooks and the open‑source scientific Python ecosystem.
178
+
179
+ If you find MechLab useful, please ⭐ the repository on GitHub!
@@ -0,0 +1,2 @@
1
+ from .statics import Beam, RigidBody
2
+ __all__ = ["Beam"]
@@ -0,0 +1,56 @@
1
+ r"""
2
+ Mechanics & Dynamics
3
+ ====================
4
+
5
+ This module provides tools for both static structural analysis and
6
+ rigid body dynamics.
7
+ """
8
+
9
+ class Beam:
10
+ r"""
11
+ Represents a structural cantilever beam.
12
+
13
+ **Deflection Formula:**
14
+
15
+ .. math::
16
+
17
+ \delta_{max} = \frac{P L^3}{3 E I}
18
+
19
+ Args:
20
+ L (float): Length [m].
21
+ E (float): Young's Modulus [Pa].
22
+ I (float): Moment of Inertia [m^4].
23
+ """
24
+ def __init__(self, L, E, I):
25
+ self.L, self.E, self.I = L, E, I
26
+
27
+ def max_deflection(self, load):
28
+ r"""
29
+ Calculates max deflection at the free end using:
30
+ :math:`\delta = \frac{FL^3}{3EI}`
31
+ """
32
+ return (load * self.L**3) / (3 * self.E * self.I)
33
+
34
+
35
+
36
+ class RigidBody:
37
+ r"""
38
+ Represents a point mass for dynamic calculations.
39
+
40
+ **Weight Calculation:**
41
+
42
+ .. math::
43
+
44
+ W = m \cdot g
45
+
46
+ Args:
47
+ mass (float): Mass [kg].
48
+ position (tuple): (x, y) coordinates [m].
49
+ """
50
+ def __init__(self, mass, position):
51
+ self.mass = mass
52
+ self.position = position
53
+
54
+ def weight(self):
55
+ """Returns weight in Newtons (:math:`N`)."""
56
+ return self.mass * 9.81
@@ -0,0 +1,12 @@
1
+ """
2
+ Thermodynamics Module
3
+ =====================
4
+ """
5
+ # Only import what definitely exists
6
+ from .state import State
7
+
8
+ # If properties.py doesn't have get_fluid_properties yet,
9
+ # comment this out until the function is written:
10
+ # from .properties import get_fluid_properties
11
+
12
+ __all__ = ["State"]
@@ -0,0 +1,18 @@
1
+ import numpy as np
2
+ import sympy as sp
3
+
4
+ # Symbols for SymPy
5
+ P, V, n, R, T = sp.symbols('P V n R T')
6
+
7
+ def enthalpy_TP(fluid: str, temp: float, press: float) -> float:
8
+ # Example: Simple CP*T for an ideal gas
9
+ cp_air = 1005 # J/kg-K
10
+ return cp_air * temp
11
+
12
+ def entropy_TP(fluid: str, temp: float, press: float) -> float:
13
+ # Example: Simple calculation
14
+ return 1.0 * temp / press
15
+
16
+ def get_pressure_func():
17
+ ideal_gas_eq = (n * R * T) / V
18
+ return sp.lambdify((n, R, T, V), ideal_gas_eq, 'numpy')
@@ -0,0 +1,17 @@
1
+ class State:
2
+ """
3
+ Represents a thermodynamic state of a pure substance.
4
+
5
+ Usage:
6
+ >>> from mechlab.thermodynamics import State
7
+ >>> water = State("water", T=373.15, P=101325)
8
+ >>> print(f"Enthalpy: {water.h:.2f} J/kg")
9
+
10
+ Expected Output:
11
+ .. code-block:: text
12
+
13
+ Enthalpy: 2675529.15 J/kg
14
+
15
+ The state is defined by two independent intensive properties.
16
+ Internal logic handles phase detection (Subcooled, Saturated, Superheated).
17
+ """
@@ -0,0 +1,23 @@
1
+ from mechlab.thermodynamics import state
2
+ import numpy as np
3
+
4
+ def run_test():
5
+ print("--- Starting Thermodynamics Test (SymPy/NumPy) ---")
6
+
7
+ # 1. Test the Enthalpy function (Linear model)
8
+ temp = 300.0
9
+ press = 101325.0
10
+ h = state.enthalpy_TP("Air", temp, press)
11
+ print(f"Calculated Enthalpy: {h} J/kg")
12
+
13
+ # 2. Test the Symbolic-to-Numerical Pressure function
14
+ p_func = state.get_pressure_func()
15
+ # P = nRT/V -> (1 mole, 8.314 R, 300K, 0.025 m^3)
16
+ p_result = p_func(1.0, 8.314, 300, 0.025)
17
+ print(f"Calculated Pressure: {p_result:,.2f} Pa")
18
+
19
+ print("------------------------------------------------")
20
+ print("SUCCESS: All functions executed correctly!")
21
+
22
+ if __name__ == "__main__":
23
+ run_test()
@@ -0,0 +1,88 @@
1
+ [project]
2
+ name = "mechlab"
3
+ version = "0.0.1"
4
+ description = "Computational Mechanical Engineering Toolkit"
5
+ readme = "README.md" # Crucial: This links your description to PyPI
6
+ requires-python = ">=3.14"
7
+ authors = [
8
+ {name = "Sewak Sunar", email = "sewaksunar@hotmail.com"}
9
+ ]
10
+ license = {text = "MIT"}
11
+
12
+ keywords = [
13
+ "mechanical-engineering",
14
+ "thermodynamics",
15
+ "fluid-mechanics",
16
+ "control-systems",
17
+ "engineering",
18
+ "scientific-computing"
19
+ ]
20
+
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Intended Audience :: Science/Research",
24
+ "Intended Audience :: Education",
25
+ "Topic :: Scientific/Engineering",
26
+ "Topic :: Scientific/Engineering :: Physics",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Programming Language :: Python :: 3",
29
+ "Operating System :: OS Independent"
30
+ ]
31
+
32
+ dependencies = [
33
+ "colorama (==0.4.6)",
34
+ "contourpy (==1.3.3)",
35
+ "control (==0.10.2)",
36
+ "coolprop (==7.2.0)",
37
+ "cycler (==0.12.1)",
38
+ "flexcache (==0.3)",
39
+ "flexparser (==0.4)",
40
+ "fluids (==1.3.0)",
41
+ "fonttools (==4.61.1)",
42
+ "iniconfig (==2.3.0)",
43
+ "kiwisolver (==1.4.9)",
44
+ "matplotlib (==3.10.8)",
45
+ "mpmath (==1.3.0)",
46
+ "numpy (==2.4.1)",
47
+ "packaging (==26.0)",
48
+ "pillow (==12.1.0)",
49
+ "pint (==0.25.2)",
50
+ "platformdirs (==4.5.1)",
51
+ "pluggy (==1.6.0)",
52
+ "pygments (==2.19.2)",
53
+ "pyparsing (==3.3.2)",
54
+ "pytest (==9.0.2)",
55
+ "python-dateutil (==2.9.0.post0)",
56
+ "scipy (==1.17.0)",
57
+ "six (==1.17.0)",
58
+ "sympy (==1.14.0)",
59
+ "typing-extensions (==4.15.0)",
60
+ "furo (>=2025.12.19,<2026.0.0)",
61
+ "sphinx-copybutton (>=0.5.2,<0.6.0)",
62
+ "myst-parser (>=5.0.0,<6.0.0)",
63
+ "sphinx-design (>=0.7.0,<0.8.0)",
64
+ "sphinx-autobuild (>=2025.8.25,<2026.0.0)"
65
+ ]
66
+
67
+ [tool.poetry]
68
+ # Keep the package inclusion here
69
+ packages = [
70
+ { include = "mechlab" }
71
+ ]
72
+
73
+ [dependency-groups]
74
+ docs = [
75
+ "sphinx (>=9.1.0,<10.0.0)",
76
+ "sphinx-autodoc-typehints (>=3.6.2,<4.0.0)",
77
+ "furo (>=2025.12.19,<2026.0.0)",
78
+ "myst-parser (>=5.0.0,<6.0.0)",
79
+ "sphinx-design (>=0.7.0,<0.8.0)",
80
+ "sphinx-copybutton (>=0.5.2,<0.6.0)"
81
+ ]
82
+
83
+ [project.scripts]
84
+ dev = "scripts:docs_dev"
85
+
86
+ [build-system]
87
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
88
+ build-backend = "poetry.core.masonry.api"