Commit Graph

8 Commits

Author SHA1 Message Date
Michele Guerini Rocco
0a87a3ef76
src/polarization.f90: rewrite
- Remove the Stokes parameters as an intermediate step in the
  conversion between Jones vectors and polarisation ellipses.

- Document every single step performed when converting between
  different parametrisations and how the polarisation at the
  plasma boundary is computed. This includes how everything
  was derived from first principles.

- Mark the subroutines as pure.

- Remove `set_pol` entirely.
2024-04-11 21:49:52 +02:00
Michele Guerini Rocco
f82f91bc8d
fix coupling for subsequent beams
In situations when multiple beams are traced, either when allowing
multiple plasma crossings (raytracing.ipass > 0) or the initial polarisation
is mixed (raytracing.ipol == .true.), the couplings of all but the first
beam (with least index_rt) were invalid.

The bug is due to the re-use of the psipol,chipol variables as the beams
are traced sequentially over the beam_loop. For the first beam being
traced the psipol,chipol are correctly initialised to the user-defined
value and the resulting coupling is correct.
However, in each subsequent beam the values were not set to those of the
parent beam (or to the user-defined value in the case of the first X
mode beam), but to those of the previous beams (current index_rt - 1).

This change repurposes the psipv,chipv arrays to store the polarisation
of the parent beams, including the initial user-defined value and makes
plasma_in always use these to compute the coupling.

In addition, in the case the polarisation is not immediately known (i.e.
if raytracing.ipol == .false.), this change postpones the computation of
the Jones vector (ext, eyt) from the launch point, if the magnetic
equilibrium is available, to when the ray actually crosses the
plasma boundary.
The original code, besides being strictly incorrect, can lead to
non-negligible alterations to the coupling. This change also mean:

1. most of the functionality of `set_pol` has been merged with
   `plasma_in`
2. the polarisation is undefined and the Jones vector is set to the
   placeholder value [1, 0] till `plasma_im` is called

Finally, `polarcold` is removed because it's unused.
2024-04-11 18:06:46 +02:00
Michele Guerini Rocco
73bd010458
remove unnecessary implicit statements
Only a single `implicit none` at the start of each module is required.
2024-02-09 11:16:18 +01:00
Michele Guerini Rocco
8bc5ac0064
always use generic math functions
This replaces double precision-specific function in order to allow
building GRAY with other real kinds, for example single or quadruple
precision.
2023-09-21 14:21:24 +02:00
Michele Guerini Rocco
0a63a20e73
src/dispersion.f90: cleanup
- merge branch with a method to control the speed of iteration and
  improve the convergence of `warmdisp` (thanks Thomas)

- unify `diel_tens_fr` and `diel_tens_wr` into a single subroutine,
  `dielectric_tensor`

- stay as close as possible to the notation of Daniela Farina's paper

- make `sox` an integer

- mark more subroutines as pure

- add more comments
2023-04-12 23:45:49 +02:00
Michele Guerini Rocco
d18e05353a
src: remove unused parameters 2022-05-11 01:15:02 +02:00
Daniele Micheletti
27f1793f14 trunk: added multiple passes calculation; added multipass module; graycore/gray_main: subroutine rewritten; equilibrium/read_equil_an: limiter coordinates read from equilibrium file for ipass>1; err_codes/check_err: istop=1 only for alpha<0; pec/pec_tab: fixed index assignements in loops; polarization/pol_limit: fixed ext,eyt normalization 2019-03-26 14:21:22 +00:00
ce10204479 nocommon branch merged back into trunk 2015-11-18 16:34:33 +00:00