First-Principles Based Model of Spin-state Phase Transition