gvec-to-python


Namegvec-to-python JSON
Version 1.2.2 PyPI version JSON
download
home_pageNone
SummaryParse GVEC output in Python
upload_time2024-04-09 15:48:47
maintainerNone
docs_urlNone
authorTin Kei Cheng, Florian Hindenlang, Stefan Possanner
requires_python>=3.7
licenseCopyright 2021 (c) T.K. Cheng, F. Hindenlang, S. Possanner | Max Planck Institute for Plasma Physics Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords plasma physics fusion numerical modeling mhd equilibrium
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 3D GVEC equilibria in Python

PyPI install:

```
pip install gvec_to_python
```
Or from source:
```
git clone git@gitlab.mpcdf.mpg.de:gvec-group/gvec_to_python.git
cd gvec_to_python
pip install -e .
```
Compile kernels for faster evaluations:
```
compile-gvec-tp
```

# Usage

The [Galerkin Variational Equilibrium Code (GVEC)](https://gitlab.mpcdf.mpg.de/gvec-group/gvec) calculates magneto-hydrodynamic (MHD) equilibria for Tokamaks and Stellarators. `gvec_to_python` parses the GVEC output file (`.dat`) and collects the data in a `.json` file: 
```
from gvec_to_python.reader.gvec_reader import create_GVEC_json

create_GVEC_json(dat_file_in, json_file_out)  # give absolute paths to the files
```
In a second step, callables of MHD equilibrium quantities are created as methods of the GVEC class:
```
from gvec_to_python import GVEC

gvec = GVEC(json_file_out, mapping='gvec')
```
Profiles can be evaluated via
```
gvec.profiles.profile(s, name='phi')        # toroidal flux profile (radial coordinate s~sqrt(phi_norm)
gvec.profiles.profile(s, name='chi')        # poloidal flux profile
gvec.profiles.profile(s, name='iota')       # iota profile
gvec.profiles.profile(s, name='pressure')   # pressure profile
```
where the radial coordinate `s` is the square-root of the normalized toroidal flux. Profile derivatives are callable via
```
gvec.profiles.profile(s, name='phi', der='s') # first derivative
gvec.profiles.profile(s, name='phi', der='ss') # second derivative
```

![Profiles](notebooks/profiles.png "Title")

The mapping and metric coefficients are called via
```
gvec.f(s, a1, a2)       # mapping
gvec.df(s, a1, a2)      # Jacobian matrix
gvec.det_df(s, a1, a2)  # Jacobian determinant
gvec.df_inv(s, a1, a2)  # inverse Jacobian matrix
gvec.g(s, a1, a2)       # metric tensor
gvec.g_inv(s, a1, a2)   # inverse metric tensor
```
The **radial coordinate** denotes `s`  is **always the square-root of the normalized toroidal flux**, `a1` is the poloidal angle and `a2` denotes the toroidal angle.

![Profiles](notebooks/poloidal.png "Title")
![](notebooks/topview.png)

Five different mappings can be invoked by the `mapping.setter`:
```
# gvec standard coordinates: (s, th, ze) -> (x, y, z) 
#   from (s,a1,a2)=(s,theta,zeta) in [0,1],[0,2pi],[0,2pi] to cartesian coordinates (x,y,z)
gvec.mapping = 'gvec'

# gvec straight-field-line mapping (PEST) (s, theta*, zeta*) -> (x, y, z) 
#   from (s,a1,a2)=(s,theta*,zeta*) in [0,1],[0,2pi],[0,2pi] to cartesian coordinates (x,y,z)
gvec.mapping = 'pest'

# gvec with unit cube as logical domain  (s, u, v) -> (x,y,z)
#   from (s,a1,a2)=(s,u,v) in [0,1],[0,1],[0,1] to cartesian coordinates (x,y,z)
gvec.mapping = 'unit'

# gvec straight-field-line (PEST)  with unit cube as logical domain  (s, u*, v*) -> (x,y,z)
#   from (s,a1,a2)=(s,u*,v*) in [0,1],[0,1],[0,1] to cartesian coordinates (x,y,z)
gvec.mapping = 'unit_pest'

# gvec without hmap (s,th,ze) -> (X1,X2,zeta) 
#   from (s,a1,a2)=(s,theta,zeta) in [0,1],[0,2pi],[0,2pi] to GVECs internal coordinates (X1,X2,zeta)
#   if default torus (hmap=1) is used in GVEC, then (R,Z,phi)=(X1,X2,-zeta)
gvec.mapping = 'wo_hmap'
```

![](notebooks/dtheta.png)
![](notebooks/det_df.png)

The MHD quantities are called via
```
gvec.p0(s, a1, a2)      # pressure as 0-form
gvec.p3(s, a1, a2)      # pressure as 3-form

gvec.bv(s, a1, a2)      # contra-variant B-field
gvec.b1(s, a1, a2)      # co-variant B-field (1-form)
gvec.b2(s, a1, a2)      # 2-form B-field
gvec.b_cart(s, a1, a2)  # Cartesian B-field

gvec.av(s, a1, a2)      # contra-variant vector potential
gvec.a1(s, a1, a2)      # co-variant vector potential (1-form)
gvec.a2(s, a1, a2)      # 2-form vector potential
gvec.a_cart(s, a1, a2)  # Cartesian vector potential

gvec.jv(s, a1, a2)      # contra-variant current 
gvec.j1(s, a1, a2)      # co-variant current (1-form)
gvec.j2(s, a1, a2)      # 2-form current
gvec.j_cart(s, a1, a2)  # Cartesian current
```

![](notebooks/pressure.png)

![](notebooks/absB.png)





            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gvec-to-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "plasma physics, fusion, numerical modeling, mhd equilibrium",
    "author": "Tin Kei Cheng, Florian Hindenlang, Stefan Possanner",
    "author_email": "stefan.possanner@ipp.mpg.de, florian.hindenlang@ipp.mpg.de",
    "download_url": "https://files.pythonhosted.org/packages/f8/cf/c321b2ceb0909e15936f2e494e7ed27d27fe67892aa14de8337271451ed9/gvec-to-python-1.2.2.tar.gz",
    "platform": null,
    "description": "# 3D GVEC equilibria in Python\n\nPyPI install:\n\n```\npip install gvec_to_python\n```\nOr from source:\n```\ngit clone git@gitlab.mpcdf.mpg.de:gvec-group/gvec_to_python.git\ncd gvec_to_python\npip install -e .\n```\nCompile kernels for faster evaluations:\n```\ncompile-gvec-tp\n```\n\n# Usage\n\nThe [Galerkin Variational Equilibrium Code (GVEC)](https://gitlab.mpcdf.mpg.de/gvec-group/gvec) calculates magneto-hydrodynamic (MHD) equilibria for Tokamaks and Stellarators. `gvec_to_python` parses the GVEC output file (`.dat`) and collects the data in a `.json` file: \n```\nfrom gvec_to_python.reader.gvec_reader import create_GVEC_json\n\ncreate_GVEC_json(dat_file_in, json_file_out)  # give absolute paths to the files\n```\nIn a second step, callables of MHD equilibrium quantities are created as methods of the GVEC class:\n```\nfrom gvec_to_python import GVEC\n\ngvec = GVEC(json_file_out, mapping='gvec')\n```\nProfiles can be evaluated via\n```\ngvec.profiles.profile(s, name='phi')        # toroidal flux profile (radial coordinate s~sqrt(phi_norm)\ngvec.profiles.profile(s, name='chi')        # poloidal flux profile\ngvec.profiles.profile(s, name='iota')       # iota profile\ngvec.profiles.profile(s, name='pressure')   # pressure profile\n```\nwhere the radial coordinate `s` is the square-root of the normalized toroidal flux. Profile derivatives are callable via\n```\ngvec.profiles.profile(s, name='phi', der='s') # first derivative\ngvec.profiles.profile(s, name='phi', der='ss') # second derivative\n```\n\n![Profiles](notebooks/profiles.png \"Title\")\n\nThe mapping and metric coefficients are called via\n```\ngvec.f(s, a1, a2)       # mapping\ngvec.df(s, a1, a2)      # Jacobian matrix\ngvec.det_df(s, a1, a2)  # Jacobian determinant\ngvec.df_inv(s, a1, a2)  # inverse Jacobian matrix\ngvec.g(s, a1, a2)       # metric tensor\ngvec.g_inv(s, a1, a2)   # inverse metric tensor\n```\nThe **radial coordinate** denotes `s`  is **always the square-root of the normalized toroidal flux**, `a1` is the poloidal angle and `a2` denotes the toroidal angle.\n\n![Profiles](notebooks/poloidal.png \"Title\")\n![](notebooks/topview.png)\n\nFive different mappings can be invoked by the `mapping.setter`:\n```\n# gvec standard coordinates: (s, th, ze) -> (x, y, z) \n#   from (s,a1,a2)=(s,theta,zeta) in [0,1],[0,2pi],[0,2pi] to cartesian coordinates (x,y,z)\ngvec.mapping = 'gvec'\n\n# gvec straight-field-line mapping (PEST) (s, theta*, zeta*) -> (x, y, z) \n#   from (s,a1,a2)=(s,theta*,zeta*) in [0,1],[0,2pi],[0,2pi] to cartesian coordinates (x,y,z)\ngvec.mapping = 'pest'\n\n# gvec with unit cube as logical domain  (s, u, v) -> (x,y,z)\n#   from (s,a1,a2)=(s,u,v) in [0,1],[0,1],[0,1] to cartesian coordinates (x,y,z)\ngvec.mapping = 'unit'\n\n# gvec straight-field-line (PEST)  with unit cube as logical domain  (s, u*, v*) -> (x,y,z)\n#   from (s,a1,a2)=(s,u*,v*) in [0,1],[0,1],[0,1] to cartesian coordinates (x,y,z)\ngvec.mapping = 'unit_pest'\n\n# gvec without hmap (s,th,ze) -> (X1,X2,zeta) \n#   from (s,a1,a2)=(s,theta,zeta) in [0,1],[0,2pi],[0,2pi] to GVECs internal coordinates (X1,X2,zeta)\n#   if default torus (hmap=1) is used in GVEC, then (R,Z,phi)=(X1,X2,-zeta)\ngvec.mapping = 'wo_hmap'\n```\n\n![](notebooks/dtheta.png)\n![](notebooks/det_df.png)\n\nThe MHD quantities are called via\n```\ngvec.p0(s, a1, a2)      # pressure as 0-form\ngvec.p3(s, a1, a2)      # pressure as 3-form\n\ngvec.bv(s, a1, a2)      # contra-variant B-field\ngvec.b1(s, a1, a2)      # co-variant B-field (1-form)\ngvec.b2(s, a1, a2)      # 2-form B-field\ngvec.b_cart(s, a1, a2)  # Cartesian B-field\n\ngvec.av(s, a1, a2)      # contra-variant vector potential\ngvec.a1(s, a1, a2)      # co-variant vector potential (1-form)\ngvec.a2(s, a1, a2)      # 2-form vector potential\ngvec.a_cart(s, a1, a2)  # Cartesian vector potential\n\ngvec.jv(s, a1, a2)      # contra-variant current \ngvec.j1(s, a1, a2)      # co-variant current (1-form)\ngvec.j2(s, a1, a2)      # 2-form current\ngvec.j_cart(s, a1, a2)  # Cartesian current\n```\n\n![](notebooks/pressure.png)\n\n![](notebooks/absB.png)\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "Copyright 2021 (c) T.K. Cheng, F. Hindenlang, S. Possanner | Max Planck Institute for Plasma Physics  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Parse GVEC output in Python",
    "version": "1.2.2",
    "project_urls": {
        "Bug Tracker": "https://gitlab.mpcdf.mpg.de/gvec-group/gvec_to_python/-/issues",
        "repository": "https://gitlab.mpcdf.mpg.de/gvec-group/gvec_to_python"
    },
    "split_keywords": [
        "plasma physics",
        " fusion",
        " numerical modeling",
        " mhd equilibrium"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c9c9da0b649470a514db1c8f5df9c8020369c8aee83d434d0568a47277fe6c9",
                "md5": "c3e4b51e1d5c7c624de55339dc2741ff",
                "sha256": "3b18be45a1ebf5758f8e8f1957bb47d71a81c367817510b7abd05147290f2d73"
            },
            "downloads": -1,
            "filename": "gvec_to_python-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c3e4b51e1d5c7c624de55339dc2741ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 241851,
            "upload_time": "2024-04-09T15:48:45",
            "upload_time_iso_8601": "2024-04-09T15:48:45.617197Z",
            "url": "https://files.pythonhosted.org/packages/1c/9c/9da0b649470a514db1c8f5df9c8020369c8aee83d434d0568a47277fe6c9/gvec_to_python-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f8cfc321b2ceb0909e15936f2e494e7ed27d27fe67892aa14de8337271451ed9",
                "md5": "50100d844f8e173b0d7bbb73eae2d0ce",
                "sha256": "b90bcb4670acdc340228f85b2dd22889a0d1a039f43f516ed4e826a8b5ab0060"
            },
            "downloads": -1,
            "filename": "gvec-to-python-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "50100d844f8e173b0d7bbb73eae2d0ce",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 235645,
            "upload_time": "2024-04-09T15:48:47",
            "upload_time_iso_8601": "2024-04-09T15:48:47.651672Z",
            "url": "https://files.pythonhosted.org/packages/f8/cf/c321b2ceb0909e15936f2e494e7ed27d27fe67892aa14de8337271451ed9/gvec-to-python-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-09 15:48:47",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gvec-to-python"
}
        
Elapsed time: 0.21777s