Modeling magnetic flux ropes in the solar atmosphere