We present a self-consistent method based on first-principles calculations to determine the magnetic ground state of materials, regardless of their dimensionality. Our methodology is founded on satisfying the stability conditions derived from the linear spin wave theory (LSWT) by optimizing the magnetic structure iteratively. We demonstrate the effectiveness of our method by successfully predicting the experimental magnetic structures of NiO, FePS₃, FeP, MnF₂, FeCl₂, and CuO. In each case, we compared our results with available experimental data and existing theoretical calculations reported in the literature. Finally, we discuss the validity of the method and the possible extensions.