Neumann - A Python Library for Applied Mathematics in Physical Sciences
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
ReferenceFrameclass for all kinds of frames, and dedicatedRectangularFrameandCartesianFrameclasses as special cases, all NumPy compliant. - NumPy compliant classes like
TensorandVectorto handle various kinds of tensorial quantities efficiently. - A
JaggedArrayand a Numba-jittablecsr_matrixto handle sparse data.
-
Operations Research
- Classes to define and solve linear and nonlinear optimization problems.
- A
LinearProgrammingProblemclass to define and solve any kind of linear optimization problem. - A
BinaryGeneticAlgorithmclass to tackle more complicated optimization problems.
- A
- Classes to define and solve linear and nonlinear optimization problems.
-
Graph Theory
- Algorithms to calculate rooted level structures and pseudo peripheral nodes of a
networkxgraph, which are useful if you want to minimize the bandwidth of sparse symmetrix matrices.
- Algorithms to calculate rooted level structures and pseudo peripheral nodes of a
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.
Installation
Neumann can be installed (either in a virtual enviroment or globally) from PyPI using pip on Python >= 3.7:
>>> pip install neumann
or chechkout with the following command using GitHub CLI
gh repo clone dewloosh/Neumann
and install from source by typing
>>> python install setup.py
Motivating Examples
Linear Algebra
Define a reference frame $\mathbf{B}$ relative to the frame $\mathbf{A}$:
>>> 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:
>>> B.dcm(target=A)
Define a vector $\mathbf{v}$ in frame $\mathbf{A}$ and show the components of it in frame $\mathbf{B}$:
>>> v = Vector([0.0, 1.0, 0.0], frame=A)
>>> v.show(B)
Define the same vector in frame $\mathbf{B}$:
>>> v = Vector(v.show(B), frame=B)
>>> v.show(A)
Linear Programming
Solve the following Linear Programming Problem (LPP) with one unique solution:
>>> 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:
>>> 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.
Metadata
Release files for neumann 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| neumann-1.0.7.tar.gz | 78.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| neumann-1.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 166.1 kB
Release files / neumann-1.0.7.tar.gz
| Download URL | neumann-1.0.7.tar.gz |
|---|---|
| Size | 78.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c10e89a3ab087f7e7f7a40d0cf60e0c6b5c7e769db571bac014e09658d22bf6
|
|
BLAKE2b-256 checksum How to use checksums |
d0011bf68fd105688f2e2a9f6cd55a47b24ae38d98057e2311c7a7ea54796ce0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|
Release files / neumann-1.0.7-py3-none-any.whl
| Download URL | neumann-1.0.7-py3-none-any.whl |
|---|---|
| Size | 87.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a81c03b42d8c108d58a1ca58ec4c81d76a17811cbf67e22f47172865e4e457a
|
|
BLAKE2b-256 checksum How to use checksums |
5e4120c0a03a8a78568de3b10e1a53f678aa8ad4e2cbcb00984060f5700bdd92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|