An innovative magnetic state generator using machine learning techniques

We propose a new efficient algorithm to simulate magnetic structures numerically. It contains a generative model using a complex-valued neural network to generate k-space information. The output information is hermitized and transformed into real-space spin configurations through an inverse fast Fourier transform. The Adam version of stochastic gradient descent is used to minimize the magnetic energy, which is the cost of our algorithm. The algorithm provides the proper ground spin configurations with outstanding performance. In model cases, the algorithm was successfully applied to solve the spin configurations of magnetic chiral structures. The results also showed that a magnetic long-range order could be obtained regardless of the total simulation system size.


Simulation Model
Our goal is to obtain ground state magnetic structures using a magnetic Hamiltonian that generally contains exchange interaction, Dzyaloshinskii-Moriya interaction (DMI) 18,19 , dipolar interaction, anisotropies, and Zeeman energy. Before considering the general case, for the quantitative investigation of the characteristics of the k-space-based algorithm, we first applied it to a simple magnetic system where the analytical solutions were known by previous studies 20,21 . The Hamiltonian, J DM ,  , used to describe the simple system contains only the exchange interaction and DMI, and is expressed as: where J and → DM ij are the strength of the exchange interaction and the Dzyaloshinskii-Moriya vectors, respectively. J and → DM ij are written in units of energy. We used the classical Heisenberg spin model, which is one of the general spin models for studying magnetic domains and magnetic properties [20][21][22][23][24][25] . In the Heisenberg model, the spin → S is considered a three-dimensional unit vector. When the energy minimization conditions are calculated analytically according to Eq. (1), it is known that the ground states of the two-dimensional magnetic systems are sinusoidal wave profiles, such as helical or cycloidal structures 20,21 .
After verifying our algorithm with known analytical solutions, as the next step, we generalized the k-space-based algorithm to obtain the magnetic configurations formed in a more complicated system, such as a quasi-two-dimensional system, in which the total Hamiltonian is expressed as: where K u and D dip are the strength of the uniaxial anisotropy and dipolar interaction, and → h ext is the applied external magnetic field. We used a square or cubic grid model to simulate two-or three-dimensional magnetic systems, so → r ij is a dimensionless displacement vector between i and j grid sites.

Machine Learning Algorithm
ML algorithm was used to generate k-space information of the spin configurations, and the total iteration process is shown in Fig. 1. The input X in Fig. 1 is composed of n randomly sampled values from the standard normal distribution for the stochastic behavior of the optimization process.
A simple complex-valued one-layer perceptron, which is the simplest CVNN, is used to obtain output k-space information f. The number of f values is m × 3, where m is the total number of grid sites in k-space. In other words, n and m × 3 are the numbers of input and output data for the one-layer CVNN, respectively. We used a one-layer CVNN rather than a multilayered CVNN because of two reasons. One is that one layered neural network structure is enough to generate energy minimized spin configurations as shown in the previous study 7 . The simple network structure of that study has the advantage of being able to investigate in detail the changes in the network parameters that occurred during the training process. The other is that the effect of the multilayer in our algorithm did not improve the results. The spin configurations from the multilayered CVNN were frozen in local energy minimum states, which means that the stochastic behavior of the algorithm from the input random numbers in X was reduced due to the additional layers.
We set the components of the network parameters, weight and bias, as complex numbers to represent the phases of k-space information; thus, each of the f values is composed of complex numbers. This information is reshaped to a three-dimensional k-space vector configuration . The î , ĵ , and k are the unit vectors of the x y , and z axes of k-space respectively. After the reshaping process for where  represents the Hadamard product. There are two main reasons for using hermitization in the k-space-based algorithm. First, this method is used to obtain real number information of spin vectors in r-space. In the Heisenberg model, a spin is a three-dimensional vector with three real numbers. Hermitization results in an IFFT consisting of only real parts, so the IFFT results can be treated as r-space spin vectors in the Heisenberg model. Second, hermitization adds a nonlinear operation defined in complex number space. The operation can emphasize differences in the k-space values, and it is expected to be advantageous in searching for the periodicity of the r-space spin configurations. The novelties of this study are the use of a one-layer CVNN and the use of hermitization operation to improve the performance of ML algorithm for generating magnetic spin configurations. The r-space spin configuration , can prevent the divergence of the magnitude of the network parameter through the cost minimization process, it can make the stochastically fluctuating behavior of our algorithm reduced gradually as training progresses. Hence, it is expected that the final spin configuration generated by our algorithm at the last iteration becomes a single stable spin configuration. We added an Adam optimizer at the last part of the k-space-based algorithm to minimize the cost, and the total process iterated 100,000 times with a 0.001 learning rate.

