Skip to main content

A lightweight Python package for mechanical tolerance stack‑up analysis.

Project description


Python 3.6+

Precision at the core: total tolerance stack‑up, intelligently fused.

StackCore is a lightweight Python package for mechanical tolerance stack‑up analysis, integrating Monte Carlo simulation and data‑driven intelligence.


🚀 Features

  • 🧮 Tolerance stack‑up under control: manage multi‑component linear and geometric assemblies.
  • 🔁 Monte Carlo engine: generate distributions, confidence ranges, and worst‑case scenarios.
  • 📊 Flexible output: summary stats, histograms, and data visualization tools.
  • 🔌 Clean APIs: Stack, PStack, MStack
  • 🛠️ Designed for engineers: zone‑independent, boundary‑aware, CAD/tool‑agnostic.

📥 Installation

pip install stackcore

Usage

To import the stackcore module, use

import stackcore

The main component, the Stack can be imported as follows:

from stackcore import Stack

The Stack Component taks a few key arguments:

Main Plane

The main plane is defined by a set of 3 points, and defines the main plane that the tolerance stack up will measure against. Here's an example:

m=np.array([[3,  2, -1],
            [0,  3,  3],
            [-1, 2,  4]])

Components

The components variable contains a dictioary of planes and their respective tolerances, with many various tolerance types such as displacement and radial (axis). Here's an example:

components = [
             {'plane': np.array([[-8, 1, 5],
                                 [-4, 7, 3],
                                 [-3, 2, 6]]),
              'tolerances': [{'type': 'cylindrical',
                              'tol': [-0.1, +0.1],
                              'axis': np.array([[0,0,1], 
                                                [0,0,1],
                                                [-.7, -0.9, 0.]])},
                              {'type': 'displacement',
                               'tol' : [-0.1, +0.1],
                               'axis': np.array([[0,0,1], 
                                                 [0,0,1],
                                                 [-.7, -0.9, 0.]])}]}
]

Metrics

The metrics variable contains a dictionary of the targeted metrics and their reference type. The 2 tolerance types currently supported are 'Angular' and 'Linear' Here's an example:

metrics = [
    { 'name': 'alpha',
      'type': 'Angular'
    }
]

Path

The path variable defines where any generated figures should be stored. Here's an example:

path = 'path/to/figures/'

Parallel Processing

For faster processing, the PStack object is provided that uses the numba package to parallelize the loops in the monte carlo simulation. To use the PStack, import it using:

from stackcore import PStack

All of the same functions of the Stack object are available in the PStack object.

Metrology

(v0.3.0) StackCore now supports component compatibility testing via metrology data. To access this, use the MStack object, which takes the same inputs as the serial and parallel stacks above. To use the MStack object:

from stackcore import Mstack

For metrology, the component input looks a little different. Each component is defined by 3 points, and each point has its own metrology (∂x, ∂y, ∂z) associated with it. Here's an example:

[
        {
            "name": "Component",
            "points": [
                {
                    "coordinates": [
                        -20,
                        10,
                        6
                    ],
                    "dx": 1.0,
                    "dy": -1.0,
                    "dz": 0.0
                },
                {
                    "coordinates": [
                        -15,
                        12,
                        5
                    ],
                    "dx": 0.0,
                    "dy": 0.2,
                    "dz": 0.3
                },
                {
                    "coordinates": [
                        -3,
                        5,
                        6
                    ],
                    "dx": -1.0,
                    "dy": 0.01,
                    "dz": -0.4
                }
            ]
        }
    ]

For a full example, see example.py

Stackfuse

To use a GUI interface, see StackFuse: A Fusion360 add-in that connects with stackcore to create an intuitive way to tolerance and analyze mechanical assemblies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stackcore-0.3.2.tar.gz (107.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackcore-0.3.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file stackcore-0.3.2.tar.gz.

File metadata

  • Download URL: stackcore-0.3.2.tar.gz
  • Upload date:
  • Size: 107.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for stackcore-0.3.2.tar.gz
Algorithm Hash digest
SHA256 613e0f585512f394e80720d88141bc5623911e145fc9aa7439d471c220c0d074
MD5 63e57a67779713cd2d9c9990d03491bc
BLAKE2b-256 dce36c3e4f2993ba83c6a5a5d19135c0c49f4c17d9afe3618b6bcf86d3b8ffb2

See more details on using hashes here.

File details

Details for the file stackcore-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: stackcore-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for stackcore-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f830cf96f7ecc80d46cffee0dabc12dae53eddbe7d08021c12f2bcfbe57fb0f7
MD5 07d0daaed6ee0f4757271805376bf048
BLAKE2b-256 9af7c6d4909792234182f5526fa91e03fa836456981a8d412b9a18b74998b077

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page