Skip to main content

Numerical solver for Thermodynamic Bethe Ansatz integral equations

Project description

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

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

tba_solve-0.2.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

tba_solve-0.2.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file tba_solve-0.2.0.tar.gz.

File metadata

  • Download URL: tba_solve-0.2.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tba_solve-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a83d9cb89e329561f2bdef8dd8956b36b66f1e7b9ec182bdd0beb4a7c89862f4
MD5 871ee0a5096a2f190c17e67aa3831750
BLAKE2b-256 8a4d61cae6f5cfa9ac8ad43485c0409ca9a1ece67abd2344bb8168c701b670b4

See more details on using hashes here.

File details

Details for the file tba_solve-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tba_solve-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tba_solve-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 607830b88b29dcbbd6e46753184e54b5ff1ad491d50c93efd4de195543d1931e
MD5 420241b002f2f0195274d4e68754ce26
BLAKE2b-256 4bb808954ff385d5d71b29a185fafbb9b2e7ef3e00a0ff169641686b1c61ab3c

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