This paper focuses on the characterization of viability zones in compartmental models with varying population size, due both to deaths caused by epidemics and to natural demography. This is achieved with the use of viscosity characterizations of viability and extensively illustrated on several models. An example taking into consideration real data is provided. The paper is completed with a viscosity approach to the optimality of minimal ("greedy") non-pharmaceutical interventions.