neumann


Nameneumann JSON
Version 1.0.7 PyPI version JSON
download
home_pagehttps://github.com/dewloosh/Neumann
SummaryA Python Library for Applied Mathematics in Physical Sciences.
upload_time2023-05-26 16:50:00
maintainer
docs_urlNone
authorBence Balogh
requires_python>=3.7, <3.11
license
keywords
VCS
bugtrack_url
requirements dewloosh.core linkeddeepdict numba numpy scipy awkward sympy
Travis-CI No Travis.
coveralls test coverage
            # **Neumann** - A Python Library for Applied Mathematics in Physical Sciences

[![CircleCI](https://circleci.com/gh/dewloosh/Neumann.svg?style=shield)](https://circleci.com/gh/dewloosh/Neumann)
[![Documentation Status](https://readthedocs.org/projects/neumann/badge/?version=latest)](https://neumann.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PyPI](https://badge.fury.io/py/Neumann.svg)](https://pypi.org/project/Neumann)
[![codecov](https://codecov.io/gh/dewloosh/Neumann/branch/main/graph/badge.svg?token=TBI6GG4ECG)](https://codecov.io/gh/dewloosh/Neumann)
[![Python 3.7-3.10](https://img.shields.io/badge/python-3.7%E2%80%923.10-blue)](https://www.python.org)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

`Neumann` is a Python library that provides tools to formulate and solve problems related to all kinds of scientific disciplines. It is a part of the DewLoosh ecosystem which is designed mainly to solve problems related to computational solid mechanics, but if something is general enough, it ends up here. A good example is the included vector and tensor algebra modules, or the various optimizers, which are applicable in a much broader context than they were originally designed for.

The most important features:

* Linear Algebra
  * A mechanism that guarantees to maintain the property of objectivity of tensorial quantities.
  * A `ReferenceFrame` class for all kinds of frames, and dedicated `RectangularFrame` and `CartesianFrame` classes as special cases, all NumPy compliant.
  * NumPy compliant classes like `Tensor` and `Vector` to handle various kinds of tensorial quantities efficiently.
  * A `JaggedArray` and a Numba-jittable `csr_matrix` to handle sparse data.

* Operations Research
  * Classes to define and solve linear and nonlinear optimization problems.
    * A `LinearProgrammingProblem` class to define and solve any kind of linear optimization problem.
    * A `BinaryGeneticAlgorithm` class to tackle more complicated optimization problems.

* Graph Theory
  * Algorithms to calculate rooted level structures and pseudo peripheral nodes of a `networkx` graph, which are useful if you want to minimize the bandwidth of sparse symmetrix matrices.

> **Note**
> Be aware, that the library uses JIT-compilation through Numba, and as a result,
> first calls to these functions may take longer, but pay off in the long run.

## **Documentation**

The documentation is hosted on [ReadTheDocs](https://Neumann.readthedocs.io/en/latest/).

## **Installation**

`Neumann` can be installed (either in a virtual enviroment or globally) from PyPI using `pip` on Python >= 3.7:

```console
>>> pip install neumann
```

or chechkout with the following command using GitHub CLI

```console
gh repo clone dewloosh/Neumann
```

and install from source by typing

```console
>>> python install setup.py
```

## **Motivating Examples**

### Linear Algebra

Define a reference frame $\mathbf{B}$ relative to the frame $\mathbf{A}$:

```python
>>> from neumann.linalg import ReferenceFrame, Vector, Tensor
>>> A = ReferenceFrame(name='A', axes=np.eye(3))
>>> B = A.orient_new('Body', [0, 0, 90*np.pi/180], 'XYZ', name='B')
```

Get the *DCM matrix* of the transformation between two frames:

```python
>>> B.dcm(target=A)
```

Define a vector $\mathbf{v}$ in frame $\mathbf{A}$ and show the components of it in frame $\mathbf{B}$:

```python
>>> v = Vector([0.0, 1.0, 0.0], frame=A)
>>> v.show(B)
```

Define the same vector in frame $\mathbf{B}$:

```python
>>> v = Vector(v.show(B), frame=B)
>>> v.show(A)
```

### Linear Programming

Solve the following Linear Programming Problem (LPP) with one unique solution:

```python
>>> from neumann.optimize import LinearProgrammingProblem as LPP
>>> from neumann.function import Function, Equality
>>> import sympy as sy
>>> variables = ['x1', 'x2', 'x3', 'x4']
>>> x1, x2, x3, x4 = syms = sy.symbols(variables, positive=True)
>>> obj1 = Function(3*x1 + 9*x3 + x2 + x4, variables=syms)
>>> eq11 = Equality(x1 + 2*x3 + x4 - 4, variables=syms)
>>> eq12 = Equality(x2 + x3 - x4 - 2, variables=syms)
>>> problem = LPP(cost=obj1, constraints=[eq11, eq12], variables=syms)
>>> problem.solve()['x']
array([0., 6., 0., 4.])
```

### NonLinear Programming

Find the minimizer of the Rosenbrock function:

```python
>>> from neumann.optimize import BinaryGeneticAlgorithm
>>> def Rosenbrock(x):
...     a, b = 1, 100
...     return (a-x[0])**2 + b*(x[1]-x[0]**2)**2
>>> ranges = [[-10, 10], [-10, 10]]
>>> BGA = BinaryGeneticAlgorithm(Rosenbrock, ranges, length=12, nPop=200)
>>> BGA.solve()
...
```

## **License**

This package is licensed under the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dewloosh/Neumann",
    "name": "neumann",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7, <3.11",
    "maintainer_email": "",
    "keywords": "",
    "author": "Bence Balogh",
    "author_email": "dewloosh@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d0/01/1bf68fd105688f2e2a9f6cd55a47b24ae38d98057e2311c7a7ea54796ce0/neumann-1.0.7.tar.gz",
    "platform": null,
    "description": "# **Neumann** - A Python Library for Applied Mathematics in Physical Sciences\n\n[![CircleCI](https://circleci.com/gh/dewloosh/Neumann.svg?style=shield)](https://circleci.com/gh/dewloosh/Neumann)\n[![Documentation Status](https://readthedocs.org/projects/neumann/badge/?version=latest)](https://neumann.readthedocs.io/en/latest/?badge=latest)\n[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PyPI](https://badge.fury.io/py/Neumann.svg)](https://pypi.org/project/Neumann)\n[![codecov](https://codecov.io/gh/dewloosh/Neumann/branch/main/graph/badge.svg?token=TBI6GG4ECG)](https://codecov.io/gh/dewloosh/Neumann)\n[![Python 3.7-3.10](https://img.shields.io/badge/python-3.7%E2%80%923.10-blue)](https://www.python.org)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n`Neumann` is a Python library that provides tools to formulate and solve problems related to all kinds of scientific disciplines. It is a part of the DewLoosh ecosystem which is designed mainly to solve problems related to computational solid mechanics, but if something is general enough, it ends up here. A good example is the included vector and tensor algebra modules, or the various optimizers, which are applicable in a much broader context than they were originally designed for.\n\nThe most important features:\n\n* Linear Algebra\n  * A mechanism that guarantees to maintain the property of objectivity of tensorial quantities.\n  * A `ReferenceFrame` class for all kinds of frames, and dedicated `RectangularFrame` and `CartesianFrame` classes as special cases, all NumPy compliant.\n  * NumPy compliant classes like `Tensor` and `Vector` to handle various kinds of tensorial quantities efficiently.\n  * A `JaggedArray` and a Numba-jittable `csr_matrix` to handle sparse data.\n\n* Operations Research\n  * Classes to define and solve linear and nonlinear optimization problems.\n    * A `LinearProgrammingProblem` class to define and solve any kind of linear optimization problem.\n    * A `BinaryGeneticAlgorithm` class to tackle more complicated optimization problems.\n\n* Graph Theory\n  * Algorithms to calculate rooted level structures and pseudo peripheral nodes of a `networkx` graph, which are useful if you want to minimize the bandwidth of sparse symmetrix matrices.\n\n> **Note**\n> Be aware, that the library uses JIT-compilation through Numba, and as a result,\n> first calls to these functions may take longer, but pay off in the long run.\n\n## **Documentation**\n\nThe documentation is hosted on [ReadTheDocs](https://Neumann.readthedocs.io/en/latest/).\n\n## **Installation**\n\n`Neumann` can be installed (either in a virtual enviroment or globally) from PyPI using `pip` on Python >= 3.7:\n\n```console\n>>> pip install neumann\n```\n\nor chechkout with the following command using GitHub CLI\n\n```console\ngh repo clone dewloosh/Neumann\n```\n\nand install from source by typing\n\n```console\n>>> python install setup.py\n```\n\n## **Motivating Examples**\n\n### Linear Algebra\n\nDefine a reference frame $\\mathbf{B}$ relative to the frame $\\mathbf{A}$:\n\n```python\n>>> from neumann.linalg import ReferenceFrame, Vector, Tensor\n>>> A = ReferenceFrame(name='A', axes=np.eye(3))\n>>> B = A.orient_new('Body', [0, 0, 90*np.pi/180], 'XYZ', name='B')\n```\n\nGet the *DCM matrix* of the transformation between two frames:\n\n```python\n>>> B.dcm(target=A)\n```\n\nDefine a vector $\\mathbf{v}$ in frame $\\mathbf{A}$ and show the components of it in frame $\\mathbf{B}$:\n\n```python\n>>> v = Vector([0.0, 1.0, 0.0], frame=A)\n>>> v.show(B)\n```\n\nDefine the same vector in frame $\\mathbf{B}$:\n\n```python\n>>> v = Vector(v.show(B), frame=B)\n>>> v.show(A)\n```\n\n### Linear Programming\n\nSolve the following Linear Programming Problem (LPP) with one unique solution:\n\n```python\n>>> from neumann.optimize import LinearProgrammingProblem as LPP\n>>> from neumann.function import Function, Equality\n>>> import sympy as sy\n>>> variables = ['x1', 'x2', 'x3', 'x4']\n>>> x1, x2, x3, x4 = syms = sy.symbols(variables, positive=True)\n>>> obj1 = Function(3*x1 + 9*x3 + x2 + x4, variables=syms)\n>>> eq11 = Equality(x1 + 2*x3 + x4 - 4, variables=syms)\n>>> eq12 = Equality(x2 + x3 - x4 - 2, variables=syms)\n>>> problem = LPP(cost=obj1, constraints=[eq11, eq12], variables=syms)\n>>> problem.solve()['x']\narray([0., 6., 0., 4.])\n```\n\n### NonLinear Programming\n\nFind the minimizer of the Rosenbrock function:\n\n```python\n>>> from neumann.optimize import BinaryGeneticAlgorithm\n>>> def Rosenbrock(x):\n...     a, b = 1, 100\n...     return (a-x[0])**2 + b*(x[1]-x[0]**2)**2\n>>> ranges = [[-10, 10], [-10, 10]]\n>>> BGA = BinaryGeneticAlgorithm(Rosenbrock, ranges, length=12, nPop=200)\n>>> BGA.solve()\n...\n```\n\n## **License**\n\nThis package is licensed under the MIT license.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python Library for Applied Mathematics in Physical Sciences.",
    "version": "1.0.7",
    "project_urls": {
        "Download": "https://github.com/dewloosh/Neumann/archive/refs/tags/1.0.7.zip",
        "Homepage": "https://github.com/dewloosh/Neumann"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e4120c0a03a8a78568de3b10e1a53f678aa8ad4e2cbcb00984060f5700bdd92",
                "md5": "44cfd5cfd83330e0a731748567dacbeb",
                "sha256": "2a81c03b42d8c108d58a1ca58ec4c81d76a17811cbf67e22f47172865e4e457a"
            },
            "downloads": -1,
            "filename": "neumann-1.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "44cfd5cfd83330e0a731748567dacbeb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7, <3.11",
            "size": 87561,
            "upload_time": "2023-05-26T16:49:57",
            "upload_time_iso_8601": "2023-05-26T16:49:57.448882Z",
            "url": "https://files.pythonhosted.org/packages/5e/41/20c0a03a8a78568de3b10e1a53f678aa8ad4e2cbcb00984060f5700bdd92/neumann-1.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d0011bf68fd105688f2e2a9f6cd55a47b24ae38d98057e2311c7a7ea54796ce0",
                "md5": "fb29324c42552f4832856f92101e2b39",
                "sha256": "4c10e89a3ab087f7e7f7a40d0cf60e0c6b5c7e769db571bac014e09658d22bf6"
            },
            "downloads": -1,
            "filename": "neumann-1.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "fb29324c42552f4832856f92101e2b39",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7, <3.11",
            "size": 78527,
            "upload_time": "2023-05-26T16:50:00",
            "upload_time_iso_8601": "2023-05-26T16:50:00.018454Z",
            "url": "https://files.pythonhosted.org/packages/d0/01/1bf68fd105688f2e2a9f6cd55a47b24ae38d98057e2311c7a7ea54796ce0/neumann-1.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-26 16:50:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dewloosh",
    "github_project": "Neumann",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "circle": true,
    "requirements": [
        {
            "name": "dewloosh.core",
            "specs": [
                [
                    ">=",
                    "1.0.21"
                ]
            ]
        },
        {
            "name": "linkeddeepdict",
            "specs": [
                [
                    ">=",
                    "1.1.0"
                ]
            ]
        },
        {
            "name": "numba",
            "specs": [
                [
                    ">=",
                    "0.56.4"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.23.5"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.9.3"
                ]
            ]
        },
        {
            "name": "awkward",
            "specs": [
                [
                    ">=",
                    "2.0.8"
                ]
            ]
        },
        {
            "name": "sympy",
            "specs": [
                [
                    ">=",
                    "1.11.1"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "neumann"
}
        
Elapsed time: 0.07094s