diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24541b8ce762b67a869dca57d2dc90d1e1786cb5..c9164e8ab4ba7603cbe2f4aaaf61af16b0e59054 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,11 +15,10 @@ default: reports: coverage_report: coverage_format: cobertura - path: coverage/cobertura-coverage.xml + path: coverage.xml paths: - logs/execution.log - dist/* - - public # Sphinx autodoc. after_script: # Global `after_script`. - tree -I 'ipp-env' # Print directory structure, but exclude virtual environment directory. @@ -45,7 +44,7 @@ install_and_test: # - apt-get -qq insall -y texlive-latex-recommended texlive-fonts-recommended tex-gyre texlive-latex-extra latexmk texlive-lang-cyrillic texlive-lang-greek cm-super texlive-xetex texlive-luatex fonts-freefont-otf xindy graphviz - python -m venv ipp-env - source ipp-env/bin/activate - - pip install -U pip build wheel pytest coverage + - pip install -U pip build wheel pytest pytest-cov coverage # - pip install -r requirements.txt # Print directory structure, but exclude virtual environment directory. @@ -58,7 +57,7 @@ install_and_test: - python -m build - ls -lah dist - echo "Install dist:" - - pip install -U dist/gvec_to_python-*.whl # --force-reinstall + - pip install -U dist/gvec_to_python-*.whl --force-reinstall # compile - pip show gvec_to_python @@ -69,7 +68,6 @@ install_and_test: - coverage run -m pytest - coverage xml - coverage report --skip-empty - - coverage erase # Deploy: run deploy. - echo "Run deploy:" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..28e48116d0f2dae4521fafd4b6bf578b9b1119ca --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,8 @@ +## Max Planck Institute for Plasma Physics + +* Florian Hindenlang +* Stefan Possanner + +## TU Munich + +* Tin Kei Cheng diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..29ce171c7f179856e6f0e8ef708c8fced6fcd7d8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +Copyright 2023 (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. + diff --git a/README.md b/README.md index d3c40df917aec14f82428fc66561ebea904a5a1a..42b282f80a4b974bf1c1f51fded5f7865c795205 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,17 @@ # 3D GVEC equilibria in Python -Install: +PyPI install (not yet :-): ``` pip install gvec_to_python ``` -Compile kernels (for fast evaluations): +Or from source: +``` +git clone git@gitlab.mpcdf.mpg.de:spossann/gvec_to_python.git +cd gvec_to_python +pip install -e . +``` +Compile kernels for faster evaluations: ``` compile_gvec_to_python ``` @@ -22,7 +28,7 @@ In a second step, callables of MHD equilibrium quantities are created as methods ``` from gvec_to_python import GVEC -gvec = GVEC(json_file_out) +gvec = GVEC(json_file_out, mapping='gvec', use_nfp=False, use_pyccel=False) ``` Profiles can be evaluated via ``` @@ -31,6 +37,8 @@ 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 ``` + + The mapping and metric coefficients are called via ``` gvec.f(s, a1, a2) # mapping @@ -41,7 +49,11 @@ gvec.g(s, a1, a2) # metric tensor gvec.g_inv(s, a1, a2) # inverse metric tensor ``` Here, `s` is the radial coordinate, `a1` is the poloidal angle and `a2` denotes the toroidal angle. -Four different mappings can be invoked by the `mapping.setter`: + + + + +Five different mappings can be invoked by the `mapping.setter`: ``` # gvec standard coordinates gvec.mapping = 'gvec' @@ -54,7 +66,14 @@ gvec.mapping = 'unit' # gvec straight-field-line with unit cube as logical domain gvec.mapping = 'unit_pest' + +# gvec without hmap +gvec.mapping = 'wo_hmap' ``` + + + + The MHD quantities are called via ``` gvec.p0(s, a1, a2) # pressure as 0-form @@ -68,8 +87,11 @@ 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 ``` -See the notebook `notebooks/plt_mhd_equil.ipynb` for example plots like this one: - + + + + + diff --git a/build_and_test.sh b/build_and_test.sh deleted file mode 100755 index 8af68dcb54886b2fadac07a11d593e39459fce9e..0000000000000000000000000000000000000000 --- a/build_and_test.sh +++ /dev/null @@ -1,31 +0,0 @@ -# This script is similar to the pipeline in GitLab CI `.gitlab-ci.yml` file. - -# Docs: Make sphinx docs. -echo "Make sphinx docs:" -sphinx-apidoc -f -o ./docs/source ./src/gvec_to_python -sphinx-build -b html ./docs/source ./public -# cd docs/ -# make latex -# make latexpdf -# cd .. - -# Build: -# echo "Run pyccel:" -# cd src/ && make flags_openmp_mhd= flags_openmp_pic=--openmp && cd .. -echo "Run python build:" -python -m build -ls -lah dist -echo "Install dist:" -pip install -U dist/gvec_to_python-*.whl # --force-reinstall - -# Test: run pytest. -echo "Run pytest:" -coverage run -m pytest -coverage xml -coverage report --skip-empty -coverage erase -python test/cleanup.py - -# Deploy: run deploy. -echo "Run deploy:" -echo "Release pipeline not implemented." diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index d0c3cbf1020d5c292abdedf27627c6abe25e2293..0000000000000000000000000000000000000000 --- a/docs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index 6fcf05b4b76f8b9774c317ac8ada402f8a7087de..0000000000000000000000000000000000000000 --- a/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://www.sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/docs/source/_static/css/my_theme.css b/docs/source/_static/css/my_theme.css deleted file mode 100644 index 8aa6c288f61f3d5df3dbc4feeefb21eba4ecda31..0000000000000000000000000000000000000000 --- a/docs/source/_static/css/my_theme.css +++ /dev/null @@ -1,3 +0,0 @@ -.wy-nav-content { - max-width: 1200px !important; -} diff --git a/docs/source/conf.py b/docs/source/conf.py deleted file mode 100644 index d43334890c1c111f7cba2ad09327e6ccf89b2c29..0000000000000000000000000000000000000000 --- a/docs/source/conf.py +++ /dev/null @@ -1,84 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys -# sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath(os.path.join('..', '..', 'src'))) - -import sphinx_rtd_theme - - -# -- Project information ----------------------------------------------------- - -project = 'Python Interface for GVEC Equilibria' -copyright = '2021, Max Planck Institute for Plasma Physic' -author = 'Tin Kei CHENG' - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.duration', # https://www.sphinx-doc.org/en/master/usage/extensions/duration.html - 'sphinx.ext.napoleon', # https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html - 'sphinx.ext.autodoc', # https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html - 'sphinx.ext.mathjax', # https://www.sphinx-doc.org/en/master/usage/extensions/math.html - 'sphinx.ext.viewcode', # https://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html - 'sphinx.ext.graphviz', # https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html - 'sphinx.ext.inheritance_diagram', # https://www.sphinx-doc.org/en/master/usage/extensions/inheritance.html - 'sphinx_rtd_theme', # https://sphinx-rtd-theme.readthedocs.io/en/stable/index.html -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = [] - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -# html_theme = 'alabaster' -html_theme = 'sphinx_rtd_theme' - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# These paths are either relative to html_static_path -# or fully qualified paths (eg. https://...) -html_css_files = [ - 'css/my_theme.css', -] - - -# -- Options for LaTeX output ------------------------------------------------ - -# https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder -# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-latex-output -latex_engine = 'xelatex' diff --git a/docs/source/index.rst b/docs/source/index.rst deleted file mode 100644 index 8c64f3129efb8679ab298137a866ccdbd9cd8d35..0000000000000000000000000000000000000000 --- a/docs/source/index.rst +++ /dev/null @@ -1,99 +0,0 @@ -.. Python Interface for GVEC Equilibria documentation master file, created by - sphinx-quickstart on Thu Nov 4 11:55:49 2021. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to Python Interface for GVEC Equilibria's documentation! -================================================================ - -`STRUcture-Preserving HYbrid code (STRUPHY) <https://gitlab.mpcdf.mpg.de/clapp/hylife>`_ is a code base for kinetic-fluid plasma simulations developed at the `Max Planck Institute for Plasma Physics in Garching <https://www.ipp.mpg.de/17301/garching>`_. -In this package we add to STRUPHY several general Python interfaces for reading magneto-hydrodynamic (MHD) equilibrium data for Tokamaks and Stellarators. -In particular, interfaces to the equilibrium code `Galerkin Variational Equilibrium Code (GVEC) <https://gitlab.mpcdf.mpg.de/gvec-group/gvec>`_ (and in the future, to the ``eqdsk`` file format) are provided. -From the data, a flux-aligned coordinate system is created, and the MHD quantities are transformed into differential forms for the use in STRUPHY. - -.. toctree:: - :maxdepth: 3 - :caption: Contents: - - modules - -.. - Below is a comment. - .. inheritance-diagram:: gvec_to_python.GVEC_functions.GVEC - - -How to use -========== - -First and foremost, one need to setup the package. -It can be accomplished as simple as a ``pip install -e ./``. - -.. - See Section "Build and install" below for detailed instructions. - -This code needs to read in a GVEC MHD equilibrium in JSON format. -Therefore, the `.dat` GVEC output data has to be converted into ``.json`` using a utility as demonstrated below. -This only needs to be done once, per GVEC equilibrium. - -.. code-block:: python - - from gvec_to_python.reader.gvec_reader import GVEC_Reader - - # Spline coefficients are not provided by GVEC by default. - read_filepath = 'GVEC/testcases/circ_tok/' - read_filename = 'CIRC_TOK_State_0000_00010000.dat' - save_filepath = 'GVEC/testcases/circ_tok/' - save_filename = 'CIRC_TOK_State_0000_00010000.json' - reader = GVEC_Reader(read_filepath, read_filename, save_filepath, save_filename, with_spl_coef=False) - - # Special case with spline coefficients. - read_filepath = 'GVEC/testcases/ellipstell/' - read_filename = 'GVEC_ellipStell_profile_update_State_0000_00010000.dat' - save_filepath = 'GVEC/testcases/ellipstell/' - save_filename = 'GVEC_ellipStell_profile_update_State_0000_00010000.json' - reader = GVEC_Reader(read_filepath, read_filename, save_filepath, save_filename, with_spl_coef=True) - -The main features can then be used simply as follows: - -.. code-block:: python - :emphasize-lines: 6,24,25,26,27,28 - - import numpy as np - from gvec_to_python import GVEC, Form, Variable - - gvec_data_filepath = 'GVEC/testcases/ellipstell/' - gvec_data_filename = 'GVEC_ellipStell_profile_update_State_0000_00010000.json' - gvec = GVEC(gvec_data_filepath, gvec_data_filename) - - # The functions can accept various types of inputs: - # - Individual point in logical coordinates. - (s, u, v) = (0.1, 0.2, 0.3) - # - 1D arrays of a grid. - s_range = np.linspace(0, 1, 11) - u_range = np.linspace(0, 1, 21) - v_range = np.linspace(0, 1, 31) - # - A sparse 3D meshgrid. - s_sparse, u_sparse, v_sparse = np.meshgrid(s_range, u_range, v_range, indexing='ij', sparse=True) - # - A dense 3D meshgrid. - s_dense, u_dense, v_dense = np.meshgrid(s_range, u_range, v_range, indexing='ij', sparse=False) - - # Function parameters can either be floats gvec.F(s, u, v), - # or 1D arrays gvec.F(s_range, u_range, v_range), - # or 3D arrays from sparse meshgrid gvec.F(s_sparse, u_sparse, v_sparse), - # or dense meshgrid gvec.F(s_dense, u_dense, v_dense). - (x, y, z) = gvec.F(s, u, v) - jacobian = gvec.DF(s, u, v) - pressure = gvec.get_variable(s, u, v, variable=Variable.PRESSURE, form=Form.ZERO) - pressure = gvec.P(s, u, v) # Alternatively, a shorthand is available. - p_3 = gvec.P_3(s, u, v) # 3-form pressure. - -Caveat: The mapping function ``F()`` returns in the shape ``(3, #s, #u, #v)`` so that we can do ``(x, y, z) = gvec.F(s, u, v)``, but the Jacobian function ``DF()`` returns in the shape ``(#s, #u, #v, 3, 3)`` in order to comply with numpy's convention. - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/literature/.gitkeep b/literature/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/literature/STRUPHY_Hybrid_kinetic_MHD_26062020_compressed.pdf b/literature/STRUPHY_Hybrid_kinetic_MHD_26062020_compressed.pdf deleted file mode 100644 index b734a5777ccdac5ccb09f248f56e77a1877ee521..0000000000000000000000000000000000000000 Binary files a/literature/STRUPHY_Hybrid_kinetic_MHD_26062020_compressed.pdf and /dev/null differ diff --git a/logs/.gitignore b/logs/.gitignore deleted file mode 100644 index 86d0cb2726c6c7c179b99520c452dd1b68e7a813..0000000000000000000000000000000000000000 --- a/logs/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore \ No newline at end of file diff --git a/notebooks/absB.png b/notebooks/absB.png new file mode 100644 index 0000000000000000000000000000000000000000..420272608dcede82b4f65f75f70bc3336b322400 Binary files /dev/null and b/notebooks/absB.png differ diff --git a/notebooks/det_df.png b/notebooks/det_df.png new file mode 100644 index 0000000000000000000000000000000000000000..c70e52027764ea7166cc2e51fc0b4dc820ac0861 Binary files /dev/null and b/notebooks/det_df.png differ diff --git a/notebooks/dtheta.png b/notebooks/dtheta.png new file mode 100644 index 0000000000000000000000000000000000000000..9390efbfeeaee7b60597ac9fcbf60effe321c864 Binary files /dev/null and b/notebooks/dtheta.png differ diff --git a/notebooks/plot_mhd_equil.ipynb b/notebooks/plot_mhd_equil.ipynb index 8ae96e5265e1a68509676b640a4499a688bb32e3..47e47953a1e0398732b911a8c6a3a2ad562b4cb5 100644 --- a/notebooks/plot_mhd_equil.ipynb +++ b/notebooks/plot_mhd_equil.ipynb @@ -28,7 +28,7 @@ "create_GVEC_json(dat_file_in, json_file_out, with_spl_coef=False)\n", "\n", "# main object (one without, the other one with pyccel kernels)\n", - "gvec = GVEC(json_file_out, use_nfp=True)" + "gvec = GVEC(json_file_out, use_nfp=False)" ] }, { @@ -92,7 +92,7 @@ "source": [ "gvec.mapping = 'unit' # use the mapping setter\n", "\n", - "n_planes = 7 \n", + "n_planes = 4 \n", "s = np.linspace(0, 1, 20) # radial coordinate in [0, 1]\n", "u = np.linspace(0, 1, 49) # poloidal angle in [0, 1]\n", "v = np.linspace(0, 1, n_planes) # toroidal angle in [0, 1]\n", @@ -349,46 +349,11 @@ " ax.set_title('Theta derivative of mapping at $\\\\phi$={0:4.1f} $\\pi$'.format(v[n] * 2 / gvec.domain.nfp))\n", " #fig.colorbar(map, ax=ax, location='right')" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3.8.10 ('genv': venv)", "language": "python", "name": "python3" }, @@ -406,7 +371,7 @@ }, "vscode": { "interpreter": { - "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" + "hash": "2e3dd3b8aae930b0cf67aaa55aa23c15417e1d1f27cc215887027ec35573dcf8" } } }, diff --git a/notebooks/poloidal.png b/notebooks/poloidal.png new file mode 100644 index 0000000000000000000000000000000000000000..5c33a4552dcf5468c9cf7e6751343a9afe3decf5 Binary files /dev/null and b/notebooks/poloidal.png differ diff --git a/notebooks/pressure.png b/notebooks/pressure.png new file mode 100644 index 0000000000000000000000000000000000000000..62cc3bd1932e926a99e4d87a58adb354b2a8845f Binary files /dev/null and b/notebooks/pressure.png differ diff --git a/notebooks/profiles.png b/notebooks/profiles.png new file mode 100644 index 0000000000000000000000000000000000000000..167c0fe902039ed6c82973ec875020be824c26b4 Binary files /dev/null and b/notebooks/profiles.png differ diff --git a/notebooks/topview.png b/notebooks/topview.png new file mode 100644 index 0000000000000000000000000000000000000000..84b0536d438db2b21ec4e411e356b1b0749f9a1d Binary files /dev/null and b/notebooks/topview.png differ diff --git a/poloidal_grid.png b/poloidal_grid.png deleted file mode 100644 index edb94ec3fbaf2079ac62c0ed5db4db57fcf2c3a8..0000000000000000000000000000000000000000 Binary files a/poloidal_grid.png and /dev/null differ diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1221ad0efb363c7c361c4526cc5d0756172ac65a..0000000000000000000000000000000000000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -matplotlib>=3.3.3 -numpy>=1.19.5 -pandas>=1.2.1 -scipy>=1.6.0 -sphinx>=4.2.0 -sphinx_rtd_theme>=1.0.0 -tqdm>=4.56.0 -vtk>=9.0.3 diff --git a/src/gvec_to_python/GVEC_functions.py b/src/gvec_to_python/GVEC_functions.py index 0064be1044ae3e72c9801411abce3d1cae85d1a8..263587f7900b01e2b843b99338e7cf199b1767f0 100644 --- a/src/gvec_to_python/GVEC_functions.py +++ b/src/gvec_to_python/GVEC_functions.py @@ -35,7 +35,7 @@ class GVEC: The absolute path to the .json file created by GVEC_Reader. mapping : str - Which mapping to use: "gvec", "pest", "unit", "unit_pest" or "rzphi" (see GVEC_domain class). + Which mapping to use: "gvec", "pest", "unit", "unit_pest" or "wo_hmap" (see GVEC_domain class). Can be changed later using the setter. use_nfp : bool @@ -98,7 +98,7 @@ class GVEC: sgrid, degree, spos_grev, phi_grev, chi_grev, iota_grev, pres_grev) # use the mapping setter - assert mapping in {'gvec', 'pest', 'unit', 'unit_pest'} + assert mapping in {'gvec', 'pest', 'unit', 'unit_pest', 'wo_hmap'} self.mapping = mapping # Expose other metadata @@ -127,7 +127,7 @@ class GVEC: @property def mapping(self): - '''Which mapping to use: "gvec", "pest", "unit", "unit_pest" or "rzphi" (see GVEC_domain class).''' + '''Which mapping to use: "gvec", "pest", "unit", "unit_pest" or "wo_hmap" (see GVEC_domain class).''' return self._mapping @mapping.setter @@ -143,7 +143,7 @@ class GVEC: self._g_inv = getattr(self.domain, 'g_' + mapping + '_inv') # for transformations of a1_gvec and bv_gvec to other logical coordinates than "gvec" - if mapping in {'gvec', 'rzphi'}: + if mapping in {'gvec', 'wo_hmap'}: self.l = None self.dl = None self.dl_inv = None diff --git a/src/gvec_to_python/geometry/domain.py b/src/gvec_to_python/geometry/domain.py index 854f2707b90cacae764f1f9aa5bc61015af96c12..392e517f12680def945ebc936f0036012718cc0e 100644 --- a/src/gvec_to_python/geometry/domain.py +++ b/src/gvec_to_python/geometry/domain.py @@ -23,7 +23,7 @@ class GVEC_domain: There is also a fifth mapping to R-Z-phi coordinates: - 5. f_rzphi: (s, th, ze) -> (q1, q2, ze) ... Mapping to R-Z-phi coordinates + 5. f_wo_hmap: (s, th, ze) -> (q1, q2, ze) ... Mapping to R-Z-phi coordinates All five mappings have a polar singulatiry at s=0 (resp. s2=0). The mappings are compositions of sub-functions: @@ -31,7 +31,7 @@ class GVEC_domain: f_pest = f_gvec ° P f_unit = f_gvec ° L f_unit_pest = f_pest ° L - f_rzphi = X + f_wo_hmap = X where @@ -568,8 +568,8 @@ class GVEC_domain: return np.linalg.inv(self.g_unit_pest(s, u, v)) # R-Z-phi coordinates - def f_rzphi(self, s, th, ze): - '''The map f_rzphi:(s, th, ze) -> (q1, q2, ze), where (s, th, ze) in [0, 1] x [0, 2*pi]^2 and (q1, q2, ze) R-Z-phi coordinates. + def f_wo_hmap(self, s, th, ze): + '''The map f_wo_hmap:(s, th, ze) -> (q1, q2, ze), where (s, th, ze) in [0, 1] x [0, 2*pi]^2 and (q1, q2, ze) R-Z-phi coordinates. Parameters ---------- @@ -582,8 +582,8 @@ class GVEC_domain: ''' return self.Xmap(s, th, ze) - def df_rzphi(self, s, th, ze): - '''The Jacobian matrix of f_rzphi. + def df_wo_hmap(self, s, th, ze): + '''The Jacobian matrix of f_wo_hmap. Parameters ---------- @@ -597,8 +597,8 @@ class GVEC_domain: ''' return self.dX(s, th, ze) - def det_df_rzphi(self, s, th, ze): - '''The Jacobian determinant of f_rzphi. + def det_df_wo_hmap(self, s, th, ze): + '''The Jacobian determinant of f_wo_hmap. Parameters ---------- @@ -611,8 +611,8 @@ class GVEC_domain: ''' return self.det_dX(s, th, ze) - def df_rzphi_inv(self, s, th, ze): - '''The inverse Jacobian matrix of f_rzphi. + def df_wo_hmap_inv(self, s, th, ze): + '''The inverse Jacobian matrix of f_wo_hmap. Parameters ---------- @@ -623,10 +623,10 @@ class GVEC_domain: ------- A 2d numpy array (single-point evaluation) or a 5d numpy array (meshgrid evaluation).''' - return np.linalg.inv(self.df_rzphi(s, th, ze)) + return np.linalg.inv(self.df_wo_hmap(s, th, ze)) - def g_rzphi(self, s, th, ze): - '''The metric tensor of f_rzphi. + def g_wo_hmap(self, s, th, ze): + '''The metric tensor of f_wo_hmap. Parameters ---------- @@ -637,7 +637,7 @@ class GVEC_domain: ------- A 2d numpy array (single-point evaluation) or a 5d numpy array (meshgrid evaluation).''' - tmp = np.ascontiguousarray(self.df_rzphi(s, th, ze)) # Jacobian of f_rzphi + tmp = np.ascontiguousarray(self.df_wo_hmap(s, th, ze)) # Jacobian of f_wo_hmap # meshgrid evaluation if tmp.ndim == 5: @@ -648,8 +648,8 @@ class GVEC_domain: return out - def g_rzphi_inv(self, s, th, ze): - '''Inverse metric tensor of f_rzphi. + def g_wo_hmap_inv(self, s, th, ze): + '''Inverse metric tensor of f_wo_hmap. Parameters ---------- @@ -660,7 +660,7 @@ class GVEC_domain: ------- A 2d numpy array (single-point evaluation) or a 5d numpy array (meshgrid evaluation).''' - return np.linalg.inv(self.g_rzphi(s, th, ze)) + return np.linalg.inv(self.g_wo_hmap(s, th, ze)) # --------------- diff --git a/tests/test_gvec_domain.py b/tests/test_gvec_domain.py index 48e99c9e32b6a1d1eb3b2bd4210f5bddea17c728..fe7cc93281f97c31b9e2bdaeaed109e62afa6544 100644 --- a/tests/test_gvec_domain.py +++ b/tests/test_gvec_domain.py @@ -1,6 +1,6 @@ import pytest -@pytest.mark.parametrize('mapping', ['gvec', 'pest', 'unit', 'unit_pest']) +@pytest.mark.parametrize('mapping', ['gvec', 'pest', 'unit', 'unit_pest', 'wo_hmap']) @pytest.mark.parametrize('use_pyccel', [False, True]) def test_output_formats(mapping, use_pyccel): '''Test whether the return of mapping evaluations has the correct type/dimension.''' diff --git a/tests/test_gvec_equil.py b/tests/test_gvec_equil.py index 4c8cd9e4235823c49ee00bf1d4518e9ef4d51f44..951fd3ddffcdfc95f5c62911180009075a40013a 100644 --- a/tests/test_gvec_equil.py +++ b/tests/test_gvec_equil.py @@ -1,6 +1,6 @@ import pytest -@pytest.mark.parametrize('mapping', ['gvec', 'pest', 'unit', 'unit_pest']) +@pytest.mark.parametrize('mapping', ['gvec', 'pest', 'unit', 'unit_pest', 'wo_hmap']) @pytest.mark.parametrize('use_pyccel', [False, True]) def test_mhd_fields(mapping, use_pyccel): '''Test whether the return of mhd field evaluations has the correct type/dimension.'''