No project description provided
Project description
dimstack
Python library for mechanical engineers to help with statistical tolerancing analysis and design.
https://pypi.org/project/dimstack/
Example (MIT Calc Demonstration Analysis)
import dimstack as ds
ds.display.mode("rich")
k = 0.25
target_process_sigma = 6
stdev = 0.036 / target_process_sigma
m1 = ds.dim.Statistical(
nom=208,
tol=ds.tol.SymmetricBilateral(0.036),
distribution=ds.dist.Normal(208 + k * target_process_sigma * stdev, stdev),
target_process_sigma=target_process_sigma,
name="a",
desc="Shaft",
)
m2 = ds.dim.Statistical(
nom=-1.75,
tol=ds.tol.UnequalBilateral(0, 0.06),
target_process_sigma=3,
name="b",
desc="Retainer ring",
)
m3 = ds.dim.Statistical(nom=-23, tol=ds.tol.UnequalBilateral(0, 0.12), target_process_sigma=3, name="c", desc="Bearing")
m4 = ds.dim.Statistical(
nom=20,
tol=ds.tol.SymmetricBilateral(0.026),
target_process_sigma=3,
name="d",
desc="Bearing Sleeve",
)
m5 = ds.dim.Statistical(nom=-200, tol=ds.tol.SymmetricBilateral(0.145), target_process_sigma=3, name="e", desc="Case")
m6 = ds.dim.Basic(
nom=20,
tol=ds.tol.SymmetricBilateral(0.026),
# target_process_sigma=3,
name="f",
desc="Bearing Sleeve",
)
m7 = ds.dim.Statistical(nom=-23, tol=ds.tol.UnequalBilateral(0, 0.12), target_process_sigma=3, name="g", desc="Bearing")
items = [m1, m2, m3, m4, m5, m6, m7]
stack = ds.Stack(name="stacks on stacks", dims=items)
stack.show()
ds.calc.Closed(stack).show()
ds.calc.WC(stack).show()
ds.calc.RSS(stack).show()
ds.calc.MRSS(stack).show()
designed_for = ds.calc.SixSigma(stack, at=4.5)
designed_for.show()
spec = ds.Spec("stack spec", "", distribution=designed_for.distribution, LL=0.05, UL=0.8)
spec.show()
ds.plot.StackPlot().add(stack).add(stack.RSS).show()
Returns:
STACK: stacks on stacks
┏━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━┳━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Name ┃ Desc. ┃ ± ┃ Nom. ┃ Tol. ┃ Sens. (a) ┃ Abs. Bounds ┃
┡━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━╇━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ 0 │ a │ Shaft │ + │ 208 │ ± 0.036 │ 1 │ [207.964, 208.036] │
│ 1 │ b │ Retainer ring │ - │ 1.75 │ + 0.06 / + 0 │ 1 │ [-1.75, -1.69] │
│ 2 │ c │ Bearing │ - │ 23 │ + 0.12 / + 0 │ 1 │ [-23, -22.88] │
│ 3 │ d │ Bearing Sleeve │ + │ 20 │ ± 0.026 │ 1 │ [19.974, 20.026] │
│ 4 │ e │ Case │ - │ 200 │ ± 0.145 │ 1 │ [-200.145, -199.855] │
│ 5 │ f │ Bearing Sleeve │ + │ 20 │ ± 0.026 │ 1 │ [19.974, 20.026] │
│ 6 │ g │ Bearing │ - │ 23 │ + 0.12 / + 0 │ 1 │ [-23, -22.88] │
└────┴──────┴────────────────┴───┴──────────┴────────────────┴───────────┴──────────────────────┘
DIMENSION: stacks on stacks - Closed Analysis -
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Name ┃ Desc. ┃ ± ┃ Nom. ┃ Tol. ┃ Sens. (a) ┃ Rel. Bounds ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ 7 │ stacks on stacks - Closed Analysis │ │ + │ 0.25 │ + 0.233 / - 0.533 │ 1 │ [-0.283, 0.483] │
└────┴────────────────────────────────────┴───────┴───┴──────┴───────────────────┴───────────┴─────────────────┘
DIMENSION: stacks on stacks - WC Analysis -
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━┳━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Name ┃ Desc. ┃ ± ┃ Nom. ┃ Tol. ┃ Sens. (a) ┃ Rel. Bounds ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━╇━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ 8 │ stacks on stacks - WC Analysis │ │ + │ 0.1 │ ± 0.383 │ 1 │ [-0.283, 0.483] │
└────┴────────────────────────────────┴───────┴───┴──────┴────────────────┴───────────┴─────────────────┘
WARNING:root:Converting Basic Dim. (5: f Bearing Sleeve +20 ± 0.026) to Statistical Dim.
WARNING:root:Assuming Normal Dist. for 10: stacks on stacks - RSS Analysis (assuming inputs with Normal Dist. & uniform SD) +0.1 ± 0.17825 @ Normal Dist. (μ=0.1, σ=0.05942)
DIMENSION: stacks on stacks - RSS Analysis - (assuming inputs with Normal Dist. & uniform SD)
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━┳━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Desc. ┃ ± ┃ Nom. ┃ Tol. ┃ Sens. (a) ┃ Abs. Bounds ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━╇━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ 10 │ (assuming inputs with Normal Dist. & uniform SD) │ + │ 0.1 │ ± 0.17825 │ 1 │ [-0.07825, 0.27825] │
└────┴──────────────────────────────────────────────────┴───┴──────┴────────────────┴───────────┴─────────────────────┘
WARNING:root:Converting Basic Dim. (5: f Bearing Sleeve +20 ± 0.026) to Statistical Dim.
WARNING:root:Assuming Normal Dist. for 12: stacks on stacks - MRSS Analysis (assuming inputs with Normal Dist. & uniform SD) +0.1 ± 0.24046 @ Normal Dist. (μ=0.1, σ=0.06383)
DIMENSION: stacks on stacks - MRSS Analysis - (assuming inputs with Normal Dist. & uniform SD)
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━┳━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Desc. ┃ ± ┃ Nom. ┃ Tol. ┃ Sens. (a) ┃ Abs. Bounds ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━╇━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ 12 │ (assuming inputs with Normal Dist. & uniform SD) │ + │ 0.1 │ ± 0.24046 │ 1 │ [-0.14046, 0.34046] │
└────┴──────────────────────────────────────────────────┴───┴──────┴────────────────┴───────────┴─────────────────────┘
WARNING:root:Assuming Normal Dist. for 1: b Retainer ring -1.75 + 0.06 / + 0 @ Normal Dist. (μ=1.78, σ=0.01)
WARNING:root:Assuming Normal Dist. for 2: c Bearing -23 + 0.12 / + 0 @ Normal Dist. (μ=23.06, σ=0.02)
WARNING:root:Assuming Normal Dist. for 3: d Bearing Sleeve +20 ± 0.026 @ Normal Dist. (μ=20.0, σ=0.00867)
WARNING:root:Assuming Normal Dist. for 4: e Case -200 ± 0.145 @ Normal Dist. (μ=200.0, σ=0.04833)
WARNING:root:Converting Basic Dim. (5: f Bearing Sleeve +20 ± 0.026) to Statistical Dim.
WARNING:root:Assuming Normal Dist. for 13: f Bearing Sleeve +20 ± 0.026 @ Normal Dist. (μ=20.0, σ=0.00867)
WARNING:root:Assuming Normal Dist. for 6: g Bearing -23 + 0.12 / + 0 @ Normal Dist. (μ=23.06, σ=0.02)
WARNING:root:Assuming Normal Dist. for 14: stacks on stacks - '6 Sigma' Analysis (assuming inputs with Normal Dist.) +0.1 ± 0.26433 @ Normal Dist. (μ=0.1, σ=0.05874)
DIMENSION: stacks on stacks - '6 Sigma' Analysis - (assuming inputs with Normal Dist.)
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━┳━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Desc. ┃ ± ┃ Nom. ┃ Tol. ┃ Sens. (a) ┃ Abs. Bounds ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━╇━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ 14 │ (assuming inputs with Normal Dist.) │ + │ 0.1 │ ± 0.26433 │ 1 │ [-0.16433, 0.36433] │
└────┴─────────────────────────────────────┴───┴──────┴────────────────┴───────────┴─────────────────────┘
SPEC: stack spec
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Desc. ┃ Distribution ┃ Median ┃ Spec. Limits ┃ Yield Prob. ┃ Reject PPM ┃
┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ │ Normal Dist. (μ=0.1, σ=0.05874) │ 0.425 │ [0.05, 0.8] │ 80.2675148 │ 197324.85 │
└───────┴─────────────────────────────────┴────────┴──────────────┴─────────────┴────────────┘
Usage
dimstack works great as a library in a python script, in REPL, or in JupyterLab.
and Notebook setup
%pip install -q dimstack
Development
Testing
uv run python -m unittest
Documenting
python -m mkdocs build
python -m mkdocs serve
python -m mkdocs gh-deploy
uv run mkdocs build
uv run mkdocs serve
uv run mkdocs gh-deploy
Deploying
First bump version in pyproject.toml, then
uv build
uv publish
cp '.\\dist\\*.whl' '.\\notebooks\\pypi\\'
Acknowledgements
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dimstack-0.7.0.tar.gz
(4.5 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
dimstack-0.7.0-py3-none-any.whl
(14.7 kB
view details)
File details
Details for the file dimstack-0.7.0.tar.gz.
File metadata
- Download URL: dimstack-0.7.0.tar.gz
- Upload date:
- Size: 4.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e6339109fc0facd8df9461d0a01fdb4e2e9ac62062a9f03c743b2052e7e1a1e
|
|
| MD5 |
257dddee6ae990936b6dbd53936aa9fa
|
|
| BLAKE2b-256 |
85505d635c827018643cbf7455382a482d60384d70b9a979667564c27d1130d5
|
File details
Details for the file dimstack-0.7.0-py3-none-any.whl.
File metadata
- Download URL: dimstack-0.7.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7a4735a5651496cb7ef54bbfa84ca97a1e6a20c7c4c06f6656d3be6ca2ca932
|
|
| MD5 |
3d3fa706cbe6cdd856cb192f8254aef6
|
|
| BLAKE2b-256 |
564d83d4403029c07bb87a15fbe291b4976e188f972d4ef669b4d67c764c3461
|