I note that the simulation is a "mathematical solution" and that the mathematics is quite detailed and useful. HFSS was finite element based but now one can invoke additional solvers.
Array factor is a function of both number of elements and spacing. If your elements do not have identical power patterns and other than zero phase offset the resulting array patterns are more interesting. See Kraus for more discussion. If you are interested in a wide bandwidth the picture can be even more fun.
You might also find the discussion in Kraus about antenna arrays useful. With multiple radiators, spacing and number are the strongest factors modifying the gain. As the array gets larger the beamwidth generally decreases causing gain to increase. Painting with a broad brush, spacing should be between spacing between 1/2 and 1 wavelength. Spacing too wide can result in significant loss in gain. With two elements the spacing should be no larger than 0.7 wavelengths. With more elements, spacing can be increased without falling off a gain cliff (by creating grating lobes).
Microwave Engineer's Handbook (vol 2 ) has a handy chart of gain vs spacing and number of elements. It might be helpful to track down a copy.
Sidelobe pattern details will also change the gain but are generally controlled with aperture element weights and phasing. Silver has a helpful chart where he discusses the character of different aperture distributions.
Element patterns also play into the secondary radiation pattern. Pay attention to the idea of pattern multiplication. That can provide additional insight into what is happening.
I just looked at the plots above again and noticed that they were made with software other than HFSS. The gain variation shown is effected by both beamwith and sidelobe distribution. Narrowing beamwidth generally increases gain and decreasing sidelobe level will also generally increase gain. The two are not often completely independent, particularly if you only have two elements in play. If you want more gain try endfire, but then you might want to use something other than a patch as an element.
Regards,
Azulykit