Phase change materials (PCMs) and thermal energy storage (TES) represent a way toward sustainable utilization of renewable energy resources. An air-PCM thermal storage unit integrated in solar systems is a device, which employs the latent heat TES to balance between the demand and supply of heat (or cold) for space heating (or cooling) in buildings. Previously published studies demonstrate that this approach is viable but design parameters of the unit need to be optimized. In the paper, a computer model of the heat storage unit was developed and coupled to metaheuristic nature-inspired optimization algorithms with the aim of design optimization of the TES unit. The unit consisted of flat plates made of a PCM, which was macro-encapsulated in aluminium containers. The energy balance and control volume methods were used to build the model and the effective heat capacity technique was applied for phase change modelling. The model was created in Python, validated against experimental data and an open-source optimization library DEAP with metaheuristics was used as an optimization solver. A design optimization problem was specified with including the arrangement of the PCM plates and their thickness. Results showed that the DEAP library and metaheuristics are well applicable for the solution of this kind of optimization problem.