Dynamical models of molecular clouds: nitrogen chemistry