Realistic three dimensional simulation on the performance of micromegas