Exactly energy conserving semi-implicit particle in cell formulation