In the previous section, we introduced a constraint DFT method to control the spin direction. 
 The constraint DFT method enables us to evaluate a magnetic anisotropy energy (MAE) 
 for magnetic systems in a self-consistet manner based on the total energy. 
 However, the computation tends to become very costly, and the calculation
 tends to be trapped to a local minima due to the degree of freedom of the occupation to degenerate 
 localized states such as 
-orbitals. A way to bypass these problems is to use a second variational 
 method that a one-shot diagonalization within the non-colliear DFT is performed with spin-orbit 
 coupling (SOI) and the charge density calculated by the collinear DFT as initial guess
 after getting the SCF charge density within the collinear DFT.
 Since the variational scheme is based on the Harris functional [14], 
 the perturbation by the spin 
 rotation and the SOI is taken into account only in the band energy. 
 The double counting term does not depend on the spin rotation, while 
 it looks changed in the output of OpenMX, since the energy terms are calculated by the output 
 density rather than the input density (please don't be confused by the output). 
 Using the second variational method, we first calculate a ferromagnetic state within 
 the collinear DFT, resulting in the SCF charge density. 
 Then, the one-shot diagonalization for the Hamiltonian including SOI is performed 
 within the non-colliear DFT using the restart file storing the SCF charge density. 
 The restart file can be read by the following keywords:
 
       scf.restart.filename               FePt
       scf.restart                        c2n
Using the keyword 'scf.restart.filename', the restart file to be read is specified. 
  By 'c2n' for the keyword 'scf.restart' one can port a restart file generated by a collinear 
  DFT calculation to a non-collinear DFT calculation. 
  As an example, the restart file above is generated by an input file 'FePt.dat' available 
  in the directory 'work'.
  In the second calculation, the spin direction can be specified by the following keywords:
  
  
 
       scf.Restart.Spin.Angle.Theta       90.0
       scf.Restart.Spin.Angle.Phi          0.0
The spin direction at all the spatial points is aligned along the direction determined 
 by the two keywords which specify Euler angles. Therefore, it should be noted that the evaluation 
 of the MAE by the second variational method is valid only for ferromagnetic systems.
 Let us demonstrate how the second variational method works to evaluate the MAE. 
 Figure 36 shows the MAE curves for the spin rotational angle in the L1
 
   
 | 
The second variational scheme might be useful for not only the evaluation of MAE, but also calculations of band structure of large-scale systems, which may hamper direct SCF calculations by the non-collinear DFT method, to investigate how the SOI modifies the band structure.