Skip to main content

Automatic convergence detection for iterative numerical methods. Stop wasting compute.

Project description

Convergio

Automatic convergence detection for iterative numerical methods.

Stop wasting compute. One function call tells you if your solver has converged, is oscillating, is stuck between two states, or is diverging.

"Your solver finished 3000 iterations ago."

Install

pip install convergio

Only dependency: NumPy.

Usage

Analyze a completed run

from convergio import detect

result = detect(my_residual_history)

print(result.state)        # "converged" | "oscillating" | "bistable" | "diverging"
print(result.quality)      # 0.0 — 1.0
print(result.converged_at) # step where convergence was detected
print(result.n_modes)      # number of distinct stable states

Monitor a running simulation

from convergio import watch

mon = watch(var_threshold=1e-6)

for step in range(10000):
    residual = solver.step()
    stop, info = mon.step(residual)
    if stop:
        print(f"Converged at step {step}")
        break

What it detects

State Meaning Recommendation
converged Signal has stabilized Stop
oscillating Signal oscillates without settling Continue or adjust parameters
bistable Signal jumps between 2+ distinct states Investigate — multiple solutions exist
diverging Variance is growing Restart with different parameters
warming_up Not enough data yet Continue

Works with

  • FEM / CFD solvers (residual monitoring)
  • ML training (loss convergence)
  • Monte Carlo simulations (running averages)
  • Optimization loops (objective function)
  • Molecular dynamics (energy equilibration)
  • Any iterative numerical process that produces a scalar time series

API

detect(signal, window=0, var_threshold=1e-6)

Analyze a complete time series. Returns ConvergenceResult.

watch(var_threshold=1e-6, check_every=50, min_steps=100)

Create a live monitor. Returns Watch object. Call .step(value) each iteration.

ConvergenceResult

Field Type Description
state str converged, oscillating, bistable, diverging, warming_up
quality float 0.0 — 1.0 convergence quality
converged_at int or None Step where convergence detected
final_variance float Variance of last window
oscillation_freq float Detected oscillation frequency
n_modes int Number of distinct stable states
recommendation str stop, continue, restart

License

MIT

Author

Maximilian Jurak — 3 Kaiserberge Engineering & Research

max.jurak@3kaiserberge.com

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

convergio-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

convergio-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file convergio-0.1.1.tar.gz.

File metadata

  • Download URL: convergio-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for convergio-0.1.1.tar.gz
Algorithm Hash digest
SHA256 65a1c0f8dff595d3f6d533835ef554cb6594e51489c06f9a31daf1932ee18667
MD5 e958944327f71cbaf7a4d5abb6845b76
BLAKE2b-256 daa96f3521cec73b29c69b702c1664b5955f66942fbe6b7391d1f1b0bf3ac4c8

See more details on using hashes here.

File details

Details for the file convergio-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: convergio-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for convergio-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a9e7d47cb1a48fdf692b7e1b15fb1a105c6b877fda77c05d6bbb9f7dfa977bc
MD5 1715402733832abb70929bf708575cb1
BLAKE2b-256 d52c2db1c77d8b1f1330244bdd96bf4f5ec3d22b7db223273206a3b00879d570

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