Skip to main content

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

Project description


Python 3.6+ PyPI - Version

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.3.tar.gz (107.3 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.3-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stackcore-0.3.3.tar.gz
  • Upload date:
  • Size: 107.3 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.3.tar.gz
Algorithm Hash digest
SHA256 7865ffdb400d006b02de06cb2bb721ab271438cfc0123765e6e65d9c0bec96f3
MD5 9376dbec96fb81781a40eb914bc7b36f
BLAKE2b-256 894db53d1863dda239280869635d8b3c0648dc10d5e8b7de52974757fcb98b67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stackcore-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 07edcd644f7512ad137c38e906cc858fdd27870a412b092d0b18aa4b5b0f4a5f
MD5 620824f1301ff5fa60738a4ba8445aa3
BLAKE2b-256 74dfdc0d4b87ba28253109bc7c9186b8fcfda4f59c177fe4c69712ff1426a934

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