Efficient Cohomology Computation for Electromagnetic Modeling