Optimization of a leaching process for copper-bearing materials