Transfer matrix calculation for ion optical elements using real fields