Open Access
Issue
A&A
Volume 699, July 2025
Article Number A233
Number of page(s) 16
Section Numerical methods and codes
DOI https://doi.org/10.1051/0004-6361/202453107
Published online 14 July 2025

© The Authors 2025

Licence Creative CommonsOpen Access article, published by EDP Sciences, under the terms of the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

This article is published in open access under the Subscribe to Open model. Subscribe to A&A to support open access publication.

1 Introduction

The magnetic field is known to play a key role in the solar chromosphere and chromosphere-corona transition region, but its inference in these layers is notoriously challenging. The difficulty is due to the information about these atmospheric layers being mainly contained in strong ultraviolet (UV) lines, and the sensitivity of the Zeeman effect diminishing at short wave-lengths and in hot plasmas. One of the most promising strategies to overcome this issue involves exploiting, in addition to the Zeeman effect, the magnetic sensitivity of the linear polarisation signals that the scattering of anisotropic radiation produces in strong resonance lines of the solar spectrum (e.g. Trujillo Bueno & del Pino Alemán 2022). Indeed, conspicuous scattering polar-isation signals are observed in several strong chromospheric lines, both in the visible (e.g. Gandorfer 2000, 2002, 2005) and in the UV (e.g. Kano et al. 2017; Rachmeler et al. 2022). These signals, which usually extend into the line wings, are sensitive to the magnetic field through the joint action of two physical mechanisms: the Hanle effect (e.g. Landi Degl’Innocenti & Landolfi 2004) and magneto-optical (MO) effects (e.g. Alsina Ballester et al. 2016; del Pino Alemán et al. 2016). The former operates in the core of spectral lines, while the latter in the wings. With respect to the Zeeman effect, the Hanle effect allows for the detection of significantly weaker magnetic fields (typically in the range 1 − 100 G). Moreover, its sensitivity does not decrease for wavelengths towards the blue or when observing very hot plasmas (e.g. Trujillo Bueno 2014). Magneto-optical effects are effective at modifying the scattering polarisation wings of strong resonance lines in a range of magnetic field strengths similar to that of the Hanle effect (Alsina Ballester et al. 2016). Notably, various instruments have recently been developed or proposed to exploit the diagnostic potential of scattering polarisation in strong UV lines. These include the series of CLASP sounding rocket experiments, (Kobayashi et al. 2012; McKenzie et al. 2019, 2021) and the proposed Chromospheric Magnetism Explorer (CMEx) satellite mission1.

To accurately model the scattering polarisation signals of strong resonance lines as measured by such instruments, it is necessary to solve the radiative transfer (RT) problem for polarised radiation out of local thermodynamic equilibrium (NLTE conditions) while taking partial frequency redistribution (PRD) effects in scattering processes into account. Additionally, in the case of atomic multiplets, another important element to consider is quantum interference between different fine structure levels of the same term, generally referred to as J-state interference (e.g. Belluzzi & Trujillo Bueno 2011, 2012; Belluzzi et al. 2012). Various theoretical approaches for describing the generation and transfer of polarised radiation accounting for PRD effects and J-state interference have been proposed during the past decades (see, e.g. Sect. 1 of Casini et al. 2014, and references therein). Here, we mention the one by Casini et al. (2014, 2017a,b) and the one by Bommier (2017), which converge to the same expressions when considering a two-term atom (i.e. an atomic model composed of two terms and including J-state interference) with an unpolarised lower term (Casini et al. 2017b). The former is presently implemented in the HanleRT-TIC code (del Pino Alemán et al. 2016, 2020; Li et al. 2022)2. The latter is implemented in the code described in Alsina Ballester et al. (2022) and is also used in this work.

Modelling PRD effects is notoriously demanding from a computational point of view, even when just considering a 1D plane-parallel atmospheric geometry or neglecting polarisation. To simplify the problem, the so-called angle-averaged (AA) approximation (e.g. Mihalas 1978; Rees & Saliba 1982; Bommier 1997b) has been widely applied in the past. The first results of NLTE RT calculations for scattering polarisation in 1D plane-parallel models of the solar atmosphere including PRD effects in their most general angle-dependent (AD) formulation have been obtained only very recently (e.g. del Pino Alemán et al. 2020; Janett et al. 2021a; Riva et al. 2023; Guerreiro et al. 2024). These calculations are presently considered the state of the art in the numerical modelling of Hanle-Zeeman signals, but they are still regarded as an extremely complex and challenging computational problem. Consequently, it is crucial to devise numerical methods tailored to the considered problem that are both fast and accurate. Doing so will help bring better understanding of the relative impact of the various physical processes at play on the observed polarisation signals and develop reliable inversion techniques targeted at extracting information on the upper layers of the solar atmosphere.

In this paper, we present the solution strategy we have developed to solve the NLTE RT problem for polarised radiation that takes AD PRD effects into account. Our approach allows both two-level and two-term atomic models to be considered with an unpolarised and infinitely sharp lower level or term in the presence of arbitrary magnetic and bulk velocity fields. As the computational bottleneck of the problem is the evaluation of the contribution of scattering processes to the line emissivity and, in particular, the large number of evaluations of the so-called redistribution functions, we devised a strategy to minimise this number and speed up the calculations. This strategy is implemented in a code named TRAnsfer of Polarized radiation in Plane-Parallel models with PRD (TRAP4), which allows us to solve the NLTE RT problem considering 1D plane-parallel atmospheric models. The TRAP4 code was then applied to synthesise the Stokes profiles of the Mg II h&k doublet and the H I Ly-α line.

The paper is structured as follows. In Sect. 2, we present the main equations inherent to the NLTE RT problem for polarised radiation along with the redistribution matrix formalism for describing PRD effects. We also discuss our main assumptions and approximations, and we present the discretisation and algebraic formulation of the problem used in this work. In Sect. 3, we discuss the formal solution of the RT equation. Then, in Sect. 4, we describe the numerical calculation of the emissivity, focusing on the quadrature of the so-called scattering integral. Section 5 exposes the applied matrix-free iterative solution strategy. In Sect. 6, we report on the verification of our calculations, the validation of our solution strategy, and the synthesis of wavelength-integrated linear polarisation profiles of the H I Ly-α line. Finally, we provide remarks and conclusions in Sect. 7.

2 Formulation of the problem

In this section, we first present the most relevant equations describing the considered NLTE RT problem for polarised radiation. Second, we expose the main assumption of the proposed approach, under which the problem is linear with respect to the radiation field. Third, we present a suitable discretisation of the linear problem. Finally, we outline the ensuing algebraic formulation, which proves to be particularly simple and accessible.

2.1 NLTE RT problem

The intensity and polarisation of a beam of radiation are fully described by the four-component Stokes vector I=(I,Q,U,V)T=(I1,I2,I3,I4)T+×3\[I = \frame{(I,Q,U,V)^T} = \frame{\left(\nolbrace \frame{\frame{I_1},\frame{I_2},\frame{I_3},\frame{I_4}} \norbrace\right)^T} \in \frame{\mathbb{R}_ + } \times \frame{\mathbb{R}^3}\] where I is the specific intensity, and Q, U, and V encode the polarisation while always satisfying the condition IQ2+U2+V2$\sqrt \frame{\frame{Q^2} + \frame{U^2} + \frame{V^2}} $. For a given medium, such as the plasma of a stellar atmosphere, the variation of a radiation beam of frequency ν ∈ ℝ+ and direction Ω at a spatial location rD, with D ⊂ ℝ3, is described by the following RT equation: ΩI(r,Ω,v)=K(r,Ω,v)I(r,Ω,v)+ε(r,Ω,v),\[\frame{\nabla _\frame{\mathbf{\Omega }}}I(r,\frame{\mathbf{\Omega }},v) = - K(r,\frame{\mathbf{\Omega }},v)I(r,\frame{\mathbf{\Omega }},v) + \varepsilon (r,\frame{\mathbf{\Omega }},v),\](1) where Ω = Ω · ∂/∂r denotes the directional derivative along the unit vector Ω. The propagation matrix K ∈ ℝ4×4 quantifies how the medium attenuates the intensity for all polarisation states (absorption) and how it differentially absorbs (dichroism) and couples (dispersion) the different Stokes parameters. The emission vector ε=(ε1,ε2,ε3,ε4)T+×3\[\varepsilon = \frame{\left(\nolbrace \frame{\frame{\varepsilon _1},\frame{\varepsilon _2},\frame{\varepsilon _3},\frame{\varepsilon _4}} \norbrace\right)^T} \in \frame{\mathbb{R}_ + } \times \frame{\mathbb{R}^3}\] represents the radiation emitted by the plasma in the four Stokes parameters. The RT coefficients K and ε include all the relevant contributions of both line and continuum processes. Hereafter, we only present the former, as this is the central topic of this paper, while we refer to Appendix A for a discussion of the latter.

The contribution of line processes depends on the state of the atom giving rise to the considered spectral line. This needs to be determined by solving the statistical equilibrium (SE) equations, which describe the interaction of the atom with the radiation field (radiative processes), other particles (collisional processes), and the possible presence of external electric and/or magnetic fields. The NLTE RT problem thus consists of finding a self-consistent solution of the RT equation, Eq. (1), for the radiation field I and the SE equations for the atomic system. This problem is in general integro-differential, non-local, and, because of the dependence of the radiative rates in the SE equations on the radiation field I, non-linear.

2.2 Atomic models

In this work, we consider an atomic model composed of two terms (two-term atom, see Sect. 7.6 of Landi Degl’Innocenti & Landolfi 2004), which includes the two-level atom as a particular case. The formalism that we introduce in the following allows both atomic models to be treated.

Assuming LS coupling, each term of a two-term atom is specified by a set of inner quantum numbers β, the quantum number for the orbital angular momentum L, and the quantum number for the electronic spin S. In the absence of magnetic fields, the energy eigenstates are given by |βLS JM⟩, where J is the total angular momentum quantum number and M ∈ {−J, −J + 1, …, J} is the magnetic quantum number. The presence of an external magnetic field induces a splitting between the magnetic sublevels. If the magnetic splitting is much smaller than the separation between the different J-levels, it can be calculated in the Zeeman effect regime, and it is thus linear with respect to the magnetic field strength B. On the other hand, if the magnetic splitting is comparable to the separation between different J-levels, one has to consider the Paschen-Back effect. In this case, the splitting is not linear with B and J ceases to be a good quantum number (e.g. Landi Degl’Innocenti & Landolfi 2004). In the present work, we account for the Paschen-Back effect and we introduce a label j to distinguish between different states with the same quantum numbers β, L, S, and M. We recall that a two-term atomic model accounts for J-state interference within each term. The case of a two-level atom can be easily recovered by setting S = 0, so that each term is composed of a single J-level, with J = L.

Hereafter, we assume that the lower level or term of the considered atomic system is infinitely sharp. This is a very good assumption for resonance lines, as their lower level (ground or metastable) has a very long lifetime. Moreover, we neglect atomic polarisation in the lower level or term. This assumption, which is always correct for levels with J = 0 and J = 1/23, is generally good for any long-lived level in a sufficiently dense plasma, due to the depolarising effect of elastic collisions. The assumptions of unpolarised and infinitely sharp lower level or term are thus very good for strong resonance lines such as Ca I 4227 and Sr II 4077, whose polarisation signals are suitably modelled considering a two-level atom, as well as Mg II h&k, H I Ly-α, and He II 304, which require a two-term atomic model.

The explicit expressions of the line contributions to the elements of the propagation matrix K for a two-level and a two-term atom with unpolarised lower level or term can be found in Chapter 7 of Landi Degl’Innocenti & Landolfi (2004). The line contribution to the emission vector for the same atomic models is discussed in the next section. Noticing that a two-term atom is formally equivalent to a two-level atom with hyperfine structure (e.g. Landi Degl’Innocenti & Landolfi 2004), the framework described in this paper can be applied to both atomic models, as detailed in Janett et al. (2023).

2.3 Line emissivity

Neglecting stimulated emission, the SE equations for two-level or two-term atomic models with an unpolarised lower level or term have an analytic solution, and it is thus possible to apply the redistribution matrix formalism to describe PRD effects (e.g. Mihalas 1978). In this case, the line contribution to the emission vector can be written as the sum of two terms describing the contributions from atoms that are either radiatively excited (scattering term, label ‘sc’) or collisionally excited (thermal term, label ‘th’), that is, εl(r,Ω,v)=εlsc(r,Ω,v)+εl,th(r,Ω,v),\[\frame{\varepsilon ^\ell }(r,\frame{\mathbf{\Omega }},v) = \frame{\varepsilon ^\frame{\ell sc}}(r,\frame{\mathbf{\Omega }},v) + \frame{\varepsilon ^\frame{\ell ,th}}(r,\frame{\mathbf{\Omega }},v),\] where the superscript denotes line processes.

Under the assumption of isotropic inelastic collisions, the thermal term is given by ε,th(r, Ω, ν) = ϵ(r)WT(r)η(r, Ω, ν), where ϵ(r) = ΓI(r)/ [ΓR + ΓI(r)] is the photon destruction probability; ΓR and ΓI are the line broadening constants due to radiative decays and inelastic collisions, respectively; WT is the Planck function in the Wien limit (consistently with the assumption of neglecting stimulated emission)4; and the vector η gathers the absorption and dichroism coefficients (Landi Degl’Innocenti & Landolfi 2004). Moreover, using the redistribution matrix formalism, the scattering term is directly related to the radiation field that illuminates the atom through the scattering integral εl,sc(r,Ω,v)=k(r)dvdΩ4πR(r,Ω,Ω,v,v)I(r,Ω,v),\[\frame{\varepsilon ^\frame{\ell ,sc}}(r,\frame{\mathbf{\Omega }},v) = k(r)\smallint \frame{\text{d}}v\prime\oint \frac{\frame{\frame{\text{d}}\frame{\mathbf{\Omega \prime}}}}{\frame{4\pi }}R\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right)I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},v\prime} \norbrace\right),\](2) where k is the frequency-integrated absorption coefficient and R ∈ ℝ4×4 is the redistribution matrix, which encodes an analytic solution of the SE equations. Here, primed and unprimed quantities refer to the incident and scattered radiation, respectively.

The most general form of the redistribution matrix for an atomic system with infinitely sharp lower states is expressed by the linear combination of two terms (e.g. Bommier 1997a,b, 2017): R(r,Ω,Ω,v,v)=RII(r,Ω,Ω,v,v)+RIII(r,Ω,Ω,v,v),\[R\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right) = \frame{R^\frame{II}}\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right) + \frame{R^\frame{III}}\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right),\] where RII and RIII repectively describe scattering processes that are coherent in frequency and totally uncorrelated in the atomic rest frame. Using the formalism of the irreducible spherical tensors for polarimetry (see Chapter 5 of Landi Degl’Innocenti & Landolfi 2004), each redistribution matrix can be written as RX(r,Ω,Ω,v,v)=K,K,QRQX,KK(r,Ω,Ω,v,v)PQKK(r,Ω,Ω),\[\frame{R^\frame{\text{X}}}\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right) = \mathop \sum \limits_\frame{K,K\prime,Q} \mathcal{R}_Q^\frame{\frame{\text{X}},KK\prime}\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right)\mathcal{P}_Q^\frame{KK\prime}\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }}} \norbrace\right),\] with X=II,III,RQX,KK$\frame{\text{X}} = II,III,\mathcal{R}_Q^\frame{\frame{\text{X}},KK\prime} \in \mathbb{C}$ as the redistribution function and PQKK4×4$\mathcal{P}_Q^\frame{KK\prime} \in \frame{\mathbb{C}^\frame{4 \times 4}}$ as the scattering phase matrix. The explicit expression of the scattering phase matrix can be found in Alsina Ballester et al. (2022).

2.4 Redistribution functions

Hereafter, we outline the expressions of the redistribution functions considered in this work, as this is a crucial element of our optimisation strategy. To treat both a two-level and a two-term atomic model within the same formalism, we introduce the indexes ku and k to characterise the upper (label ‘u’) and lower (label ‘’) states of the considered atom. Specifically, we have ku = Mu and k = M for a two-level atom, and ku = ju Mu and k = j M for a two-term atom5. Moreover, since the computation of RQX,KK$\mathcal{R}_Q^\frame{\frame{\text{X}},KK\prime}$ is local in space, in this subsection we neglect the dependence of any quantity on r for ease of notation.

