both hydrogen and helium . Computing non-equilibrium ionization in post-processing is not possible, so instead we derive the non-LTE electron density through solving the non-LTE problem for hydrogen together with the charge conservation equation.

First, we tried an approach similar to what the RH code uses [@2001ApJ...557..389U]. The electron density is updated after every M-ALI iteration to be consistent with the proton density, while the ionization of all other elements is computed in LTE. We found this approach to unstable in our calculations and the NLTE populations for hydrogen did not converge for our problem.

Instead, we decided to solve simultaneously in each M-ALI iteration the equation of charge conservation and the system of statistical equilibrium equations for preconditioned rates. This new system of equations is non-linear with respect to the unknown electron density and hydrogen level populations as some of the rates depend on the electron density. We solve it iteratively using the Newton-Raphson method. A similar technique has been used in other radiative transfer codes . Our implementation is explained in Appendix \[app:charge\_conservation\].

We note that this is a substantial improvement over previous radiative transfer calculations with the Multi3D code for hydrogen, where the proton density could be 