The significant growth in demand for electricity has led to increasing congestion on distribution networks. The challenge is twofold: it is needed to expand and modernize our grid to meet this increased demand but also to implement smart grid technologies to improve the efficiency and reliability of electricity distribution. In order to mitigate these congestions, novel approaches by using flexibility sources such as battery energy storage can be used. This involves the use of battery storage systems to absorb excess energy at times of low demand and release it at peak times, effectively balancing the load and reducing the stress on the grid. In this paper, two optimal power flow formulations are discussed: the branch flow model (non-convex) and the relaxed bus injection model (convex). These formulations determine the optimal operation of the flexibility sources, i.e., battery energy storage, with the objective of minimizing power losses while avoiding congestions. Furthermore, a comparison of the performance of these two formulations is performed, analyzing the objective function results and the flexibility operation. For this purpose, a real Spanish distribution network with its corresponding load data for seven days has been used.