The redistribution function RQII,KK$\mathcal{R}_Q^\frame{II,KK\prime}$ in its general AD description and in the observer’s frame can be written as RQII,KK(Ω,Ω,v,v)=kukuklklAQKK(ku,ku,kl,kl)×[G(Ω,Ω,v,v,ku,kl,kl)+G(Ω,Ω,v,v,ku,kl,kl)],\[\begin{array}{{c}} \frame{\mathcal{R}_Q^\frame{II,KK\prime}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right) = } \hfill & \frame{\mathop \sum \limits_\frame{\frame{k_u}k_u^\prime } \mathop \sum \limits_\frame{\frame{k_\ell }k_\ell ^\prime } A_Q^\frame{KK\prime}\left(\nolbrace \frame{\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right)} \hfill \\ \frame{} \hfill & \frame{ \times \left[\nolbrace \frame{G\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v,k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right)} \norbrace\right.} \hfill \\ \frame{} \hfill & \frame{\left.\nolbrace \frame{ + G\frame{\frame{\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v,\frame{k_u},\frame{k_\ell },k_\ell ^\prime } \norbrace\right)}^ \star }} \norbrace\right],} \hfill \\ \end{array} \](3) where the function G is defined as G(Ω,Ω,v,v,ku,kl,kl)=F(Θ,u(v)+ub(Ω)+uku,kl,u(v)+ub(Ω)+uku,kl),\[\begin{array}{{c}} \frame{G\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v,\frame{k_u},\frame{k_\ell },k_\ell ^\prime } \norbrace\right)} \\ \frame{ = F\left(\nolbrace \frame{\frame{\text{\Theta }},u\left(\nolbrace \frame{v\prime} \norbrace\right) + \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right) + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}},u(v) + \frame{u_\frame{\text{b}}}(\frame{\mathbf{\Omega }}) + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}} \norbrace\right)} \\ \end{array} \](4) with F(Θ,u,u)=1sin(Θ)exp[(uu2sin(Θ/2))2]×W(acos(Θ/2),u+u2cos(Θ/2)).\[\begin{array}{{c}} \frame{F\left(\nolbrace \frame{\frame{\text{\Theta }},u\prime,u} \norbrace\right) = \frac{1}{\frame{\sin (\frame{\text{\Theta }})}}\exp \left[\nolbrace \frame{ - \frame{\frame{\left(\nolbrace \frame{\frac{\frame{u - u\prime}}{\frame{2\sin (\frame{\text{\Theta }}/2)}}} \norbrace\right)}^2}} \norbrace\right]} \\ \frame{ \times W\left(\nolbrace \frame{\frac{a}{\frame{\cos (\frame{\text{\Theta }}/2)}},\frac{\frame{u + u\prime}}{\frame{2\cos (\frame{\text{\Theta }}/2)}}} \norbrace\right).} \\ \end{array} \]

We refer to Appendix B for the definition of AQKK$A_Q^\frame{KK\prime}$. Here, Θ = arccos(Ω · Ω′) is the angle between the incoming Ω′ and outgoing Ω directions (scattering angle), W is the Faddeeva function, and a = (ΓR + ΓI + ΓE)/(4πΔνD) is the damping constant, with ΓE as the line broadening constant due to elastic collisions. In Eq. (4), u(v)=v0vΔvD,ub(Ω)=v0cvbΩΔvD,uku,kl=vku,klv0ΔvD\[u(v) = \frac{\frame{\frame{v_0} - v}}{\frame{\frame{\text{\Delta }}\frame{v_\frame{\text{D}}}}},\quad \frame{u_\frame{\text{b}}}(\frame{\mathbf{\Omega }}) = \frac{\frame{\frame{v_0}}}{c}\frac{\frame{\frame{v_\frame{\text{b}}} \cdot \frame{\mathbf{\Omega }}}}{\frame{\frame{\text{\Delta }}\frame{v_\frame{\text{D}}}}},\quad \frame{u_\frame{\frame{k_u},\frame{k_\ell }}} = \frac{\frame{\frame{v_\frame{\frame{k_u},\frame{k_\ell }}} - \frame{v_0}}}{\frame{\frame{\text{\Delta }}\frame{v_\frame{\text{D}}}}}\] are the reduced frequency, the reduced Doppler shift frequency due to the local plasma bulk velocity vb6, and the reduced frequency for the transition between the upper state |ku⟩ and the lower state |k⟩, respectively, with ν0 as a reference frequency for the considered spectral line or multiplet, ΔνD as the Doppler width in frequency units, c as the speed of light, and vku,kl=[E(ku)E(kl)]/h$\frame{v_\frame{\frame{k_u},\frame{k_\ell }}} = \left[\nolbrace \frame{E\left(\nolbrace \frame{\frame{k_u}} \norbrace\right) - E\left(\nolbrace \frame{\frame{k_\ell }} \norbrace\right)} \norbrace\right]/h$, where E and h are the energy of the considered state and the Planck constant, respectively.

In the definition of RQII,KK$\mathcal{R}_Q^\frame{II,KK\prime}$, Eq. (3), the function G locally couples all frequencies and directions of incident and scattered radiation, making the evaluation of Eq. (2) computationally very demanding. However, we note that in the absence of bulk velocities (or when evaluated in the co-moving frame, see Sect. 4.1), G does not depend on all the couples (Ω′, Ω), but only on the scattering angle Θ. Since evaluating the Faddeeva function is computationally expensive, this property is particularly useful for accelerating the calculation of the emissivity, as detailed in Sect. 4.2.

As far as the ℛIII redistribution function is concerned, we consider its simplified expression under the assumption that the scattering processes that it describes are completely uncorrelated not only in the atomic rest frame, but also in the observer’s frame. This approximation provides accurate results while ensuring a drastic reduction of the computational cost (e.g. Sampoorna et al. 2017; Riva et al. 2023). The redistribution function ℛIII can then be written in a form similar to Eq. (3): RQIII,KK(Ω,Ω,v,v)=kukuklklBQKK(ku,ku,kl,kl)×[W(a,u(v)+ub(Ω)+uku,kl)+W(a,u(v)+ub(Ω)+uku,kl)]×[W(a,u(v)+ub(Ω)+uku,kl)+W(a,u(v)+ub(Ω)+uku,kl)],\[\begin{array}{{c}} \frame{\mathcal{R}_Q^\frame{III,KK\prime}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},v\prime,v} \norbrace\right) = } \hfill & \frame{\mathop \sum \limits_\frame{\frame{k_u}k_u^\prime } \mathop \sum \limits_\frame{\frame{k_\ell }k_\ell ^\prime } B_Q^\frame{KK\prime}\left(\nolbrace \frame{\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right)} \hfill \\ \frame{} \hfill & \frame{ \times \left[\nolbrace \frame{W\left(\nolbrace \frame{a,u\left(\nolbrace \frame{v\prime} \norbrace\right) + \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right) + \frame{u_\frame{k_u^\prime ,\frame{k_\ell }}}} \norbrace\right)} \norbrace\right.} \hfill \\ \frame{} \hfill & \frame{\left.\nolbrace \frame{ + W\frame{\frame{\left(\nolbrace \frame{a,u\left(\nolbrace \frame{v\prime} \norbrace\right) + \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right) + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}}} \norbrace\right)}^ \star }} \norbrace\right]} \hfill \\ \frame{} \hfill & \frame{ \times \left[\nolbrace \frame{W\left(\nolbrace \frame{a,u(v) + \frame{u_\frame{\text{b}}}(\frame{\mathbf{\Omega }}) + \frame{u_\frame{k_u^\prime ,k_\ell ^\prime }}} \norbrace\right)} \norbrace\right.} \hfill \\ \frame{} \hfill & \frame{\left.\nolbrace \frame{ + W\frame{\frame{\left(\nolbrace \frame{a,u(v) + \frame{u_\frame{\text{b}}}(\frame{\mathbf{\Omega }}) + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}} \norbrace\right)}^ \star }} \norbrace\right]} \hfill \\ \end{array} \](5) where the quantity BQKK$B_Q^\frame{KK\prime}$ is defined in Appendix B. Notably, in this expression, all incident directions and frequencies are decoupled from their scattered counterparts.

2.5 Linearity with respect to the radiation field

In our formulation, the non-linearity of the RT problem in I arises from the frequency-integrated absorption coefficient k, which enters both the propagation matrix K and the emission coefficient ε. Indeed, the coefficient k is proportional to the population of the lower level or term, which, in turn, depends non-linearly on the incident radiation field through the SE equations. Notably, the problem becomes linear in I if the population of the lower level or term is known a priori (see, e.g. Janett et al. 2021b). In this case, the propagation matrix K becomes independent of the radiation field I, while ε depends linearly on I. We note that this is formally equivalent to working in optical depth space (τ, see Sect. 3) and incorporating the absorption coefficient, given by the known population of the lower level or term, into the coordinate transformation r → τ (Janett et al. 2021b). In this case, the RT problem can likewise be formulated as a linear system (see, e.g. Trujillo Bueno & Manso Sainz 1999).

In the following, we assume that the polarisation of the radiation field has a negligible impact on the population of the lower level or term, which can thus be reliably obtained from independent RT calculations that neglect polarisation and magnetic fields. This assumption appears justified, given that we are dealing with resonance lines and that the polarisation of the solar radiation, which rarely exceeds a few percent, should only marginally impact the population of ground (or metastable) levels. An analogous approach was also used by Faurobert-Scholl (1992). The lower level or term population thus becomes a fixed input parameter of our polarised RT problem, making it linear. A quantitative verification of the accuracy of this approach is presented in Sect. 6.5.

We note that already available RT codes, such as RH (Uitenbroek 2001) and Multi (Carlsson 1986), allow solving the (unpolarised) NLTE RT problem considering comprehensive multi-level atomic models. Such codes can provide very accurate estimates of the lower-level or term population, through which the considered approach can provide more reliable results than those that would be obtained with self-consistent two-level or term atom calculations.

2.6 Discretisation

To numerically solve the RT problem introduced in the previous subsections, one has first to discretise the continuum variables of the problem r, Ω, and ν. The spatial grid points are provided by the considered atmospheric model, which usually discretises the spatial domain through a Cartesian grid with Nr nodes. The angular discretisation, which samples the unit sphere with NΩ angular nodes, is usually defined in terms of the quadrature chosen to evaluate the angular integral in Eq. (2), that is, we used the same angular grid for the incident and scattered radiation. The angular quadrature is thoroughly examined in Sect. 4.2. Finally, the approximate solution of RT problems also requires a frequency discretisation suitable to sample the spectral features present in the Stokes profiles. Therefore, we discretised the considered finite spectral interval [νmin, νmax] ⊂ ℝ+ with Nν unevenly spaced frequency nodes, which are approximately uniformly spaced in the line core(s) of the considered spectral line(s), and logarithmically distributed in the wings, where less spectral resolution is needed.

2.7 Algebraic formulation

Following a lexicographic criterion ordering (see Benedusi et al. 2023), we collected the discretised Stokes parameters in the vector I ∈ ℝN, with N = 4NrNνNΩ the total number of degrees of freedom, which is also the number of unknowns for the considered problem7. Equation (1) can thus be expressed in the compact matrix form I=Λε+t,\[I = \Lambda \varepsilon + t\frame{\text{,}}\](6) where the linear transfer operator Λ ∈ RN×N encodes the formal solution (see Sect. 3) and the vectors εRN and t ∈ ℝN represent the total emissivity and the radiation transmitted from the boundaries, respectively. We note that using a reverse lexicographic criterion ordering (i.e. considering Λ=UTΛ˜U$\frame{\text{\Lambda }} = \frame{U^T}\overset{}{\mathop \Lambda } U$, with U as a suitable permutation matrix), one can write the transfer operator as a block diagonal matrix Λ˜=diag(Λ˜11,Λ˜12,,Λ˜21,,Λ˜NΩNv)$\overset{}{\mathop \Lambda } = \frame{\text{diag}}\left(\nolbrace \frame{\frame{\frame{\overset{}{\mathop \Lambda } }_\frame{11}},\frame{\frame{\overset{}{\mathop \Lambda } }_\frame{12}}, \ldots ,\frame{\frame{\overset{}{\mathop \Lambda } }_\frame{21}}, \ldots ,\frame{\frame{\overset{}{\mathop \Lambda } }_\frame{\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}} \norbrace\right)$, where the blocks Λ˜ij4Nr×4Nr$\frame{\overset{}{\mathop \Lambda } _\frame{ij}} \in \frame{\mathbb{R}^\frame{4\frame{N_r} \times 4\frame{N_r}}}$ (with i = 1, …, NΩ and j = 1, …, Nν) are lower (for upwards rays) or upper (for downwards rays) triangular because of the structure of the formal solution. Analogously, we can express the calculation of the emission coefficient as ε=ΣI+εth,\[\varepsilon = \Sigma I + \frame{\varepsilon ^\frame{th}},\](7) where the vector εth ∈ ℝN represents the thermal contribution to emissivity and the linear scattering operator Σ ∈ RN×N encodes the numerical quadratures necessary to evaluate Eq. (2), respectively8. Here, Σ=diag(Σ1,,ΣNr)$\frame{\text{\Sigma }} = \frame{\text{diag}}\left(\nolbrace \frame{\frame{\frame{\text{\Sigma }}_1}, \ldots ,\frame{\frame{\text{\Sigma }}_\frame{\frame{N_r}}}} \norbrace\right)$ is a block diagonal matrix, with the spatially local blocks Σi4NvNΩ×4NvNΩ(i=1,,Nr)$\frame{\text{\Sigma }} = \frame{\text{diag}}\left(\nolbrace \frame{\frame{\frame{\text{\Sigma }}_1}, \ldots ,\frame{\frame{\text{\Sigma }}_\frame{\frame{N_r}}}} \norbrace\right)$ that are dense because of the structure of R in Eq. (2). As sparsity patterns suggest, the application of Λ and Σ has a very different computational cost. Indeed, O(N) and O(NNΩNν) floating point operations are required to apply Λ and Σ, respectively.

Equations (6) and (7) can be combined into the matrix equation with an unknown I: (IdΛΣ)I=Λεth+t,\[(Id - \frame{\text{\Lambda \Sigma }})I = \frame{\text{\Lambda }}\frame{\varepsilon ^\frame{th}} + t\](8) where Id ∈ ℝ N×N is the identity matrix. The explicit assembly of the dense coefficient matrix Id − ΛΣ is not suitable for practical applications, because N is typically ∼ 107 for 1D plane-parallel atmospheric models and exceeds 1010 for full 3D atmospheric models. Crucially, we opted for matrix-free applications of the transfer and scattering operators and for an efficient iterative solution to solve the large linear system in Eq. (8). In particular, an efficient strategy to numerically compute the actions of both Λ on ε and Σ on I is exposed in Sects. 3 and 4, respectively. An efficient iterative strategy to solve Eq. (8) for I, given Λ, Σ, εth, and t, is then presented in Sect. 5.

3 Formal solution

The application of Λ in Eq. (6) commonly requires two steps: the conversion from the geometrical scale to the optical depth scale, denoted as τ, and the subsequent numerical integration of Eq. (1) with a suitable formal solver. The conversion to the optical scale is required both to apply an exponential integrator (i.e. the DELO-methods) and to enforce the numerical stability of the formal solution (e.g. Janett & Paganini 2018). The accuracy of the formal solution is thus impacted by the choice of both the formal solver and the optical depth conversion scheme (D’Anna et al. 2024).

We note that the RT equation is inherently 1D in space, as it describes how the radiation varies while propagating along a straight line. Hereafter, we thus consider the RT problem for the 1D plane-parallel setting, noting that the generalisation to the 3D case is conceptually straightforward. Formally, in a 1D plane-parallel atmosphere, the coordinate r = (x, y, z) is replaced by the vertical coordinate z ∈ [zmin, zmax]. By defining the optical depth scale as the solution to the initial value problem dτ(z,Ω,v)=η1(z,Ω,v)cos(θ)dz,\[\frame{\text{d}}\tau (z,\frame{\mathbf{\Omega }},v) = - \frac{\frame{\frame{\eta _1}(z,\frame{\mathbf{\Omega }},v)}}{\frame{\cos (\theta )}}\frame{\text{d}}z,\] with the initial condition τ (zmax, Ω, ν) = 0 and where η1 ∈ ℝ+ is the total absorption coefficient for intensity, we recast Eq. (1) into the form ddτI(τ,Ω,v)=K(τ,Ω,v)η1(τ,Ω,v)I(τ,Ω,v)ε(τ,Ω,v)η1(τ,Ω,v),\[\frac{\frame{\text{d}}}{\frame{\frame{\text{d}}\tau }}I(\tau ,\frame{\mathbf{\Omega }},v) = \frac{\frame{K(\tau ,\frame{\mathbf{\Omega }},v)}}{\frame{\frame{\eta _1}(\tau ,\frame{\mathbf{\Omega }},v)}}I(\tau ,\frame{\mathbf{\Omega }},v) - \frac{\frame{\varepsilon (\tau ,\frame{\mathbf{\Omega }},v)}}{\frame{\frame{\eta _1}(\tau ,\frame{\mathbf{\Omega }},v)}},\](9) where the dependence of τ on Ω and ν has not been explicitly indicated for notation simplicity. Here, the term ε/η1 corresponds to the well known source vector. The increment of optical depth between two generic height nodes zi and zi+1 (assuming zi+1 > zi, and thus θ ∈ [0, π/2)) for a given direction Ω is computed by solving Δτ(Ω,v)=1cos(θ)zizi+1η1(z,Ω,v)dz0,\[\frame{\text{\Delta }}\tau (\frame{\mathbf{\Omega }},v) = \frac{1}{\frame{\cos (\theta )}}\mathop \smallint \nolimits_\frame{\frame{z_i}}^\frame{\frame{z_\frame{i + 1}}} \frame{\eta _1}\left(\nolbrace \frame{z\prime,\frame{\mathbf{\Omega }},v} \norbrace\right)\frame{\text{d}}z\prime \geqslant 0\] which requires a suitable quadrature scheme (e.g. trapezoidal, backward parabolic, spline, cubic Hermite; see D’Anna et al. 2024).

Once the optical depth conversion scheme is set, one can solve Eq. (9) by means of a suitable integrator, provided that appropriate boundary conditions are given. Presently, we assume that the radiation entering the atmospheric model from the lower boundary is isotropic, unpolarised, and Planckian in the Wien limit, and that no radiation is entering from the upper boundary. Finally, given K, ε, and τ at all spatial points, Eq. (9) is numerically solved for each individual ray of orientation Ω and frequency ν by applying a suitable formal solver, such as the DELO-linear, DELOPAR, DELO-parabolic, and BESSER exponential integrators (e.g. Trujillo Bueno 2003; Štěpán & Trujillo Bueno 2013; Janett et al. 2017; Janett & Paganini 2018).

4 Calculation of emissivity

In this section, we present a strategy to perform an accurate and efficient application of Σ in Eq. (7). This involves the evaluation of ε,sc through Eq. (2), which requires both an angular quadrature (see Sect. 4.2) and a spectral quadrature (see Sect. 4.3). Since the evaluation of ℛII is generally the computational bottle-neck of PRD–AD numerical codes (e.g. Riva 2023), our strategy aims at minimising the number of its evaluations, as detailed in the following.

4.1 Treatment of bulk velocities

The numerical solution of RT problems in dynamic atmospheres is more complex than its static counterpart. Indeed, the presence of a local bulk velocity field vb introduces frequency (Doppler) shifts in the radiation field, as perceived by the atoms. These shifts depend on the projections vb · Ω′ (for the absorbed radiation) and vb · Ω (for the emitted radiation) and add angular and spatial dependencies to the arguments of the frequency-dependent functions appearing in the definitions of both K and ε.

In order to speed up the computation of εsc, and drawing inspiration from the work by Leenaarts et al. (2012), Eq. (2) is evaluated in the co-moving reference frame, in which the local bulk velocity is zero. Namely, we first transformed the incident radiation field from the observer’s frame to the co-moving frame: I(r,Ω,v)I¯(r,Ω,v)=I(r,Ω,v¯),\[I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},v\prime} \norbrace\right) \to \bar I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},v\prime} \norbrace\right) = I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\frame{\bar v}^\prime }} \norbrace\right),\] with v¯=v+v0vbΩ/c$\frame{\bar v^\prime } = v\prime + \frame{v_0}\frame{v_\frame{\text{b}}} \cdot \frame{\mathbf{\Omega \prime}}/c$ denoting the incident Doppler shifted frequency and Ī as the Stokes vector in the co-moving frame. This is easily performed by means of interpolations. We then computed the scattering integral in the co-moving frame: ε¯sc(r,Ω,v)=k(r)dvdΩ4πR¯(r,Θ,v,v)I¯(r,Ω,v),\[\frame{\bar \varepsilon ^\frame{sc}}(r,\frame{\mathbf{\Omega }},v) = k(r)\smallint \frame{\text{d}}v\prime\oint \frac{\frame{\frame{\text{d}}\frame{\mathbf{\Omega \prime}}}}{\frame{4\pi }}\bar R\left(\nolbrace \frame{r,\frame{\text{\Theta }},v\prime,v} \norbrace\right)\bar I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},v\prime} \norbrace\right),\](10) with R¯(r,Θ,v,v)=R(r,Ω,Ω,v¯,v¯)$\bar R\left(\nolbrace \frame{r,\frame{\text{\Theta }},v\prime,v} \norbrace\right) = R\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},\frame{\frame{\bar v}^\prime },\bar v} \norbrace\right)$ as the redistribution matrix evaluated in the co-moving frame, where v¯=v+v0vbΩ/c$\bar v = v + \frame{v_0}\frame{v_\frame{\text{b}}} \cdot \frame{\mathbf{\Omega }}/c$. The advantage of this choice is that R¯$\bar R$ does not depend on all the couples of angles (Ω′, Ω), but only on the scattering angle Θ (see Sect. 2.4). At the same time, the dedicated quadrature grid for calculating the scattering integral is independent of the Doppler shifts. This way, the number of evaluations of the redistribution functions can be drastically reduced (see Sects. 4.2 and 4.3).

