Hybrid functionals for solids with an optimized Hartree–Fock mixing parameter