We investigate phase transformations and electronic-structure transitions in oxides and inorganic materials for atomic and molecular switches: validation focuses on the free energy of phase transformations in oxide materials as a function of bias and oxygen vacancies and organic materials as a function of redox potentials.