Skip to main content

tba-solve

Tests PyPI version Python License: MIT

Numerical solver for Thermodynamic Bethe Ansatz integral equations.

Installation

pip install tba-solve

Requires NumPy and SciPy.

The equation

The Thermodynamic Bethe Ansatz (TBA) is a class of nonlinear integral equations studied in mathematical physics — in particular in statistical field theory, quantum integrability, and gauge theories. The general form is:

$$y_j(x) = f_j(x) + \sum_k \int_{-\infty}^{\infty} \varphi_{j,k}(x - t),\log!\bigl[1 + c_{j,k},e^{,\sigma_{j,k},y_k(t)}\bigr],dt$$

where $y_j(x)$ are the unknowns, $f_j(x)$ the forcing terms, $\varphi_{j,k}(x)$ the convolution kernels, $c_{j,k}$ some constants, and $\sigma_{j,k} = \pm 1$.

Due to its nonlinear structure, the TBA cannot be solved symbolically and requires a dedicated numerical treatment.

Usage

Pre-built models

from tba_solve import sinh_gordon
import numpy as np

sols = sinh_gordon(r=0.1)
y = sols[0]

x = np.linspace(-5, 5, 200)
print(y(x))

Each model function returns a list of callable solution objects (one per dependent variable), which can be evaluated at arbitrary points within the grid domain.

Available models: sinh_gordon, liouville, seiberg_witten_su2.

Custom equations

Any TBA equation can be solved by providing its decomposed components directly:

from tba_solve import TBASolver
import numpy as np

solver = TBASolver(
    forcing=[lambda x: 0.1 * np.cosh(x)],
    kernels=[[lambda x: -1 / (2 * np.pi * np.cosh(x))]],
    crossing=[[0]],
)
sols = solver.solve()

Coupled systems

Systems of coupled TBA equations are specified in the same way. The crossing parameter indicates which dependent variable each kernel term acts on:

from tba_solve import TBASolver
import numpy as np

solver = TBASolver(
    forcing=[
        lambda x: 3.0 * np.exp(x),
        lambda x: 3.0 * np.exp(x),
    ],
    kernels=[
        [lambda x: -1 / (np.pi * np.cosh(x))],
        [lambda x: -1 / (np.pi * np.cosh(x))],
    ],
    crossing=[[1], [0]],   # equation 0 couples to y_1, equation 1 to y_0
)
y1, y2 = solver.solve()

Parameters

Parameter Default Description
forcing — Forcing terms $f_j(x)$, one callable per equation
kernels — Convolution kernels $\varphi_{j,k}(x)$, nested list of callables
crossing — Index of the dependent variable in each kernel term
constants all 1 Coefficients $c_{j,k}$ inside the log terms
signs all −1 Signs $\sigma_{j,k}$ inside the exponentials

Options

Option Default Description
grid_cutoff 100.2 Half-width of the symmetric grid $[-L, L]$
grid_resolution 1024 Number of grid points (ideally a power of 2)
stopping_accuracy 10⁻¹⁰ Convergence threshold on relative iteration error
max_iterations 4000 Hard upper bound on iterations
damping 0.1 Relaxation parameter for iteration stability
boundary_ext 0 External boundary terms, added to forcing
boundary_int 0 Internal boundary terms, added inside each convolution
monitor False Print iteration progress
labels None Names for the solution components

Higher grid_resolution and grid_cutoff improve accuracy at the cost of speed. Lower stopping_accuracy requires more iterations; increase max_iterations accordingly.

Method

The solver implements the method of successive approximations:

  1. The solution is initialised to the forcing terms.
  2. At each iteration, the log-terms are evaluated and convolved with the kernels using FFT, then mixed with the previous solution via a damping factor.
  3. Convergence is checked every 100 iterations against the relative difference between successive iterates.
  4. The converged solution is returned as a cubic spline interpolation over the grid.

The convolutions are computed in Fourier space for efficiency: $O(N \log N)$ per convolution per iteration, where $N$ is the grid resolution.

Origin

This package is a Python translation of the ThermodynamicBetheAnsatzSolve Wolfram Language resource function. The Wolfram version additionally includes an automatic symbolic equation parser; the Python version requires the user to provide the equation components explicitly.

References

License

MIT

Metadata

Release files for tba-solve 0.2.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 tba-solve 0.2.0
File Size Uploaded
tba_solve-0.2.0.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tba-solve 0.2.0
File Interpreter ABI Platform
tba_solve-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.9 kB

Release files / tba_solve-0.2.0.tar.gz

Download URL tba_solve-0.2.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a83d9cb89e329561f2bdef8dd8956b36b66f1e7b9ec182bdd0beb4a7c89862f4
BLAKE2b-256 checksum
How to use checksums
8a4d61cae6f5cfa9ac8ad43485c0409ca9a1ece67abd2344bb8168c701b670b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / tba_solve-0.2.0-py3-none-any.whl

Download URL tba_solve-0.2.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
607830b88b29dcbbd6e46753184e54b5ff1ad491d50c93efd4de195543d1931e
BLAKE2b-256 checksum
How to use checksums
4bb808954ff385d5d71b29a185fafbb9b2e7ef3e00a0ff169641686b1c61ab3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

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