  Heusler alloys exhibiting magnetic and martensitic transitions enable
applications like magnetocaloric refrigeration and actuation based on the
magnetic shape memory effect. Their outstanding functional properties depend on
low hysteresis losses and low actuation fields. These are only achieved if the
atomic positions deviate from a tetragonal lattice by periodic displacements.
The origin of the so-called modulated structures is the subject of much
controversy: They are either explained by phonon softening or adaptive
nanotwinning. Here we used large-scale density functional theory calculations
on the Ni2MnGa prototype system to demonstrate interaction energy between twin
boundaries. Minimizing the interaction energy resulted in the experimentally
observed ordered modulations at the atomic scale, it explained that a/b twin
boundaries are stacking faults at the mesoscale, and contributed substantially
to the macroscopic hysteresis losses. Furthermore, we found that phonon
softening paves the transformation path towards the nanotwinned martensite
state. This unified both opposing concepts to explain modulated martensite.
