In order to examine electron dynamics and the electromagnetic interaction in the process of the microwave generation in magnetron, we newly started to develop a three dimensional (3D) magnetron simulator with electromagnetic particle-in-cell (PIC) model. In the test simulation, we could confirm the nonlinear evolution of electrons' cross-field flow and associated microwave emission in magnetron. We particularly focused on the effect of the end-hat/end-space attached at each side of cathode/anode on the microwave emission as well as the electron dynamics in magnetron. We found that the frequency shift is due to the admittance of end-space which works as a resonator