Electromagnetic field simulation