Extended molecular dynamics scheme for crystals with fully relaxed size and shape