In magnetic atomic gases, the dipolar relaxation process couples the system spin and kinetic degrees of freedom. When the average kinetic energy is significantly lower than the Zeeman splitting, the atoms predominantly occupy the lowest Zeeman state. As the Zeeman splitting approaches the average kinetic energy, some atoms transfer to adjacent Zeeman states through dipolar relaxation, converting kinetic energy into Zeeman energy. By utilizing optical pumping, atoms transferred to higher spin states can be repumped to the ground state, thereby achieving a continuous cooling cycle and effectively lowering the system’s temperature. As the energy removed in a single cooling cycle is much larger than the energy of scattered photons, this demagnetization cooling scheme significantly enhances cooling effciency and reduces atomic loss. In this work, we establish state-coupled equations that incorporate dipolar relaxation and optical pumping to analyze the demagnetization cooling process, modeling the evolution of atom number and temperature during the cooling of $^{164}{\text{Dy}}$ atoms. We develop a strategy to generate an optimal magnetic field waveform by maximizing the demagnetization rate. Based on this strategy, we investigate the influence of crucial experimental parameters on demagnetization cooling and determine their specific ranges for producing large atom number of BEC, including the optical dipole trap frequency, as well as the intensity and polarization purity of the optical pumping light. The results indicate that demagnetization cooling enables the direct preparation of a large number of dysprosium BEC with sub-second timescales, reducing the cooling time by an order of magnitude compared to conventional methods for dysprosium atoms. Furthermore, it could achieve a cooling effciency of $\chi \approx 44.92$, an order of magnitude higher than that of traditional evaporative cooling.