pyhamsys


Namepyhamsys JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttp://github.com/cchandre/pyhamsys
SummarySome tools for Hamiltonian systems
upload_time2023-05-26 10:33:52
maintainer
docs_urlNone
authorCristel Chandre
requires_python>=3.6
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyHamSys
pyHamSys is a Python package for scientific computing involving Hamiltonian systems

![PyPI](https://img.shields.io/pypi/v/pyhamsys)
![License](https://img.shields.io/badge/license-BSD-lightgray)

Installation: 
```
pip install pyhamsys
```

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

- `Verlet` (order 2, all purpose), also referred to as Strang or Störmer-Verlet splitting 
- From [Forest, Ruth, Physica D 43, 105 (1990)](https://doi.org/10.1016/0167-2789(90)90019-L): 
    - `FR` (order 4, all purpose)
- From [Yoshida, Phys. Lett. A 150, 262 (1990)](https://doi.org/10.1016/0375-9601(90)90092-3):
    - `Yo#`: # should be replaced by an even integer, e.g., `Yo6` for 6th order symplectic integrator (all purpose)
    - `Yos6`: (order 6, all purpose) optimized symplectic integrator (solution A from Table 1)
- From [McLachlan, SIAM J. Sci. Comp. 16, 151 (1995)](https://doi.org/10.1137/0916010):
    - `M2` (order 2, all purpose)
    - `M4` (order 4, all purpose)
- From [Omelyan, Mryglod, Folk, Comput. Phys. Commun. 146, 188 (2002)](https://doi.org/10.1016/S0010-4655(02)00451-4): 
    - `EFRL` (order 4) optimized for *H* = *A* + *B*
    - `PEFRL` and `VEFRL` (order 4) optimized for *H* = *A*(*p*) + *B*(*q*). For `PEFRL`, *chi* should be exp(*h*A)exp(*h*B). For `VEFRL`, *chi* should be exp(*h*B)exp(*h*A).
- From [Blanes, Moan, J. Comput. Appl. Math. 142, 313 (2002)](https://doi.org/10.1016/S0377-0427(01)00492-7):
    - `BM4` (order 4, all purpose) refers to S<sub>6</sub> 
    - `BM6` (order 6, all purpose) refers to S<sub>10</sub>
    - `RKN4b` (order 4) refers to SRKN<sub>6</sub><sup>*b*</sup> optimized for *H* = *A*(*p*) + *B*(*q*). Here *chi* should be exp(*h*B)exp(*h*A).
    - `RKN6b` (order 6) refers to SRKN<sub>11</sub><sup>*b*</sup> optimized for *H* = *A*(*p*) + *B*(*q*). Here *chi* should be exp(*h*B)exp(*h*A).
    - `RKN6a` (order 6) refers to SRKN<sub>14</sub><sup>*a*</sup> optimized for *H* = *A*(*p*) + *B*(*q*). Here *chi* should be exp(*h*A)exp(*h*B).
- From [Blanes, Casas, Farrés, Laskar, Makazaga, Murua, Appl. Numer. Math. 68, 58 (2013)](http://dx.doi.org/10.1016/j.apnum.2013.01.003):
    - `ABA104` (order (10,4)) optimized for *H* = *A* + &epsilon; *B*. Here *chi* should be exp(*h*A)exp(*h*B).
    - `ABA864` (order (8,6,4)) optimized for *H* = *A* + &epsilon; *B*. Here *chi* should be exp(*h*A)exp(*h*B).
    - `ABA1064` (order (10,6,4)) optimized for *H* = *A* + &epsilon; *B*. Here *chi* should be exp(*h*A)exp(*h*B).
    
All purpose integrators are for any splitting of the Hamiltonian *H*=&sum;<sub>*k*</sub> *X*<sub>*k*</sub> in any order of the functions *X*<sub>*k*</sub>. 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* X<sub>*n*</sub>)...exp(*h* X<sub>1</sub>) *y*. If the selected integrator is not all purpose, refer to the list above for the specific ordering of the operators. The operator X<sub>*k*</sub> is the Liouville operator associated with the function *X*<sub>*k*</sub>, i.e., X<sub>*k*</sub> = {*X*<sub>*k*</sub>, &centerdot;}.
  - *chi_star* : function of (*h*, *y*).
    Function returning exp(*h* X<sub>1</sub>)...exp(*h* X<sub>*n*</sub>) *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](https://arxiv.org/abs/2104.10269)

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/cchandre/pyhamsys",
    "name": "pyhamsys",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Cristel Chandre",
    "author_email": "cristel.chandre@cnrs.fr",
    "download_url": "https://files.pythonhosted.org/packages/89/1d/b990f607f354577a9f3a3b2b9ebb29c9ee20d1c1045427fada54aa62b4db/pyhamsys-0.0.5.tar.gz",
    "platform": null,
    "description": "# pyHamSys\npyHamSys is a Python package for scientific computing involving Hamiltonian systems\n\n![PyPI](https://img.shields.io/pypi/v/pyhamsys)\n![License](https://img.shields.io/badge/license-BSD-lightgray)\n\nInstallation: \n```\npip install pyhamsys\n```\n\n## Symplectic Integrators\npyHamSys includes a class SymplecticIntegrator containing the following symplectic splitting integrators:\n\n- `Verlet` (order 2, all purpose), also referred to as Strang or St\u00f6rmer-Verlet splitting \n- From [Forest, Ruth, Physica D 43, 105 (1990)](https://doi.org/10.1016/0167-2789(90)90019-L): \n    - `FR` (order 4, all purpose)\n- From [Yoshida, Phys. Lett. A 150, 262 (1990)](https://doi.org/10.1016/0375-9601(90)90092-3):\n    - `Yo#`: # should be replaced by an even integer, e.g., `Yo6` for 6th order symplectic integrator (all purpose)\n    - `Yos6`: (order 6, all purpose) optimized symplectic integrator (solution A from Table 1)\n- From [McLachlan, SIAM J. Sci. Comp. 16, 151 (1995)](https://doi.org/10.1137/0916010):\n    - `M2` (order 2, all purpose)\n    - `M4` (order 4, all purpose)\n- From [Omelyan, Mryglod, Folk, Comput. Phys. Commun. 146, 188 (2002)](https://doi.org/10.1016/S0010-4655(02)00451-4): \n    - `EFRL` (order 4) optimized for *H* = *A* + *B*\n    - `PEFRL` and `VEFRL` (order 4) optimized for *H* = *A*(*p*) + *B*(*q*). For `PEFRL`, *chi* should be exp(*h*A)exp(*h*B). For `VEFRL`, *chi* should be exp(*h*B)exp(*h*A).\n- From [Blanes, Moan, J. Comput. Appl. Math. 142, 313 (2002)](https://doi.org/10.1016/S0377-0427(01)00492-7):\n    - `BM4` (order 4, all purpose) refers to S<sub>6</sub> \n    - `BM6` (order 6, all purpose) refers to S<sub>10</sub>\n    - `RKN4b` (order 4) refers to SRKN<sub>6</sub><sup>*b*</sup> optimized for *H* = *A*(*p*) + *B*(*q*). Here *chi* should be exp(*h*B)exp(*h*A).\n    - `RKN6b` (order 6) refers to SRKN<sub>11</sub><sup>*b*</sup> optimized for *H* = *A*(*p*) + *B*(*q*). Here *chi* should be exp(*h*B)exp(*h*A).\n    - `RKN6a` (order 6) refers to SRKN<sub>14</sub><sup>*a*</sup> optimized for *H* = *A*(*p*) + *B*(*q*). Here *chi* should be exp(*h*A)exp(*h*B).\n- From [Blanes, Casas, Farr\u00e9s, Laskar, Makazaga, Murua, Appl. Numer. Math. 68, 58 (2013)](http://dx.doi.org/10.1016/j.apnum.2013.01.003):\n    - `ABA104` (order (10,4)) optimized for *H* = *A* + &epsilon; *B*. Here *chi* should be exp(*h*A)exp(*h*B).\n    - `ABA864` (order (8,6,4)) optimized for *H* = *A* + &epsilon; *B*. Here *chi* should be exp(*h*A)exp(*h*B).\n    - `ABA1064` (order (10,6,4)) optimized for *H* = *A* + &epsilon; *B*. Here *chi* should be exp(*h*A)exp(*h*B).\n    \nAll purpose integrators are for any splitting of the Hamiltonian *H*=&sum;<sub>*k*</sub> *X*<sub>*k*</sub> in any order of the functions *X*<sub>*k*</sub>. Otherwise, the order of the operators is specified for each integrator.\n\nUsage: *integrator* = SymplecticIntegrator(*name*, *step*)\nwhere *name* is one of the names listed above and *step* is the time step of the integrator (float). \n\nThe function *integrator*.`_integrate` integrates the Hamiltonian flow by one step.\n\nThe 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*.\n\nParameters:\n  - *chi* : function of (*h*, *y*), y being the state vector.\n    Function returning exp(*h* X<sub>*n*</sub>)...exp(*h* X<sub>1</sub>) *y*. If the selected integrator is not all purpose, refer to the list above for the specific ordering of the operators. The operator X<sub>*k*</sub> is the Liouville operator associated with the function *X*<sub>*k*</sub>, i.e., X<sub>*k*</sub> = {*X*<sub>*k*</sub>, &centerdot;}.\n  - *chi_star* : function of (*h*, *y*).\n    Function returning exp(*h* X<sub>1</sub>)...exp(*h* X<sub>*n*</sub>) *y*.\n  - *y* : initial state vector (numpy array)\n  - *times* : times at which the values of the state vector are computed\n  - *command* : function of (*t*, *y*).\n    Function to be run at each time step (e.g., plotting an observable associated with the state vector, or register specific events). \n  - *autonomous* : boolean.\n    If autonomous is False, the state vector y should be of the form *y* = [*t*, *x*], where the first coordinate is time. \n\nReturns:\n   - 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.\n   - If *times* is a list or array, returns the times and values of *y* or *x* at *times*. \n   - If *times* is a list or array with a single element, returns the times and values of *y* or *x* at all computed times. \n\nReferences:\n  - Hairer, Lubich, Wanner, 2003, *Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations* (Springer)\n  - McLachlan, *Tuning symplectic integrators is easy and worthwhile*, Commun. Comput. Phys. 31, 987 (2022); [arxiv:2104.10269](https://arxiv.org/abs/2104.10269)\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Some tools for Hamiltonian systems",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "http://github.com/cchandre/pyhamsys"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e4347c8f4f79e1051ee6559bf84f2b8f66d2f1dcfe9cc1cdfb361c8d69c3b2e",
                "md5": "831bc2097698ea3576bc550d5d67bcdc",
                "sha256": "066c756017b3853aabfbecd69b08530fad9d7e4535c7cbd57a300ce677d1ea2f"
            },
            "downloads": -1,
            "filename": "pyhamsys-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "831bc2097698ea3576bc550d5d67bcdc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8607,
            "upload_time": "2023-05-26T10:33:50",
            "upload_time_iso_8601": "2023-05-26T10:33:50.219576Z",
            "url": "https://files.pythonhosted.org/packages/8e/43/47c8f4f79e1051ee6559bf84f2b8f66d2f1dcfe9cc1cdfb361c8d69c3b2e/pyhamsys-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "891db990f607f354577a9f3a3b2b9ebb29c9ee20d1c1045427fada54aa62b4db",
                "md5": "33de53f6529df4993de5f312e90120ab",
                "sha256": "58a4c2f82af904cc2ace90eff1ea78f0900d7e0b0c9c31b480a7311f27c4018f"
            },
            "downloads": -1,
            "filename": "pyhamsys-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "33de53f6529df4993de5f312e90120ab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8416,
            "upload_time": "2023-05-26T10:33:52",
            "upload_time_iso_8601": "2023-05-26T10:33:52.519569Z",
            "url": "https://files.pythonhosted.org/packages/89/1d/b990f607f354577a9f3a3b2b9ebb29c9ee20d1c1045427fada54aa62b4db/pyhamsys-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-26 10:33:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cchandre",
    "github_project": "pyhamsys",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyhamsys"
}
        
Elapsed time: 0.12770s