Ionization, atomization, and bond energies as functions of distances in inorganic molecules and crystals