SplitNewton


NameSplitNewton JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/gpavanb1/SplitNewton
SummarySplit Newton Solver
upload_time2025-01-31 18:16:14
maintainerNone
docs_urlNone
authorgpavanb1
requires_pythonNone
licenseMIT
keywords newton python continuation armijo optimization pseudotransient splitting
VCS
bugtrack_url
requirements numpy scipy pytest
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SplitNewton

[![Downloads](https://pepy.tech/badge/splitnewton)](https://pepy.tech/project/splitnewton)
![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14782293.svg)](https://doi.org/10.5281/zenodo.14782293)

Bounded, SPLIT [Newton](https://en.wikipedia.org/wiki/Newton%27s_method) with [pseudo-transient continuation
](https://ctk.math.ncsu.edu/TALKS/Purdue.pdf) and [backtracking](https://en.wikipedia.org/wiki/Backtracking_line_search)

Good for ill-conditioned problems where there are two different sets of systems

Particular applications include
* [Fast-Slow Reaction-Diffusion systems](https://en.wikipedia.org/wiki/Reaction%E2%80%93diffusion_system)
* [CFD](https://en.wikipedia.org/wiki/Computational_fluid_dynamics) - Pressure-Velocity coupling

## What does 'split' mean?

The system is divided into multiple segments, and for ease of communication, let’s refer to the first segment of variables as "outer" and the remaining as "inner".

* Holding the outer variables fixed, Newton iteration is performed recursively for the inner variables, using the sub-Jacobian associated with them, until convergence is reached.

* One Newton step is then performed for the outer variables, while the inner variables are kept fixed, using the sub-Jacobian for the outer subsystem.

* This process is repeated, alternating between solving the inner and outer subsystems, until the convergence criterion for the entire system (similar to standard Newton) is met.

### Example:

Consider a system of 5 variables, with the split locations at indices [1, 4]. This results in the following segments:

  * `a1` (variables from 0 to 1)
  * `a2 a3 a4` (variables from 1 to 4)
  * `a5` (variable at index 4)

1. First, the innermost segment `a5` is solved recursively using Newton's method while holding the variables `a1` and `a2 a3 a4`) fixed. This step is repeated until the convergence criterion for `a5` is met.

2. Next, one Newton step is taken for the segment `a2 a3 a4`, with `a5` held fixed. This step is followed by solving `a5` again till convergence.

3. This alternating process repeats: solving for `a5` until convergence, then one step for `a2 a3 a4`, and so on, until all subsystems converge.

Finally, one Newton step is performed for `a1`, with the other segments fixed. This completes one cycle of the split Newton process.

## How to install and execute?

Just run 
```
pip install splitnewton
```

There is an [examples](https://github.com/gpavanb1/SplitNewton/examples) folder that contains a test function and driver program

## How good is this?

Consider the test problem

$\lambda_{a} = 10^{6}$, 
$\lambda_{b} = 10^{2}$
with the second system,
$\lambda_{c} = 10^{-1}$
$\lambda_{d} = 10^{-4}$
and third system,
$\lambda_{c} = 10^{-6}$
$\lambda_{d} = 10^{-8}$

and using `logspace` for variation in $\lambda_{i}$


$$ F(u) = \lambda_{a} u^{4}_{1} + ... + \lambda_{b} u^{4}_{\lfloor N/3 \rfloor} + \lambda_{c} u^{4}_{\lceil N/3 \rceil} + ... + \lambda_{d} u^{4}_{\lfloor 2N/3 \rfloor} + \lambda_{e} u^{4}_{\lceil 2N/3 \rceil} + ... + \lambda_{f} u^{4}_{N}$$

$$
J(u) = 3 \times \begin{bmatrix}
\lambda_a & \dots & 0 & 0 & \dots & 0 & 0 & \dots & 0 \\
\vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\
0 & \dots & \lambda_b & 0 & \dots & 0 & 0 & \dots & 0 \\
0 & \dots & 0 & \lambda_c & \dots & 0 & 0 & \dots & 0 \\
\vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\
0 & \dots & 0 & 0 & \dots & \lambda_d & 0 & \dots & 0 \\
0 & \dots & 0 & 0 & \dots & 0 & \lambda_e & \dots & 0 \\
\vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\
0 & \dots & 0 & 0 & \dots & 0 & 0 & \dots & \lambda_f
\end{bmatrix} \cdot u^2
$$

For N=5000 (with no backtracking and pseudo-transient continuation), 

| Method    | Time       | Iterations    |
|-----------|------------|---------------|
| Split Newton    |    34 seconds |  33   |
| Newton |  not converged > 1 min  | NA  |

## How to test?
You can run tests with the `pytest` framework using `python -m pytest`

The coverage reports can be generated with `pytest-cov` plugin using `python -m pytest --cov=splitnewton`

## Whom to contact?

Please direct your queries to [gpavanb1](http://github.com/gpavanb1)
for any questions.

## Citing

If you are using `SplitNewton` in any scientific work, please make sure to cite as follows
```
@software{pavan_b_govindaraju_2025_14782293,
  author       = {Pavan B Govindaraju},
  title        = {gpavanb1/SplitNewton: v0.3.1},
  month        = jan,
  year         = 2025,
  publisher    = {Zenodo},
  version      = {v0.3.1},
  doi          = {10.5281/zenodo.14782293},
  url          = {https://doi.org/10.5281/zenodo.14782293},
}
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gpavanb1/SplitNewton",
    "name": "SplitNewton",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "newton python continuation armijo optimization pseudotransient splitting",
    "author": "gpavanb1",
    "author_email": "gpavanb@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4d/b0/e2679e62e01e8480c4a954c60737edfe232cec5d960c121844d5763726e5/SplitNewton-0.3.1.tar.gz",
    "platform": null,
    "description": "# SplitNewton\n\n[![Downloads](https://pepy.tech/badge/splitnewton)](https://pepy.tech/project/splitnewton)\n![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14782293.svg)](https://doi.org/10.5281/zenodo.14782293)\n\nBounded, SPLIT [Newton](https://en.wikipedia.org/wiki/Newton%27s_method) with [pseudo-transient continuation\n](https://ctk.math.ncsu.edu/TALKS/Purdue.pdf) and [backtracking](https://en.wikipedia.org/wiki/Backtracking_line_search)\n\nGood for ill-conditioned problems where there are two different sets of systems\n\nParticular applications include\n* [Fast-Slow Reaction-Diffusion systems](https://en.wikipedia.org/wiki/Reaction%E2%80%93diffusion_system)\n* [CFD](https://en.wikipedia.org/wiki/Computational_fluid_dynamics) - Pressure-Velocity coupling\n\n## What does 'split' mean?\n\nThe system is divided into multiple segments, and for ease of communication, let\u2019s refer to the first segment of variables as \"outer\" and the remaining as \"inner\".\n\n* Holding the outer variables fixed, Newton iteration is performed recursively for the inner variables, using the sub-Jacobian associated with them, until convergence is reached.\n\n* One Newton step is then performed for the outer variables, while the inner variables are kept fixed, using the sub-Jacobian for the outer subsystem.\n\n* This process is repeated, alternating between solving the inner and outer subsystems, until the convergence criterion for the entire system (similar to standard Newton) is met.\n\n### Example:\n\nConsider a system of 5 variables, with the split locations at indices [1, 4]. This results in the following segments:\n\n  * `a1` (variables from 0 to 1)\n  * `a2 a3 a4` (variables from 1 to 4)\n  * `a5` (variable at index 4)\n\n1. First, the innermost segment `a5` is solved recursively using Newton's method while holding the variables `a1` and `a2 a3 a4`) fixed. This step is repeated until the convergence criterion for `a5` is met.\n\n2. Next, one Newton step is taken for the segment `a2 a3 a4`, with `a5` held fixed. This step is followed by solving `a5` again till convergence.\n\n3. This alternating process repeats: solving for `a5` until convergence, then one step for `a2 a3 a4`, and so on, until all subsystems converge.\n\nFinally, one Newton step is performed for `a1`, with the other segments fixed. This completes one cycle of the split Newton process.\n\n## How to install and execute?\n\nJust run \n```\npip install splitnewton\n```\n\nThere is an [examples](https://github.com/gpavanb1/SplitNewton/examples) folder that contains a test function and driver program\n\n## How good is this?\n\nConsider the test problem\n\n$\\lambda_{a} = 10^{6}$, \n$\\lambda_{b} = 10^{2}$\nwith the second system,\n$\\lambda_{c} = 10^{-1}$\n$\\lambda_{d} = 10^{-4}$\nand third system,\n$\\lambda_{c} = 10^{-6}$\n$\\lambda_{d} = 10^{-8}$\n\nand using `logspace` for variation in $\\lambda_{i}$\n\n\n$$ F(u) = \\lambda_{a} u^{4}_{1} + ... + \\lambda_{b} u^{4}_{\\lfloor N/3 \\rfloor} + \\lambda_{c} u^{4}_{\\lceil N/3 \\rceil} + ... + \\lambda_{d} u^{4}_{\\lfloor 2N/3 \\rfloor} + \\lambda_{e} u^{4}_{\\lceil 2N/3 \\rceil} + ... + \\lambda_{f} u^{4}_{N}$$\n\n$$\nJ(u) = 3 \\times \\begin{bmatrix}\n\\lambda_a & \\dots & 0 & 0 & \\dots & 0 & 0 & \\dots & 0 \\\\\n\\vdots & \\ddots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n0 & \\dots & \\lambda_b & 0 & \\dots & 0 & 0 & \\dots & 0 \\\\\n0 & \\dots & 0 & \\lambda_c & \\dots & 0 & 0 & \\dots & 0 \\\\\n\\vdots & \\ddots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n0 & \\dots & 0 & 0 & \\dots & \\lambda_d & 0 & \\dots & 0 \\\\\n0 & \\dots & 0 & 0 & \\dots & 0 & \\lambda_e & \\dots & 0 \\\\\n\\vdots & \\ddots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n0 & \\dots & 0 & 0 & \\dots & 0 & 0 & \\dots & \\lambda_f\n\\end{bmatrix} \\cdot u^2\n$$\n\nFor N=5000 (with no backtracking and pseudo-transient continuation), \n\n| Method    | Time       | Iterations    |\n|-----------|------------|---------------|\n| Split Newton    |    34 seconds |  33   |\n| Newton |  not converged > 1 min  | NA  |\n\n## How to test?\nYou can run tests with the `pytest` framework using `python -m pytest`\n\nThe coverage reports can be generated with `pytest-cov` plugin using `python -m pytest --cov=splitnewton`\n\n## Whom to contact?\n\nPlease direct your queries to [gpavanb1](http://github.com/gpavanb1)\nfor any questions.\n\n## Citing\n\nIf you are using `SplitNewton` in any scientific work, please make sure to cite as follows\n```\n@software{pavan_b_govindaraju_2025_14782293,\n  author       = {Pavan B Govindaraju},\n  title        = {gpavanb1/SplitNewton: v0.3.1},\n  month        = jan,\n  year         = 2025,\n  publisher    = {Zenodo},\n  version      = {v0.3.1},\n  doi          = {10.5281/zenodo.14782293},\n  url          = {https://doi.org/10.5281/zenodo.14782293},\n}\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Split Newton Solver",
    "version": "0.3.1",
    "project_urls": {
        "Bug Reports": "https://github.com/gpavanb1/SplitNewton/issues",
        "Homepage": "https://github.com/gpavanb1/SplitNewton",
        "Source": "https://github.com/gpavanb1/SplitNewton/"
    },
    "split_keywords": [
        "newton",
        "python",
        "continuation",
        "armijo",
        "optimization",
        "pseudotransient",
        "splitting"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a19d5c092e5e77743ad9a412c4b8a5e808563ea034ae812abcc099fe59dde76c",
                "md5": "97c6015cfd5778c8d7bf3f85c0872683",
                "sha256": "27597f37492b5acaf3b515ed7604c67e47c3c5f887154da3215ca047279a8802"
            },
            "downloads": -1,
            "filename": "SplitNewton-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "97c6015cfd5778c8d7bf3f85c0872683",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7404,
            "upload_time": "2025-01-31T18:16:12",
            "upload_time_iso_8601": "2025-01-31T18:16:12.583218Z",
            "url": "https://files.pythonhosted.org/packages/a1/9d/5c092e5e77743ad9a412c4b8a5e808563ea034ae812abcc099fe59dde76c/SplitNewton-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4db0e2679e62e01e8480c4a954c60737edfe232cec5d960c121844d5763726e5",
                "md5": "5a506cf96b5b1f7e24f3818c815fe080",
                "sha256": "9a397bc659ac681fb7b04002620579df46ad108f04a0ff1e5bbecf57851c0295"
            },
            "downloads": -1,
            "filename": "SplitNewton-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5a506cf96b5b1f7e24f3818c815fe080",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6363,
            "upload_time": "2025-01-31T18:16:14",
            "upload_time_iso_8601": "2025-01-31T18:16:14.769986Z",
            "url": "https://files.pythonhosted.org/packages/4d/b0/e2679e62e01e8480c4a954c60737edfe232cec5d960c121844d5763726e5/SplitNewton-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-31 18:16:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gpavanb1",
    "github_project": "SplitNewton",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.23.5"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    "==",
                    "1.9.3"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": []
        }
    ],
    "lcname": "splitnewton"
}
        
Elapsed time: 8.86036s