A general model to calculate coherent solid/solid and immiscible liquid/liquid interfacial energies