Phase diversity techniques commonly employ a pair of focused–defocused images to retrieve the incident wave front and to restore the observed scene. However, the combination of more images, each one affected by a different amount of defocus, has been barely explored in solar astronomy. In this work we reformulate the “classic” two-images phase diversity approach to accommodate an arbitrary number of phase differences and we investigate its performance in synthetic magnetohydrodynamical simulations of the solar scene corrupted by noise and degraded by a certain set of aberrations. We employ different combinations of images defocused from ±0.5 λ up to ±2 λ (peak to peak) and compare both the retrieved wave front with the incident one and the restored images with the unaberrated noiseless scene. We investigate the effect of using a series of images defocused both symmetrically and asymmetrically with respect to the focused one. In these two cases the performance of the method is improved with the use of more than two images, although it benefits more from the use of symmetric defocuses. We find also that there is a qualitative best choice of the number of phase diversity images in terms of the goodness of the wave front retrieval and of the restored object. The presented method has a potential use either in instruments equipped with a refocusing mechanism or during the laboratory calibrations of the instrument provided that an optical target can be defocused manually by different amounts.