# SplitFDM
[![Downloads](https://pepy.tech/badge/splitfdm)](https://pepy.tech/project/splitfdm)
![img](https://github.com/gpavanb1/SplitFDM/blob/main/assets/logo.jpg)
1D [Finite-Difference](https://en.wikipedia.org/wiki/Finite_difference_method) 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 splitfdm
```
There is an [examples](https://github.com/gpavanb1/SplitFDM/examples) 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
```
# Define the problem
m = AdvectionDiffusion(c=0.2, nu=0.001)
# Define the domain and variables
# ng stands for ghost point count
d = Domain.from_size(20, 2, ["u", "v", "w"]) # nx, ng, variables
# Set IC and BC
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)
# Advance in time or to steady state
s.evolve(dt=0.1)
bounds = [[-1., -2., 0.], [5., 4., 3.]]
iter = s.steady_state(split=True, split_loc=1, bounds=bounds)
# Visualize
draw(d, "label")
```
## Whom to contact?
Please direct your queries to [gpavanb1](http://github.com/gpavanb1)
for any questions.
## Acknowledgements
Do visit its [Finite-Volume](https://github.com/gpavanb1/SplitFVM) cousin
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/SplitFDM",
"name": "SplitFDM",
"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/15/7e/cdbc84a2f0414c7a8b6c3701755f4171c566fe346fa19a140baa1591fb17/SplitFDM-0.2.tar.gz",
"platform": null,
"description": "# SplitFDM\n\n[![Downloads](https://pepy.tech/badge/splitfdm)](https://pepy.tech/project/splitfdm)\n\n![img](https://github.com/gpavanb1/SplitFDM/blob/main/assets/logo.jpg)\n\n1D [Finite-Difference](https://en.wikipedia.org/wiki/Finite_difference_method) 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 splitfdm\n```\n\nThere is an [examples](https://github.com/gpavanb1/SplitFDM/examples) 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```\n# Define the problem\nm = AdvectionDiffusion(c=0.2, nu=0.001)\n\n# Define the domain and variables\n# ng stands for ghost point count\nd = Domain.from_size(20, 2, [\"u\", \"v\", \"w\"]) # nx, ng, variables\n\n# Set IC and BC\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)\n\n# Advance in time or to steady state\ns.evolve(dt=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## Whom to contact?\n\nPlease direct your queries to [gpavanb1](http://github.com/gpavanb1)\nfor any questions.\n\n## Acknowledgements\n\nDo visit its [Finite-Volume](https://github.com/gpavanb1/SplitFVM) cousin\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": "MIT",
"summary": "1D Finite-Difference Split Newton Solver",
"version": "0.2",
"project_urls": {
"Bug Reports": "https://github.com/gpavanb1/SplitFDM/issues",
"Homepage": "https://github.com/gpavanb1/SplitFDM",
"Source": "https://github.com/gpavanb1/SplitFDM/"
},
"split_keywords": [
"amr",
"newton",
"python",
"finite-difference",
"armijo",
"optimization",
"pseudotransient",
"splitting"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "157ecdbc84a2f0414c7a8b6c3701755f4171c566fe346fa19a140baa1591fb17",
"md5": "cf33540ca98909d7c5e63186cd83bc02",
"sha256": "974c1207520106945df3874467bc8a9b701ebbecf6c7785994a59d7629dd6bc2"
},
"downloads": -1,
"filename": "SplitFDM-0.2.tar.gz",
"has_sig": false,
"md5_digest": "cf33540ca98909d7c5e63186cd83bc02",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14014,
"upload_time": "2024-08-07T16:33:49",
"upload_time_iso_8601": "2024-08-07T16:33:49.189617Z",
"url": "https://files.pythonhosted.org/packages/15/7e/cdbc84a2f0414c7a8b6c3701755f4171c566fe346fa19a140baa1591fb17/SplitFDM-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-07 16:33:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gpavanb1",
"github_project": "SplitFDM",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "splitfdm"
}