Ordinary differential equations are coupled with mixed constrained optimization problems when modeling the thermodynamic equilibrium of a system evolving with time. A particular application arises in the modeling of atmospheric particles. Discontinuity points are created by the activation/deactivation of inequality constraints. A numerical method for the solution of optimization-constrained differential equations is proposed by coupling an implicit Runge-Kutta method (RADAU5), with numerical techniques for the detection of the events (activation and deactivation of constraints). The computation of the events is based on dense output formulas, continuation techniques, and geometric arguments. Numerical results are presented for the simulation of the time-dependent equilibrium of organic atmospheric aerosol particles, and show the efficiency and accuracy of the approach.