%  Maximum time step for explicit integration 
function [tauMin tau] = dtMax(dT,Tref,t)
  if (size(Tref)~=size(dT(Tref,t)))
    Tref=Tref';
  end
  [M,N]=size(Tref);
  Rate=zeros(M,N);
  tau=Inf*ones(M,N);
  Tpert=Tref;
  delT=0.1;

  Rate=dT(Tref,t);
  for m=1:M
    for n=1:N
      Tpert(m,n)=Tref(m,n)+delT;
      NewRate=dT(Tpert,t);
      Change=NewRate(m,n)-Rate(m,n);
      if Change tau(m,n)=abs(delT/Change);
      end
      Tpert(m,n)=Tref(m,n);
    end
  end
  tauMin=min(min(tau));
end
