Determination of magnetic structure from Hamiltonian