Skip to main content

Worst case analysis and sensitivity studies. Extreme Value, Root-Sum-Square, Monte Carlo.

Project description

worstcase

For a detailed example of how this software may be leveraged in a true to life example, consider reading this blog post, where the end-to-end measurement uncertainty of a high-side current-sensing circuit is computed.

What's the worst that could happen?

Professional engineers spend a disproportionate amount of time considering the worst case, especially in fields such as aerospace where the cost of failure can be enormous and therefore the tolerance for technical risk is low.

When delivering hardware to a customer it is typical to also deliver analyses as data products. One such analysis is the worst-case analysis. Hardware performance must be analytically verified to meet requirements for the life of the mission, across all operational environments, with worst-case component variations.

The typical method for performing such an analysis is a spreadsheet like this one... the worstcase Python package offers a far more effective solution.

Usage

At its core, the worstcase Python package computes three values: the nominal, the lower bound, and the upper bound. These values may be determind either by Extreme Value, Root-Sum-Square, or Monte Carlo methods.

Input parameters are defined by their range or tolerance, (param.byrange, param.bytol).

# define the resistor uncertainties
R1 = param.bytol(nom=100 * unit.mohm, tol=0.01, rel=True, tag="R1")
R2 = param.bytol(nom=1.001 * unit.kohm, tol=0.01, rel=True, tag="R2")
R3 = param.bytol(nom=50.5 * unit.kohm, tol=0.01, rel=True, tag="R3")
R4 = param.bytol(nom=1.001 * unit.kohm, tol=0.01, rel=True, tag="R4")
R5 = param.bytol(nom=50.5 * unit.kohm, tol=0.01, rel=True, tag="R5")

# define the amplifier offset voltage
VOS = param.bytol(nom=0 * unit.mV, tol=150 * unit.uV, rel=False, tag="VOS")

Derived parameters use a decorator to map worst case input parameters to function arguments (derive.byev, derive.bymc, or derive.byrss).

# define the output voltage
@derive.byev(r1=R1, r2=R2, r3=R3, r4=R4, r5=R5, vos=VOS)
def VO(vbus, iload, r1, r2, r3, r4, r5, vos):
    vp = vbus * r3 / (r2 + r3)
    vn = vp + vos
    vo = vn - (vbus - r1 * iload - vn) * r5 / r4
    return vo

# define the end-to-end uncertainty
@derive.byev(r1=R1, r2=R2, r3=R3, r4=R4, r5=R5, vos=VOS)
def IUNC(r1, r2, r3, r4, r5, vos, vbus, iload):
    vo = VO(vbus, iload, r1, r2, r3, r4, r5, vos)
    return vo / VO(vbus, iload).nom * iload - iload

The worst case solution is determined by brute force. If desired, the resulting derived parameter can then be used in the definition of another derived parameter to build up a more complicated analysis.

# calculate at 36V, 1A operating point
VOUT_1A = VO(vbus=36 * unit.V, iload=1 * unit.A, tag="VOUT_1A")
IUNC_1A = IUNC(vbus=36 * unit.V, iload=1 * unit.A, tag="IUNC_1A")

print([VOUT_1A, IUNC_1A])

# [VOUT_1A: 5.045 V (nom), 3.647 V (lb), 6.387 V (ub),
#  IUNC_1A: 0 A (nom), -277 mA (lb), 266 mA (ub)]

Parameter units are supported via the default Pint UnitRegistry object. Results can also be further analyzed for their uncertainty drivers by performing a sensitivity study (ss()).

# perform sensitivity study at the 36V, 1A operating point
IUNC_1A_sensitivities = [
    IUNC_1A(tag="IUNC_1A-R1-sens").ss(R1),
    IUNC_1A(tag="IUNC_1A-VOS-sens").ss(VOS),
    IUNC_1A(tag="IUNC_1A-R2-thru-R5-sens").ss([R2, R3, R4, R5]),
]

print(IUNC_1A_sensitivities)

# [IUNC_1A-R1-sens: 0 A (nom), -10 mA (lb), 10 mA (ub),
#  IUNC_1A-VOS-sens: 0 A (nom), -1.53 mA (lb), 1.53 mA (ub),
#  IUNC_1A-R2-thru-R5-sens: 0 A (nom), -265.3 mA (lb), 254.7 mA (ub)]

Installation

pip install worstcase

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

worstcase-0.6.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

worstcase-0.6.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file worstcase-0.6.0.tar.gz.

File metadata

  • Download URL: worstcase-0.6.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.5 Windows/11

File hashes

Hashes for worstcase-0.6.0.tar.gz
Algorithm Hash digest
SHA256 e9a8e4381276c93bd10d72521149e3b523a85402bbc2a88a187b557581fb5019
MD5 b00ffc97a5ffa9e661d5c7d9f9aaa9d7
BLAKE2b-256 7c576d0718a7a3d15031726a4101a50aa4c22ee5b06362be9bccd256091a8f10

See more details on using hashes here.

File details

Details for the file worstcase-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: worstcase-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.5 Windows/11

File hashes

Hashes for worstcase-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d261a3638e4ffc61b7785478d9df71f6d37a7e9d1dc401ba50df92ac69372412
MD5 48aa7b9a6b0958d34b3597a6ffcd64e8
BLAKE2b-256 ca5308bd2cf1ab06c032dd924b0b6f4679d291a0b32228a442f893049329374b

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