After obtaining the microstructural information by (S)TEM, we measured the macroscopic magnetic properties which are extracted from hysteresis loops for both samples, as shown in Table 1. The coercive field strength (H cB) is drastically decreased from 870 kA mˉ1 for sample 1 (lower iron content) to 250 kA mˉ1 for sample 2 (high iron content). This results in a relatively low remanence and energy density for sample 2. For sample 1 attractive magnetic properties were achieved: B r = 1.2 T, (BH)max = 262 kJ mˉ3, H cB = 870 kA mˉ1. We attribute the difference in the magnetic properties of these two samples to their distinguished microstructures. Since Sm2Co17 is a typical pinning-controlled magnet, we used microstructure-based micromagnetic simulations to qualitatively elucidate the domain pinning in these two samples. In order to reduce the computation cost, half of the TEM images shown in Figs 1a,c were adopted to construct the micromagnetic models with a size of 440 × 440 × 220 nm3, as shown in Supplementary Fig. 4. The initial domain wall lies in the plane parallel to the easy axis and separates two antiparallel magnetic domains (Supplementary Fig. 4). With this initial condition, micromagnetic simulations are carried out to calculate the demagnetization curves (Fig. 3a) and capture the magnetization reversal process (Fig. 3b,c). The plateaus in Fig. 3a are a result of domain wall pinning. The zigzag domain walls in Fig. 3b and c indicate the 1:5 phase and the Z-phase as pinning sites. It is obvious that sample 1 exhibits much more plateaus, thus, much more pining sites as compared to sample 2. This is in agreement with the experimental results (sample 1 has higher coercivity). It should be noted that the micromagnetic model is only an extremely small part of the real sample. So the simulated reversal curves cannot be directly compared with the experimental curves. Nevertheless, we analyzed the detailed reversal process to reveal the underlying microstructure-related mechanism. In Figs 3b,c, P1- and P2-type sites show representative pinning sites where the 1:5 phase intersects with the Z-phase, and P1′- and P2′-type sites show representative sites only with the Z-phase. It should be mentioned that unlike the P1- and P2-type pinning sites, P1′- and P2′-type sites are not fixed to particular positions. They move intermittently and their actual position is determined by the interplay between the cost of domain wall energy and the gain of magnetostatic energy (Supplementary Movies 1 and 2). As shown in 1i–1v of Fig. 3b, P1-type sites in sample 1 are strongly pinned until the external field reaches ~1,200 kA mˉ1. But intermittent movements of domain walls occur in the P1′-type sites, resulting in lots of plateaus between 0 to ~1,000 kA mˉ1 in the reversal curve of sample 1 (Fig. 3a). In contrast, in sample 2 domain walls intermittently move much faster in P2′-type sites and rapidly sweep through most of the sample at a low external field of ~400 kA mˉ1 (2iii in Fig. 3c). But P2-type sites in 2i of Fig. 3c are still strongly pinned. Furthermore, the domain wall cannot be pinned by Z-phase any more when it is depinned in 1:5 phase. As shown in Fig. 3b(1v–1vi), the domain wall in 1v contains a long segment in the Z-phase, but this segment collapses immediately after it is not stabilized by the 1:5 phase (1vi). This indicates that in both samples, 1:5 phase related, P1- and P2-type sites have larger pinning strength than Z-phase related P1′- and P2′-type sites. The diamond-shaped cellular structure with a continuous 1:5 phase, i.e. more P1- and P2-type sites, is responsible for the increased number and pinning strength of the pinning sites, which are favorable for an enhanced coercivity. The Z-phase can act as pinning sites, but contributes little to the coercivity. Since the domain wall energy in the Z-phase is lower compared to the 2:17 and the 1:5 phase, the Z-phase acts as a weak attractive pinning site. In contrast, the 1:5 phase act as repulsive pinning site because of its much higher domain wall energy.Fig. 3Simulation results on domain wall pinning. a Demagnetization curves with the red and green lines corresponding to samples 1 and 2, respectively. The magnetization reversal process of b sample 1 and c sample 2 at different values of applied external magnetic field marked in a. m c denotes the magnetization component along the easy axis. P1 and P2 show typical pinning sites, where 1:5 phase intersects with the Z-phase. P1′ and P2′ denote typical sites containing only the Z-phase. The yellow arrows denote the positions