Afterwards, the ensuing emission coefficient is transformed from the co-moving frame back to the observer’s frame: ε¯Sc(r,Ω,v)εSc(r,Ω,v)=ε¯Sc(r,Ω,vv0vbΩ/c).\[\frame{\bar \varepsilon ^\frame{Sc}}(r,\frame{\mathbf{\Omega }},v) \to \frame{\varepsilon ^\frame{Sc}}(r,\frame{\mathbf{\Omega }},v) = \frame{\bar \varepsilon ^\frame{Sc}}\left(\nolbrace \frame{r,\frame{\mathbf{\Omega }},v - \frame{v_0}\frame{v_\frame{\text{b}}} \cdot \frame{\mathbf{\Omega }}/c} \norbrace\right).\]

Once again, this is performed by means of interpolations, from the co-moving to the observer’s frame frequency grid. We note that interpolations between the ν and ν¯$\bar \nu $ grids allow for the use of different discretisation schemes in the observer’s and co-moving frames. In this work, we adopted the same grid in both frames for simplicity. Moreover, the presence of numerical instabilities (e.g. oscillations) in the computed Stokes profiles may indicate that the frequency grid of the problem is not sufficiently dense (or wide) for the considered bulk velocities. A possible remedy to this issue is the use of high-order non-oscillatory interpolations (e.g. Janett et al. 2019).

4.2 Angular quadrature

When selecting the angular quadrature to be applied to Eq. (2), one has to consider some constraints imposed by the nature of the RT problem (e.g. Riva et al. 2023). First, the number of distinct scattering angle nodes NΘ should be kept as small as possible. Indeed, when implementing the optimisation strategy described in Sect. 4.1, the required number of evaluations of RQII,KK$\mathcal{R}_Q^\frame{II,KK\prime}$ scales with NΘ, rather than with NΩ2$N_\frame{\text{\Omega }}^2$. Thus, if NΘNΩ2$\frame{N_\frame{\text{\Theta }}} \ll N_\frame{\text{\Omega }}^2$, we can achieve a significant speed-up of the computation of the emissivity. Second, considering that the integration of the scattering emissivity requires a large amount of time to solution, one must guarantee a given accuracy with the smallest possible number of quadrature nodes. Third, quadrature nodes that imply a backward scattering geometry (i.e. the scattering angle Θ = π) should be avoided (see Sect. 4.3). Finally, we note that quadrature nodes with an inclination of θ = π/2 are usually avoided in practical applications because horizontal directions never encounter the vertical top and bottom boundaries of the spatial domain.

Many methods for performing the angular quadrature have been proposed in the literature (e.g. Carlson 1963; Koch & Becker 2004; Hesse et al. 2015), also with a focus on the RT modelling of scattering polarisation signals (e.g. Stepán et al. 2020; Jaume Bestard et al. 2021). In particular, Riva (2023) analysed different angular quadrature rules for the PRD–AD setting, finding that the most suitable ones are the approaches based on the Cartesian product and Lebedev’s rules. In particular, the Cartesian product rule guarantees a high order of accuracy and easily allows one to avoid both horizontal directions (e.g. by using for the inclination a Gauss-Legendre (GL) quadrature with an even number of nodes, or two contiguous GL quadratures) and the backward scattering geometry (e.g. by using for the azimuth a trapezoidal quadrature with an odd number of nodes). We thus adopted an angular quadrature given by the tensor product of a trapezoidal quadrature for the azimuthal interval [0, 2π) for χ and two GL quadrature nodes, one in each inclination subinterval [−1, 0] and [0, 1] for the heliocentric angle µ = cos(θ).

4.3 Spectral quadrature

Hereafter, it is convenient to work directly with the reduced frequencies un = u(νn), where the set {vn}n=1Nv$\left\{\nolbrace \frame{\frame{v_n}} \norbrace\right\}_\frame{n = 1}^\frame{\frame{N_v}}$ represents the discrete points of the frequency grid. The integral over ν′ in Eq. (10) is then numerically evaluated as R¯(r,Θ,v,vn)I¯(r,Ω,v)dvΔvDn=1NvwnR¯(r,Θ,un,un)I(r,Ω,unub(Ω)),\[\begin{array}{{c}} \frame{\smallint \bar R\left(\nolbrace \frame{r,\frame{\text{\Theta }},v\prime,\frame{v_n}} \norbrace\right)\bar I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},v\prime} \norbrace\right)\frame{\text{d}}v\prime} \\ \frame{ \approx \frame{\text{\Delta }}\frame{v_\frame{\text{D}}}\mathop \sum \limits_\frame{n\prime = 1}^\frame{\frame{N_\frame{v\prime}}} \frame{w_\frame{n\prime}}\bar R\left(\nolbrace \frame{r,\frame{\text{\Theta }},\frame{u_\frame{n\prime}},\frame{u_n}} \norbrace\right)I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},\frame{u_\frame{n\prime}} - \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right)} \norbrace\right),} \\ \end{array} \] where {un}n=1Ny$\left\{\nolbrace \frame{\frame{u_\frame{n\prime}}} \norbrace\right\}_\frame{n\prime = 1}^\frame{\frame{N_\frame{y\prime}}}$ and {wn}n=1Nv$\left\{\nolbrace \frame{\frame{w_\frame{n\prime}}} \norbrace\right\}_\frame{n\prime = 1}^\frame{\frame{N_\frame{v\prime}}}$ are the chosen quadrature nodes and weights, respectively. Here, we used I(r, Ω, ν)dν = ΔνD I(r, Ω, u)du, noting that in this work, we always define the Stokes parameters I, as well as the redistribution matrices R, per unit of frequency. We also note that to apply the chosen quadrature rule, the radiation field I has to be interpolated from the original grid un to the quadrature grid in the co-moving frame unub(Ω)$\frame{u_\frame{n\prime}} - \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right)$. Moreover, since the redistribution functions R¯II$\frame{\bar \mathcal{R}^\frame{II}}$ and R¯III $\frame{\bar \mathcal{R}^\frame{\frame{\text{III~}}}}$ (the overbars indicating that they are expressed in the comoving frame, as discussed in Sect. 4.1) display very different computational complexities, distinct quadrature grids are used to evaluate the integral over ν′ for the two different cases. These are detailed below.

Given the high computational cost of evaluating R¯II$\frame{\bar R^\frame{II}}$, it is crucial to minimise Nv$\frame{N_\frame{v\prime}}$. By considering that the transformation of G from the observer’s frame to the co-moving frame is G(Ω,Ω,vn,vn,ku,kl,kl)G¯(Θ,vn,vn,ku,kl,kl)=F(Θ,un+uku,kl,un+uku,kl),\[\begin{array}{{c}} \frame{G\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},\frame{v_\frame{n\prime}},\frame{v_n},\frame{k_u},\frame{k_\ell },k_\ell ^\prime } \norbrace\right) \to \bar G\left(\nolbrace \frame{\frame{\text{\Theta }},\frame{v_\frame{n\prime}},\frame{v_n},\frame{k_u},\frame{k_\ell },k_\ell ^\prime } \norbrace\right)} \\ \frame{ = F\left(\nolbrace \frame{\frame{\text{\Theta }},\frame{u_\frame{n\prime}} + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}},\frame{u_n} + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}} \norbrace\right),} \\ \end{array} \] our selection of {un}n=1Nv$\left\{\nolbrace \frame{\frame{u_\frame{n\prime}}} \norbrace\right\}_\frame{n\prime = 1}^\frame{\frame{N_\frame{v\prime}}}$ and {wn}n=1Nv$\left\{\nolbrace \frame{\frame{w_\frame{n\prime}}} \norbrace\right\}_\frame{n\prime = 1}^\frame{\frame{N_\frame{v\prime}}}$ is based on the following properties: (a) the behaviour in frequency of the integrands in Eq. (10) is mostly driven by the dependence of R¯$\bar R$ on Θ, ν′, and ν, and only to a lesser extent by the incident radiation field; (b) for typical solar chromospheric conditions, a ≪ 1; (c) the function F quickly drops to 0 as |ununukl,kl|$\left|\nolbrace \frame{\frame{u_\frame{n\prime}} - \frame{u_n} - \frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }}} \norbrace\right|$ increases, with ukl,kl=vkl,kl/ΔvD$\frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }} = \frame{v_\frame{\frame{k_\ell },k_\ell ^\prime }}/\frame{\text{\Delta }}\frame{v_\frame{\text{D}}}$ as the reduced frequency splitting between states pertaining to the same level or term; (d) if Θ is small or |un+uku,kl|$\left|\nolbrace \frame{\frame{u_n} + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}} \norbrace\right|$ is large, then F is close to a Gaussian function centred on un=un+ukl,kl$\frame{u_\frame{n\prime}} = \frame{u_n} + \frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }}$; (e) if |un+uku,kp|2$\left|\nolbrace \frame{\frame{u_n} + \frame{u_\frame{\frame{k_u},k_p^\prime }}} \norbrace\right| \lesssim 2$, then Re(F) has one local maximum and Im(F) experiences a sharp sign reversal close to un=(un+uku,kl)cos(Θ)uku,kl$\frame{u_\frame{n\prime}} = \left(\nolbrace \frame{\frame{u_n} + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}} \norbrace\right)\cos (\frame{\text{\Theta }}) - \frame{u_\frame{\frame{k_u},\frame{k_\ell }}}$, with Re and Im denoting the real and the imaginary part, respectively; (f) if 2|un+uku,kl|6$2 \lesssim \left|\nolbrace \frame{\frame{u_n} + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}} \norbrace\right| \leqslant 6$, then Re(F) has two local maxima and Im(F) displays one local extremum and a sharp sign reversal, respectively; (g) the case Θ = π introduces extremely sharp peaks that are difficult to integrate numerically. The regimes (e) and (f) are generally referred to as line core and near wings, respectively. For instance, the left panel of Fig. 1 displays Re(F) in the near-wing (blue line) and line-core (red line) regimes, as well as the positive (yellow line) and negative (purple line) values of Im(F) in the near-wing regime. We refer to Chapter 2 of Riva (2023) for a more comprehensive analysis of the behaviour of the redistribution function ℛ II. Finally, we note that under typical solar chromospheric conditions, the shifts uku,kl$\frame{u_\frame{\frame{k_u},\frame{k_\ell }}}$ cluster around either one single value (for either a two-level atom or a two-term atom with completely blended fine-structure components, such as H I Ly-α) or around a few values (e.g. two for the Mg II h&k doublet), with the distance of uku,kl$\frame{u_\frame{\frame{k_u},\frame{k_\ell }}}$ from the centre of the corresponding cluster being much smaller than one. We denote the centre of each cluster as ui$u_i^ \star $, with i = 1, …, # of clusters9.

In practice, we do not need to generate a quadrature grid for each possible combination (ku,kl,kl)$\left(\nolbrace \frame{\frame{k_u},\frame{k_\ell },k_\ell ^\prime } \norbrace\right)$. Instead, it is enough to consider a set of quadrature nodes that well approximates the integral F(Θ,u+ui,un+uj)du$\smallint F\left(\nolbrace \frame{\frame{\text{\Theta }},u\prime + u_i^ \star ,\frame{u_n} + u_j^ \star } \norbrace\right)\frame{\text{d}}u\prime$ for all couples (i, j). This means that the selection of {un}n=1Nv$\left\{\nolbrace \frame{\frame{u_\frame{n\prime}}} \norbrace\right\}_\frame{n\prime = 1}^\frame{\frame{N_\frame{v\prime}}}$ only depends on r, Θ, u, and ui$u_i^ \star $ 10. This property of the spectral quadrature allows us to reduce the number of interpolations of I required to evaluate the emissivity.

The strategy adopted in this work, which is detailed in Appendix C, can be summarised as follows: if Θ = 0, then F(0,u,u)=πδ(uu)W(a,u)$F\left(\nolbrace \frame{0,u,u\prime} \norbrace\right) = \sqrt \pi \delta \left(\nolbrace \frame{u - u\prime} \norbrace\right)W\left(\nolbrace \frame{a,u\prime} \norbrace\right)$ and the integral F(Θ,u+uku,kl,un+uku,kl)I(r,Ω,uub(Ω))du\[\smallint F\left(\nolbrace \frame{\frame{\text{\Theta }},u\prime + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}},\frame{u_n} + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}} \norbrace\right)I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},u\prime - \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right)} \norbrace\right)\frame{\text{d}}u\prime\](11) is carried out analytically. Otherwise, if Θ is small or − un is far from all ui$u_i^ \star $, we used a Gauss-Hermite quadrature with 65 nodes, thus exploiting property (d). In all other cases, we are either in the line-core (e) or in the near-wing (f) regimes, and we adopted a GL quadrature with a number of nodes that depends on Θ and |un+ui|$\left|\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right|$. An additional strategy adopted in this work to further diminish the number of evaluations of the Faddeeva function is presented in Appendix D.

