wnstatmech is a python package for handling the statistical mechanics of fermions and bosons.
Installation
Install from PyPI with pip by typing in your favorite terminal:
$ pip install wnstatmech
Performance controls
Fermion and Boson objects accept optional integration_epsabs and integration_epsrel arguments to control numerical integration accuracy. Their scalar exact-result caches retain 1,024 entries by default; pass cache_size=0 to disable them or call clear_cache() to clear a particle’s cached values and chemical-potential warm start.
For an application-specific direct inversion, install a chemical-potential function that accepts scalar temperature and number-density values and returns alpha or None to use the numerical fallback:
electron.update_chemical_potential_function(my_direct_alpha)
For better throughput over many thermodynamic states, pass vectorized temperature and alpha arrays to compute_quantity rather than calling it repeatedly in a Python loop:
import wnstatmech as ws
import numpy as np
electron = ws.fermion.create_electron(integration_epsrel=1.0e-6)
temperatures = np.geomspace(1.0e7, 1.0e10, 24)
alphas = np.linspace(-8.0, 8.0, 24)
pressures = electron.compute_quantity("pressure", temperatures, alphas)
Scalar call signatures remain backwards compatible with 1.0.x usage.
Performance benchmarks
Optional benchmarks measure representative scalar, batched, and fixed-density derivative workloads. They are separate from the correctness tests and are not run by the normal build. Install the benchmark extra and run them with:
$ pip install -e '.[benchmark]' $ pytest benchmarks --benchmark-only
Benchmark results are most useful when compared before and after a change on the same machine. The benchmark cases intentionally create a fresh particle for scalar calls so that they measure a cold numerical solve rather than a cache hit.
Contribute
Issue Tracker: https://github.com/mbradle/wnstatmech/issues/
Source Code: https://github.com/mbradle/wnstatmech/
License
The project is licensed under the GNU Public License v3 (or later).
Documentation
The project documentation is available at https://wnstatmech.readthedocs.io.
Usage
The best way to get started using wnstatmech is to follow the tutorial.
Release files for wnstatmech 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wnstatmech-1.2.0.tar.gz | 28.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wnstatmech-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.6 kB
Release files / wnstatmech-1.2.0.tar.gz
| Download URL | wnstatmech-1.2.0.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fba9d277556a00759e2ed7aae6b16918c17cc71746b272cc6533586a9b4431e
|
|
BLAKE2b-256 checksum How to use checksums |
c9784f444c2d07a9e1c90488434cdc1e211146ddf569ac3593240b614014732b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Release files / wnstatmech-1.2.0-py3-none-any.whl
| Download URL | wnstatmech-1.2.0-py3-none-any.whl |
|---|---|
| Size | 26.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0787535bec0f64d8387e53af773b6db34d510755a19aed30e81213d445aa7776
|
|
BLAKE2b-256 checksum How to use checksums |
ae6eb4792efdc9023313603a76750457cda782013c4bfee0b42eecb598983851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|