function [cavitation,isterminal,direction] = pressureEventsFcn(t, p, pcav)
  global pcav
  cavitation = (p > pcav); % The value that we want to be zero, 
                     % i.e pressure reaches vapour pressure
  isterminal = 1;  % Halt integration 
  direction = 0;   % The zero is approached when pressure is decreasing 
                    % in trapped volume
end