nrpylatex


Namenrpylatex JSON
Version 1.3.post1 PyPI version JSON
download
home_pagehttps://github.com/zachetienne/nrpylatex
SummaryLaTeX Interface to SymPy (CAS) for General Relativity
upload_time2023-06-05 20:19:02
maintainer
docs_urlNone
authorKen Sible
requires_python
licenseBSD License (BSD)
keywords general relativity latex cas
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![NRPyLaTeX Logo](https://raw.githubusercontent.com/zachetienne/nrpylatex/main/docs/imgs/logo.png)](https://zachetienne.github.io/nrpylatex/)

---

[![CI](https://github.com/zachetienne/nrpylatex/actions/workflows/main.yaml/badge.svg)](https://github.com/zachetienne/nrpylatex/actions/workflows/main.yaml)
[![PyPI](https://img.shields.io/pypi/v/nrpylatex.svg)](https://pypi.org/project/nrpylatex/)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/zachetienne/nrpylatex.git/HEAD?filepath=docs%2FNRPyLaTeX%20Tutorial.ipynb)
[![arXiv](https://img.shields.io/badge/arXiv-2111.05861-B31B1B)](https://arxiv.org/abs/2111.05861)

[NRPy+](https://github.com/zachetienne/nrpytutorial)'s LaTeX Interface to SymPy (CAS) for General Relativity

- automatic expansion of
  - [Einstein summation convention](https://en.wikipedia.org/wiki/Einstein_notation)
  - Levi-Civita and Christoffel symbols
  - Lie and covariant derivatives
  - metric inverse and determinant
- automatic index raising and lowering
- arbitrary coordinate system (default)
- exception handling and debugging

## § Installation

To install **NRPyLaTeX** using [PyPI](https://pypi.org/project/nrpylatex/), run the following command in the terminal

    $ pip install nrpylatex

## § Exporting (CAS)

If you are using Mathematica instead of SymPy, run the following code to convert your output

    from sympy import mathematica_code
    
    namespace = parse_latex(...)
    for var in namespace:
        exec(f'{var} = mathematica_code({var})')

If you are using a different CAS, reference the SymPy [documentation](https://docs.sympy.org/latest/modules/printing.html) to find the relevant printing function.

## § Interactive Tutorial (MyBinder)

[Quick Start](https://mybinder.org/v2/gh/zachetienne/nrpylatex.git/HEAD?filepath=docs%2FNRPyLaTeX%20Tutorial.ipynb) | [NRPy+ Integration](https://mybinder.org/v2/gh/zachetienne/nrpytutorial/HEAD?filepath=Tutorial-SymPy_LaTeX_Interface.ipynb) | [Guided Example (BSSN Formalism)](https://mybinder.org/v2/gh/zachetienne/nrpytutorial/HEAD?filepath=Tutorial-LaTeX_Interface_Example-BSSN_Cartesian.ipynb)

## § Documentation and Usage

[Getting Started and API Reference](https://zachetienne.github.io/nrpylatex/)

### Simple Example ([Kretschmann Scalar](https://en.wikipedia.org/wiki/Kretschmann_scalar))

**Python REPL or Script (*.py)**

    >>> from nrpylatex import parse_latex
    >>> parse_latex(r"""
    ...     % ignore "\begin{align}" "\end{align}"
    ...     \begin{align}
    ...         % coord [t, r, \theta, \phi]
    ...         % define gDD --dim 4 --zeros
    ...         % define G M --const
    ...         %% define Schwarzschild metric diagonal
    ...         g_{t t} &= -\left(1 - \frac{2GM}{r}\right) \\
    ...         g_{r r} &=  \left(1 - \frac{2GM}{r}\right)^{-1} \\
    ...         g_{\theta \theta} &= r^2 \\
    ...         g_{\phi \phi} &= r^2 \sin^2{\theta} \\
    ...         %% generate metric inverse gUU, determinant det(gDD), and connection GammaUDD
    ...         % assign gDD --metric
    ...         R^\alpha{}_{\beta \mu \nu} &= \partial_\mu \Gamma^\alpha_{\beta \nu} - \partial_\nu \Gamma^\alpha_{\beta \mu}
    ...             + \Gamma^\alpha_{\mu \gamma} \Gamma^\gamma_{\beta \nu} - \Gamma^\alpha_{\nu \sigma} \Gamma^\sigma_{\beta \mu} \\
    ...         K &= R^{\alpha \beta \mu \nu} R_{\alpha \beta \mu \nu}
    ...     \end{align}
    ... """)
    ('G', 'GammaUDD', 'gDD', 'gUU', 'epsilonUUUU', 'RUDDD', 'K', 'RUUUU', 'M', 'r', 'theta', 'RDDDD', 'gdet')
    >>> from sympy import simplify
    >>> print(simplify(K))
    48*G**2*M**2/r**6

**IPython REPL or Jupyter Notebook**

    In [1]: %load_ext nrpylatex
    In [2]: %%parse_latex
       ...: % ignore "\begin{align}" "\end{align}"
       ...: \begin{align}
       ...:     % coord [t, r, \theta, \phi]
       ...:     % define gDD --dim 4 --zeros
       ...:     % define G M --const
       ...:     %% define Schwarzschild metric diagonal
       ...:     g_{t t} &= -\left(1 - \frac{2GM}{r}\right) \\
       ...:     g_{r r} &=  \left(1 - \frac{2GM}{r}\right)^{-1} \\
       ...:     g_{\theta \theta} &= r^2 \\
       ...:     g_{\phi \phi} &= r^2 \sin^2{\theta} \\
       ...:     %% generate metric inverse gUU, determinant det(gDD), and connection GammaUDD
       ...:     % assign gDD --metric
       ...:     R^\alpha{}_{\beta \mu \nu} &= \partial_\mu \Gamma^\alpha_{\beta \nu} - \partial_\nu \Gamma^\alpha_{\beta \mu}
       ...:         + \Gamma^\alpha_{\mu \gamma} \Gamma^\gamma_{\beta \nu} - \Gamma^\alpha_{\nu \sigma} \Gamma^\sigma_{\beta \mu} \\
       ...:     K &= R^{\alpha \beta \mu \nu} R_{\alpha \beta \mu \nu}
       ...: \end{align}
    Out[2]: ('G', 'GammaUDD', 'gDD', 'gUU', 'epsilonUUUU', 'RUDDD', 'K', 'RUUUU', 'M', 'r', 'theta', 'RDDDD', 'gdet')
    In [3]: from sympy import simplify
    In [4]: print(simplify(K))
    Out[4]: 48*G**2*M**2/r**6

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zachetienne/nrpylatex",
    "name": "nrpylatex",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "General Relativity,LaTeX,CAS",
    "author": "Ken Sible",
    "author_email": "ksible@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/de/859741f6b9cc873b1830cb28f0f33dd6e3bb0580baf7db31bb3acdd7a2e6/nrpylatex-1.3.post1.tar.gz",
    "platform": null,
    "description": "[![NRPyLaTeX Logo](https://raw.githubusercontent.com/zachetienne/nrpylatex/main/docs/imgs/logo.png)](https://zachetienne.github.io/nrpylatex/)\n\n---\n\n[![CI](https://github.com/zachetienne/nrpylatex/actions/workflows/main.yaml/badge.svg)](https://github.com/zachetienne/nrpylatex/actions/workflows/main.yaml)\n[![PyPI](https://img.shields.io/pypi/v/nrpylatex.svg)](https://pypi.org/project/nrpylatex/)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/zachetienne/nrpylatex.git/HEAD?filepath=docs%2FNRPyLaTeX%20Tutorial.ipynb)\n[![arXiv](https://img.shields.io/badge/arXiv-2111.05861-B31B1B)](https://arxiv.org/abs/2111.05861)\n\n[NRPy+](https://github.com/zachetienne/nrpytutorial)'s LaTeX Interface to SymPy (CAS) for General Relativity\n\n- automatic expansion of\n  - [Einstein summation convention](https://en.wikipedia.org/wiki/Einstein_notation)\n  - Levi-Civita and Christoffel symbols\n  - Lie and covariant derivatives\n  - metric inverse and determinant\n- automatic index raising and lowering\n- arbitrary coordinate system (default)\n- exception handling and debugging\n\n## § Installation\n\nTo install **NRPyLaTeX** using [PyPI](https://pypi.org/project/nrpylatex/), run the following command in the terminal\n\n    $ pip install nrpylatex\n\n## § Exporting (CAS)\n\nIf you are using Mathematica instead of SymPy, run the following code to convert your output\n\n    from sympy import mathematica_code\n    \n    namespace = parse_latex(...)\n    for var in namespace:\n        exec(f'{var} = mathematica_code({var})')\n\nIf you are using a different CAS, reference the SymPy [documentation](https://docs.sympy.org/latest/modules/printing.html) to find the relevant printing function.\n\n## § Interactive Tutorial (MyBinder)\n\n[Quick Start](https://mybinder.org/v2/gh/zachetienne/nrpylatex.git/HEAD?filepath=docs%2FNRPyLaTeX%20Tutorial.ipynb) | [NRPy+ Integration](https://mybinder.org/v2/gh/zachetienne/nrpytutorial/HEAD?filepath=Tutorial-SymPy_LaTeX_Interface.ipynb) | [Guided Example (BSSN Formalism)](https://mybinder.org/v2/gh/zachetienne/nrpytutorial/HEAD?filepath=Tutorial-LaTeX_Interface_Example-BSSN_Cartesian.ipynb)\n\n## § Documentation and Usage\n\n[Getting Started and API Reference](https://zachetienne.github.io/nrpylatex/)\n\n### Simple Example ([Kretschmann Scalar](https://en.wikipedia.org/wiki/Kretschmann_scalar))\n\n**Python REPL or Script (*.py)**\n\n    >>> from nrpylatex import parse_latex\n    >>> parse_latex(r\"\"\"\n    ...     % ignore \"\\begin{align}\" \"\\end{align}\"\n    ...     \\begin{align}\n    ...         % coord [t, r, \\theta, \\phi]\n    ...         % define gDD --dim 4 --zeros\n    ...         % define G M --const\n    ...         %% define Schwarzschild metric diagonal\n    ...         g_{t t} &= -\\left(1 - \\frac{2GM}{r}\\right) \\\\\n    ...         g_{r r} &=  \\left(1 - \\frac{2GM}{r}\\right)^{-1} \\\\\n    ...         g_{\\theta \\theta} &= r^2 \\\\\n    ...         g_{\\phi \\phi} &= r^2 \\sin^2{\\theta} \\\\\n    ...         %% generate metric inverse gUU, determinant det(gDD), and connection GammaUDD\n    ...         % assign gDD --metric\n    ...         R^\\alpha{}_{\\beta \\mu \\nu} &= \\partial_\\mu \\Gamma^\\alpha_{\\beta \\nu} - \\partial_\\nu \\Gamma^\\alpha_{\\beta \\mu}\n    ...             + \\Gamma^\\alpha_{\\mu \\gamma} \\Gamma^\\gamma_{\\beta \\nu} - \\Gamma^\\alpha_{\\nu \\sigma} \\Gamma^\\sigma_{\\beta \\mu} \\\\\n    ...         K &= R^{\\alpha \\beta \\mu \\nu} R_{\\alpha \\beta \\mu \\nu}\n    ...     \\end{align}\n    ... \"\"\")\n    ('G', 'GammaUDD', 'gDD', 'gUU', 'epsilonUUUU', 'RUDDD', 'K', 'RUUUU', 'M', 'r', 'theta', 'RDDDD', 'gdet')\n    >>> from sympy import simplify\n    >>> print(simplify(K))\n    48*G**2*M**2/r**6\n\n**IPython REPL or Jupyter Notebook**\n\n    In [1]: %load_ext nrpylatex\n    In [2]: %%parse_latex\n       ...: % ignore \"\\begin{align}\" \"\\end{align}\"\n       ...: \\begin{align}\n       ...:     % coord [t, r, \\theta, \\phi]\n       ...:     % define gDD --dim 4 --zeros\n       ...:     % define G M --const\n       ...:     %% define Schwarzschild metric diagonal\n       ...:     g_{t t} &= -\\left(1 - \\frac{2GM}{r}\\right) \\\\\n       ...:     g_{r r} &=  \\left(1 - \\frac{2GM}{r}\\right)^{-1} \\\\\n       ...:     g_{\\theta \\theta} &= r^2 \\\\\n       ...:     g_{\\phi \\phi} &= r^2 \\sin^2{\\theta} \\\\\n       ...:     %% generate metric inverse gUU, determinant det(gDD), and connection GammaUDD\n       ...:     % assign gDD --metric\n       ...:     R^\\alpha{}_{\\beta \\mu \\nu} &= \\partial_\\mu \\Gamma^\\alpha_{\\beta \\nu} - \\partial_\\nu \\Gamma^\\alpha_{\\beta \\mu}\n       ...:         + \\Gamma^\\alpha_{\\mu \\gamma} \\Gamma^\\gamma_{\\beta \\nu} - \\Gamma^\\alpha_{\\nu \\sigma} \\Gamma^\\sigma_{\\beta \\mu} \\\\\n       ...:     K &= R^{\\alpha \\beta \\mu \\nu} R_{\\alpha \\beta \\mu \\nu}\n       ...: \\end{align}\n    Out[2]: ('G', 'GammaUDD', 'gDD', 'gUU', 'epsilonUUUU', 'RUDDD', 'K', 'RUUUU', 'M', 'r', 'theta', 'RDDDD', 'gdet')\n    In [3]: from sympy import simplify\n    In [4]: print(simplify(K))\n    Out[4]: 48*G**2*M**2/r**6\n",
    "bugtrack_url": null,
    "license": "BSD License (BSD)",
    "summary": "LaTeX Interface to SymPy (CAS) for General Relativity",
    "version": "1.3.post1",
    "project_urls": {
        "Homepage": "https://github.com/zachetienne/nrpylatex"
    },
    "split_keywords": [
        "general relativity",
        "latex",
        "cas"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cace498efd799a5915bdefd048cf6e97cc7167e8be8e552560115ef91632d4fa",
                "md5": "a800135305a73fc0493ec58a8b7c401f",
                "sha256": "c87aab9bdb55ba6ead1da004fed5a5934240ad58fe3da7f052464dabe5ccaff2"
            },
            "downloads": -1,
            "filename": "nrpylatex-1.3.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a800135305a73fc0493ec58a8b7c401f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 34903,
            "upload_time": "2023-06-05T20:19:00",
            "upload_time_iso_8601": "2023-06-05T20:19:00.478048Z",
            "url": "https://files.pythonhosted.org/packages/ca/ce/498efd799a5915bdefd048cf6e97cc7167e8be8e552560115ef91632d4fa/nrpylatex-1.3.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aade859741f6b9cc873b1830cb28f0f33dd6e3bb0580baf7db31bb3acdd7a2e6",
                "md5": "d1c3d926c6ae05516ae960d5387aa523",
                "sha256": "9890d9497385f305c785ed5a2b0cadf869de02536111691f059858922ee6b6a9"
            },
            "downloads": -1,
            "filename": "nrpylatex-1.3.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "d1c3d926c6ae05516ae960d5387aa523",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 33176,
            "upload_time": "2023-06-05T20:19:02",
            "upload_time_iso_8601": "2023-06-05T20:19:02.327645Z",
            "url": "https://files.pythonhosted.org/packages/aa/de/859741f6b9cc873b1830cb28f0f33dd6e3bb0580baf7db31bb3acdd7a2e6/nrpylatex-1.3.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-05 20:19:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zachetienne",
    "github_project": "nrpylatex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nrpylatex"
}
        
Elapsed time: 0.23587s