code: def calc_time_step(self):
          
          system = self.system
          config = self.config
          convergence = self.convergence
          niter = self.niter
          t = self.t
  
          if t == 0:
              self._calc_time_step_first()
              return
  
          if convergence:
              if niter >= 15:
                  config.deltat = max(config.deltat * 0.5, config.deltatmin)
              elif niter <= 6:
                  config.deltat = min(config.deltat * 1.1, config.deltatmax)
              else:
                  config.deltat = max(config.deltat * 0.95, config.deltatmin)
  
              # adjust fixed time step if niter is high
              if config.fixt:
                  config.deltat = min(config.tstep, config.deltat)
          else:
              config.deltat *= 0.9
              if config.deltat < config.deltatmin:
                  config.deltat = 0
  
          if system.Fault.is_time(t) or system.Breaker.is_time(t):
              config.deltat = min(config.deltat, 0.002778)
          elif system.check_event(t):
              config.deltat = min(config.deltat, 0.002778)
  
          if config.method == 'fwdeuler':
              config.deltat = min(config.deltat, config.tstep)
  
          # last step size
          if self.t + config.deltat > config.tf:
              config.deltat = config.tf - self.t
  
          # reduce time step for fixed_times events
          for fixed_t in self.fixed_times:
              if (fixed_t > self.t) and (fixed_t <= self.t + config.deltat):
                  config.deltat = fixed_t - self.t
                  self.switch = True
                  break
  
          self.h = config.deltat
docs: Set the time step during time domain simulations
  
          Parameters
          ----------
          convergence: bool
              truth value of the convergence of the last step
          niter: int
              current iteration count
          t: float
              current simulation time
  
          Returns
          -------
          float
              computed time step size