As illustrative examples, the left panel of Fig. 1 shows the frequency quadrature nodes as dots for the case of a single cluster with u = −11.15. The central panel displays the number of frequency nodes Nv$\frame{N_\frame{v\prime}}$ generated with u1=11.15$u_1^ \star = - 11.15$ and u2=20$u_2^ \star = 20$ for different un and Θ. Finally, the right panel illustrates the relative error of evaluating Eq. (11) with the strategy outlined above, with I = (1, 0, 0, 0), a = 0.01, uku,kl=uku,kf=11.1,u1=11.15$\frame{u_\frame{\frame{k_u},\frame{k_\ell }}} = \frame{u_\frame{\frame{k_u},k_f^\prime }} = - 11.1,u_1^\prime = - 11.15$, and u2=20$u_2^ \star = 20$ 11. Notably, with about 100−300 spectral quadrature nodes, we obtain a relative error that is always smaller than 10−8.

Concerning the R¯III $\frame{\bar \mathcal{R}^\frame{\frame{\text{III~}}}}$ redistribution function, the situation is much simpler than for its R¯II$\frame{\bar \mathcal{R}^\frame{\frame{\text{II}}}}$ counterpart, as the incident and emergent frequencies are totally uncorrelated (see Sect. 2.4). Therefore, for the numerical integration of R¯III $\frame{\bar \mathcal{R}^\frame{\frame{\text{III~}}}}$ I over frequency, it is possible to choose a quadrature grid independent of r, Θ, and un. In the following, we consider a single GL rule with 2001 nodes in the interval [ − 200, 200].

We note that when evaluated numerically, Eq. (2) should be suitably normalised to avoid spurious sources or sinks of photons (e.g. Adams et al. 1971). In Appendix E, we show how the generalised Kirchhoff’s law can be used to perform this task. This method is presently used to normalise the intensity component of the emission vector when computing the results presented in Sect. 6. By applying this procedure, we improved both the accuracy of the results and the robustness of the iterative method.

thumbnail Fig. 1

Illustrative examples of the quadrature grids. Left: real part (blue and red lines) and positive and negative values of the imaginary part (yellow and purple lines, respectively) of F as a function of u(un+uk,k)$u\prime - \left(\nolbrace \frame{\frame{u_n} + \frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }}} \norbrace\right)$, with u′ = u(ν′), un = u(νn), and uk,k=uku,kuku,k$\frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }} = \frame{u_\frame{\frame{k_u},k_\ell ^\prime }} - \frame{u_\frame{\frame{k_u},\frame{k_\ell }}}$, for different values of u+uku,k$u + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}$. Here, a = 0.01, Θ = 0.9π, uku,k=11.1$\frame{u_\frame{\frame{k_u},\frame{k_\ell }}} = - 11.1$, and uku,kf=11.2$\frame{u_\frame{\frame{k_u},k_f^\prime }} = - 11.2$. The dots denote the quadrature nodes un′ generated with u = −11.15. Centre: number of quadrature nodes as a function of un and Θ, with a = 0.01, u1=11.15$u_1^ \star = - 11.15$, and u2=20$u_2^ \star = 20$. Right: logarithm of the relative error of evaluating Eq. (11) with the quadrature nodes of the central panel with respect to the reference values obtained with the Gauss–Kronrod adaptive method, with I = (1, 0, 0, 0), a = 0.01, and uku,k=uku,k=11.1$\frame{u_\frame{\frame{k_u},\frame{k_\ell }}} = \frame{u_\frame{\frame{k_u},k_\ell ^\prime }} = - 11.1$.

5 Iterative solution strategy

The considered RT problem has been recast in the linear system given by Eq. (8), for which we have to find a solution. Given the size of the system (N ∼ 107 for small-scale 1D applications, see Sect. 6.2) and that the matrix Id − ΛΣ in Eq. (8) is dense, the use of direct matrix inversion methods is unfeasible. Thus, the application of an iterative solution strategy is necessary.

5.1 Matrix-free iterative methods

Krylov methods are well suited for matrix-free approaches and proved to be highly effective solution strategies in the RT context for large linear systems (e.g. Jolivet et al. 2021; Benedusi et al. 2021, 2023). In the present work, we thus considered the generalised minimal residual (GMRES) iterative method in its matrix-free version. For increased flexibility, we also explored other iterative solution strategies, such as the Richardson and the alternating Anderson-Richardson (AAR) methods (Hackbusch 1994; Suryanarayana et al. 2019). We monitored the convergence of the iterative methods by evaluating the relative residual res =||Λεth+t(IdΛΣ)I||2||Λεth+t||2,\[\frame{\text{res~}} = \frac{\frame{\Lambda \frame{\varepsilon ^\frame{th}} + t - (Id - \frame{\text{\Lambda \Sigma }})\frame{I_2}}}{\frame{\frame{\text{\Lambda }}\frame{\varepsilon ^\frame{th}} + \frame{t_2}}},\] taking as a stopping criterion res < tol for a given tolerance, tol.

5.2 Preconditioning

Preconditioning of linear systems can significantly increase robustness and convergence speed of iterative techniques. Given P ∈ ℝ N×N a non-singular matrix, the left preconditioning12 of Eq. (8) was obtained by considering the equivalent system P1(IdΛΣ)I=P1(Λεth+t).\[\frame{P^\frame{ - 1}}(Id - \frame{\text{\Lambda \Sigma }})I = \frame{P^\frame{ - 1}}\left(\nolbrace \frame{\frame{\text{\Lambda }}\frame{\varepsilon ^\frame{th}} + t} \norbrace\right)\]

We emphasise that to be effective, P should be a good and computationally cheap approximation of the operator Id − ΛΣ. Janett et al. (2024) showed that when dealing with RT problems for polarised radiation including AD PRD effects, common algebraic preconditioners, such as Jacobi and SOR, are out-performed by tailored physics-based preconditioners, that is, operators corresponding to a simplified physical setting of the considered problem. Crucially, physics-based preconditioners do not require the explicit algebraic description of the operators of interest and are very intuitive to implement. In our RT problem, we can write physics-based preconditioners as P=IdΛΣ,\[P = Id - \frame{\frame{\text{\Lambda }}^ \star }\frame{\frame{\text{\Sigma }}^ \star }\] where Λ and Σ encode the approximations of Λ and Σ.

A variety of simplifications can be adopted to design Σ. For instance, a common approach to lower the computational complexity of Σ is to consider the so-called AA approximation (e.g. Mihalas 1978; Rees & Saliba 1982; Bommier 1997b). Within this approximation, the redistribution function in the co-moving frame describing scattering processes that are coherent in frequency in the atomic rest frame can be written as R¯QIIAA,KK(v,v)=120πsin(Θ)R¯QII,KK(Θ,v,v).\[\bar \mathcal{R}_Q^\frame{II - AA,KK\prime}\left(\nolbrace \frame{v\prime,v} \norbrace\right) = \frac{1}{2}\mathop \smallint \nolimits_0^\pi \sin (\frame{\text{\Theta }})\bar \mathcal{R}_Q^\frame{II,KK\prime}\left(\nolbrace \frame{\frame{\text{\Theta }},v\prime,v} \norbrace\right)\frame{\text{d\Theta }}.\](12)

Remarkably, this redistribution function is independent of propagation directions and only couples the frequencies of the incident and scattered radiation. We note that the AA approximation is not only useful in the context of physics-based preconditioners, but it also yields reliable results when applied to the modelling of the intensity spectra of strong resonance lines (see Leenaarts et al. 2012; Sukhorukov & Leenaarts 2017). As far as scattering polarisation is concerned, the AA approximation can either provide satisfactory results (e.g. Riva et al. 2024; del Pino Alemán et al. 2024), or introduce large and hardly predictable inaccuracies (e.g. Sampoorna et al. 2017; Janett et al. 2021a; Belluzzi et al. 2024). For this reason, it is always important to carefully assess its suitability under different conditions, as discussed in Sect. 6.6 for the H I Ly-α line.

To further simplify Λ and Σ, it is also possible to neglect polarisation and magnetic fields, or assume an isotropic emission vector in the co-moving frame (Benedusi et al. 2022; Janett et al. 2024). Finally, we note that the application of P−1 itself requires solving a linear system of the form Px = y. This is presently achieved iteratively with a matrix-free iterative method, meaning that the whole linear problem is solved by means of two nested iterative solvers. To further enhance the performance of our solution strategy, we also implemented the possibility of preconditioning the linear system Px = y, as detailed in Appendix F.

6 Numerical applications

The solution strategy outlined in Sects. 25 was implemented in TRAP4 as a MATLAB (MATLAB 2023) routine, considering plane-parallel 1D models, and parallelised by spatially decomposing the calculation of εsc across threads. Hereafter, we discuss concrete applications of TRAP4. Specifically, after presenting the atmospheric and atomic models and the numerical setting, we investigate the numerical error affecting our results, we perform a benchmark with the HanleRT-TIC13 code (del Pino Alemán et al. 2016, 2020), and we discuss the suitability of using the PRD–AA approximation with respect to full AD calculations. For our applications, we considered the following chromospheric resonance lines whose modelling requires the inclusion of both PRD effects and J-state interference: the Mg II h&k doublet at 2800 Å and the H I Ly-α line at 1216 Å. For sake of conciseness, in the following we do not discuss Stokes V, although it is always included in our calculations.

6.1 Atmospheric and atomic models

In this work, calculations were carried out in a 1D plane-parallel domain extracted from the semi-empirical atmospheric model C (hereafter FAL-C) of Fontenla et al. (1993), which fully contains the formation region of the considered spectral lines. Even if 1D, this model is sophisticated enough to test our strategy and assess the suitability of using the AA approximation to model wavelength-integrated scattering polarisation signals of the H I Ly-α line.

In the following, we consider the contribution to the Doppler width due to non-thermal microturbulent velocity: ΔvD(z)=v0c2kBT(z)M+ξ(z)2,\[\frame{\text{\Delta }}\frame{v_\frame{\text{D}}}(z) = \frac{\frame{\frame{v_0}}}{c}\sqrt \frame{\frac{\frame{2\frame{k_\frame{\text{B}}}T(z)}}{M} + \xi \frame{\frame{(z)}^2}} ,\] where T is the temperature, M the mass of the atom, and ξ the microturbulent velocity determined according to Fontenla et al. (1991). Moreover, for the sake of generality, some calculations were carried out in the presence of magnetic and bulk velocity fields, which were added ad-hoc to the atmospheric model, as detailed in the following subsections.

The Mg II h&k lines result from two distinct fine-structure transitions between the ground level of ionised magnesium 3s2S1/2 and the first excited term composed by the levels 3p2P1/2o$3\frame{\frame{\text{p}}^2}\frame{\text{P}}_\frame{1/2}^\frame{\text{o}}$ and 3p2P3/2o$3\frame{\frame{\text{p}}^2}\frame{\text{P}}_\frame{3/2}^o$. These two fine-structure components are separated by 7 Å and give thus rise to two well distinct lines. The H I Ly-α line also results from two distinct fine-structure transitions, between the ground level of hydrogen 1s 2S1/2 and the excited term composed by the levels 2p2P1/2o$2\frame{\frame{\text{p}}^2}\frame{\text{P}}_\frame{1/2}^o$ and 2p2P3/2o$2\frame{\frame{\text{p}}^2}\frame{\text{P}}_\frame{3/2}^o$ 14. Contrary to the Mg II h&k lines, these two fine-structure components are separated by 6 mÅ only, and are thus completely blended. The relevant atomic parameters for the Mg II h&k doublet and the H I1 Ly-α line are provided in Table 1.

In addition to the atmospheric and atomic parameters, TRAP4 also requires as input quantities the broadening constants ΓR, ΓI, ΓE, and the lower-level or term population of the considered transition. For all our calculations, we used ΓR = Auℓ, with Auℓ the Einstein coefficient for spontaneous emission from the upper to the lower term (see Table 1). For Mg II, we calculated the ground-level population using the HanleRT-TIC code, neglecting polarisation and considering a static unmagnetised atmosphere and a two-term atom with AD PRD effects. The same code was also used to calculate the ΓE and ΓI broadenings, as well as the continuum coefficients κc, σc, and εc,th (see Appendix A). In particular, ΓE accounts for elastic collisions with both neutral hydrogen and helium perturbers via Van der Waals interactions and the quadratic Stark effect, while ΓI is calculated treating inelastic collisions in a two-term atom following Belluzzi et al. (2013). For H I Ly-α, we used the hydrogen ground-level population tabulated in the FAL-C model. The broadening due to inelastic de-exciting collisions was evaluated as ΓI = NeQul, with Ne the electron density from the FAL-C model and Qul(z)=8.63106v(z)guT(z),\[\frame{Q_\frame{ul}}(z) = 8.63 \cdot \frame{10^\frame{ - 6}}\frac{\frame{v(z)}}{\frame{\frame{g_u}\sqrt \frame{T(z)} }},\] where gu = 8 is the degeneracy of the upper level with principal quantum number n = 2 and the coefficient v (which depends on T ) is taken according to Przybilla & Butler (2004). Furthermore, ΓE was computed with the RH code (Uitenbroek 2001), fixing the hydrogen ground-level population to the value provided by the FAL-C model and considering collisions with neutral hydrogen and helium perturbers via both linear and quadratic Stark effects. The values of κc, σc, and εc,th were also computed with RH. A similar procedure was used to initialise the H I Ly-α calculations in Alsina Ballester et al. (2022).

Table 1

Atomic parameters for the Mg II h&k doublet and the H I Ly-α line.

6.2 Physical and numerical parameters

Concerning the spectral grid, we used 210 wavelength nodes in the interval [2705.5 Å, 2901.2 Å] for the Mg II h&k doublet and 191 wavelength nodes in the interval [1184.5 Å, 1248.6 Å] for the H I Ly-α line. For the angular discretisation, we used nine nodes uniformly distributed in χ, whereas we used two sets (one for each hemisphere) of six GL nodes for the heliocentric angles µ = cos(θ), for a total NΩ = 108. Given that Nr = 70 for the FAL-C atmospheric model, the RT problem in Eq. (8) thus had N = 4NrNνNΩ ∼ 6 · 106 degrees of freedom for both atomic models. We note that the chosen grids correspond to a number of scattering angles NΘ=205NΩ2=11664$\frame{N_\frame{\text{\Theta }}} = 205 \ll N_\frame{\text{\Omega }}^2 = 11664$ and an averaged number of spectral quadrature nodes Nv133$\frame{N_\frame{v\prime}} \simeq 133$ and Nv127$\frame{N_\frame{v\prime}} \simeq 127$ for Mg II and H I, respectively. Presently, all inter-polations between the observer’s and the co-moving frame (and vice versa) are performed in terms of cubic splines.

Concerning the formal solver, we used the BESSER exponential integrator for the Mg II h&k doublet, consistently with the recent work by del Pino Alemán et al. (2024). On the other hand, we used the DELOPAR exponential integrator for the H I Ly-α line, to allow direct comparisons with previous works in the literature (e.g. Alsina Ballester et al. 2022). As the BESSER integrator introduces some small non-linearity into the problem due to the source vector interpolation used to avoid overshooting (see the definition of the control points in Štěpán & Trujillo Bueno 2013), we opted for the AAR iterative method with tol = 10−9 for the Mg II h&k doublet, whereas we used GMRES with tol = 10−10 for the H I Ly-α line. After reaching the desired tolerance, we performed an additional formal solution to compute the final results at specific directions that are not part of the angular grid.

With the above numerical parameters, the code employed approximately 1700 s for the Mg II h&k doublet and 1450 s for the H I Ly-α line to perform a single preconditioned iteration on an Intel Xeon CPU E5-1620. Overall, for both atomic mod-els, the largest fraction of the computational time was spent for evaluating ε,sc, which took about 1300 s per iteration. Thanks to our solution strategy, only 25% of this time was spent in evaluating the Faddeeva function, whereas approximately 55 − 60% of it was employed to interpolate I to the spectral quadrature grid and assemble Wku,kl$\frame{W_\frame{\frame{k_u},\frame{k_\ell }}}$ in Eq. (D.1). Moreover, by employing the block-diagonal preconditioner introduced in Appendix F, we ensured that less than 20% of the full solution time was spent in pre-conditioning the system. Finally, given the high performances of physics-based preconditioned methods, the target tolerance was reached with only 10–12 iterations when starting from a zero initial guess.

