Skip to main content

Solverz

Documentation · Cookbook · API reference · PyPI

Solverz is an open-source, general-purpose modeling and simulation toolkit for Python. Define symbolic equations, generate numerical functions or compiled Python modules, and solve your models through a consistent interface.

Installation

Solverz requires Python 3.10 or later.

pip install Solverz

Model types

Solverz supports three equation types.

  • Algebraic Equations (AEs) $0=F(y,p)$
  • Finite Difference Algebraic Equations (FDAEs) $0=F(y,p,y_0)$
  • Differential Algebraic Equations (DAEs) $M\dot{y}=F(t,y,p)$

where $p$ is the parameter set of your models, $y_0$ is the previous time node value of $y$.

A first simulation

The following example models an object launched vertically from the ground. Its velocity and height satisfy

$$ \begin{aligned} &v'=-9.8\ &h'=v \end{aligned} $$

with $v(0)=20$ and $h(0)=0$, we can just type the codes

import matplotlib.pyplot as plt
import numpy as np
from Solverz import Model, Var, Ode, Opt, made_numerical, Rodas4

# Declare a simulation model
m = Model()
# Declare variables and equations
m.h = Var('h', 0)
m.v = Var('v', 20)
m.f1 = Ode('f1', f=m.v, diff_var=m.h)
m.f2 = Ode('f2', f=-9.8, diff_var=m.v)
# Create the symbolic equation instance and the variable combination 
bball, y0 = m.create_instance()
# Transform symbolic equations to python numerical functions.
nbball = made_numerical(bball, y0, sparse=True)

# Define events, that is,  if the apple hits the ground then the simulation will cease.
def events(t, y):
    value = np.array([y[0]]) 
    isterminal = np.array([1]) 
    direction = np.array([-1]) 
    return value, isterminal, direction

# Solve the DAE
sol = Rodas4()(nbball,
               np.linspace(0, 30, 100),
               y0,
               Opt(event=events))

# Visualize
plt.plot(sol.T, sol.Y['h'][:, 0])
plt.xlabel('Time/s')
plt.ylabel('h/m')
plt.show()

The result is

Height of the object over time

Use the numerical interface

The example uses a Rosenbrock method. Solverz also exposes numerical functions for custom solvers. The following Newton–Raphson implementation solves algebraic equations.

@ae_io_parser
def nr_method(eqn: nAE,
              y: np.ndarray,
              opt: Opt = None):
    if opt is None:
        opt = Opt(ite_tol=1e-8)

    tol = opt.ite_tol
    p = eqn.p
    df = eqn.F(y, p)
    ite = 0
    # main loop
    while max(abs(df)) > tol:
        ite = ite + 1
        y = y - solve(eqn.J(y, p), df)
        df = eqn.F(y, p)
        if ite >= 100:
            print(f"Cannot converge within 100 iterations. Deviation: {max(abs(df))}!")
            break

    return aesol(y, ite)

The implementation of the NR solver just resembles the formulae you read in any numerical analysis book. This is because the numerical AE object eqn provides the $F(t,y,p)$ interface and its Jacobian $J(t,y,p)$, which is derived by symbolic differentiation.

Generate a reusable module

Save a model as an independent Python module when you need to reuse it.

from Solverz import module_printer

pyprinter = module_printer(bball,
                           y0,
                           'bounceball',
                           jit=True)
pyprinter.render()

Import the generated model with

from bounceball import mdl as nbball, y as y0

Resources

Cite Solverz

Chinese

[1] 俞睿智,顾伟,陆帅,张苏涵,徐一骏.面向综合能源系统的开源高性能仿真建模工具开发[J].中国电机工程学报,2026,46(9):3654-3665.DOI:10.13334/j.0258-8013.pcsee.242788.

English

[1] R. Yu, W. Gu, S. Lu, S. Zhang, Y. Xu and R. Wang, "Efficient and Generic Co-simulation Framework for Integrated Energy Systems with Renewable Energy Penetration," 2026 IEEE PES International Meeting (PES IM), Hong Kong, Hong Kong, 2026, pp. 1-5, doi: 10.1109/PESIM67009.2026.11439048.

Metadata

Release files for Solverz 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Solverz 0.12.0
File Size Uploaded Provenance Actions
solverz-0.12.0.tar.gz 7.4 MB With provenance Details for solverz-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for Solverz 0.12.0
File Interpreter ABI Platform Actions
solverz-0.12.0-py3-none-any.whl Python 3 none any Details for solverz-0.12.0-py3-none-any.whl

Total release size: 7.8 MB

Release files / solverz-0.12.0.tar.gz

Download URL solverz-0.12.0.tar.gz
Size 7.4 MB
Tags Source
SHA-256 checksum
How to use checksums
aa534a1c024fd928cb8bf5fd26aa96100d4a33d1515ac61722a865d5120be3cd
BLAKE2b-256 checksum
How to use checksums
492ae0ee5bf34e7f1ad276640637f0033c93e55bdc3a4293e7015c23f7a242db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / solverz-0.12.0-py3-none-any.whl

Download URL solverz-0.12.0-py3-none-any.whl
Size 440.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e88f31f8344bc86ff7259df71fe5e2efcf3961aee465dd8c7663c765fff1d4c
BLAKE2b-256 checksum
How to use checksums
9b856599737d0087bdb3f36657c890f574ab18804605e6b01aa8b1dbe1576b75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for Solverz 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for solverz-0.12.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.12.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page