{ "info": { "author": "Nico Schl\u00f6mer", "author_email": "nico.schloemer@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "# pyfvm\n\n[![CircleCI](https://img.shields.io/circleci/project/github/nschloe/pyfvm.svg)](https://circleci.com/gh/nschloe/pyfvm)\n[![codecov](https://img.shields.io/codecov/c/github/nschloe/pyfvm.svg)](https://codecov.io/gh/nschloe/pyfvm)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n[![PyPi Version](https://img.shields.io/pypi/v/pyfvm.svg)](https://pypi.org/project/pyfvm)\n[![GitHub stars](https://img.shields.io/github/stars/nschloe/pyfvm.svg?logo=github&label=Stars)](https://github.com/nschloe/pyfvm)\n\nCreating finite volume equation systems with ease.\n\npyfvm provides everything that is needed for setting up finite volume equation\nsystems. The user needs to specify the finite volume formulation in a\nconfiguration file, and pyfvm will create the matrix/right-hand side or the\nnonlinear system for it. This package is for everyone who wants to quickly\nconstruct FVM systems.\n\n### Examples\n\n#### Linear equation systems\n\npyfvm works by specifying the residuals, so for solving Poisson's equation with\nDirichlet boundary conditions, simply do\n```python,test\nimport pyfvm\nfrom pyfvm.form_language import *\nimport meshzoo\nfrom scipy.sparse import linalg\nimport meshplex\n\nclass Poisson(object):\n def apply(self, u):\n return integrate(lambda x: -n_dot_grad(u(x)), dS) \\\n - integrate(lambda x: 1.0, dV)\n\n def dirichlet(self, u):\n return [(lambda x: u(x) - 0.0, Boundary())]\n\n# Create mesh using meshzoo\nvertices, cells = meshzoo.rectangle(0.0, 2.0, 0.0, 1.0, 401, 201)\nmesh = meshplex.MeshTri(vertices, cells)\n\nmatrix, rhs = pyfvm.discretize_linear(Poisson(), mesh)\n\nu = linalg.spsolve(matrix, rhs)\n\nmesh.write('out.vtk', point_data={'u': u})\n```\nThis example uses [meshzoo](https://pypi.org/project/meshzoo) for creating\na simple mesh, but anything else that provides vertices and cells works as\nwell. For example, reading from a wide variety of mesh files is supported\n(via [meshio](https://pypi.org/project/meshio)):\n```python\nmesh, _, _ = pyfvm.reader.read('pacman.e')\n```\nLikewise, [PyAMG](https://github.com/pyamg/pyamg) is a much faster solver\nfor this problem\n```\nimport pyamg\nml = pyamg.smoothed_aggregation_solver(linear_system.matrix)\nu = ml.solve(linear_system.rhs, tol=1e-10)\n```\n\nMore examples are contained in the [examples directory](examples/).\n\n#### Nonlinear equation systems\nNonlinear systems are treated almost equally; only the discretization and\nobviously the solver call is different. For Bratu's problem:\n```python,test\nimport pyfvm\nfrom pyfvm.form_language import *\nimport meshzoo\nimport numpy\nfrom sympy import exp\nimport meshplex\n\nclass Bratu(object):\n def apply(self, u):\n return integrate(lambda x: -n_dot_grad(u(x)), dS) \\\n - integrate(lambda x: 2.0 * exp(u(x)), dV)\n\n def dirichlet(self, u):\n return [(u, Boundary())]\n\nvertices, cells = meshzoo.rectangle(0.0, 2.0, 0.0, 1.0, 101, 51)\nmesh = meshplex.MeshTri(vertices, cells)\n\nf, jacobian = pyfvm.discretize(Bratu(), mesh)\n\ndef jacobian_solver(u0, rhs):\n from scipy.sparse import linalg\n jac = jacobian.get_linear_operator(u0)\n return linalg.spsolve(jac, rhs)\n\nu0 = numpy.zeros(len(vertices))\nu = pyfvm.newton(f.eval, jacobian_solver, u0)\n\nmesh.write('out.vtk', point_data={'u': u})\n```\nNote that the Jacobian is computed symbolically from the `Bratu` class.\n\nInstead of `pyfvm.newton`, you can use any solver that accepts the residual\ncomputation `f.eval`, e.g.,\n```\nimport scipy.optimize\nu = scipy.optimize.newton_krylov(f.eval, u0)\n```\n\n### Installation\n\npyfvm is [available from the Python Package\nIndex](https://pypi.org/project/pyfvm/), so simply type\n```\npip install -U pyfvm\n```\nto install or upgrade.\n\n### Testing\n\nTo run the tests, check out this repository and type\n```\npytest\n```\n\n### Distribution\n\nTo create a new release\n\n1. bump the `__version__` number,\n\n2. publish to PyPi and GitHub:\n ```\n make publish\n ```\n\n### License\n\npyfvm is published under the [MIT license](https://en.wikipedia.org/wiki/MIT_License).\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nschloe/pyfvm", "keywords": "", "license": "License :: OSI Approved :: MIT License", "maintainer": "", "maintainer_email": "", "name": "pyfvm", "package_url": "https://pypi.org/project/pyfvm/", "platform": "any", "project_url": "https://pypi.org/project/pyfvm/", "project_urls": { "Homepage": "https://github.com/nschloe/pyfvm" }, "release_url": "https://pypi.org/project/pyfvm/0.2.5/", "requires_dist": [ "meshplex", "numpy", "pipdate (<0.4.0,>=0.3.0)", "scipy", "sphinxcontrib-bibtex", "sympy" ], "requires_python": "", "summary": "Finite Volume Discretizations for Python", "version": "0.2.5" }, "last_serial": 4228800, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "27b9e9ce4e058ce146671e106f9e749b", "sha256": "5b63aea33ca6b81b0c03e9034b25701d9dfaa6def5aa58a5a12eddce3b35d18b" }, "downloads": -1, "filename": "pyfvm-0.1.0.tar.gz", "has_sig": true, "md5_digest": "27b9e9ce4e058ce146671e106f9e749b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23275, "upload_time": "2016-06-20T13:53:13", "url": "https://files.pythonhosted.org/packages/93/94/455f7d914eb0e7a48dc7101dc908a5090cd6dbd78c25b0943bf710d58bff/pyfvm-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "0a211b18882582a23a5132fc1cb78979", "sha256": "8c9e4115986359754b0a1b2b23f84328fc882c7ec89e540ca39aa084d1fd7a9b" }, "downloads": -1, "filename": "PyFVM-0.2.0.tar.gz", "has_sig": true, "md5_digest": "0a211b18882582a23a5132fc1cb78979", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13945, "upload_time": "2017-05-26T11:13:42", "url": "https://files.pythonhosted.org/packages/ca/5c/8d2ec311b199202641931e045fc3cc02578e8cf0974dec1f7ea2d360bc58/PyFVM-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "faa874b3ab6060cc38bc35708a968dbe", "sha256": "8001cba3467058ddc1f81e114dcc90e0a8081a1bf64f87e0381f0e5cfb7fe35b" }, "downloads": -1, "filename": "PyFVM-0.2.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "faa874b3ab6060cc38bc35708a968dbe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17983, "upload_time": "2017-05-26T13:01:51", "url": "https://files.pythonhosted.org/packages/90/73/f7db62ed4ecb311d2bcdb26cec4c4c20ed113799e51f3daf47b5569a42f5/PyFVM-0.2.1-py2.py3-none-any.whl" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "a0e0666b0ecd733e44e12eae9ee9966d", "sha256": "f722b6dbb6e73aeb2e4490752da0f3e7cbc8c13fe7332ff19fe636ddec9f0dac" }, "downloads": -1, "filename": "PyFVM-0.2.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "a0e0666b0ecd733e44e12eae9ee9966d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17793, "upload_time": "2017-05-27T21:23:54", "url": "https://files.pythonhosted.org/packages/05/75/ccd101fd4ce8234bb22ab9a6d93a03ff11d08cd608303a50e126f8b8041d/PyFVM-0.2.2-py2.py3-none-any.whl" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "70e4773763d2e71671ee75040113051c", "sha256": "45b887465c9f0d68fc750599f72301c6ef3157b47875f2b5d309d39fb5bfbc04" }, "downloads": -1, "filename": "PyFVM-0.2.3-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "70e4773763d2e71671ee75040113051c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17547, "upload_time": "2017-05-29T21:12:10", "url": "https://files.pythonhosted.org/packages/c4/12/d15678b973cfde5e4fad57abba9023400f82091cd62a0ae3daf0fb43534f/PyFVM-0.2.3-py2.py3-none-any.whl" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "a365f6c94f81324566bf47f2978c1250", "sha256": "26ff181ae0dde28098b12c98e6312a97ea067d4a84b932465c6bed949296c60f" }, "downloads": -1, "filename": "pyfvm-0.2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a365f6c94f81324566bf47f2978c1250", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17615, "upload_time": "2018-06-25T20:55:46", "url": "https://files.pythonhosted.org/packages/8d/67/91286780a7ac46bbb7c6ae87f21e5b7114f22d8e13efed8b847ac3c4a382/pyfvm-0.2.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f43f7a5c29917324a0a8ede78cbc1c40", "sha256": "3690628a88fa4b22590f73f462443c1713611ea13fd8df3d462999fb922b671c" }, "downloads": -1, "filename": "pyfvm-0.2.4.tar.gz", "has_sig": false, "md5_digest": "f43f7a5c29917324a0a8ede78cbc1c40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13757, "upload_time": "2018-06-25T20:55:47", "url": "https://files.pythonhosted.org/packages/84/3c/3fd813944cdc49c9f7d46949c73f7d6a1ef68e478e551b21f60a9cec38d8/pyfvm-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "0ba108ec73e4153127a45d007d84c29e", "sha256": "f026061192c51ba4baf6054604a64ef41215c6894baea8283fab2dda3dc194de" }, "downloads": -1, "filename": "pyfvm-0.2.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0ba108ec73e4153127a45d007d84c29e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17362, "upload_time": "2018-09-01T08:52:59", "url": "https://files.pythonhosted.org/packages/64/b0/d1a30037d99cc0176771d65a196062161646360872b6af3b687c29ff8b9c/pyfvm-0.2.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "644f62bf657ad377b6647e90540fa000", "sha256": "76a1de6ae09585ae20f96ba9c71f3d0e0304213c207ab01fdbe1d7f2e44903e5" }, "downloads": -1, "filename": "pyfvm-0.2.5.tar.gz", "has_sig": false, "md5_digest": "644f62bf657ad377b6647e90540fa000", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16629, "upload_time": "2018-09-01T08:53:00", "url": "https://files.pythonhosted.org/packages/d4/19/5244898207c9dcd58fb45d7fc6d8413efd7eadd9c1276a76780c7ab5e277/pyfvm-0.2.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0ba108ec73e4153127a45d007d84c29e", "sha256": "f026061192c51ba4baf6054604a64ef41215c6894baea8283fab2dda3dc194de" }, "downloads": -1, "filename": "pyfvm-0.2.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0ba108ec73e4153127a45d007d84c29e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17362, "upload_time": "2018-09-01T08:52:59", "url": "https://files.pythonhosted.org/packages/64/b0/d1a30037d99cc0176771d65a196062161646360872b6af3b687c29ff8b9c/pyfvm-0.2.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "644f62bf657ad377b6647e90540fa000", "sha256": "76a1de6ae09585ae20f96ba9c71f3d0e0304213c207ab01fdbe1d7f2e44903e5" }, "downloads": -1, "filename": "pyfvm-0.2.5.tar.gz", "has_sig": false, "md5_digest": "644f62bf657ad377b6647e90540fa000", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16629, "upload_time": "2018-09-01T08:53:00", "url": "https://files.pythonhosted.org/packages/d4/19/5244898207c9dcd58fb45d7fc6d8413efd7eadd9c1276a76780c7ab5e277/pyfvm-0.2.5.tar.gz" } ] }