Most developed countries around the world are seriously concerned about recent global warming, the depletion of fossil fuels and environmental degradation. So as to meet the environmental burden reduction targets set by different international agreements, manufacturing companies are seriously encouraged to invest considerable efforts in the field of energy. Energy storage systems (ESS) have the potential to revolutionize the way in which electrical power grids are designed and operated. Presently, power grids require that the generation of electricity continuously balance the demand. The constant balancing of supply and demand has significant operational and cost implications. Incorporation of storage devices into the grid should reduce this constraint by enabling electrical energy to be withdrawn from the grid when there is excess generation and held in reserve until needed. In this work we consider stationary applications with medium discharge time (minutes to hours), thus batteries have been considered. The object is to find the optimal sizing of the energy storage device (i.e. batteries) with which it is possible to minimize the cost of energy in a production plant.