Add nonlinear component (triad interactions) 
loop: 1 <= j <= N 
 Calculate Mlocal
 # Triad: j=q+p 
 loop: 1 <= p <= j-1 
 q=j-p 
 loop: 0 <= List of triads <= |Mlocal| 
 if (modes J(j,s), P(p,u), and Q(q,v) exist) then 
 Compute ȝ
 if (ȝ < ȝc) then 
 Add nonlinear contribution of triad: J, P, Q 
 end 
 end 
 end 
 end 
 # Triad: j=q-p 
 loop: 1 <= p <= j-1 
 q=j+p 
 0 <= List of triads <= |Mlocal|
 if (modes J(j,s), P(p,u), and Q(q,v) exist) then 
 Compute ȝ
 if (ȝ < ȝc) then 
 Add nonlinear contribution of triad: J, P, Q 
 end 
 end 
 end 
 end 
end
```