Results and Discussion
To investigate how the learning process of the k-space-based algorithm progresses quantitatively, we applied this algorithm to the simple system described by the Hamiltonian in Eq. (1) with J = 1, → = .
, exhibits the characteristics of the r-space spin configuration more clearly. → F k ( ) z of the simulation was distributed randomly at the early stage and evolved to a feature with two bright peaks, which indicate a sinusoidal structure in r-space.
In addition to generating the magnetic structures with the morphological characteristics of the ground state, increasing the degree of ordering of the generated magnetic structures is also an important factor to minimize the system energy as experimentally observed well-ordered magnetic states 10,11 . We investigated two parameters to quantitatively analyze the ordering of the generated spin configurations. One is the magnitude of the peaks appearing in k-space, and the other is the long-range order (LRO) parameter 7,22 , which was calculated from the time correlation between spins at the current iteration and spins at the final state. Both values increased as the generated spin configuration became aligned Fig. 2(b). The magnetic structure was almost ordered in the initial www.nature.com/scientificreports www.nature.com/scientificreports/ 10 3 iterations, which is a hundredth of the total number of iterations. This indicates that this algorithm utilizing k-space is very efficient in building long-range order at an early stage. As a comparison, when the ML technique was applied to directly generate the r-space spin configuration 7 , the LRO parameter was typically built up around 10 4 ∼10 5 iterations. Therefore, adopting a series of processes in k-space greatly improved the ML technique to generate long-range ordered spin configurations.
This algorithm was also found to be efficient in escaping from local minimum states. Notice that the period and the alignment direction of the spin configuration were not fixed during the simulation process, which implies that this algorithm can easily overcome the energy barrier needed to change the periodicity of magnetic structures. This property is important in studying the ground states of systems with hysteresis. The spin configuration is not inherited from the previous iteration since the algorithm basically converts the random input into the spin configuration through a trained neural network. Therefore, our algorithm has stochastic behavior that generates a different magnetic structure for every iteration to find a ground state without being affected by hysteresis characteristics.
Another advantage of the k-space-based algorithm is manifested in the large-scale simulations possible in k-space. As the system size of the simulations increases, unwanted boundary or size effects diminish, and the accuracy of the results significantly improves. A large-scale simulation is also required to investigate systems where magnetic structures with various length scales coexist. However, increasing the size of the simulations based on r-space can cause problems since the results are made up of domains built with local energy minimization, and the long-range order of the system is lost. We can overcome these problems by exploring magnetic structures in k-space, which can represent the characteristics of spin configurations consistently for various system sizes.
To verify this approach, we compared the results obtained with k-space-based and r-space-based algorithms for systems with various lateral sizes from = = L L 50 x y to 400 Fig. 3. Our k-space-based algorithm can perfectly simulate the aligned chiral structures regardless of system size Fig. 3(a). On the other hand, the spin configurations generated by the r-space-based algorithm with the same simulation conditions (batch size n b = 1 and n = 1) showed less ordered structures Fig. 3(b). It is known that increasing the batch size and the size of random input is effective in generating ground states in an r-space-based algorithm 7 . We ran another simulation using the algorithm with batch sizes n b = 256 and n = 32. The alignment of generated spin configurations improved Fig. 3(c), but the perfectly aligned ground state appearing in our k-space-based results Fig. 3(a) could still not be obtained. Moreover, increasing the batch size can cause a disadvantage of a longer iteration run time due to a large amount of the computational process. In our case, the computation run time for obtaining results using the r-space-based algorithm with the n b = 256 condition is increased by 10 times compared to the case of n b = 1 condition.
To clearly show the differences between the algorithms discussed in Fig. 3(a-c), the simulated energy from each of the algorithms is compared with the analytic solution Fig. 3(d). The results from the k-space-based algorithm are closer to the analytically calculated ground state energy than the results from both r-space-based algorithms for all system sizes. These results clearly show the correctness of the proposed algorithm in this study.
To show that the k-space-based algorithm can be used to investigate the ground state of a more complicated system, we applied the algorithm to obtain the ground state of the magnetic bubble domain formed in a quasi-two-dimensional system where the thickness can affect the magnetic domain profile. Since the magnetic bubble structures are coupled to each other by long-range dipolar interaction, the binding strength sharply decreases as the distance between the bubbles increases. Hence, it is difficult to obtain a perfectly aligned bubble www.nature.com/scientificreports www.nature.com/scientificreports/ domain with a certain periodicity and lattice structure through a numerical simulation method. In addition, the Neel cap regions, which are generated from the boundary effect of the dipolar interaction, can appear in a quasi-two-dimensional system [26][27][28][29] . Therefore, it is a suitable and challenging system that can be used to prove the performance of this algorithm.
We performed a simulation on a 100 × 100 × 15 system (m = 15 × 10 5 ) by a k-space-based algorithm using the Hamiltonian in Eq. (2) with n = 8, J = 1, , and D dip = 0.15. We used periodic boundary conditions in the x and y directions and non-periodic boundary conditions in the out-of-plane (z) direction. Figure 4 shows that our algorithm can generate a bubble domain with a hexagonal lattice structure with Neel cap regions on both surfaces of the quasi-two-dimensional system. Because this bubble domain is formed by dipolar interaction, domain walls coexist with two chiralities, as seen by the color change of a single bubble from the top surface to the bottom surface in Fig. 4. This result proves that the k-space-based algorithm can be an effective simulation technique to obtain the ground state of complicated systems.

conclusion
We propose an algorithm that obtains ground state spin configurations through an IFFT of hermitized k-space information formed by a generative ML model using a simple CVNN.
The network parameters in the proposed algorithm are trained to generate the k-space information of energy minimized spin structures. The training results show perfectly long-range ordered structures close to the known magnetic ground states. This shows that the magnetic spin configurations generated using the k-space-based