6.3 Solution verification

Before using any numerical results to perform a physical investigation, it is essential to assess if they are accurate enough for their intended use. This task is known as solution verification. In this respect, we note that the tolerances specified in Sect. 6.2 are very conservative, thus ensuring unnoticeable differences in the emerging profiles when further reducing tol by an order of magnitude. Moreover, besides carrying out the reference calculations with numerical parameters as given in Sect. 6.2, we carried out three additional calculations for both the Mg II h&k doublet and the H I Ly-α line: one with doubled spatial resolution, where we introduced a new set of grid points equidistant to each pair of adjacent original points and interpolated the input variables to the new grid; one with increased angular resolution, with fifteen azimuths and two sets of ten GL inclinations for a total NΩ = 300; and one with doubled Nν. For all these calculations, we considered a static atmosphere with a height-independent horizontal (χB = 0 and θB = π/2) magnetic field of 20 and 50 G for the Mg II h&k doublet and the H I Ly-α line, respectively.

The resulting profiles for a LOS µ = 0.1 are shown in Fig. 2. In general, we see an excellent agreement between the black solid (reference calculations) and the colour lines15. Minor discrepancies are observed away from the line cores, in particular in the fractional linear polarisation signals of the H I Ly-α line. These extremely small discrepancies suggest that the reference calculations are at convergence in resolution. Moreover, the profiles look very similar to other computations in the literature (compare to Figs. 3 and B.3 of Alsina Ballester et al. 2022, for the Mg II h&k doublet and the H I Ly-α line, respectively), thus increasing the reliability of our results. We also carried out an additional set of computations (not shown in Fig. 2 for clarity), where we used the highly accurate (though more time-consuming) adaptive Gauss–Kronrod method for integrating Eq. (D.1) over frequency. Negligible differences with respect to the reference emergent profiles were found.

thumbnail Fig. 2

Intensity (left column), Q/I (middle column), and U/I (right column) as a function of vacuum wavelength for the Mg II h&k doublet (first row) and the H I Ly-α line (second row), obtained with PRD–AD calculations in a static magnetic FAL-C atmosphere (see text) for a LOS with µ = 0.1. The solid black curves correspond to reference calculations, whereas the red (dashed), yellow (dot-dashed), and purple (dotted) lines are the results of calculations with increased spatial, angular, and frequency resolution, respectively. The reference direction for positive Stokes Q is the parallel to the limb.

thumbnail Fig. 3

Intensity (left column), Q/I (middle column), and U/I (right column) as a function of vacuum wavelength for the Mg II k line obtained with PRD–AA (dashed lines) and PRD–AD (solid lines) calculations in a dynamic magnetic atmosphere (see text) for the two LOSs with µ = 0.1 (first row) and µ = 1 (second row). The blue and red curves correspond to calculations carried out with the HanleRT-TIC and the TRAP4 code, respectively. The reference direction for positive Stokes Q is the parallel to the limb.

6.4 Benchmark with the HanleRT-TIC code

To verify the TRAP4 code, we performed a benchmark study for the Mg II h&k doublet with the HanleRT-TIC code. We recall that the two codes are based on different theoretical frameworks, so that the form of the redistribution matrices RII and RIII is not exactly the same. Moreover, they use different frequency grids, quadrature grids, and iterative solution methods. Also the way of normalising the emissivity is different.

For this test, we considered a height-independent horizontal (χB = 0 and θB = π/2) magnetic field of 20 G. Moreover, to increase the complexity of the problem, we added a bulk velocity to the atmospheric model, with the vertical component mimicking Fig. 1 of del Pino Alemán et al. (2024) and defined as vz=10e[(z2100)/500]2[1+erf(2100z150)]\[\frame{v_z} = - 10 \cdot \frame{e^\frame{ - \frame{\frame{[(z - 2100)/500]}^2}}} \cdot \left[\nolbrace \frame{1 + \frame{\text{erf}}\left(\nolbrace \frame{\frac{\frame{2100 - z}}{\frame{150}}} \norbrace\right)} \norbrace\right]\frame{\text{,~}}\] the horizontal components given by vx=0.7|vz|cos(χv) and vy=0.7|vz|sin(χv)\[\frame{v_x} = 0.7\left|\nolbrace \frame{\frame{v_z}} \norbrace\right|\cos \left(\nolbrace \frame{\frame{\chi _v}} \norbrace\right)\quad \frame{\text{~and~}}\quad \frame{v_y} = 0.7\left|\nolbrace \frame{\frame{v_z}} \norbrace\right|\sin \left(\nolbrace \frame{\frame{\chi _v}} \norbrace\right)\frame{\text{,~}}\] and χv=2πzzminzmaxzmin+π,\[\frame{\chi _v} = - 2\pi \frac{\frame{z - \frame{z_\frame{\min }}}}{\frame{\frame{z_\frame{\max }} - \frame{z_\frame{\min }}}} + \pi ,\] where zmin = − 100 km and zmax = 2219.43 km and z is given in kilometres. We then solved the RT problem with the TRAP4 and HanleRT-TIC codes for the AA and AD cases.

The results are shown in Fig. 3 for the k line at the two LOSs µ = 0.1 (first row) and µ = 1 (second row), with the latter denoting a forward-scattering geometry (see, e.g. Belluzzi et al. 2024). Here, we only focus on the k line, as it is the spectral region showing the largest discrepancies between the results of the two codes. Overall, we found very satisfying agreement between HanleRT-TIC (blue curves) and TRAP4 (red curves), in particular for the fractional polarisation signals (middle and right columns). On the other hand, relative differences of the order of 5 − 10% are visible in I near the k line core. This discrepancy is probably related to the different normalisation of the emissivity and formulation of the redistribution matrices used in the two codes.

The comparison between the PRD–AA (dashed lines) and PRD–AD (solid lines) results reveals once more the importance of using an AD description of scattering processes when modelling the Mg II h&k doublet in a dynamic and magnetic atmosphere, as discussed in great detail in del Pino Alemán et al. (2024). Indeed, it is particularly important in order to accurately model the forward-scattering Hanle effect (see Q/I and U/I at µ = 1, as well as the discussion in Belluzzi et al. 2024).

6.5 Validation of the two-step approach

It is important to note that in agreement with our assumption that polarisation has a negligible impact on the ground-level population of Mg II, the input parameters of the TRAP4 code were obtained from HanleRT-TIC PRD calculations for a static, unmagnetic atmosphere and neglecting polarisation, as detailed in Sect. 6.1. On the other hand, the HanleRT-TIC results in Fig. 3 (blue lines) were obtained calculating the ground-level population in a self-consistent way, accounting for the impact of polarisation, magnetic fields, and velocities. Remarkably, we found relative differences in the ground-level populations between the two cases that are below 0.2%. A detailed investigation also revealed that these extremely small differences do not play any role in the Stokes profiles computed with TRAP4. This fact, in combination with the excellent agreement between the HanleRT-TIC and TRAP4 results of Sect. 6.4, is thus a validation of the working assumptions discussed in Sect. 2.5 and of our solution strategy.

6.6 Impact of PRD–AD on the Ly-α line

As an application of broad physical interest, we also investigated the suitability of using the AA approximation when modelling wavelength-integrated scattering polarisation signals of the H I Ly-α line, as done by Alsina Ballester et al. (2023). To this aim, we computed the emergent Stokes profiles of the H I Ly-α line obtained with a static magnetic atmosphere, with height-independent horizontal magnetic fields of different strengths B = 0, 10, 25, 50, and 100 G, both within the PRD–AA and PRD–AD descriptions. Then, following Alsina Ballester et al. (2023), synthetic narrow-band signals are obtained by weighting by a Gaussian the numerical emergent Stokes profiles and integrating the results over wavelength. Namely, X¯(μ)=12πσλλ0Δλλ0+Δλexp((λλ0)22σλ2)X(zmax,μ,λ)dλ,\[\bar X(\mu ) = \frac{1}{\frame{\sqrt \frame{2\pi } \frame{\sigma _\lambda }}}\mathop \smallint \nolimits_\frame{\frame{\lambda _0} - \frame{\text{\Delta }}\lambda }^\frame{\frame{\lambda _0} + \frame{\text{\Delta }}\lambda } \exp \left(\nolbrace \frame{ - \frac{\frame{\frame{\frame{\left(\nolbrace \frame{\lambda - \frame{\lambda _0}} \norbrace\right)}^2}}}{\frame{2\sigma _\lambda ^2}}} \norbrace\right)X\left(\nolbrace \frame{\frame{z_\frame{\max }},\mu ,\lambda } \norbrace\right)\frame{\text{d}}\lambda ,\] where X = I, Q, and U; λ0 = 1215.67 Å is the H I Ly-α line-centre wavelength in vacuum; and σλ is the standard deviation of the Gaussian weighting function, selected so that it corresponds to a full width at half maximum of 22log(2)σλ=35$2\sqrt \frame{2\log (2)} \frame{\sigma _\lambda } = 35\AA$. For the present study, we considered as integration limit Δλ = 30 Å (see Alsina Ballester et al. 2023, for a discussion of the impact of Δλ on the results).

The resulting centre-to-limb profiles are displayed in Fig. 4, with dashed and solid lines for PRD–AA and PRD–AD calculations, respectively. Overall, there is excellent agreement between PRD–AA and PRD–AD results. Minor discrepancies are found, in particular for Ū/Ī near disk centre (µ ∼ 1), but their amplitude is small. We also repeated the computations for different values of Δλ and with the atmospheric models A, F, and P of Fontenla et al. (1993), finding negligible differences between PRD–AA and PRD–AD results.

thumbnail Fig. 4

Centre-to-limb variation of Q¯/I¯$\bar Q/\bar I$ (left panel) and Ū/Ī (right panel) as a function of µ = cos(θ). The results are obtained for χ = 0 and considering height-independent horizontal (θB = π/2 and χB = 0) magnetic fields of different strengths (see the legend). Dashed and solid lines correspond to PRD–AA and PRD–AD calculations, respectively.

7 Conclusions

In the present paper, we have illustrated an accurate and effective solution strategy to model the Stokes profiles of strong resonance lines originating in the solar atmosphere while taking into account scattering polarisation with PRD effects in their general AD formulation, J-state interference, and the impact of arbitrary magnetic fields and bulk velocities. The formalism we have introduced can be applied to the two-level and two-term atoms, and it can also be used for the inclusion of the atomic hyperfine structure. Moreover, although we applied the formalism to 1D plane-parallel atmospheric models, it can be easily generalised to 3D geometries (see Benedusi et al. 2023).

After introducing the new formalism, we introduced a suitable physical approximation, thanks to which the problem became linear in the radiation field I. The approximation consists of assuming that polarisation has a negligible impact on the population of the lower level or term of resonance lines so that it can be retrieved from independent unpolarised calculations and considered as an input parameter of the problem. Together with a suitable algebraic formulation of the problem, this allowed us to exploit the innovative physics-based preconditioners of Janett et al. (2024) and efficiently solve the problem with matrix-free preconditioned algorithms. Since the computational time necessary to apply the physics-based preconditioner to the full problem can be a large fraction of the full time to solution, we also introduced an additional block-diagonal preconditioner, which we successfully used to speed up the calculations.

To accelerate the calculations in the presence of bulk velocities, we computed the scattering emissivity in the co-moving frame and then interpolated it to the observer’s frame. This strategy drastically reduces the required number of evaluations of the redistribution functions. Moreover, we presented a careful choice of the angular and spectral quadrature nodes that, in combination with a proper normalisation of the scattering emissivity, allowed for a solution of the problem that is at the same time fast and accurate.

We applied the presented solution strategy to the synthesis of the Stokes profiles of the Mg II h&k doublet and the H I Ly-α line. In particular, considering the 1D FAL-C atmo-spheric model, we performed a solution verification of the emerging synthetic profiles, showing that for the considered numerical parameters, the results are solid and the numerical errors considerably small. A detailed benchmark of TRAP4 with HanleRT-TIC results also displayed good agreement between the two codes. This is a remarkable validation of the linearisation strategy outlined in Sect. 2.5.

Finally, wavelength-integrated polarisation profiles of the H I Ly-α line show excellent agreement when comparing PRD– AA and PRD–AD calculations. The very minor discrepancies between the two computations suggest that a complete PRD– AD description of scattering processes is not strictly necessary to accurately model the impact of magnetic fields with B ≤ 100 G on these signals, thus validating the work of Alsina Ballester et al. (2023). However, this comparison was limited to 1D plane-parallel atmospheric models, and it will be important to verify whether this conclusion also remains valid in comprehensive 3D models, for example by implementing the presented solution strategy in the novel 3D numerical framework of Benedusi et al. (2023).

Acknowledgements

The financial support by the Swiss National Science Foundation (SNSF) through grant CRSII5_180238 is gratefully acknowledged. T.P.A., E.A.B., and J.T.B. acknowledge support from the Agencia Estatal de Investigación del Ministerio de Ciencia, Innovación y Universidades (MCIU/AEI) under grant “Polarimetric Inference of Magnetic Fields” and the European Regional Development Fund (ERDF) with reference PID2022-136563NB-I00/10.13039/501100011033. E.A.B. acknowledges support from the European Research Council through the Synergy grant No. 810218 (“The Whole Sun” ERC-2018-SyG). T.P.A.’s participation in the publication is part of the Project RYC2021-034006-I, funded by MICIN/AEI/10.13039/501100011033, and the

European Union “NextGenerationEU”/RTRP. We also sincerely thank the referee for the careful reading of the manuscript and the many comments, which greatly helped us to improve the quality of the paper.

Appendix A Continuum processes

Under typical conditions of the solar atmosphere, it is a good approximation to assume that continuum processes do not contribute to dispersion and dichroism, that is, to the off-diagonal elements of K (e.g. Landi Degl’Innocenti & Landolfi 2004). Additionally, the continuum contribution to the diagonal elements of K (continuum opacity) is given by η1c(r,v)=κc(r,v)+σc(r,v)$\eta _1^c(r,v) = \frame{\kappa ^c}(r,v) + \frame{\sigma ^c}(r,v)$, where κc and σc are the isotropic extinction coefficients for true absorption and scattering, respectively, and the superscript c denotes continuum contributions.

Concerning the continuum emissivity, we consider both thermal and scattering processes, for which we make the assumption of coherent scattering in the observer’s frame. This implies that the continuum contribution to the emissivity can be written as εc(r,Ω,v)=εc, th (r,v)+σc(r,v)K,Q(1)QTQK(Ω)×TQK(Ω)I(r,Ω,v)dΩ4π,\[\begin{array}{{c}} \frame{\frame{\varepsilon ^c}(r,\frame{\mathbf{\Omega }},v) = \frame{\varepsilon ^\frame{c,\frame{\text{~th~}}}}(r,v) + \frame{\sigma ^c}(r,v)\mathop \sum \limits_\frame{K,Q} \frame{\frame{( - 1)}^Q}\mathcal{T}_Q^K(\frame{\mathbf{\Omega }})} \\ \frame{ \times \oint \mathcal{T}_\frame{ - Q}^K\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right) \cdot I\left(\nolbrace \frame{r,\frame{\mathbf{\Omega \prime}},v} \norbrace\right)\frac{\frame{\frame{\text{d}}\frame{\mathbf{\Omega \prime}}}}{\frame{4\pi }}} \\ \end{array} \] where εc,th is the continuum thermal emissivity (which is isotropic and only contributes to Stokes I) and 𝒯 is a vector whose four components are the polarisation tensors (see Section 5.11 of Landi Degl’Innocenti & Landolfi 2004) in the four Stokes parameters. We note that κc, σc, and εc,th are currently evaluated with publicly available routines (e.g. Uitenbroek 2001; Li et al. 2022).

Appendix B

AQKK,BQKK$A_Q^\frame{KK\prime},B_Q^\frame{KK\prime}$, and branching ratios

