Maximal degenerations, log structures, wall crossing and theta functions