SplitFXM


NameSplitFXM JSON
Version 0.3.4 PyPI version JSON
download
home_pagehttps://github.com/gpavanb1/SplitFXM
Summary1D Finite-Difference/Volume Split Newton Solver
upload_time2024-09-17 19:34:19
maintainerNone
docs_urlNone
authorgpavanb1
requires_pythonNone
licenseCC BY-NC 4.0 for non-commercial use, commercial license available
keywords amr newton python finite-difference armijo optimization pseudotransient splitting
VCS
bugtrack_url
requirements black matplotlib numdifftools numpy SplitNewton
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SplitFXM

[![Downloads](https://pepy.tech/badge/splitfxm)](https://pepy.tech/project/splitfxm)
![Coverage](https://img.shields.io/badge/coverage-99%25-brightgreen.svg)


![img](https://github.com/gpavanb1/SplitFXM/blob/main/assets/logo.jpg)

1D [Finite-Difference](https://en.wikipedia.org/wiki/Finite_difference_method) or [Finite-Volume](https://en.wikipedia.org/wiki/Finite_volume_method) using asymmetric stencils with [adaptive mesh refinement](https://en.wikipedia.org/wiki/Adaptive_mesh_refinement) and steady-state solver using Newton and [Split-Newton](https://github.com/gpavanb1/SplitNewton) approach

## What does 'split' mean?

The system is divided into two and for ease of communication, let's refer to first set of variables as "outer" and the second as "inner".

* Holding the outer variables fixed, Newton iteration is performed till convergence using the sub-Jacobian

* One Newton step is performed for the outer variables with inner held fixed (using its sub-Jacobian)

* This process is repeated till convergence criterion is met for the full system (same as in Newton)

## How to install and execute?

Just run 
```
pip install splitfxm
```

There is an [examples](https://github.com/gpavanb1/SplitFXM/models) folder that contains a test model - [Advection-Diffusion](https://en.wikipedia.org/wiki/Convection%E2%80%93diffusion_equation)

You can define your own equations by simply creating a derived class from `Model` and adding to the `_equations` using existing or custom equations!

A basic driver program is as follows
```
from splitfxm.domain import Domain
from splitfxm.simulation import Simulation
from splitfxm.schemes import default_scheme
from splitfxm.visualize import draw

# Define the problem
method = 'FDM'
m = AdvectionDiffusion(c=0.2, nu=0.001, method=method)
d = Domain.from_size(20, 1, 1, ["u", "v", "w"]) # nx, nb_left, nb_right, variables
ics = {"u": "gaussian", "v": "rarefaction"}
bcs = {
    "u": {
        "left": "periodic",
        "right": "periodic"
    },
    "v": {
        "left": {"dirichlet": 3},
        "right": {"dirichlet": 4}
    },
    "w": {
        "left": {"dirichlet": 2},
        "right": "periodic"
    }
}
s = Simulation(d, m, ics, bcs, default_scheme(method))


# Advance in time or to steady state
s.evolve(t_diff=0.1)
bounds = [[-1., -2., 0.], [5., 4., 3.]]
iter = s.steady_state(split=True, split_loc=1, bounds=bounds)

# Visualize
draw(d, "label")
```

## Run benchmark
There is a benchmark that is included, which compares the time it takes to generate both a sparse and dense Jacobian. The results are as follows:

For N=250, 

| Method    | Time       | 
|-----------|------------|
| Dense   |    20 seconds |
| Sparse |  ~0.6 seconds  |

The benchmark can be executed from the parent folder using the command

`python -m pytest -s benchmark`

## How to run tests?

To run the tests, execute the following command from the parent folder:
```
python -m pytest tests
```

You can use the `-s` flag to show `print` outputs of the tests

## How to get coverage?

To get coverage, execute the following command from the parent folder:
```
python -m pytest --cov=splitfxm --cov-report <option> tests
```

The `option` can be related to showing covered/missed lines or specifying the output format of the report. For example, to get a line-by-line report, use the following command:
```
python -m pytest --cov=splitfxm --cov-report term-missing tests
```

## Whom to contact?

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

## Acknowledgements

Special thanks to [Cantera](https://github.com/Cantera/cantera) and [WENO-Scalar](https://github.com/comp-physics/WENO-scalar) for serving as an inspiration for code architecture.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gpavanb1/SplitFXM",
    "name": "SplitFXM",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "amr newton python finite-difference armijo optimization pseudotransient splitting",
    "author": "gpavanb1",
    "author_email": "gpavanb@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b5/d6/f2a9dd1a1c72f96a08c2271893caf339c2937929f2b3d9ae321925eb7af1/SplitFXM-0.3.4.tar.gz",
    "platform": null,
    "description": "# SplitFXM\n\n[![Downloads](https://pepy.tech/badge/splitfxm)](https://pepy.tech/project/splitfxm)\n![Coverage](https://img.shields.io/badge/coverage-99%25-brightgreen.svg)\n\n\n![img](https://github.com/gpavanb1/SplitFXM/blob/main/assets/logo.jpg)\n\n1D [Finite-Difference](https://en.wikipedia.org/wiki/Finite_difference_method) or [Finite-Volume](https://en.wikipedia.org/wiki/Finite_volume_method) using asymmetric stencils with [adaptive mesh refinement](https://en.wikipedia.org/wiki/Adaptive_mesh_refinement) and steady-state solver using Newton and [Split-Newton](https://github.com/gpavanb1/SplitNewton) approach\n\n## What does 'split' mean?\n\nThe system is divided into two and for ease of communication, let's refer to first set of variables as \"outer\" and the second as \"inner\".\n\n* Holding the outer variables fixed, Newton iteration is performed till convergence using the sub-Jacobian\n\n* One Newton step is performed for the outer variables with inner held fixed (using its sub-Jacobian)\n\n* This process is repeated till convergence criterion is met for the full system (same as in Newton)\n\n## How to install and execute?\n\nJust run \n```\npip install splitfxm\n```\n\nThere is an [examples](https://github.com/gpavanb1/SplitFXM/models) folder that contains a test model - [Advection-Diffusion](https://en.wikipedia.org/wiki/Convection%E2%80%93diffusion_equation)\n\nYou can define your own equations by simply creating a derived class from `Model` and adding to the `_equations` using existing or custom equations!\n\nA basic driver program is as follows\n```\nfrom splitfxm.domain import Domain\nfrom splitfxm.simulation import Simulation\nfrom splitfxm.schemes import default_scheme\nfrom splitfxm.visualize import draw\n\n# Define the problem\nmethod = 'FDM'\nm = AdvectionDiffusion(c=0.2, nu=0.001, method=method)\nd = Domain.from_size(20, 1, 1, [\"u\", \"v\", \"w\"]) # nx, nb_left, nb_right, variables\nics = {\"u\": \"gaussian\", \"v\": \"rarefaction\"}\nbcs = {\n    \"u\": {\n        \"left\": \"periodic\",\n        \"right\": \"periodic\"\n    },\n    \"v\": {\n        \"left\": {\"dirichlet\": 3},\n        \"right\": {\"dirichlet\": 4}\n    },\n    \"w\": {\n        \"left\": {\"dirichlet\": 2},\n        \"right\": \"periodic\"\n    }\n}\ns = Simulation(d, m, ics, bcs, default_scheme(method))\n\n\n# Advance in time or to steady state\ns.evolve(t_diff=0.1)\nbounds = [[-1., -2., 0.], [5., 4., 3.]]\niter = s.steady_state(split=True, split_loc=1, bounds=bounds)\n\n# Visualize\ndraw(d, \"label\")\n```\n\n## Run benchmark\nThere is a benchmark that is included, which compares the time it takes to generate both a sparse and dense Jacobian. The results are as follows:\n\nFor N=250, \n\n| Method    | Time       | \n|-----------|------------|\n| Dense   |    20 seconds |\n| Sparse |  ~0.6 seconds  |\n\nThe benchmark can be executed from the parent folder using the command\n\n`python -m pytest -s benchmark`\n\n## How to run tests?\n\nTo run the tests, execute the following command from the parent folder:\n```\npython -m pytest tests\n```\n\nYou can use the `-s` flag to show `print` outputs of the tests\n\n## How to get coverage?\n\nTo get coverage, execute the following command from the parent folder:\n```\npython -m pytest --cov=splitfxm --cov-report <option> tests\n```\n\nThe `option` can be related to showing covered/missed lines or specifying the output format of the report. For example, to get a line-by-line report, use the following command:\n```\npython -m pytest --cov=splitfxm --cov-report term-missing tests\n```\n\n## Whom to contact?\n\nPlease direct your queries to [gpavanb1](http://github.com/gpavanb1)\nfor any questions.\n\n## Acknowledgements\n\nSpecial thanks to [Cantera](https://github.com/Cantera/cantera) and [WENO-Scalar](https://github.com/comp-physics/WENO-scalar) for serving as an inspiration for code architecture.",
    "bugtrack_url": null,
    "license": "CC BY-NC 4.0 for non-commercial use, commercial license available",
    "summary": "1D Finite-Difference/Volume Split Newton Solver",
    "version": "0.3.4",
    "project_urls": {
        "Bug Reports": "https://github.com/gpavanb1/SplitFXM/issues",
        "Homepage": "https://github.com/gpavanb1/SplitFXM",
        "Source": "https://github.com/gpavanb1/SplitFXM/"
    },
    "split_keywords": [
        "amr",
        "newton",
        "python",
        "finite-difference",
        "armijo",
        "optimization",
        "pseudotransient",
        "splitting"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b5d6f2a9dd1a1c72f96a08c2271893caf339c2937929f2b3d9ae321925eb7af1",
                "md5": "29d5e77091de8aff1cf00e4c3a818634",
                "sha256": "1b0469429abad41ed3790bcd12db7a709b5181903de22a9aacfbda7a4660b230"
            },
            "downloads": -1,
            "filename": "SplitFXM-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "29d5e77091de8aff1cf00e4c3a818634",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20619,
            "upload_time": "2024-09-17T19:34:19",
            "upload_time_iso_8601": "2024-09-17T19:34:19.285463Z",
            "url": "https://files.pythonhosted.org/packages/b5/d6/f2a9dd1a1c72f96a08c2271893caf339c2937929f2b3d9ae321925eb7af1/SplitFXM-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-17 19:34:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gpavanb1",
    "github_project": "SplitFXM",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "black",
            "specs": []
        },
        {
            "name": "matplotlib",
            "specs": []
        },
        {
            "name": "numdifftools",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "SplitNewton",
            "specs": []
        }
    ],
    "lcname": "splitfxm"
}
        
Elapsed time: 4.72773s