The quantity AQKK$A_Q^\frame{KK\prime}$ appearing in Eq. (3) is defined as AQKK(r,ku,ku,kl,kl)=αku,ku(r)2πΔvD(r)2AQKK(ku,ku,kl,kl),\[A_Q^\frame{KK\prime}\left(\nolbrace \frame{r,\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right) = \frac{\frame{\frame{\alpha _\frame{\frame{k_u},k_u^\prime }}(r)}}{\frame{2\pi \frame{\text{\Delta }}\frame{v_D}\frame{\frame{(r)}^2}}}\mathcal{A}_Q^\frame{KK\prime}\left(\nolbrace \frame{\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right),\] where αku,ku$\frame{\alpha _\frame{\frame{k_u},k_u^\prime }}$ represents the branching ratio for scattering processes described by ℛ II (it contains both the branching ratio between thermal and scattering processes and the one between ℛ II and ℛ III) and AQKK$\mathcal{A}_Q^\frame{KK\prime}$ is a quantity depending on a series of quantum numbers characterising the involved atomic states.

According to the works of Bommier (1997a,b, 2017), the branching ratio for ℛ II is given by αku,ku(r)=ΓRΓR+ΓI(r)+ΓE(r)+2πivku,ku(r).\[\frame{\alpha _\frame{\frame{k_u},k_u^\prime }}(r) = \frac{\frame{\frame{\frame{\text{\Gamma }}_\frame{\text{R}}}}}{\frame{\frame{\frame{\text{\Gamma }}_\frame{\text{R}}} + \frame{\frame{\text{\Gamma }}_\frame{\text{I}}}(r) + \frame{\frame{\text{\Gamma }}_\frame{\text{E}}}(r) + 2\pi i\frame{v_\frame{\frame{k_u},k_u^\prime }}(r)}}.\]

With this definition and taking AQKK(ku,ku,kl,kl)=CQKKMuMuMlMlpppp$\mathcal{A}_Q^\frame{KK\prime}\left(\nolbrace \frame{\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right) = \frame{C_\frame{QKK\prime\frame{M_u}M_u^\prime \frame{M_\ell }M_\ell ^\prime pp\primep\prime \primep\prime \prime \prime}}$ (see Eq. (12) of Bommier 1997b), one recovers an expression for RQII,KK$\mathcal{R}_Q^\frame{II,KK\prime}$ fully analogous to Eq. (23) of Alsina Ballester et al. (2017) for the two-level atom. Similarly, by considering AQKK(ku,ku,kl,kl)=AQKK(juMu,juMu,jlMl,jlMl)$\mathcal{A}_Q^\frame{KK\prime}\left(\nolbrace \frame{\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right) = \mathcal{A}_Q^\frame{KK\prime}\left(\nolbrace \frame{\frame{j_u}\frame{M_u},j_u^\prime M_u^\prime ,\frame{j_\ell }\frame{M_\ell },j_\ell ^\prime M_\ell ^\prime } \norbrace\right)$ (see Eq. (C.19) of Alsina Ballester et al. 2022), one recovers the redistribution functions in Eq. (10) of Alsina Ballester et al. (2022) for a two-term atom.16

The quantity BQKK$B_Q^\frame{KK\prime}$ appearing in the definition of RQIII,KK$\mathcal{R}_Q^\frame{III,KK\prime}$, Eq. (5), is defined as BQKK(r,ku,ku,kl,kl)=βku,ku(r)αku,ku(r)4πΔvD(r)2AQKK(ku,ku,kl,kl),\[B_Q^\frame{KK\prime}\left(\nolbrace \frame{r,\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right) = \frac{\frame{\frame{\beta _\frame{\frame{k_u},k_u^\prime }}(r) - \frame{\alpha _\frame{\frame{k_u},k_u^\prime }}(r)}}{\frame{4\pi \frame{\text{\Delta }}\frame{v_D}\frame{\frame{(r)}^2}}}\mathcal{A}_Q^\frame{KK\prime}\left(\nolbrace \frame{\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right),\] where the term βku,kuαku,ku$\frame{\beta _\frame{\frame{k_u},k_u^\prime }} - \frame{\alpha _\frame{\frame{k_u},k_u^\prime }}$ is the branching ratio for ℛIII, with βku,ku(r)=ΓRΓR+ΓI(r)+2πivku,ku(r).\[\frame{\beta _\frame{\frame{k_u},k_u^\prime }}(r) = \frac{\frame{\frame{\frame{\text{\Gamma }}_\frame{\text{R}}}}}{\frame{\frame{\frame{\text{\Gamma }}_\frame{\text{R}}} + \frame{\frame{\text{\Gamma }}_\frame{\text{I}}}(r) + 2\pi i\frame{v_\frame{\frame{k_u},k_u^\prime }}(r)}}\]

Here, we assumed that the depolarising effect of elastic collisions is negligible. Notably, this is a good approximation when modelling the polarisation of strong resonance lines that form in the low-density plasma of the solar chromosphere (Alsina Ballester et al. 2021). We note that the expression we provided for βku,ku$\frame{\beta _\frame{\frame{k_u}}},k_u^\prime $ holds both for a two-level atom (Bommier 1997b) and for a two-term atom (Bommier 2017) and include the term 1 − ϵ.

If depolarising collisions are not negligible, the redistribution matrix formalism cannot be used for a two-term atomic model, as the SE equations do not have a closed analytic solution (unless magnetic fields and collisional transitions between different J-levels of the same term are neglected; see Bommier 2017). However, the redistribution matrix can be derived also accounting for depolarising collisions in the case of a two-level atom (see Bommier 1997b), the only difference being in the βku,ku$\frame{\beta _\frame{\frame{k_u},k_u^\prime }}$ factor, which takes the form βku,ku(K)(r)=ΓRΓR+ΓI(r)+D(K)(r)+2πivku,ku(r),\[\beta _\frame{\frame{k_u},k_u^\prime }^\frame{(K)}(r) = \frac{\frame{\frame{\frame{\text{\Gamma }}_\frame{\text{R}}}}}{\frame{\frame{\frame{\text{\Gamma }}_\frame{\text{R}}} + \frame{\frame{\text{\Gamma }}_\frame{\text{I}}}(r) + \frame{D^\frame{(K)}}(r) + 2\pi i\frame{v_\frame{\frame{k_u},k_u^\prime }}(r)}},\] with D(K) the depolarisation rate due to elastic collisions. With these branching ratios, one recovers the expressions for ℛ III in Eq. (20) of Alsina Ballester et al. (2017) and in Eq. (11) of Alsina Ballester et al. (2022) for two-level and two-term atoms, respectively.

Appendix C Spectral quadrature grid for ℛII

Here, we detail the spectral quadrature grids {un}n=1Ny$\left\{\nolbrace \frame{\frame{u_\frame{n\prime}}} \norbrace\right\}_\frame{n\prime = 1}^\frame{\frame{N_\frame{y\prime}}}$ used to numerically evaluate Eq. (11). Recalling that un denotes a discrete point of the reduced frequency grid, these are defined as follows:

  1. if Θ = 0, Eq. (11) is integrated analytically;

  2. if Θ ≥ π/8 or min |un+ui|ut$\left|\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right| \geqslant \frame{u^\frame{\text{t}}}$, case (d) in Sect. 4.3, we use a Gauss-Hermite quadrature with 65 nodes;

  3. if Θ > π/8 and |un+ui|2$\left|\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right| \leqslant 2,$, we are in the line-core regime, case (e) in Sect. 4.3, and we distinguish between the three different cases

    • π/8 ≤ Θ ≤ π/2, for which a single GL quadrature of 101 nodes over the interval [uM − Δ1, uM + Δ1] is used,

    • π/2 < Θ ≤ 15π/16, for which three contiguous GL quadratures of 55, 81, and 55 nodes over the intervals [u − Δ1, uM− Δ2], [uM − Δ2, uM + Δ2], and [uM + Δ2, u + Δ1], respectively, are used, and

    • 15π/16 < Θ < π, for which four contiguous GL quadratures of 65, 101, 101, and 65 nodes over the intervals [u − Δ1, uM− Δ3], [uM − Δ3, uM], [uM, uM + Δ3], and [uM + Δ3, u + Δ1], respectively, are used;

  4. if Θ > π/8 and 2<mini|un+ui|<ut$2 < \underset{i}{\mathop \frame{\min }} \left|\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right| < \frame{u^\frame{\text{t}}}$, we are in the nearwing regime, case (f) in Sect. 4.3, and we combine three GL contiguous quadratures of 55, 95, 121 nodes (121, 95, 55 if un+ui*<0$\frame{u_n} + u_i^* < 0$ over the intervals [Lnw, uM − Δ4], [uM − Δ4, uM + Δ4], and [uM + Δ4, Rnw], respectively.

Here, we introduced the threshold ut = max(5.8, 2.5 Θ) and we defined uM=(un+ui*)cos(Θ)ui*$\frame{u^\frame{\text{M}}} = \left(\nolbrace \frame{\frame{u_n} + u_i^*} \norbrace\right)\cos (\Theta ) - u_i^*$, Δ1 = 11 sin(Θ/2), Δ2 = 6(0.1 + a + cos(Θ/2))/(a + 1), Δ3 = 6(0.05 + a + cos(Θ/2))/(a + 1), Δ4 = 6 cos(Θ/2) + 0.2, Lnw = min(uM − Δ4 1, ũ − Δ1), and Rnw = max(uM + Δ4 + 1, ũ + Δ1), where ui*$u_i^*$ is the cluster centre closest to − un, and ũ = uRe and ũ = uIm for the real and imaginary parts of Eq. (11), respectively, are uRe=sign(un+ui)(un+ui)24sin2(Θ/2),uIm=sign(un+ui)(un+ui)22sin2(Θ/2).\[\begin{array}{{c}} \frame{\frame{u_\frame{\operatorname{Re} }} = sign\left(\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right)\sqrt \frame{\frame{\frame{\left(\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right)}^2} - 4\frame{\frame{\sin }^2}(\frame{\text{\Theta }}/2)} ,} \\ \frame{\frame{u_\frame{Im}} = sign\left(\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right)\sqrt \frame{\frame{\frame{\left(\nolbrace \frame{\frame{u_n} + u_i^ \star } \norbrace\right)}^2} - 2\frame{\frame{\sin }^2}(\frame{\text{\Theta }}/2)}.} \\ \end{array} \]

Concerning the AA approximation, the integral over Θ in Eq. (12) smooths out the sharp peaks and sign reversals of R¯II$\frame{\bar \mathcal{R}^\frame{II}}$ near Θ = 0 and Θ = π, thus simplifying the numerical integration of R¯IIAAI$\frame{\bar \mathcal{R}^\frame{II - AA}} \cdot I$ over frequency with respect to the general AD case. The integral in Eq. (12) also drastically reduces the degree of freedom of the redistribution function, removing its dependence on Θ and making it possible to assemble R¯IIAA$\frame{\bar \mathcal{R}^\frame{II - AA}}$ only once, before starting the iterative process, and simply storing it in memory. For the selection of {un}n=1Nv$\left\{\nolbrace \frame{\frame{u_\frame{n\prime}}} \norbrace\right\}_\frame{n\prime = 1}^\frame{\frame{N_\frame{v\prime}}}$, we thus opted for a compromise between minimum number of quadrature nodes, simplicity, and accuracy. Specifically, we used two GL quadratures of 142 nodes each in the two intervals [un − 7.8, un] and [un, un + 7.8]. For the integral over Θ, we opted for one GL quadrature of 25 nodes in the interval [0, π].

Appendix D Additional optimisation strategies

In this appendix, we neglect the dependence of any quantity on r for ease of notation. First, to further optimise the code, we note RQII,KKPQKK+RQII,KKPQKK=2Re(R|Q|II,KKP|Q|KK)$\mathcal{R}_\frame{ - Q}^\frame{II,KK\prime}\mathcal{P}_\frame{ - Q}^\frame{KK\prime} + \mathcal{R}_Q^\frame{II,KK\prime}\mathcal{P}_Q^\frame{KK\prime} = 2\operatorname{Re} \left(\nolbrace \frame{\mathcal{R}_\frame{\left|\nolbrace Q \norbrace\right|}^\frame{II,KK\prime}\mathcal{P}_\frame{\left|\nolbrace Q \norbrace\right|}^\frame{KK\prime}} \norbrace\right)$. This is exploited to avoid evaluating RQII,K˜K$\mathcal{R}_Q^\frame{II,\overset{}{\mathop K} K\prime}$ for negative Q. Additionally, to reduce the number of evaluations of the Faddeeva function, of integrals over frequency, and of interpolations, we define the function Wku,kl(Ω,Ω,un)=ΔvDF(Θ,u+uku,kl,un+uku,kl)×I(Ω,uub(Ω))du.\[\begin{array}{{c}} \frame{\frame{\mathcal{W}_\frame{\frame{k_u},\frame{k_\ell }}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},\frame{u_n}} \norbrace\right) = \frame{\text{\Delta }}\frame{v_D}\smallint F\left(\nolbrace \frame{\frame{\text{\Theta }},u\prime + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}},\frame{u_n} + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}}} \norbrace\right)} \\ \frame{ \times I\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},u\prime - \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right)} \norbrace\right)\frame{\text{d}}u\prime.} \\ \end{array} \](D.1)

Using this definition, we rewrite the RII contribution to Eq. (2) as εl,sc,II(Ω,vn)=kK,K,QkukuklklA|Q|KK(ku,ku,kl,kl)×dΩP|Q|KK(Ω,Ω)×[Wku,kl(Ω,Ω,un+ub(Ω)+ukl,kl)+Wku,kl(Ω,Ω,un+ub(Ω)+ukl,kl)].\[\begin{array}{{c}} \frame{\frame{\varepsilon ^\frame{\ell ,sc,II}}\left(\nolbrace \frame{\frame{\mathbf{\Omega }},\frame{v_n}} \norbrace\right)} \hfill & \frame{ = k\mathop \sum \limits_\frame{K,K\prime,Q} \mathop \sum \limits_\frame{\frame{k_u}k_u^\prime } \mathop \sum \limits_\frame{\frame{k_\ell }k_\ell ^\prime } A_\frame{\left|\nolbrace Q \norbrace\right|}^\frame{KK\prime}\left(\nolbrace \frame{\frame{k_u},k_u^\prime ,\frame{k_\ell },k_\ell ^\prime } \norbrace\right)} \hfill \\ \frame{} \hfill & \frame{ \times \oint \frame{\text{d}}\frame{\frame{\frame{\mathbf{\Omega \prime}}}^}\mathcal{P}_\frame{\left|\nolbrace Q \norbrace\right|}^\frame{KK\prime}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }}} \norbrace\right)} \hfill \\ \frame{} \hfill & \frame{ \times \left[\nolbrace \frame{\frame{\mathcal{W}_\frame{k_u^\prime ,\frame{k_\ell }}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},\frame{u_n} + \frame{u_\frame{\text{b}}}(\frame{\mathbf{\Omega }}) + \frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }}} \norbrace\right)} \norbrace\right.} \hfill \\ \frame{} \hfill & \frame{\left.\nolbrace \frame{ + \frame{W_\frame{\frame{k_u},\frame{k_\ell }}}\frame{\frame{\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{\mathbf{\Omega }},\frame{u_n} + \frame{u_\frame{\text{b}}}(\frame{\mathbf{\Omega }}) + \frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }}} \norbrace\right)}^ \star }} \norbrace\right].} \hfill \\ \end{array} \](D.2)

In practice, we never fully assemble the redistribution function RQII,KK$R_Q^\frame{II,KK\prime}$ in the code. Instead, we first evaluate F(Θ,un+uku,kl,un+uku,kl)$F\left(\nolbrace \frame{\frame{\text{\Theta }},\frame{u_\frame{n\prime}} + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}},\frame{u_n} + \frame{u_\frame{\frame{k_u},\frame{k_\ell }}}} \norbrace\right)$ and I(Ω,unub(Ω))$I\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}},\frame{u_\frame{n\prime}} - \frame{u_\frame{\text{b}}}\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right)} \norbrace\right)$ separately. Then, we perform the quadrature in frequency of the product of the two quantities to get Wku,kl$\frame{W_\frame{\frame{k_u},\frame{k_\ell }}}$. Before computing the sum over k and kl$k_\ell ^\prime $, one has to interpolate Wku,kl$\frame{W_\frame{\frame{k_u},\frame{k_\ell }}}$ from un to un+ub(Ω)+ukl,kl$\frame{u_n} + \frame{u_\frame{\text{b}}}(\frame{\mathbf{\Omega }}) + \frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }}$. Finally, ε,sc,II is evaluated according to Eq. (D.2). This strategy allows us to evaluate ε,sc,II by computing the Faddeeva function and interpolating I as few times as possible, while still ensuring an accurate result.

Appendix E Normalisation of line emissivity

In LTE, in the presence of a magnetic field, Kirchhoff’s law (Kirchhoff 1860) can be generalised by accounting for the Zeeman effect and for polarisation (see Sect. 9.1 of Landi Degl’Innocenti & Landolfi 2004), that is, ε(r,Ω,v)=WT(r)η(r,Ω,v),\[\varepsilon (r,\frame{\mathbf{\Omega }},v) = \frame{W_T}(r)\eta (r,\frame{\mathbf{\Omega }},v),\] where the Planck function in the Wien limit (WT ) is used because stimulated emission is neglected. The dependence of WT on wavelength is also neglected. Moreover, considering that the branching ratio of scattering contributions to the emission vector is 1 − ϵ, we can write εsc(r,Ω,v)=[1ϵ(r)]WT(r)η(r,Ω,v).\[\frame{\varepsilon ^\frame{sc}}(r,\frame{\mathbf{\Omega }},v) = [1 - \varepsilon (r)]\frame{W_T}(r)\eta (r,\frame{\mathbf{\Omega }},v).\](E.1)

