In this research, the optimization of energy consumption of zero-energy buildings using PCMs in the two study cities of Vancouver and Dubai and its energy supply with a multi-generation geothermal system is discussed. PCMs used in the walls and roofs of designed buildings are of two types, namely PCM (solid) and PCM (liquid). By optimizing the energy consumption of the residential complex in two study cities, it is finally possible to choose the best mode in optimal conditions to reduce energy consumption in the residential complex, reduce the costs of the residential complex, and reduce the environmental pollution. The results showed that the amount of electricity consumption, heating, and cooling of the residential complex during the year in the city of Vancouver is 8493.55, 7899.1, and 1083.97 kWh, respectively, and in the city of Dubai, the values are 9572.1, 8.99, and 18,845.44 kW, respectively. Also, by optimizing the energy consumption of residential complexes in Vancouver and Dubai, it is possible to reduce CO2 emissions by 2129.7 and 2773.2 kg/year, respectively. The electricity consumption of the residential complex in Dubai is 11.26% and the carbon dioxide emission is 23.20% more. In the end, a multi-generation system is proposed to meet the energy consumption of a six-unit zero-energy residential complex with 120 m2 and two bedrooms in Vancouver, Canada. By setting up the study system in the city of Vancouver, 237,364.6 kWh of electricity, 425,959.4 kWh of heating, and 304,732.8 kWh of electricity can be produced in one year. According to the investigation, the geothermal system can easily provide the energy consumption required by residential buildings.