Solar-powered air conditioners offer a high potential for energy-efficient cooling with a high economic feasibility. They can significantly reduce the energy consumption in the building sector, which is essential to meet the greater ambition of reducing greenhouse gas emissions by 80% in the EU by 2050. This paper presents a computational model development capable of simulating the behaviour of a photovoltaic-assisted heat pump in different locations and working conditions. In addition, this model has been used to optimise a solar on-grid air conditioning system. The generated model has been validated with experimental data obtained in a real facility for a whole summer of operation (more than 100 tested days) in a Mediterranean climate (Alicante, Spain). According to the simulation results, the average Energy Efficiency Ratio (EER) of the system is 16.0, 10.7 and 7.8 in Barcelona, Madrid and Seville, respectively. The optimisation analysis has proven that the severity of the climatic region increases the costs as well as the optimum PV power to drive the AC unit. The obtained values for the the PV power and the annualised cost are 400 W and 506.2 € for Barcelona, 900 W and 536.7 € for Madrid, and 1300 W and 564.7 € for Seville. The annualised cost and the CO2 emission levels are higher for the conventional system (no PV panels) than for the solar on-grid system, regardless of the installed PV power. This difference can be up to 66.64 € (10.55%) and 112.94 kg CO2 (64.83%) per summer season in the case of Seville.