This relation must hold not only when considering the sum of line and continuum contributions, but also when we consider the two contributions individually. In TRAP4, we account for numerical deviations from Kirchhoff’s law in the line emission contribution in the following way:

  1. we calculate the reference for the scattering contribution to line emissivity, ε,sc,ref, with Eq. (E.1);

  2. we assume LTE by setting a Planckian incident radiation field (i.e. unpolarised, flat, and isotropic), namely, I(r, Ω, ν) = (WT (r), 0, 0, 0), and we accordingly calculate the line scattering contribution to emissivity, ε,sc,num, with the code;

  3. we calculate the normalisation factor f ∈ ℝN, which is the ratio between Kirchhoff (calculated at 1.) and numerical (calculated at 2.) scattering contribution to line emissivity, namely f(r,Ω,v)=εl,sc,ref(r,Ω,v)εl,sc,num(r,Ω,v);\[f(r,\frame{\mathbf{\Omega }},v) = \frac{\frame{\frame{\varepsilon ^\frame{\ell ,sc,ref}}(r,\frame{\mathbf{\Omega }},v)}}{\frame{\frame{\varepsilon ^\frame{\ell ,sc,num}}(r,\frame{\mathbf{\Omega }},v)}}\]

  4. we multiply ε,sc, calculated via Eq. (2), by the normalisation factor f when solving iteratively the linear system given by Eq. (8).

Since the normalisation factor only depends on the input parameters of the problem (i.e. it does not depend on the iteration), it can be computed a priori and then applied at each iteration. We note that for practical applications, we only normalised the intensity component of the emission vector.

Appendix F Block-diagonal preconditioner

In order to apply the physics-based preconditioner P to the RT problem given by Eq. (8), we need to routinely solve a size-N linear system of the form Px = y. This task may prove computationally expensive even when P corresponds to the simplified PRD–AA setting (see Sect. 5.2). To overcome this issue, we applied a block-diagonal preconditioner P^$\hat P$, similar to that proposed by Alsina Ballester et al. (2017), to the linear system Px = y, that is, we solved the equivalent problem P^1Px=P^1y,\[\frame{\hat P^\frame{ - 1}}Px = \frame{\hat P^\frame{ - 1}}y,\] with P^=diag(P^1,,P^Nr)$\hat P = \frame{\text{diag}}\left(\nolbrace \frame{\frame{\frame{\hat P}_1}, \ldots ,\frame{\frame{\hat P}_\frame{\frame{N_r}}}} \norbrace\right)$ an invertible block-diagonal matrix and P^i4NΩNv×4NΩNv$\frame{\hat P_i} \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v} \times 4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ the spatially local preconditioner operating at the discrete spatial point riD (with i = 1, …, Nr).

