  Aims. We tested the new atomic model using atmospheric models of stars of
different spectral types: the Sun (dG2), HD22049 (dK2, Epsilon Eridani), GJ 832
(dM2), and GJ 581 (dM3).
  Methods. We used new Breit-Pauli distorted-wave (DW) multiconfiguration
calculations, which proved to be relevant for many transitions in the
mid-infrared (MIR) range. The new atomic model of Mg I includes the following:
i) recomputed ECS data through the DW method, including the superlevels. ii)
For the nonlocal thermodynamic equilibrium (NLTE) population calculations, 5676
theoretical transitions were added (3001 term-to-term). iii) All of these
improvements were studied in the Sun and the stars listed above.
  Results. The Mg distribution between ionization states for stars with
different effective temperatures was compared. For the Sun and Epsilon Eridani,
Mg II predominates with more than 95 %, while for GJ 832 and GJ 581, Mg I
represents more than 72 % of the population. Moreover, in the latter stars, the
amount of Mg forming molecules in their atmosphere is at least two orders of
magnitude higher. Regarding the NLTE population, a noticeable lower variability
in the departure coefficients was found, indicating a better population
coupling for the new model. Comparing the synthetic spectrum calculated with
the older and new Mg I atomic model, these results show minimal differences in
the visible range but they are stronger in the IR for all of the stars. This
aspect should be considered when using lines from this region as indicators.
Nevertheless, some changes in the spectral type were found, also emphasizing
the need to test the atomic models in different atmospheric conditions. The
most noticeable changes occurred in the FUV and NUV, obtaining a higher flux
for the new atomic model regardless of the spectral type.
