The unused elements of the array are now initialized explicitly
with empty strings to add compatibility with ifort 2020, that
otherwise fails with internal error.
To keep the notation used in compute_initial_conds consistent with the
source linked (Q = K - iW for the complex curvature tensor), we need to
adds a minus sign in a few places where ∇S_I is computed.
1. Local variables are automatically deallocated when they go out of
scope.
2. When calling exit() during CLI processing some stuff wasn't being
deallocated, but it doesnt matter because the OS does it anyway.
So, get rid of it entirely.
This changes the ψ, χ polarisation ellipse angles shown in the summary
table to be those of the current plasma wave mode, not the polarisation
of the beam upon re-entering the plasma boundary after reflecting.
Note that the former has always been the intended value, but was likely
changed inadvertently when reflections have been implemented.
When the beam reflects before entering the boundary the Jones vector
(ext, eyt) is still uninitialised, set it at the beginning to avoid
raising an exception in debug mode.
The caching is cool, but it's implemented using static variables and
therefore not thread-safe. Since the savings are pretty modest (about
20% of the total eccdeff calls, itself 3% of the total execution) let's
just drop it.
This was the final module with global variables to be rewritten.
The functionaly of pec: `pec_init`, `spec`, `postproc_profiles` has been
replaced by the `ray_projector` object in `gray_project.f90` with the
following methods: `projector%init`, `projector%project` and
`projector%statistics`.
The new code is functionally identically with only breaking change being
in Δρ_J, the full-width at max/e of the current density.
Before this change Δρ_J could be negative to signal the J_φ profile had
at least one positive and one negative peak, after the value is always
positive. Note: in either case Δρ_J was given by the largest peak only.
When combining multiple independent simulations with `gray -s`, the
statistics in sum-summary.txt are computed by summing the profiles
pointwise and calling `postproc_profiles` with their (supposedly common)
MHD equilibrium.
The subroutine assumes the normalisations of dP/dV⋅dV and J_φ⋅dA are
P_inside(ρ=1), I_cd_inside(ρ=1), however if the individual profiles have
been computed with different versions of Gray, built with different
compilers, or on different machines, the values may be very slightly off.
Further, due to the use of the relation Δρ² = ⟨ρ²⟩ - ⟨ρ⟩², the profile
widths are very sensible to the normalisation, producing wildly
incorrect values.
For example, due to the refactor of `magsurf_data`, a change of about
0.05% in dV resulted in Δρ² being off by 300%.
The file format parsed by read_beam2 also includes the polarisation,
unlike those of read_beam0 and read_beam1.
When running gray standalone, however, we expect the mode to be set by
`antenna.iox` in gray.ini, not by the beam file.
- Avoid logging the same error over and over
- Make all the gray_errors actually warnings
- Replace `large_npl` error with `unstable_beam`, which is actually
the root cause of the former
- Use the gray_main error as exit code
- Replace the `get_free_unit` subroutine with the built-in
`newutin` option of the `open` statement.
- Replace `locatex` with just `locate` + an index offset.
- Replace `inside` with `contour%contains`.
- Merge `vmaxmin` and `vmaxmini` into a single subroutine
with optional arguments.
- Remove unused `range2rect`, `bubble`.
Similarly to eb648039 this change replaces the `equilibrium` module with
a new `gray_equil` module providing the same functionality without using
global variables.
- `read_eqdsk`, `read_equil_an` are replaced by a single `load_equil`
routine that handles all equilibrium kind (analytical, numerical,
and vacuum).
- `scale_equil` is merged into `load_equil`, which besides reading
the equilibrium from file peforms the rescaling and interpolation based
on the `gray_parameters` settings and the equilibrium kind.
To operate on G-EQDSK data specifically, the `change_cocors` and
`scale_eqdsk` are still available. The numeric equilibrium must then
be initialised manually by calling equil%init().
- `set_equil_spline`, `set_equil_an`, `unset_equil_spline`
are completely removed as the module no longer has any internal state.
- `fq` is replaced by `equil%safety`; `bfield` by `equil%b_field`;
`frhotor`, `frhopol` by `equil%pol2tor` and `equil%pol2tor`;
and the remaining subroutines by other methods of `abstract_equil`
retaining the old name.
- the `contours_psi` subroutine is replaced by `equil%flux_contour`,
with a slightly changed invocation but same functionality.
- the `gray_data` type is no longer required ans has been removed: all
the core subroutines now access the input data only though either
`abstract_equil`, `abstract_plasma` or the `limiter` contour.
This change adds a bit of documentation and simplifies the two
(internal) subroutines used to find the horizontal tangent points
and the magnetic O/X point.
Using a closure we can avoid explicitly passing parameters (psi0) to
hybrj1. Previously this required a custom `hybrj1mv` subroutine in
fitpack with an identical interface, except for our extra parameter.
This change replaces the `coreprofiles` module with a new `gray_plasma`
module providing the same functionality without using global variables.
- `read_profiles`, `read_profiles_an` are replaced by a single `load_plasma`
routines that handles both profiles kind (numerical, analytical).
- `scale_profiles` is merged into `load_plasma`, which besides reading
the profiles from file peforms the rescaling and interpolation based
on the `gray_parameters` settings.
- `set_profiles_spline`, `set_profiles_an`, `unset_profiles_spline`
are completely removed as the module no longer has any internal state.
- `density`, `ftemp`, `fzeff` are replaced by the `abstract_plasma`
type which provides the `dens`, `temp` and `zeff` methods for
either `numeric_plasma` or `analytic_plasma` subtypes.