From 38a8edd439b794bdbb30ead6060c4b0e3befbeef Mon Sep 17 00:00:00 2001 From: Michele Guerini Rocco Date: Thu, 8 Feb 2024 17:37:17 +0100 Subject: [PATCH] doc: reorganize example input files --- Makefile | 28 +- doc/man/beamdata.txt.5.md | 122 +++++++ doc/{ => man}/gray.1 | 8 +- doc/man/gray.ini.5.md | 312 ++++++++++++++++++ .../man/gray_params.data.5.md | 0 doc/man/magneticdata.txt.5.md | 86 +++++ doc/man/profiles.txt.5.md | 63 ++++ input/beam.data | 3 - input/equil_a.txt | 8 - input/gray.ini | 187 ----------- input/profil_a.txt | 3 - src/beams.f90 | 49 +-- 12 files changed, 625 insertions(+), 244 deletions(-) create mode 100644 doc/man/beamdata.txt.5.md rename doc/{ => man}/gray.1 (87%) create mode 100644 doc/man/gray.ini.5.md rename input/gray_params.data => doc/man/gray_params.data.5.md (100%) create mode 100644 doc/man/magneticdata.txt.5.md create mode 100644 doc/man/profiles.txt.5.md delete mode 100644 input/beam.data delete mode 100644 input/equil_a.txt delete mode 100644 input/gray.ini delete mode 100644 input/profil_a.txt diff --git a/Makefile b/Makefile index e569e18..6f53af7 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,7 @@ GRAY = $(BINDIR)/gray LIBGRAY = $(LIBDIR)/libgray.so BINARIES = $(GRAY) LIBRARIES = $(LIBGRAY) +MANPAGES = $(addprefix $(SHAREDIR)/,gray.1 gray.ini.5 profiles.txt.5 beamdata.txt.5 magneticdata.txt.5) ## ## Git information (used in the version string) @@ -60,6 +61,13 @@ GIT_REV ?= $(shell git rev-parse --short HEAD) # Whether the worktree and the latest commit differs GIT_DIRTY ?= $(shell test -n "$$(git status --porcelain)" && echo "-dirty") +# Source date +ifndef SOURCE_DATE_EPOCH +# Use current date +SOURCE_DATE_EPOCH=$(shell awk 'BEGIN {print srand(srand())}') +endif +DATE=$(shell LC_TIME=C date -d @$(SOURCE_DATE_EPOCH) '+%B %Y') + ## ## Fortran compiler and flags ## @@ -119,13 +127,14 @@ check: $(GRAY) python -Bm tests --binary $^ # Install libraries, binaries and documentation -install: $(BINARIES) $(LIBRARIES) $(SHAREDIR)/doc $(SHAREDIR)/gray.1 - mkdir -p $(PREFIX)/{bin,lib,share/{doc/res,man/man1}} +install: $(BINARIES) $(LIBRARIES) $(SHAREDIR)/doc $(MANPAGES) + mkdir -p $(PREFIX)/{bin,lib,share/{doc/res,man/man{1,5}}} install -m555 -t $(PREFIX)/bin $(BINDIR)/* install -m555 -t $(PREFIX)/lib $(LIBDIR)/* install -m644 -t $(PREFIX)/share/doc $(SHAREDIR)/doc/manual.* install -m644 -t $(PREFIX)/share/doc/res $(SHAREDIR)/doc/res/* - install -m644 -t $(PREFIX)/share/man/man1 $(SHAREDIR)/gray.1 + install -m644 -t $(PREFIX)/share/man/man1 $(SHAREDIR)/*.1 + install -m644 -t $(PREFIX)/share/man/man5 $(SHAREDIR)/*.5 # dependencies $(OBJDIR)/%.o: $(OBJDIR)/%.d @@ -149,15 +158,22 @@ $(JLIBDIR)/libgray.a: $(LIBDIR)/libgray.a install -m755 '$<' '$@' # All documentation -docs: $(SHAREDIR)/gray.1 $(SHAREDIR)/doc +docs: $(SHAREDIR)/doc $(MANPAGES) $(SHAREDIR)/doc: | $(SHAREDIR) +make -C doc cp -r doc/build/* $(SHAREDIR) # Generated man pages -$(SHAREDIR)/gray.1: $(GRAY) doc/gray.1 | $(SHAREDIR) - help2man '$<' -i doc/gray.1 -N -n 'beam-tracing code for EC waves' > '$@' +$(SHAREDIR)/gray.1: $(GRAY) doc/man/gray.1 | $(SHAREDIR) + help2man '$<' -i doc/man/gray.1 -N -n 'beam-tracing code for EC waves' > '$@' + +$(SHAREDIR)/%: doc/man/%.md $(GRAY) | $(SHAREDIR) + pandoc -s '$<' -t man \ + -V date='$(DATE)' \ + -V footer='$(shell $(GRAY) --version | sed -n 1p)' \ + -V author='$(shell $(GRAY) --version | sed -n "3 s/.$$//p")' \ + -o '$@' # Visualise the dependency graph # Note: requires makefile2graph and graphviz diff --git a/doc/man/beamdata.txt.5.md b/doc/man/beamdata.txt.5.md new file mode 100644 index 0000000..baf7162 --- /dev/null +++ b/doc/man/beamdata.txt.5.md @@ -0,0 +1,122 @@ +--- +title: BEAMDATA.txt +section: 5 +--- + +# NAME +beamdata.txt --- beam launcher data for **gray**(1) + +# FORMAT +The beam launcher data can be provided in three ways, each with a corresponding +file format. + +## 0D format +The beam parameters are given as fixed numbers, independent of the values of +the launch angles α, β. In this case the format is as follows: + + f ! comment + x₀ y₀ z₀ + w₀₁ w₀₂ d₀₁ d₀₂ φ +where: + + - *f* is the frequency (GHz) +- *x₀, y₀, z₀* are the launcher position (cm) +- *w₀₁, w₀₂* are the beam waists in the two principal directions (cm) +- *d₀₁, d₀₂* are the distances of the beam waists from the launch point (cm) +- *φ* is the rotation angle from the horizontal direction to the first + principal direction (deg) + +Note: this case implies simple astigmatism, i.e. the amplitude and phase +ellipses in the beam transverse plane are aligned. + +## 1D format +The beam parameters, including the launch position and angles, are given as a +function of the launcher steering angle *θ* in tabular format. The data will be +interpolated by GRAY to obtain the actual beam parameters at a given pair of +launch angles. + +The format is as follows: + + f ! comment + nrows + θ α β x₀ y₀ z₀ w₁ w₂ k₁ k₂ φ_w φ_R + θ α β x₀ y₀ z₀ w₁ w₂ k₁ k₂ φ_w φ_R + ... +The first two lines contain the frequency (GHz) and the number of table rows. +The rest of the file contains the whitespace-separated records, one row per +line, where: + +- *θ* is the mechanical steering angle (unused) +- *α, β* are the poloidal and toroidal launch angles (deg) +- *x₀, y₀, z₀* are the launcher position (mm) +- *w₁, w₂* are the beam widths in the two principal directions (mm) +- *k₁, k₂* are the wavefront curvatures in the two principal directions (mm⁻¹) +- *φ_w, φ_R* are the rotation angles of the amplitude and phase + ellipses in the transverse plane at the launch point (deg) + +## 2D format +The beam parameters, including the launch position, are given as a +function of the two launch angles α, β. The format is as follows: + + nbeams + id mode f na nb + α β x₀ y₀ z₀ w₁ w₂ k₁ k₂ φ_w φ_R + α β x₀ y₀ z₀ w₁ w₂ k₁ k₂ φ_w φ_R + ... + id mode f na nb + α β x₀ y₀ z₀ w₁ w₂ k₁ k₂ φ_w φ_R + α β x₀ y₀ z₀ w₁ w₂ k₁ k₂ φ_w φ_R + ... + +The first line specifies the number of beams described by the file. +The rest of the files consists of *nbeams* 2D tables preceded by a header where: + +- *id* is a string identifier of the beam +- *mode* indicates where the beam has O-mode (*1*) or X-mode (*2*) + polarisation +- *f* is the frequency (GHz) +- *nα, nβ* are the numbers of rows and columns of the table + +The 2D table is stored in row-major order over *nα×nβ* lines, that is, the +*i,j*-th record is stored on the l-th line, with *l = i + nα×j*. +The poloidal angle *α(i,j)* must be monotonic along *i* and the toroidal angle +*β(i, j)* must be monotonic along *j*. +Each line stores one record with the same fields as in the 1D format. + +Note: even if this format allows to define multiple independent beams in the +same file, this feature is not used by **gray**(1), which always load the first +table. + +# EXAMPLES + +1. A valid 0D beamdata.txt file + + 170 ! f + 950.0 0.0 62.0 ! x₀ y₉ z₀ + 2.1 2.1 162.0 162.0 0.0 ! w₀₁ w₀₂ d₀₁ d₀₂ φ + +2. A valid 1D beamdata.txt file + + 170 ! f + 27 ! nrows + -7.5 25.93 19.75 7067.6 -41.45 4233.6 42.70 43.99 -5.899E-4 -5.363E-4 -3.15 -3.15 + -5.0 31.23 19.99 7067.8 -41.48 4233.6 42.70 43.99 -5.899E-4 -5.364E-4 -2.32 -2.32 + -2.0 37.61 20.09 7068.1 -41.51 4233.5 42.69 43.98 -5.900E-4 -5.364E-4 -1.09 -1.09 + 3.5 49.29 19.77 7068.7 -41.58 4233.2 42.67 43.97 -5.902E-4 -5.366E-4 -2.11 -2.11 + +3. A valid 2D beamdata.txt file + + 1 ! nbeams + example 1 137.6 6 2 ! id mode f nα nβ + -7.96 -12.99 4352 -161.2 907 16.46 28.67 -2.48E-05 -2.36E-03 -21.79 5.61 + 4.82 -13.18 4392 -149.4 976 15.80 26.29 -4.71E-05 -2.56E-03 -17.88 8.85 + 14.52 -13.40 4416 -138.6 1031 15.30 24.50 -1.72E-04 -2.80E-03 -14.87 11.95 + 24.86 -13.70 4438 -125.4 1091 14.92 22.66 -4.36E-04 -3.19E-03 -11.63 15.84 + 36.12 -14.12 4455 -109.2 1159 14.90 20.80 -8.64E-04 -3.81E-03 -8.29 20.21 + 48.76 -14.72 4466 -89.0 1235 15.74 18.91 -1.38E-03 -4.80E-03 -7.66 23.62 + -9.80 -6.93 4353 -132.0 904 16.71 29.36 -1.71E-04 -2.28E-03 -10.02 8.52 + 2.84 -7.14 4392 -123.8 972 16.03 26.82 -1.85E-04 -2.46E-03 -7.62 10.46 + 12.39 -7.38 4416 -116.4 1025 15.53 24.95 -3.05E-04 -2.67E-03 -5.78 12.41 + 22.50 -7.72 4437 -107.4 1084 15.13 23.06 -5.55E-04 -2.99E-03 -3.79 14.90 + 33.42 -8.18 4454 -96.5 1149 14.57 21.17 -9.75E-04 -3.51E-03 -10.43 14.82 + 45.51 -8.80 4465 -83.0 1222 15.65 19.32 -1.48E-03 -4.35E-03 0.41 20.57 diff --git a/doc/gray.1 b/doc/man/gray.1 similarity index 87% rename from doc/gray.1 rename to doc/man/gray.1 index b02a970..7f43cf2 100644 --- a/doc/gray.1 +++ b/doc/man/gray.1 @@ -4,9 +4,13 @@ must be manually specified, except the parameters file. The latter defaults to \fCgray_params.data\fR and is configured using the \fB-p\fR option. All other filepaths are relative to its parent directory. +.TP +.I gray.ini +GRAY main configuration file + .TP .I gray_params.data -Parameters file +Legacy configuration file This file allows configuring all the parameters of a GRAY simulation, including all other input files. @@ -37,4 +41,4 @@ location can be changed with the \fB-o\fR option. For a list of the unit numbers and their descriptions see the GRAY user manual. [SEE ALSO] -\fBgray_params.data\fR(5), \fBbeamdata.txt\fR(5), \fBprofiles.txt\fR(5) +\fBgray.ini\fR(5), \fBgray_params.data\fR(5), \fBbeamdata.txt\fR(5), \fBprofiles.txt\fR(5) diff --git a/doc/man/gray.ini.5.md b/doc/man/gray.ini.5.md new file mode 100644 index 0000000..e3c09c8 --- /dev/null +++ b/doc/man/gray.ini.5.md @@ -0,0 +1,312 @@ +--- +title: GRAY.INI +section: 5 +--- + +# NAME +gray.ini --- Configuration file for **gray**(1) + +# CONFIGURATION +The configuration file is written in the INI format. The basic syntax +is: + + [group] + ; comment + parameter = value + +Group is one of: *raytracing*, *ecrh_cd*, *antenna*, *equilibrium*, +*profiles*, *misc*. + +Values are valid Fortran values, including numbers (integers or floating +points), strings (enclosed in quotes), booleans (*.true.*, *.false.*) +and named constants (e.g. *MODE_X*). + +# PARAMETERS +Valid configuration parameters listed by group + +Note: parameters with a default value are optional and can be omitted. + +## raytracing +Raytracing parameters + +**nrayr** +: Number of rays in the radial direction + +**nrayth** +: Number of rays in the angular direction + +**rwmax** (default: **1.0**) +: Normalized maximum radius of the beam power + +**igrad** (default: **0**) +: Switch between simple raytracing (*0*) and beamtracing (*1*) + +**ipass** (default: **1**) +: Max number of crossing (out, in, out) of the plasma. When positive + reflections occur on the plasma limiter provided by the G-EQDSK + file; when negative on a simple limiter at R=*rwall*, see below. + +**ipol** (default: **.false.**) +: Whether to compute the wave polarisation from chi, psi (see below) + +**dst** +: Step size (cm) for the numerical integration + +**nstep** (default: **12000**) +: Max number of integration steps + +**idst** (default: **STEP_TIME**) +: Choice of the integration variable. One of: + + - *STEP_ARCLEN*, arc length (s) + - *STEP_TIME*, time (actually c⋅t) + - *STEP_PHASE*, phase (actually the real part of the eikonal S_r=k₀⋅φ) + +## ecrh_cd +ECRH and current drive parameters + +**iwarm** (default: **ABSORP_FULL**) +: Choice of the power absorption model. One of: + + - *ABSORP_OFF*, no absorption at all + - *ABSORP_WEAK*, weakly relativistic + - *ABSORP_FULL*, fully relativistic (faster variant) + - *ABSORP_FULL_ALT*, fully relativistic (slower variant) + + Note: *iwarm /= ABSORP_OFF* is required for current drive. + +**ilarm** (default: **5**) +: Order of the electron Larmor radius expansion (used by some + absorption models) + +**imx** (default: **-20**) +: Max number of iterations for the solution of the dispersion relation + (used by some absorption models) + + Note: if negative the result of the first iteration will be used in case + the result doesn\'t converge within \|imx\| iterations. + +**ieccd** (default: **CD_NEOCLASSIC**) +: Current drive model. One of: + + - *CD_OFF*, no current drive at all + - *CD_COHEN*, Cohen + - *CD_NO_TRAP*, no trapping + - *CD_NEOCLASSIC*, Neoclassical + +## antenna +Antenna/beam launcher parameters + +**alpha** +: Poloidal launch angle (deg). Positive is up + +**beta** +: Toroidal launch angle (deg). Positive is right + +**power** (default: **1.0**) +: Injected power (MW) + +**iox** +: Polarisation mode. One of: + + - *MODE_O*, ordinary (O) + - *MODE_X*, extraordinary (X) + +**chi** (default: **0.0**) +: χ (deg), angle between the principal axes of the polarisation + ellipse and the (x,y) axes + + Note: only used in alternative to *iox* if *ipol=.true.*. + +**psi** (default: **0.0**) +: ψ=atan(ε) (deg), where ε is the ellipticity of the polarisation + ellipse + + Note: only used in alternative to *iox* if *ipol=.true.*. + +**ibeam** (default: **BEAM_0D**) +: Beam parameters file format. One of: + + - *BEAM_0D*, fixed beam parameters + - *BEAM_1D*, 1D steering angle table + - *BEAM_2D*, 2D steering angles table + +**filenm** +: Filepath of the beam data (relative to the gray.ini file) + +## equilibrium +MHD equilibrium parameters + +**iequil** (default: **EQ_EQDSK_FULL**) +: MHD equilibrium kind. One of: + + - *EQ_VACUUM*, vacuum (i.e. no plasma at all) + - *EQ_ANALYTICAL*, analytical model + - *EQ_EQDSK_FULL*, G-EQDSK format - data valid on the whole domain + - *EQ_EQDSK_PARTIAL*, G-EQDSK format - data valid only inside the LCFS + +**filenm** +: Filepath of the equilibrium data (relative to the gray.ini file) + +**icocos** (default: **3**) +: COCOS index of the equilibrium data (G-EQDSK only) + +**ipsinorm** (default: **.false.**) +: Whether the poloidal function is normalised (G-EQDSK only) + + Note: Normalised means ψ(axis)=0, ψ(boundary)=1 + +**idesc** (default: **.true.**) +: Whether the header starts with a description, a.k.a + identification string (G-EQDSK only) + +**ifreefmt** (default: **.false.**) +: Whether the records have variable length (G-EQDSK only) + + Note: some non-compliant programs output numbers formatted with variable + length instead of using the single (5e16.9) specifier. + +**ixp** (default: **X_IS_MISSING**) +: Position of the X point. One of: + + - *X_IS_MISSING*, No X point + - *X_AT_TOP*, At the top of the plasma + - *X_AT_BOTTOM*, At the bottom of the plasma + +**ssplps** (default: **0.005**) +: Tension for the ψ_n(R,Z) spline, normalised poloidal flux + + Note: 0 means perfect interpolation + +**ssplf** (default: **0.01**) +: Tension for the F(ψ)=R⋅B_T spline, poloidal current function + + Note: 0 means perfect interpolation + +**sgnb** (default: **0**) +: Force the sign of the toroidal field. One of: + + - *+1*, counter-clockwise (viewed from above) + - *-1*, clockwise + - *0*, use sign from COCOS + +**sgni** (default: **0**) +: Force the sign of the plasma current. One of: *+1*, + + - *+1*, counter-clockwise (viewed from above) + - *-1*, clockwise + - *0*, use sign from COCOS + +**factb** (default: **1.0**) +: Rescaling factor for the magnetic field + +## profiles +(input) plasma profiles parameters + +**iprof** +: Plasma profiles kind. One of: + + - *PROF_ANALYTIC*, analytical model + - *PROF_NUMERIC*, numerical data (ρ, n_e, T_e, table) + +**irho** +: Plasma profiles radial coordinate. One of: + + - *RHO_TOR*, ρ_t = √Φ (where Φ is the normalised toroidal flux) + - *RHO_POL*, ρ_p = √ψ (where ψ is the normalised poloidal flux) + - *RHO_PSI*, normalised poloidal flux ψ + +**filenm** +: Filepath of the plasma profiles data (relative to the gray.ini file) + +**sspld** (default: **0.1**) +: Tension of the electron density spline + + Note: 0 means perfect interpolation + +**factte** (default: **1.0**) +: Rescaling factor for the electron temperature factte = 1 + +**factne** (default: **1.0**) +: Rescaling factor for the density temperature + +**iscal** (default: **SCALE_OFF**) +: Choice of model for rescaling the temperature, density with the + magnetic field (if factb ≠ 0 only). One of: + + - *SCALE_OFF*, don't rescale at all + - *SCALE_COLLISION*, scale while preserving collisionality + - *SCALE_GREENWALD*, scale while preserving the Greenwald fraction + +## output + +Output data parameters + +**pec** (default: **SCALE_OFF**) +: ECRH&CD profiles grid: Radial coordinate of the uniform grid. + One of: + + - *RHO_TOR*, ρ_t = √Φ (where Φ is the normalised toroidal flux) + - *RHO_POL*, ρ_p = √ψ (where ψ is the normalised poloidal flux) + +**nrho** (default: **501**) +: Number of in the radial grid + +**istpr** (default: **5**) +: Subsampling factors for the beam cross section (units 8, 12) + +**istpl** (default: **5**) +: Subsampling factors for the outer rays data (unit 33) + +## misc + +Other parameters + +**rwall** + +: Radius of the inner wall (m). Used to build a simple limiter for + reflections (only when *ipass\<0*) + +# EXAMPLE + +Below is an example of a gray.ini file + + [raytracing] + ; beamtracing with 16×24 rays + nrayr = 16 + nrayth = 24 + igrad = 1 + ; integrate in the phase + dst = 0.05 + nstep = 2400 + idst = STEP_PHASE + + [antenna] + ; vertical launch + alpha = 89.45 + beta = 0.0 + iox = MODE_X + ibeam = BEAM_1D + filenm = "beamdata.txt" + + [equilibrium] + filenm = "equilibrium.eqdsk" + icocos = 2 + + [profiles] + ; analytical profiles + iprof = PROF_ANALYTIC + irho = RHO_TOR + filenm = "profiles.txt" + sspld = 0.01 + + [output] + ipec = RHO_POL + nrho = 1001 + + [misc] + rwall = 0.6 + +# SEE ALSO + +**gray**(1), **beamdata.txt**(5), **profiles.txt**(5), **magneticdata.txt**(5) diff --git a/input/gray_params.data b/doc/man/gray_params.data.5.md similarity index 100% rename from input/gray_params.data rename to doc/man/gray_params.data.5.md diff --git a/doc/man/magneticdata.txt.5.md b/doc/man/magneticdata.txt.5.md new file mode 100644 index 0000000..cc6b4fc --- /dev/null +++ b/doc/man/magneticdata.txt.5.md @@ -0,0 +1,86 @@ +--- +title: MAGNETICDATA.TXT +section: 5 +--- + +# NAME +magneticdata.txt --- MHD equilibrium data for **gray**(1) + +# FORMAT +The MHD equilibrium data can be specified in two ways: as the free parameters +of a simple analytical model, or as numerical data in the G-EQDSK format. + +## analytical equilibrium +The format for the analytical magneticdata.txt file is as follows: + + R₀ z₀ a + B₀ + q₀ q₁ α + npoints + R₁ z₁ + R₂ z₂ + ... + +where: + +- *R₀, z₀* are the coordinates of the magnetic axis (m) +- *a* is the plasma boundary minor radius (m) +- *B₀* is the value of toroidal field on the magnetic axis (T) +- *q₀, q₁, α* are the parameters of the safety factors (see below) +- *npoints* is the number of points in the plasma limiter contour + that followsAa +- *R_i, z_i* are the coordinates of the points in contour (m) + +Note: When viewing the torus from above, a positive B₀ results in a + counterclockwise toroidal field and the plasma current is + clockwise if q and B₀ have opposite signs. + +### analytical model notes +The model used in GRAY describes a plsma with circular cross section centered +on the magnetic axis at a major radius *R₀* and extending up to the minor +radius *a*, where the density is exactly zero. +There is no X point nor separatrix. + +The flux surfaces are circular and the normalised toroidal radius is exactly: + + ρ_t(R, z) = √[(R - R₀)² + (z - z₀)²]/a + +The toroidal field is given explicitly by *B_t(R) = B₀ R/R₀*; the poloidal +field is determined implicitly by the safety factor profile. +The latter is parametrised as: + + q(ρ_p) = q₀ + (q₁ - q₀)ρ_p^α, + +where *ρ_p* is the normalised poloidal flux. + +## numerical equilibrium +The format of the numerical equilibrium is the G-EQDSK informal standard +(See the GRAY manual for the specification). + +The data strictly necessary to perform a GRAY simulation are limited to: +poloidal flux, safety factor, poloidal current function, magnetic axis and +plasma boundary. +If a limiter contour is provided it will be used to compute reflections. + +# EXAMPLES +1. An analytical magneticdata.txt + + 2.96 0.0 1.25 ! R₀ z₀ a + 6 ! B₀ + 3.5 10 2 ! q₀ q₁ α + 4 ! npoints + 1.61 -1.35 ! a simple square limiter + 1.61 +1.35 + 4.31 +1.35 + 4.31 -1.35 + + +2. An analytical magneticdata.txt without limiter + + 2.96 0.0 1.25 ! R₀ z₀ a + 6 ! B₀ + 3.5 10 2 ! q₀ q₁ α + 0 ! no limiter contour + +# SEE ALSO +**gray**(1) diff --git a/doc/man/profiles.txt.5.md b/doc/man/profiles.txt.5.md new file mode 100644 index 0000000..eba5c23 --- /dev/null +++ b/doc/man/profiles.txt.5.md @@ -0,0 +1,63 @@ +--- +title: PROFILES.TXT +section: 5 +--- + +# NAME +profiles.txt --- Kinetic plasma profiles data for **gray**(1) + +# FORMAT +The plasma profiles can be specified in two ways: either as the free parameters +of a simple analytical model, or as numerical data in a tabular format. + +## analytical profiles +The format for the analytical profiles is as follows: + + n₀ a b ! comment + T₀ T₁ c d + Z_eff + +The first line contains the parameters for the electron density as a function +of the normalised poloidal flux *n(ψ)*, which in units of 10¹⁹ m⁻³ is given as: + + n(ψ) = n₀(1 - ψ^a)^b + +Similarly, the second line contains the parameters for the electron temperature +*T(ψ)*, which is defined in units of keV as: + + T(ψ) = (T₀ - T₁)(1 - ψ^c)^d + T₁ + +The last lines contains the (constant) value of the effective charge. + +## numerical profiles +The format for the numerical consists of a table with the following columns: +*radial coordinate*, *temperature*, *density*, *effective charge*. +The first line is a header specifying the number of table rows and subsequent +lines contains the whitespace-separated records, one row per line: + + nrows ! comment + ρ₁ T₁ n₁ Z₁ + ρ₂ T₂ n₂ Z₂ + ... + + +# EXAMPLES +1. A valid analytical profiles.txt file + + 10 0.3 3 ! n₀, a, b + 14 0 2 8 ! T₀, T₁, c, d + 1.0 ! Z_eff + +2. A valid numerical profiles.txt file + + 100 ! ρ_t T_e n_e Z_eff + 0.005025 17.9399 24.1717 1.64001 + 0.095477 17.4336 23.7527 1.56178 + 0.175879 16.9632 23.2699 1.65915 + 0.246231 13.7457 22.9230 1.72905 + 0.306533 10.4874 22.6312 1.76446 + 0.457286 6.59895 21.7133 1.74971 + 0.577889 4.74975 19.5653 1.60959 + +# SEE ALSO +**gray**(1) diff --git a/input/beam.data b/input/beam.data deleted file mode 100644 index 7cc9799..0000000 --- a/input/beam.data +++ /dev/null @@ -1,3 +0,0 @@ -170 : f (GHz) -950 0 62 :x00 y00 z00 (cm) : mirror position -2.1 2.1 162. 162. 0 :w0xt w0yt d0xt d0yt phiwr (cm) [d0>0 towards plasma] diff --git a/input/equil_a.txt b/input/equil_a.txt deleted file mode 100644 index 955f442..0000000 --- a/input/equil_a.txt +++ /dev/null @@ -1,8 +0,0 @@ -2.96 0.0 1.25 ! R₀,z₀,a, where ρ_p(R, z) = √[(R - R₀)² + (z - z₀)²]/a (m) -6 ! B₀, where B_φ(R) = B₀ R₀/R (T) -3.5 10 2 ! q₀,q₁,α, where q(ρ_p) = q₀ + (q₁-q₀)ρ_p^α -0 ! number of points in the limiter contourn, (R,z) pairs - -! Notes: -! 1. use B₀>0 for clockwise B_φ -! 2. use q₀,q₁<0 for clockwise I_p,B_φ diff --git a/input/gray.ini b/input/gray.ini deleted file mode 100644 index 7d81850..0000000 --- a/input/gray.ini +++ /dev/null @@ -1,187 +0,0 @@ -[raytracing] -; Number of rays in the radial/angular direction -nrayr = 1 -nrayth = 16 -; Normalized maximum radius of the beam power -rwmax = 1.0 - -; Switch between simple raytracing (0) and beamtracing (1) -igrad = 0 - -; Max number of passes inside the plasma [multipass module] -; When positive reflections occur on the plasma limiter provided by the -; G-EQDSK file; when negative on a simple limiter at R=`rwall`, see below. -ipass = 1 - -; Whether to compute the wave polarisation (from chi, psi) -ipol = .false. -; Step size (cm) for the numerical integration -dst = 0.1 -; Max number of integration steps -nstep = 12000 - -; Choice of the integration variable -; STEP_ARCLEN: arc length (s) -; STEP_TIME: time (actually c⋅t) -; STEP_PHASE: phase (actually real part of eikonal S_r=k₀⋅φ) -idst = STEP_ARCLEN - - -[ecrh_cd] -; Choice of the power absorption model -; ABSORP_OFF: no absorption at all -; ABSORP_WEAK: weakly relativistic -; ABSORP_FULL: fully relativistic (faster variant) -; ABSORP_FULL_ALT: fully relativistic (slower variant) -; Note: iwarm /= ABSORP_OFF is required for current drive -iwarm = ABSORP_FULL - -; Order of the electron Larmor radius expansion -; (used by some absorption models) -ilarm = 5 - -; Max number of iterations for the solution of the dispersion relation. -; (used by some absorption models) -; Note: if negative the result of the first iteration will be used in -; case the result doesn't converge within |imx| iterations. -imx = -20 - -; Current drive model -; CD_OFF: no current drive at all -; CD_COHEN: Cohen -; CD_NO_TRAP: no trapping -; CD_NEOCLASSIC: Neoclassical -ieccd = CD_NEOCLASSIC - - -[antenna] -; Wave launch angles (deg) -alpha = 45 ; Poloidal angle (positive → up) -beta = 0 ; Toroidal angle (positive → right) - -; Injected power (MW) -power = 1.0 - -; Polarisation mode -; MODE_O: ordinary (O) -; MODE_X: extraordinary (X) -iox = MODE_X -; Alternatively, parameters of the polarisation ellipse -; χ: angle between the principal axes and the (x,y) axes -; ψ: atan(ε), where ε is the ellipticity -chi = 0 -psi = 0 - -; Beam parameters format -; BEAM_0D: fixed beam parameters -; BEAM_1D: 1D steering angle table -; BEAM_2D: 2D steering angles table -ibeam = 0 - -; Filepath of the beam data (relative to this file) -filenm = "beamdata.txt" - - -[equilibrium] -; MHD equilibrium kind -; EQ_VACUUM: vacuum (i.e. no plasma at all) -; EQ_ANALYTICAL: analytical model -; EQ_EQDSK_FULL: G-EQDSK format - data valid on the whole domain -; EQ_EQDSK_PARTIAL: G-EQDSK format - data valid only inside the LCFS -iequil = EQ_EQDSK_FULL - -; Filepath of the equilibrium data (relative to this file) -filenm = "magneticdata.eqdsk" -; COCOS index of the EQDSK equilibrium -icocos = 7 - -; Whether the poloidal function is normalised (G-EQDSK) -; false: is not normalised, ψ → |ψ - ψ(edge)|/|ψ(axis) - ψ(edge)| -; true: is already normalised -ipsinorm = false - -; G-EQDSK format parameters -; Whether header starts with a description, a.k.a identification string -idesc = true -; Whether the records have variable length -; Note: some non-compliant programs output numbers formatted with variable length -; instead of using the single (5e16.9) specifier. -ifreefmt = false - -; Position of the X point -; X_IS_MISSING: No X point -; X_AT_TOP: At the top of the plasma -; X_AT_BOTTOM: At the bottom of the plasma -ixp = X_IS_MISSING - -; Tension of splines -; Note: 0 means perfect interpolation -ssplps = 0.005 ; for ψ(R,Z), normalised poloidal flux -ssplf = 0.01 ; for F(ψ)=R⋅B_T, poloidal current function - -; Force the sign of toroidal field/plasma current -; When viewing from above: -; +1 → counter-clockwise -; -1 → clockwise -; 0 → use sign from COCOS -sgnb = -1 -sgni = +1 -; Rescaling factor for the magnetic field -factb = 1 - - -[profiles] -; (input) plasma profiles parameters - -; Plasma profiles kind -; PROF_ANALYTIC: analytical model -; PROF_NUMERIC: numerical data (ρ, n_e, T_e, table) -iprof = PROF_NUMERIC - -; Plasma profiles radial coordinate -; RHO_TOR: ρ_t = √Φ (where Φ is the normalised toroidal flux) -; RHO_POL: ρ_p = √ψ (where ψ is the normalised poloidal flux) -; RHO_PSI: normalised poloidal flux ψ -irho = RHO_TOR - -; Filepath of the equilibrium (relative to this file) -filenm = "profiles.txt" - -; Tension of the density spline -; Note: 0 means perfect interpolation -sspld = 0.1 - -; Rescaling factor for electron temperature/density -factte = 1 -factne = 1 - -; Choice of model for rescaling the temperature/density -; with the magnetic field (if factb ≠ 0) -; SCALE_OFF: don't rescale at all -; SCALE_COLLISION: scale while preserving collisionality -; SCALE_GREENWALD: scale while preserving the Greenwald fraction -iscal = SCALE_OFF - - -[output] -; Output data parameters - -; ECRH&CD profiles grid: -; Radial coordinate -; RHO_TOR: ρ_t = √Φ (where Φ is the normalised toroidal flux) -; RHO_POL: ρ_p = √ψ (where ψ is the normalised poloidal flux) -ipec = 1 -; Number of points -nrho = 501 - -; Subsampling factors: -istpr = 5 ; beam cross section (units 8, 12) -istpl = 5 ; outer rays data (unit 33) - - -[misc] -; Other parameters - -; Radius of the inner wall (m) [multipass module] -; (when ipass<0, used to build a simple limiter for reflections) -rwall = 1.36 diff --git a/input/profil_a.txt b/input/profil_a.txt deleted file mode 100644 index 04c04dd..0000000 --- a/input/profil_a.txt +++ /dev/null @@ -1,3 +0,0 @@ -10 0.3 3 ! n₀,a,b, where n(ψ) = n₀(1 - ψ^a)^b (10¹⁹ m⁻³) -14 0 2 8 ! T₀,T₁,a,b, where T(ψ) = (T₀ - T₁)(1 - ψ^a)^b + T₁ (keV) -1.0 ! Z_eff diff --git a/src/beams.f90 b/src/beams.f90 index 236bb0e..34acf2a 100644 --- a/src/beams.f90 +++ b/src/beams.f90 @@ -216,41 +216,20 @@ contains ! where w(z, α, β) and 1/R(z, α, β) depend on the launcher angles α, β. ! ! Format notes: - ! 1. The first line contains the number N of beams defined in the file - ! 2. The following N lines contain the following data for each of the - ! N beams: - ! ID,iox,f,na,nb - ! 3. The meaning of the data is - ! - ID is a label to identify the beam - ! - iox=1,2 is a flag to select O-mode (1) or X-mode (2) polarization - ! - f is the wave frequency (GHz) - ! - n*m is the number of rows of the corresponding table below with - ! the beam parameters. - ! * If the beam steering is fixed: na=nb=1 - ! * For a steering around a single axis: - ! na>1 and nb=1, or na=1 and nb>1. - ! * For a steering with two independent axes: - ! n>1 and m>1. - ! The row number l of the following table is mapped to two indexes - ! i,j (1≤i≤na, 1≤j≤nb) via l=i+na*(j-1), i.e., the index i "runs - ! faster". - ! Index i is assumed to be associated to a steering mainly in the - ! poloidal direction and the poloidal launch angle α(i,j) must be - ! monotonous along its first dimension. - ! Index j is assumed to be associated to a steering mainly in the - ! toroidal direction and the toroidal launch angle β(i,j) must be - ! monotonous along its second dimension. - ! 4. The rest of file is a sequence of N tables with the following - ! columns: - ! α, β, x₀, y₀, z₀, w₁, w₂, k₁, k₂, φ_w, φ_R - ! 5. The meaning of the columns is - ! - α, β are the poloidal and toroidal launch angles (deg) - ! - x₀, y₀, z₀ are the launcher position (mm) - ! - w₁,w₂ are the beam widths in the two principal directions (mm) - ! - k₁,k₂ are the wavefront curvatures in the two principal - ! directions (mm⁻¹) - ! - φ_w, φ_R are the rotation angles of the amplitude and phase - ! ellipses in the transverse plane at the launch point (deg) + ! 1. The first line specifies the number N of beams described by the file. + ! 2. The rest of the files consists of N 2D tables preceded by a header + ! id, mode, f, na, nb + ! where + ! - id is a string identifier of the beam + ! - mode indicates where the beam has O-mode (1) or X-mode (2) + ! polarisation + ! - f is the frequency (GHz) + ! - nα, nβ are the numbers of rows and columns of the table. + ! 3. The 2D table is stored in row-major order over *nα×nβ* lines, that is, the + ! i,j-th record is stored on the l-th line, with l = i + nα*j. + ! 4. The poloidal angle *α(i,j)* must be monotonic along *i* and the toroidal angle + ! *β(i, j)* must be monotonic along *j*. + ! 5. Each line stores one record with the same fields as in the 1D format. use gray_params, only : antenna_parameters use utils, only : get_free_unit, intlin, locate, inside