Metadata-Version: 2.4
Name: openseespy-solvers
Version: 0.1.0
Summary: Ready-to-use, SciPy-style PythonSparse solvers for OpenSeesPy
Project-URL: Homepage, https://github.com/gaaraujo/openseespy-solvers
Project-URL: Documentation, https://openseespy-solvers.readthedocs.io/
Project-URL: Issues, https://github.com/gaaraujo/openseespy-solvers/issues
Author: openseespy-solvers contributors
License: BSD 3-Clause License
        
        Copyright (c) 2026, openseespy-solvers contributors
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Keywords: eigen,finite-element,opensees,openseespy,scipy,solver,sparse
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.12
Requires-Dist: numpy>=1.26
Requires-Dist: scipy>=1.12
Provides-Extra: cupy
Requires-Dist: cupy>=13.0; extra == 'cupy'
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.24; extra == 'docs'
Provides-Extra: opensees
Requires-Dist: openseespy; extra == 'opensees'
Provides-Extra: umfpack
Requires-Dist: scikit-umfpack>=0.3.3; extra == 'umfpack'
Description-Content-Type: text/markdown

# openseespy-solvers

Sparse linear algebra solvers for OpenSeesPy
[`PythonSparse`](https://opensees.github.io/OpenSeesDocumentation/user/manual/analysis/system/PythonSparse.html)
commands.

**Documentation:** [openseespy-solvers.readthedocs.io](https://openseespy-solvers.readthedocs.io/)

## Installation

Requires **Python ≥ 3.12**, **NumPy ≥ 1.26**, **SciPy ≥ 1.12**, and **serial OpenSeesPy**
(parallel/MPI OpenSeesPy builds are not supported — see
[docs](https://openseespy-solvers.readthedocs.io/en/latest/user-guide/pythonsparse-interface/#parallelism)).

### Full setup from scratch

Copy-paste overview — see the [installation guide](https://openseespy-solvers.readthedocs.io/en/latest/installation/#full-setup) for platform notes (UMFPACK, GPU wheels) and the complete verification checklist.

```bash
# 1. Environment (conda or venv — all platforms)
conda create -n openseespy-solvers python=3.12 -y
conda activate openseespy-solvers

# 2. Clone (examples and pytest are in the repo, not the pip wheel)
git clone https://github.com/gaaraujo/openseespy-solvers.git
cd openseespy-solvers

# 3. Install
pip install -e ".[dev,opensees]"

# 4–5. Optional backends — UMFPACK, CuPy, nvMath (see installation guide)
# 6. pip check
# 7. Verify
pytest
cd examples && python solvers/scipy_spsolve.py && python solvers/scipy_eigsh.py
python brick_bar.py && python brick_bar_eigen.py
```

GPU tests in `pytest` run when CuPy/nvMath are installed; skipped otherwise.

### Quick install (library only)

```bash
pip install openseespy-solvers
pip install openseespy-solvers[opensees]   # if OpenSeesPy is missing
```

## Recommended solvers

| Analysis | GPU (CUDA) | CPU |
|----------|------------|-----|
| Linear (`PythonSparse`, static/transient/…) | `nvmath.direct_solver` | `scipy.spsolve` or `scipy.umfpack` |
| Eigen | `cupy.eigsh` | `scipy.eigsh` |

These `PythonSparse` backends are **often faster** than native OpenSees sparse/direct/eigen
solvers on medium-to-large models because they use optimized library implementations.
Details: [recommended solvers](https://openseespy-solvers.readthedocs.io/en/latest/recommended-solvers/).

## Example

```python
from openseespy_solvers import hybrid
from openseespy_solvers.scipy import spsolve

solver = hybrid(spsolve(), rtol=1e-6, restart=50)
ops.system("PythonSparse", solver.to_openseespy())
ops.analyze(n)
```

For Newton or transient steps where the tangent changes slowly, ``hybrid`` factorizes once
then reuses that factorization as a GMRES preconditioner until the system size changes or
GMRES fails to converge.

## Submodules

| Module | Functions |
|--------|-----------|
| `openseespy_solvers.scipy` | `spsolve`, `umfpack`, `cg`, `gmres`, `eigsh`, `lobpcg` |
| `openseespy_solvers.scipy.precond` | `jacobi`, `ilu`, `direct` |
| `openseespy_solvers.cupy` | `spsolve`, `cg`, `gmres`, `eigsh`, `lobpcg` (GPU) |
| `openseespy_solvers.cupy.precond` | `jacobi`, `ilu`, `direct` |
| `openseespy_solvers.nvmath` | `direct_solver` (GPU) |
| `openseespy_solvers.hybrid` | `hybrid(direct=...)` — frozen factorization + GMRES |

Factory signatures match [`scipy.sparse.linalg`](https://docs.scipy.org/doc/scipy/reference/sparse.linalg.html)
and [`cupyx.scipy.sparse.linalg`](https://docs.cupy.dev/en/stable/reference/scipy_sparse.html);
`A` and `b` are supplied by OpenSees at solve time.

See the [tutorial](https://openseespy-solvers.readthedocs.io/en/latest/getting-started/) and
[API reference](https://openseespy-solvers.readthedocs.io/en/latest/api/scipy/) for details.

## GitHub

Repository: [github.com/gaaraujo/openseespy-solvers](https://github.com/gaaraujo/openseespy-solvers).
Report bugs and ask questions via
[issues](https://github.com/gaaraujo/openseespy-solvers/issues); send contributions
(pull requests) there as well.

## License

BSD 3-Clause — see [LICENSE](LICENSE).
