The selectivity of the sodium channel has been the subject of numerous exper- imental and theoretical studies. In this work we address this problem from a theoretical point of view, based on a model built from the selectivity filter (SF) of the open structure of the voltage-activated channel of the bacterium Mag- netococcus marinus. This approach has allowed us to calculate the interaction energies of the system (cation-water-SF-fragment), both for the sodium cation and the potassium cation. The results obtained have highlighted the importance of differential dehydration of cations, as well as the environment where it occurs. Semi-empirical and ab initio methods have been applied to analyze and quantify the interaction energies when the cations are in the SF of the sodium channel, with the DFT (ab initio) methods being those that have given us the key to the distribution of the interaction energies and therefore how dehydration occurs.