Skip to main content

Some tools for Hamiltonian systems

Project description

pyHamSys

pyHamSys is a Python package for scientific computing involving Hamiltonian systems

PyPI License

Installation:

pip install pyhamsys

Symplectic Integrators

pyHamSys includes a class SymplecticIntegrator containing the following symplectic splitting integrators:

All purpose integrators are for any splitting of the Hamiltonian H=∑k Xk in any order of the functions Xk. Otherwise, the order of the operators is specified for each integrator.

Usage: integrator = SymplecticIntegrator(name, step) where name is one of the names listed above and step is the time step of the integrator (float).

The function integrator._integrate integrates the Hamiltonian flow by one step.

The function integrator.integrate integrates the Hamiltonian flow from the initial conditions specified by the initial state vector y using integrator, one of the selected symplectic splitting integrators. It returns the value of y at times defines by the float, list or array times.

Parameters:

  • chi : function of (h, y), y being the state vector. Function returning exp(h Xn)...exp(h X1) y. If the selected integrator is not all purpose, refer to the list above for the specific ordering of the operators. The operator Xk is the Liouville operator associated with the function Xk, i.e., Xk = {Xk, ·}.
  • chi_star : function of (h, y). Function returning exp(h X1)...exp(h Xn) y.
  • y : initial state vector (numpy array)
  • times : times at which the values of the state vector are computed
  • command : function of (t, y). Function to be run at each time step (e.g., plotting an observable associated with the state vector, or register specific events).
  • autonomous : boolean. If autonomous is False, the state vector y should be of the form y = [t, x], where the first coordinate is time.

Returns:

  • If times is a float of integer, the output is a tuple (t, y or x) where y is the value of the state vector and y = [t, x] if autonomous is False.
  • If times is a list or array, returns the times and values of y or x at times.
  • If times is a list or array with a single element, returns the times and values of y or x at all computed times.

References:

  • Hairer, Lubich, Wanner, 2003, Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations (Springer)
  • McLachlan, Tuning symplectic integrators is easy and worthwhile, Commun. Comput. Phys. 31, 987 (2022); arxiv:2104.10269

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

pyhamsys-0.0.5.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

pyhamsys-0.0.5-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

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