Simulating the dynamics of DNA supercoiling and compaction