Skip to main content

A Python Library for Applied Mathematics in Physical Sciences.

Project description

Binder CircleCI Documentation Status License PyPI

Neumann

Warning This package is under active development and in an beta stage. Come back later, or star the repo to make sure you don’t miss the first stable release!

Neumann is a rapid prototyping platform focused on numerical calculations mainly corcerned with simulations of natural phenomena. It provides a set of common functionalities and interfaces with a number of state-of-the-art open source packages to combine their power seamlessly under a single development environment.

The most important features:

  • Numba-jitted classes and an extendible factory to define and manipulate vectors and tensors.

  • Classes to define and solve linear and nonlinear optimization problems.

  • A set of array routines for fast prorotyping, including random data creation to assure well posedness, or other properties of test problems.

Documentation

Click here to read the documentation.

Installation

This is optional, but we suggest you to create a dedicated virtual enviroment at all times to avoid conflicts with your other projects. Create a folder, open a command shell in that folder and use the following command

>>> python -m venv venv_name

Once the enviroment is created, activate it via typing

>>> .\venv_name\Scripts\activate

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

>>> pip install neumann

Crash Course

Linear Algebra

Define a reference frame (B) relative to the ambient frame (A):

>>> from neumann.linalg import ReferenceFrame
>>> 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 in frame A and view the components of it in frame B:

>>> v = Vector([0.0, 1.0, 0.0], frame=A)
>>> v.view(B)

Define the same vector in frame B:

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

Linear Programming

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

>>> from neumann.optimize import LinearProgrammingProblem as LPP
>>> 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, y):
>>>     a = 1, b = 100
>>>     return (a-x)**2 + b*(y-x**2)**2
>>> ranges = [[-10, 10],[-10, 10]]
>>> BGA = BinaryGeneticAlgorithm(Rosenbrock, ranges, length=12, nPop=200)
>>> BGA.solve()
array([0.99389553, 0.98901176]) 

Testing

To run all tests, open up a console in the root directory of the project and type the following

>>> python -m unittest

Dependencies

must have

  • Numba, NumPy, SciPy, SymPy, awkward

optional

  • networkx

License

This package is licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neumann-0.0.1a0.tar.gz (52.3 kB view details)

Uploaded Source

Built Distribution

neumann-0.0.1a0-py3-none-any.whl (63.5 kB view details)

Uploaded Python 3

File details

Details for the file neumann-0.0.1a0.tar.gz.

File metadata

  • Download URL: neumann-0.0.1a0.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for neumann-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 e623b597f24a9b753801e434c81faf7b3a7241fb48ec6281846627c3ac60bc95
MD5 18d5bd959aaca60747075fc45bc05b19
BLAKE2b-256 f6635fd73c83b1f3d2c055a692f672b21d6fa568547ef2e07fb73503b86a2ad4

See more details on using hashes here.

Provenance

File details

Details for the file neumann-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: neumann-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 63.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for neumann-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 d40873111c786528033548037292406a9f6eb8f4b18b29a65adca479969b530e
MD5 73d2a138c55a8300a36eecce7814e967
BLAKE2b-256 1b651d719dccf84a074e0b279c7079ab673ac2dc1525317d68770f15894aaa0b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page