{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Typical plasma parameters\n", "===" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Using the experimental result measured by the langmuir probe, electron density and temperature has been specified at 2 points. Considering both experimental and equilibrium data calculated by TSC (Tokamak Simulation Code) has enabled us to obtain their 2-D profiles." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from matplotlib import pyplot as plt\n", "from matplotlib.ticker import ScalarFormatter\n", "from raysect.optical import World\n", "\n", "from cherab.core.math import sample3d\n", "from cherab.phix.plasma import import_plasma\n", "from cherab.phix.plasma.species import PHiXSpecies\n", "from cherab.phix.tools.raytransfer import import_phix_rtc\n", "from cherab.phix.tools.visualize import show_phix_profiles\n", "\n", "plt.rcParams[\"figure.dpi\"] = 150\n", "world = World()\n", "plasma, eq = import_plasma(world)\n", "species = PHiXSpecies(equilibrium=eq)\n", "rtc = import_phix_rtc(world, equilibrium=eq)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dr = rtc.material.dr\n", "dz = rtc.material.dz\n", "nr = rtc.material.grid_shape[0]\n", "nz = rtc.material.grid_shape[2]\n", "rmin = rtc.material.rmin\n", "zmin = rtc.transform[2, 3]\n", "rmax = rmin + dr * nr\n", "zmax = zmin + dz * nz" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting the plasma parameters distribution in 1D vs $\\psi_\\text{normalized}$ and 2D $r-z$ space\n", "---" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Plasma parameters ($n_\\text{e}, T_\\text{e}$) is assumed to distribute as quadratic function along to $\\psi$.\n", "For instance, $n_\\text{e}$ represents as follows:\n", "\n", "$$\n", "n_e = (n_{\\min} - n_{\\max}) \\psi^2 + n_{\\min}\n", "$$\n", "\n", "The values of $n_{\\min}$ and $n_{\\max}$ are used as an experimental data measured by the langmuir probe which locates both near magnetic axis and LCFS." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "jupyter": { "source_hidden": true } }, "outputs": [], "source": [ "x = np.linspace(0, 1, 100)\n", "y = [species.temp1d(i) for i in x]\n", "plt.plot(x, y)\n", "plt.xlabel(\"Normalized Psi\")\n", "plt.ylabel(\"$T_e$ [eV]\")\n", "plt.xlim([0, 1])\n", "plt.annotate(f\"{y[0]}eV\", (x[0], y[0]), (0.1, 35), arrowprops=dict())\n", "plt.annotate(f\"{y[-1]}eV\", (x[-1], y[-1]), (0.7, 20), arrowprops=dict());" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = np.linspace(0, 1, 100)\n", "y = [species.dens1d(i) for i in x]\n", "fig, ax = plt.subplots()\n", "ax.plot(x, y)\n", "ax.yaxis.set_major_formatter(ScalarFormatter(useMathText=True))\n", "ax.set_xlabel(\"Normalized Psi\")\n", "ax.set_ylabel(\"$n_e$ [m$^{-3}$]\")\n", "ax.set_xlim([0, 1])\n", "plt.annotate(f\"{y[0]}\", (x[0], y[0]), (0.1, 4e18), arrowprops=dict())\n", "plt.annotate(f\"{y[-1]}\", (x[-1], y[-1]), (0.7, 1e18), arrowprops=dict());" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "nbsphinx-thumbnail" ] }, "outputs": [], "source": [ "r, _, z, ne_samples = sample3d(\n", " plasma.electron_distribution.density, (rmin, rmax, nr), (0, 0, 1), (zmin, zmax, nz)\n", ")\n", "show_phix_profiles(\n", " ne_samples.squeeze(),\n", " clabel=\"$n_e$ [m$^{-3}$]\",\n", " cmap=\"viridis\",\n", " scientific_notation=True,\n", " rtc=rtc,\n", ");" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "r, _, z, te_samples = sample3d(\n", " plasma.electron_distribution.effective_temperature,\n", " (rmin, rmax, nr),\n", " (0, 0, 1),\n", " (zmin, zmax, nz),\n", ")\n", "show_phix_profiles(te_samples.squeeze(), clabel=\"$T_e$ [eV]\", cmap=\"viridis\", rtc=rtc);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Density Profile along R axis on the equatorial plane.\n", "---" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "r, _, z, t_samples = sample3d(\n", " plasma.electron_distribution.density,\n", " (rmin, rmax, nr),\n", " (0, 0, 1),\n", " (eq.magnetic_axis.y, eq.magnetic_axis.y, 1),\n", ")\n", "fig, ax = plt.subplots()\n", "ax.plot(r, t_samples.ravel())\n", "ax.yaxis.set_major_formatter(ScalarFormatter(useMathText=True))\n", "plt.xlabel(\"$R$[m]\")\n", "plt.ylabel(\"$n_e$ [m$^{-3}$]\")\n", "plt.xlim([0.2, 0.5])\n", "plt.ylim([0, 5e18]);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Q profile as a function of $\\psi_\\text{normalized}$\n", "---" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = np.linspace(0, 0.96, 100)\n", "y = [eq.q(i) for i in x]\n", "plt.plot(x, y)\n", "plt.xlabel(\"Normalized Psi\")\n", "plt.ylabel(\"$q$\")\n", "plt.xlim([0, 1]);" ] } ], "metadata": { "celltoolbar": "Tags", "kernelspec": { "display_name": "cherab-phix-dev", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.15" }, "vscode": { "interpreter": { "hash": "2725905a4c02db19e04df9b8fdbbe5ec65a73ea52bebaf9474aa1cc98819834c" } } }, "nbformat": 4, "nbformat_minor": 4 }