To conceive P^$\hat P$, we write the spatial components of the scattering emissivity in the observer’s frame, εisc4NΩNv(i=1,,Nr)$\varepsilon _i^\frame{sc} \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}(i = \left.\nolbrace \frame{1, \ldots ,\frame{N_r}} \norbrace\right)$, in the compact matrix form εisc=ΣiIi,\[\varepsilon _i^\frame{sc} = \frame{\text{\Sigma }}_i^ \star \frame{I_i},\] where we introduced the local Stokes parameters in the observer’s frame Ii4NΩNv$\frame{I_i} \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ and the local linear scattering operator in the observer’s frame Σi4NΩNv×4NΩNv$\frame{\text{\Sigma }}_i^ \star \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v} \times 4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ (i.e. Σi$\frame{\text{\Sigma }}_i^ \star $ is the local block of the approximated scattering operator Σ used to build P, see Sects. 2.7 and 5.2). Then, we rewrite the transfer equation given by Eq. (6) as Ii=j=1NrΛij(ΣjIj+εjth)+ti,\[\frame{I_i} = \mathop \sum \limits_\frame{j = 1}^\frame{\frame{N_r}} \frame{\frame{\text{\Lambda }}_\frame{ij}}\left(\nolbrace \frame{\frame{\text{\Sigma }}_j^ \star \frame{I_j} + \varepsilon _j^\frame{th}} \norbrace\right) + \frame{t_i},\] where the diagonal matrices Λij4NΩNv×4NΩNv$\frame{\frame{\text{\Lambda }}_\frame{ij}} \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v} \times 4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ encode the formal solution (namely, the transfer from r j to ri, not to be confused with Λ˜ij$\frame{\overset{}{\mathop \Lambda } _\frame{ij}}$ introduced in Sect. 2.7) and the vectors εith4NΩNv$\varepsilon _i^\frame{th} \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ and ti4NΩNv$\frame{t_i} \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ represent the local thermal emissivity and the radiation transmitted from the boundaries to ri, respectively. Within this formalism, the block-Jacobi method can be simply written as Iin+1=j=1NrΛij(ΣjIjn+εjth)+ti+ΛiiΣi(Iin+1Iin),\[I_i^\frame{n + 1} = \mathop \sum \limits_\frame{j = 1}^\frame{\frame{N_r}} \frame{\frame{\text{\Lambda }}_\frame{ij}}\left(\nolbrace \frame{\frame{\text{\Sigma }}_j^ \star I_j^n + \varepsilon _j^\frame{th}} \norbrace\right) + \frame{t_i} + \frame{\frame{\text{\Lambda }}_\frame{ii}}\frame{\text{\Sigma }}_i^ \star \left(\nolbrace \frame{I_i^\frame{n + 1} - I_i^n} \norbrace\right),\](F.1) where the superscripts n + 1 and n denote the values of Ii at two successive iterations. Equation (F.1) can readily be recast into (Id4NΩNvΛiiΣi)(Iin+1Iin)=Rin,\[\left(\nolbrace \frame{I\frame{d^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}} - \frame{\frame{\text{\Lambda }}_\frame{ii}}\frame{\text{\Sigma }}_i^ \star } \norbrace\right)\left(\nolbrace \frame{I_i^\frame{n + 1} - I_i^n} \norbrace\right) = R_i^n,\](F.2) thus identifying the local blocks of the block-Jacobi pre-conditioner as P^i=Id4NΩNvΛiiΣj4NΩNv×4NΩNv$\frame{\hat P_i} = I\frame{d^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}} - \frame{\frame{\text{\Lambda }}_\frame{ii}}\frame{\text{\Sigma }}_j^ \star \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v} \times 4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$. Here, Id4NΩNv4NΩNv×4NΩNv$I\frame{d^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}} \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v} \times 4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ is the identity matrix and the vector Rin=j=1NrΛij(jIjn+εjth)+tiIin4NΩNv$R_i^n = \mathop \sum \limits_\frame{j = 1}^\frame{\frame{N_r}} \frame{\frame{\text{\Lambda }}_\frame{ij}}\left(\nolbrace \frame{\mathop \sum \limits_j^ \star I_j^n + \varepsilon _j^\frame{th}} \norbrace\right) + \frame{t_i} - I_i^n \in \frame{\mathbb{R}^\frame{4\frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ represents the local residual of the RT problem encoded in P at iteration n and at ri.

Unfortunately, the application of P^1$\frame{\hat P^\frame{ - 1}}$ would require inverting, and possibly storing, Nr matrices of size 4NΩNν 4NΩNν. While this can be done for small 1D plane-parallel problems, it would be computationally unfeasible for larger spatial domains. To overcome this issue, we proceed as follows. First, we further simplify the problem by considering only the unmagnetic and unpolarised setting. Within this approximation, we only consider the intensity component of all vectors and matrices introduced above (i.e. vector dimensions reduce by a factor of four and matrix dimensions reduce by a factor of 4 × 4). Moreover, in the unmagnetic and unpolarised case, the scattering phase matrix PQKK$\mathcal{P}_Q^\frame{KK\prime}$ is independent of the spatial location and reduces to a complex scalar of value (1)QTQ,1K(Ω)TQ,1K(Ω)$\frame{( - 1)^Q}\mathcal{T}_\frame{Q,1}^\frame{K\prime}(\frame{\mathbf{\Omega }})\mathcal{T}_\frame{ - Q,1}^K\left(\nolbrace \frame{\frame{\mathbf{\Omega \prime}}} \norbrace\right)$, where TQ,iK(i=1,,4)$\mathcal{T}_\frame{Q,i}^K(i = 1, \ldots ,4)$ are the geometrical tensors in the observer’s frame (see Sect. 5.11 of Landi Degl’Innocenti & Landolfi 2004). Second, we note that the AA redistribution functions in the operator Σ, when evaluated in the co-moving frame (see Sect. 4.1), are independent of the scattering angle Θ. Thus, observing that in the unmagnetic case only the components of the redistribution function with K′ = K are non-zero, we rewrite the scattering emissivity in the co-moving frame, Eq. (10), for the unmagnetic and unpolarised setting as ε¯sc(r,Ω,v)=k(r)K,Q(1)QTQ,1K(Ω)×[R¯]QKK(r,v,v)J¯QK(r,v)dv,\[\begin{array}{{c}} \frame{\frame{\frame{\bar \varepsilon }^\frame{sc}}(r,\frame{\mathbf{\Omega }},v) = k(r)\mathop \sum \limits_\frame{K,Q} \frame{\frame{( - 1)}^Q}\mathcal{T}_\frame{Q,1}^K(\frame{\mathbf{\Omega }})} \\ \frame{ \times \smallint \left[\nolbrace \frame{\frame{\frame{\bar \mathcal{R}}^ \star }} \norbrace\right]_Q^\frame{KK}\left(\nolbrace \frame{r,v\prime,v} \norbrace\right)\bar J_\frame{ - Q}^K\left(\nolbrace \frame{r,v\prime} \norbrace\right)\frame{\text{d}}v\prime,} \\ \end{array} \] where we introduced the radiation field tensor for the unpolarised setting in the co-moving frame J¯QK(r,v)=TQ,1K(Ω)I¯(r,Ω,v)dΩ/(4π)$\bar J_Q^K(r,v) = \oint \mathcal{T}_\frame{Q,1}^K(\frame{\mathbf{\Omega }})\bar I(r,\frame{\mathbf{\Omega }},v)\frame{\text{d}}\frame{\mathbf{\Omega }}/(4\pi )$. Here, [R¯]QKK$\left[\nolbrace \frame{\frame{\frame{\bar \mathcal{R}}^ \star }} \norbrace\right]_Q^\frame{KK\prime}$ denotes the redistribution functions in the co-moving frame for the unmagnetic setting. Third, we only consider the component K = Q = 0 in the following. Observing that T0,10=1$\mathcal{T}_\frame{0,1}^0 = 1$, we thus rewrote the operator Σi$\frame{\text{\Sigma }}_i^ \star $ as Σi=Υiv¯vΣ¯i*Υivv¯=Υiv¯vΦ¯iΦΩΥivv¯,\[\frame{\text{\Sigma }}_i^ \star = \frame{\text{\Upsilon }}_i^\frame{\bar vv}\bar \Sigma _i^*\frame{\text{\Upsilon }}_i^\frame{v\bar v} = \frame{\text{\Upsilon }}_i^\frame{\bar vv}\frame{\bar \Phi _i}\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{v\bar v},\] where Υivv¯NΩNv×NΩNv$\frame{\text{\Upsilon }}_i^\frame{v\bar v} \in \frame{\mathbb{R}^\frame{\frame{N_\frame{\text{\Omega }}}\frame{N_v} \times \frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ and Υiv¯vNΩNv×Nv$\frame{\text{\Upsilon }}_i^\frame{\bar vv} \in \frame{\mathbb{R}^\frame{\frame{N_\frame{\text{\Omega }}}\frame{N_v} \times \frame{N_v}}}$ denote the local interpolations from the observer’s grid ν to the co-moving grid v¯$\bar v$ and vice versa, respectively, Φ¯iNv×Nv$\frame{\bar \Phi _i} \in \frame{\mathbb{R}^\frame{\frame{N_v} \times \frame{N_v}}}$ encodes the linear operator i[ f(ri,v) ]=k(ri)[ ¯ ]000(r,v,v)f(ri,v)dv$\frame{\mathcal{L}_i}\left[\nolbrace \frame{f\left(\nolbrace \frame{\frame{r_i},v} \norbrace\right)} \norbrace\right] = k\left(\nolbrace \frame{\frame{r_i}} \norbrace\right)\frame{\smallint ^}\left[\nolbrace \frame{\frame{\frame{\bar \mathcal{R}}^ \star }} \norbrace\right]_0^\frame{00}\left(\nolbrace \frame{r,v\prime,v} \norbrace\right)f\left(\nolbrace \frame{\frame{r_i},v\prime} \norbrace\right)\frame{\text{d}}v\prime$ and ΦΩNv×NΩNv$\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}} \in \frame{\mathbb{R}^\frame{\frame{N_v} \times \frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ represents the angular quadrature (i.e. ΦΩ Ii is the local mean intensity in the observer’s frame, J00$J_0^0$, and the linear operator Σ¯=Φ¯iΦΩNv×NΩNv$\frame{\bar \Sigma ^ \star } = \frame{\bar \Phi _i}\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}} \in \frame{\mathbb{R}^\frame{\frame{N_v} \times \frame{N_\frame{\text{\Omega }}}\frame{N_v}}}$ encodes the local scattering intensity emissivity in the co-moving frame for the unpolarised and unmagnetic setting). Fourth, by multiplying both sides of Eq. (F.2) by ΦΩΥiγv¯$\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{\gamma \bar v}$, we obtain (IdNvAi)ΦΩΥivv¯(Iin+1Iin)=ΦΩΥivv¯Rin,\[\left(\nolbrace \frame{I\frame{d^\frame{\frame{N_v}}} - \frame{A_i}} \norbrace\right)\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{v\bar v}\left(\nolbrace \frame{I_i^\frame{n + 1} - I_i^n} \norbrace\right) = \frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{v\bar v}R_i^n,\](F.3) with IdNvNv×Nv$I\frame{d^\frame{\frame{N_v}}} \in \frame{\mathbb{R}^\frame{\frame{N_v} \times \frame{N_v}}}$ the identity matrix and where we introduced the invertible square matrixAi=ΦΩΥiνv¯ΛiiΥiv¯vΦ¯iNν×Nν$\frame{A_i} = \frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{\nu \bar v}\frame{\frame{\text{\Lambda }}_\frame{ii}}\frame{\text{\Upsilon }}_i^\frame{\bar vv}\frame{\bar \Phi _i} \in \frame{\mathbb{R}^\frame{\frame{N_\nu } \times \frame{N_\nu }}}$. We finally use Eq. (F.3) to write Σi(Iin+1Iin)=Υiv¯vΦ¯iΦΩΥivv¯(Iin+1Iin)=Υiv¯vΦ¯i(IdNvAi)1ΦΩΥivv¯Rin,\[\begin{array}{{c}} \frame{\frame{\text{\Sigma }}_i^ \star \left(\nolbrace \frame{I_i^\frame{n + 1} - I_i^n} \norbrace\right) = \frame{\text{\Upsilon }}_i^\frame{\bar vv}\frame{\frame{\bar \Phi }_i}\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{v\bar v}\left(\nolbrace \frame{I_i^\frame{n + 1} - I_i^n} \norbrace\right)} \\ \frame{ = \frame{\text{\Upsilon }}_i^\frame{\bar vv}\frame{\frame{\bar \Phi }_i}\frame{\frame{\left(\nolbrace \frame{I\frame{d^\frame{\frame{N_v}}} - \frame{A_i}} \norbrace\right)}^\frame{ - 1}}\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{v\bar v}R_i^n} \\ \end{array} \] and replace it in Eq. (F.1) to obtain Iin+1Iin=Rin+ΛiiΥivv¯Φ¯i(IdNvAi)1ΦΩΥivv¯Rin.\[I_i^\frame{n + 1} - I_i^n = R_i^n + \frame{\frame{\text{\Lambda }}_\frame{ii}}\frame{\text{\Upsilon }}_i^\frame{v\bar v}\frame{\bar \Phi _i}\frame{\left(\nolbrace \frame{I\frame{d^\frame{\frame{N_v}}} - \frame{A_i}} \norbrace\right)^\frame{ - 1}}\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{v\bar v}R_i^n.\]

From this expression, we can identify the local blocks of P^1$\frame{\hat P^\frame{ - 1}}$ as P^i1=IdNΩNv+ΛiiΥivv¯Φ¯i(IdNvAi)1ΦΩΥivv¯,\[\hat P_i^\frame{ - 1} = I\frame{d^\frame{\frame{N_\frame{\text{\Omega }}}\frame{N_v}}} + \frame{\frame{\text{\Lambda }}_\frame{ii}}\frame{\text{\Upsilon }}_i^\frame{v\bar v}\frame{\bar \Phi _i}\frame{\left(\nolbrace \frame{I\frame{d^\frame{\frame{N_v}}} - \frame{A_i}} \norbrace\right)^\frame{ - 1}}\frame{\frame{\text{\Phi }}^\frame{\text{\Omega }}}\frame{\text{\Upsilon }}_i^\frame{v\bar v},\] where the matrices (IdNvAi)1Nv×Nv$\frame{\left(\nolbrace \frame{I\frame{d^\frame{\frame{N_v}}} - \frame{A_i}} \norbrace\right)^\frame{ - 1}} \in \frame{\mathbb{R}^\frame{\frame{N_v} \times \frame{N_v}}}$ can be assembled a priori, before starting the iterative method. We note that for the block-diagonal preconditioner, the continuum contributions to Σi$\frame{\text{\Sigma }}_i^ \star $ were neglected for computational efficiency.

References

  1. Adams, T. F., Hummer, D. G., & Rybicki, G. B. 1971, J. Quant. Spec. Radiat. Transf., 11, 1365 [Google Scholar]
  2. Alsina Ballester, E., Belluzzi, L., & Trujillo Bueno, J. 2016, ApJ, 831, L15 [Google Scholar]
  3. Alsina Ballester, E., Belluzzi, L., & Trujillo Bueno, J. 2017, ApJ, 836, 6 [Google Scholar]
  4. Alsina Ballester, E., Belluzzi, L., & Trujillo Bueno, J. 2021, Phys. Rev. Lett., 127, 081101 [NASA ADS] [CrossRef] [Google Scholar]
  5. Alsina Ballester, E., Belluzzi, L., & Trujillo Bueno, J. 2022, A&A, 664, A76 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  6. Alsina Ballester, E., Belluzzi, L., & Trujillo Bueno, J. 2023, ApJ, 947, 71 [NASA ADS] [CrossRef] [Google Scholar]
  7. Belluzzi, L., & Trujillo Bueno, J. 2011, ApJ, 743, 3 [NASA ADS] [CrossRef] [Google Scholar]
  8. Belluzzi, L., & Trujillo Bueno, J. 2012, ApJ, 750, L11 [NASA ADS] [CrossRef] [Google Scholar]
  9. Belluzzi, L., Trujillo Bueno, J., & Štěpán, J. 2012, ApJ, 755, L2 [NASA ADS] [CrossRef] [Google Scholar]
  10. Belluzzi, L., Landi Degl’Innocenti, E., & Trujillo Bueno, J. 2013, A&A, 551, A84 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  11. Belluzzi, L., Riva, S., Janett, G., et al. 2024, A&A, 691, A278 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  12. Benedusi, P., Janett, G., Belluzzi, L., & Krause, R. 2021, A&A, 655, A88 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  13. Benedusi, P., Janett, G., Riva, G., Belluzzi, L., & Krause, R. 2022, A&A, 664, A197 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  14. Benedusi, P., Riva, S., Zulian, P., et al. 2023, J. Comput. Phys., 479, 112013 [NASA ADS] [CrossRef] [Google Scholar]
  15. Bommier, V. 1997a, A&A, 328, 706 [Google Scholar]
  16. Bommier, V. 1997b, A&A, 328, 726 [Google Scholar]
  17. Bommier, V. 2017, A&A, 607, A50 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  18. Carlson, B. G. 1963, in The Numerical Theory of Neutron Transport Methods, Computational Physics, eds. B. Alder, S. Fernbach, & M. Rotenberg (Cambridge: Academic Press), 1, 1 [Google Scholar]
  19. Carlsson, M. 1986, Uppsala Astronomical Observatory Reports, 33 [Google Scholar]
  20. Casini, R., & Sainz, R. M. 2016a, ApJ, 824, 135 [Google Scholar]
  21. Casini, R., & Sainz, R. M. 2016b, ApJ, 833, 197 [Google Scholar]
  22. Casini, R., Landi Degl’Innocenti, M., Manso Sainz, R., Land i Degl’Innocenti, E., & Landolfi, M. 2014, ApJ, 791, 94 [NASA ADS] [CrossRef] [Google Scholar]
  23. Casini, R., del Pino Alemán, T., & Manso Sainz, R. 2017a, ApJ, 835, 114 [Google Scholar]
  24. Casini, R., del Pino Alemán, T., & Manso Sainz, R. 2017b, ApJ, 848, 99 [Google Scholar]
  25. D’Anna, M., Janett, G., & Belluzzi, L. 2024, A&A, 689, A90 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  26. del Pino Alemán, T., Casini, R., & Manso Sainz, R. 2016, ApJ, 830, L24 [Google Scholar]
  27. del Pino Alemán, T., Trujillo Bueno, J., Casini, R., & Manso Sainz, R. 2020, ApJ, 891, 91 [CrossRef] [Google Scholar]
  28. del Pino Alemán, T., Alsina Ballester, E., Trujillo Bueno, J., et al. 2024, ApJ, 978, 27 [Google Scholar]
  29. Faurobert-Scholl, M. 1992, A&A, 258, 521 [NASA ADS] [Google Scholar]
  30. Fontenla, J. M., Avrett, E. H., & Loeser, R. 1991, ApJ, 377, 712 [NASA ADS] [CrossRef] [Google Scholar]
  31. Fontenla, J. M., Avrett, E. H., & Loeser, R. 1993, ApJ, 406, 319 [Google Scholar]
  32. Gandorfer, A. 2000, The Second Solar Spectrum: A High Spectral Resolution Polarimetric Survey of Scattering Polarization at the Solar Limb in Graphical Representation. Volume I: 4625 Å to 6995 Å (Zurich: vdf Hochschulverlag AG) [Google Scholar]
  33. Gandorfer, A. 2002, The Second Solar Spectrum: A High Spectral Resolution Polarimetric Survey of Scattering Polarization at the Solar Limb in Graphical Representation. Volume II: 3910 Å to 4630 Å (Zurich: vdf Hochschulverlag AG) [Google Scholar]
  34. Gandorfer, A. 2005, The Second Solar Spectrum: A High Spectral Resolution Polarimetric Survey of Scattering Polarization at the Solar Limb in Graphical Representation. Volume III: 3160 Å to 3915 Å (Zurich: vdf Hochschulverlag AG) [Google Scholar]
  35. Guerreiro, N., Janett, G., Riva, S., Benedusi, P., & Belluzzi, L. 2024, A&A, 683, A207 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  36. Hackbusch, W. 1994, Iterative Solution of Large Sparse Systems of Equations (Springer), 95 [Google Scholar]
  37. Hesse, K., Sloan, I. H., & Womersley, R. S. 2015, in Handbook of Geomathematics, eds. W. Freeden, M. Z. Nashed, & T. Sonar (Berlin, Heidelberg: Springer), 2671 [Google Scholar]
  38. Janett, G., & Paganini, A. 2018, ApJ, 857, 91 [Google Scholar]
  39. Janett, G., Carlin, E. S., Steiner, O., & Belluzzi, L. 2017, ApJ, 840, 107 [NASA ADS] [CrossRef] [Google Scholar]
  40. Janett, G., Steiner, O., Alsina Ballester, E., Belluzzi, L., & Mishra, S. 2019, A&A, 624, A104 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  41. Janett, G., Ballester, E. A., Guerreiro, N., et al. 2021a, A&A, 655, A13 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  42. Janett, G., Benedusi, P., Belluzzi, L., & Krause, R. 2021b, A&A, 655, A87 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  43. Janett, G., Alsina Ballester, E., Belluzzi, L., del Pino Alemán, T., & Trujillo Bueno, J. 2023, ApJ, 958, 38 [Google Scholar]
  44. Janett, G., Benedusi, P., & Riva, F. 2024, A&A, 682, A68 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  45. Jaume Bestard, J., Štěpán, J., & Trujillo Bueno, J. 2021, A&A, 645, A101 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  46. Jolivet, P., Badri, M. A., & Favennec, Y. 2021, J. Comput. Phys., 437, 110313 [Google Scholar]
  47. Kano, R., Trujillo Bueno, J., Winebarger, A., et al. 2017, ApJ, 839, L10 [NASA ADS] [CrossRef] [Google Scholar]
  48. Kirchhoff, G. 1860, Annal. Phys., 185, 275 [Google Scholar]
  49. Kobayashi, K., Kano, R., Trujillo-Bueno, J., et al. 2012, ASP Conf. Ser., 456, 233 [Google Scholar]
  50. Koch, R., & Becker, R. 2004, J. Quant. Spectrosc. Radiat. Transf., 84, 423 [Google Scholar]
  51. Kramida, A., Ralchenko, Y., Reader, J., & NIST ASD Team 2023, NIST Atomic Spectra Database (ver. 5.11). National Institute of Standards and Technology, Gaithersburg, MD. https://physics.nist.gov/asd. [Google Scholar]
  52. Landi Degl’Innocenti, E., & Landolfi, M. 2004, Astrophys. Space Sci. Lib., Vol. 307 [Google Scholar]
  53. Leenaarts, J., Pereira, T., & Uitenbroek, H. 2012, A&A, 543, A109 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  54. Li, H., del Pino Alemán, T., Trujillo Bueno, J., & Casini, R. 2022, ApJ, 933, 145 [NASA ADS] [CrossRef] [Google Scholar]
  55. MATLAB 2023, version 9.14.0 (R2023a) (Natick, Massachusetts: The Math-Works Inc.) [Google Scholar]
  56. McKenzie, D. E., Ishikawa, R., Trujillo Bueno, J., et al. 2019, ASP Conf. Ser., 526, 361 [Google Scholar]
  57. McKenzie, D., Ishikawa, R., Trujillo Bueno, J., et al. 2021, in AGU Fall Meeting Abstracts, Vol. 2021, SH52A–06 [Google Scholar]
  58. Mihalas, D. 1978, Stellar Atmospheres, 2nd edn. (San Francisco: W.H. Freeman and Company) [Google Scholar]
  59. Przybilla, N., & Butler, K. 2004, ApJ, 609, 1181 [NASA ADS] [CrossRef] [Google Scholar]
  60. Rachmeler, L. A., Trujillo Bueno, J., McKenzie, D. E., et al. 2022, ApJ, 936, 67 [NASA ADS] [CrossRef] [Google Scholar]
  61. Rees, D. E., & Saliba, G. J. 1982, A&A, 115, 1 [NASA ADS] [Google Scholar]
  62. Riva, S. 2023, Phd thesis, Faculty of Informatics, Università della Svizzera italiana (USI), Switzerland [Google Scholar]
  63. Riva, S., Guerreiro, N., Janett, G., et al. 2023, A&A, 679, A87 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  64. Riva, F., Janett, G., & Belluzzi, L. 2024, A&A, 688, A137 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  65. Sampoorna, M., Nagendra, K. N., & Stenflo, J. O. 2017, ApJ, 844, 97 [NASA ADS] [CrossRef] [Google Scholar]
  66. Štěpán, J., & Trujillo Bueno, J. 2013, A&A, 557, A143 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  67. Stepán, J., Jaume Bestard, J., & Trujillo Bueno, J. 2020, A&A, 636, A24 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  68. Sukhorukov, A. V., & Leenaarts, J. 2017, A&A, 597, A46 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
  69. Suryanarayana, P., Pratapa, P. P., & Pask, J. E. 2019, Comput. Phys. Commun., 234, 278 [Google Scholar]
  70. Trujillo Bueno, J. 2003, ASP Conf. Ser., 288, 551 [NASA ADS] [Google Scholar]
  71. Trujillo Bueno, J. 2014, ASP Conf. Ser., 489, 137 [Google Scholar]
  72. Trujillo Bueno, J., & del Pino Alemán, T. 2022, ARA&A, 60, 415 [NASA ADS] [CrossRef] [Google Scholar]
  73. Trujillo Bueno, J., & Manso Sainz, R. 1999, ApJ, 516, 436 [NASA ADS] [CrossRef] [Google Scholar]
  74. Uitenbroek, H. 2001, ApJ, 557, 389 [Google Scholar]

2

We note that HanleRT-TIC allows for consideration of both the two-term and multi-term lambda type (Casini & Sainz 2016a,b) atomic models.

3

Levels with J = 1/2 cannot carry atomic alignment by definition, but can carry atomic orientation if the incident radiation has net circular polarisation.

4

For simplicity, we neglect the dependence of the Wien function on frequency in the spectral interval of the line.

5

Although not considered in this work, the present formalism can be simply extended to a two-term atom with hyperfine structure by taking ku and k as the quantum numbers identifying the upper and lower states, respectively, of such an atomic model (see, e.g. Alsina Ballester et al. 2022).

6

In the definition of ub, we assume that the bulk velocity vb is non-relativistic. Moreover, we assume that the frequency interval of the line/multiplet (centred in ν0) is sufficiently small, so that νvb · Ω/cν0vb · Ω/c.

7

In the following, for the ease of notation, the symbols I and ε are used to represent both continuous and discrete quantities.

8

We note that the continuum processes contribute to the emissivity with a thermal and a scattering term that are formally analogous to those of line processes (see Appendix A).

9

If the distance between the centres of two clusters is smaller than 0.25, we considered the two clusters as a single one.

10

We recall that F depends on a, which in turn is a function of r, and that also un depends on r through the ΔνD term.

11

These numerical values are just to exemplify the grids used in the present work.

12

We consider only left preconditioning because no extra step is required to compute the final solution.

13

The code is publicly available at https://gitlab.com/TdPA/hanlert-tic

14

We neglect the contribution from the forbidden transition between the ground level and the excited level 2s 2S1/2.

15

Excellent agreement is found also for other LOSs.

16

The only difference being that, here, we also account for plasma bulk velocities, which introduce a reduced Doppler shift frequency ub.

All Tables

Table 1

Atomic parameters for the Mg II h&k doublet and the H I Ly-α line.

All Figures

thumbnail Fig. 1

Illustrative examples of the quadrature grids. Left: real part (blue and red lines) and positive and negative values of the imaginary part (yellow and purple lines, respectively) of F as a function of u(un+uk,k)$u\prime - \left(\nolbrace \frame{\frame{u_n} + \frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }}} \norbrace\right)$, with u′ = u(ν′), un = u(νn), and uk,k=uku,kuku,k$\frame{u_\frame{\frame{k_\ell },k_\ell ^\prime }} = \frame{u_\frame{\frame{k_u},k_\ell ^\prime }} - \frame{u_\frame{\frame{k_u},\frame{k_\ell }}}$, for different values of u+uku,k$u + \frame{u_\frame{\frame{k_u},k_\ell ^\prime }}$. Here, a = 0.01, Θ = 0.9π, uku,k=11.1$\frame{u_\frame{\frame{k_u},\frame{k_\ell }}} = - 11.1$, and uku,kf=11.2$\frame{u_\frame{\frame{k_u},k_f^\prime }} = - 11.2$. The dots denote the quadrature nodes un′ generated with u = −11.15. Centre: number of quadrature nodes as a function of un and Θ, with a = 0.01, u1=11.15$u_1^ \star = - 11.15$, and u2=20$u_2^ \star = 20$. Right: logarithm of the relative error of evaluating Eq. (11) with the quadrature nodes of the central panel with respect to the reference values obtained with the Gauss–Kronrod adaptive method, with I = (1, 0, 0, 0), a = 0.01, and uku,k=uku,k=11.1$\frame{u_\frame{\frame{k_u},\frame{k_\ell }}} = \frame{u_\frame{\frame{k_u},k_\ell ^\prime }} = - 11.1$.

In the text
thumbnail Fig. 2

Intensity (left column), Q/I (middle column), and U/I (right column) as a function of vacuum wavelength for the Mg II h&k doublet (first row) and the H I Ly-α line (second row), obtained with PRD–AD calculations in a static magnetic FAL-C atmosphere (see text) for a LOS with µ = 0.1. The solid black curves correspond to reference calculations, whereas the red (dashed), yellow (dot-dashed), and purple (dotted) lines are the results of calculations with increased spatial, angular, and frequency resolution, respectively. The reference direction for positive Stokes Q is the parallel to the limb.

In the text
thumbnail Fig. 3

Intensity (left column), Q/I (middle column), and U/I (right column) as a function of vacuum wavelength for the Mg II k line obtained with PRD–AA (dashed lines) and PRD–AD (solid lines) calculations in a dynamic magnetic atmosphere (see text) for the two LOSs with µ = 0.1 (first row) and µ = 1 (second row). The blue and red curves correspond to calculations carried out with the HanleRT-TIC and the TRAP4 code, respectively. The reference direction for positive Stokes Q is the parallel to the limb.

In the text
thumbnail Fig. 4

Centre-to-limb variation of Q¯/I¯$\bar Q/\bar I$ (left panel) and Ū/Ī (right panel) as a function of µ = cos(θ). The results are obtained for χ = 0 and considering height-independent horizontal (θB = π/2 and χB = 0) magnetic fields of different strengths (see the legend). Dashed and solid lines correspond to PRD–AA and PRD–AD calculations, respectively.

In the text

Current usage metrics show cumulative count of Article Views (full-text article views including HTML views, PDF and ePub downloads, according to the available data) and Abstracts Views on Vision4Press platform.

Data correspond to usage on the plateform after 2015. The current usage metrics is available 48-96 hours after online publication and is updated daily on week days.

Initial download of the metrics may take a while.