Numerical simulation of martensitic transformations in magnetic transition-metal alloys