codes for simulation of nonsmooth dynamic systems