Ab initio simulation approach for calculating the effective dielectric constant of composite materials