Lean cohomology computation for electromagnetic modeling