code: def save_state(self, fname=None):
          
          if not fname:
              date = datetime.datetime.now().strftime("%Y-%m-%dT%Hh%Mm%Ss")
              fname = date + "_energy_" + str(self.energy()) + ".state"
          with open(fname, "wb") as fh:
              pickle.dump(self.state, fh)
docs: Saves state to pickle