## 1 Background  
In the coming years, all European countries should comply with the objectives of the Energy Efficiency Directive for Buildings (2010/31/EC) [1]. This directive establishes a set of measures to face the challenge of the so-called almost zero energy consumption buildings, nZEB (nearly Zero Energy Buildings) by 2020. In the construction sector, this directive is a means of transforming the design, construction, and management procedures towards greater energy efficiency in buildings and cities. The challenge affects both architects and the rest of the agents (promoters, builders, manufacturers of materials, systems, and equipment), that will have to meet the regulatory requirements. The main priority of a nZEB is the energy efficiency. In the buildings, from the conception of design to the exploitation, the objective of actively reducing the energy consumption of the final building. Although the objective is reducing energy demand, a second priority focuses on the remaining energy needs and renewable energies. Therefore, a nZEB will not only imply an optimized design and construction, but also the exploitation of energy resources in the most efficient way. The present paper explores a methodology to design a nZEB building, by choosing design elements in two steps (Figure 1). Firstly, the selection of passive elements, and secondly the selection of active elements with a system of photovoltaic panels to generate the energy required by such building. To achieve a ZEB (Zero Energy Building), the Building Integrated Photovoltaic (BIPV) systems used to generate electricity can play an important role [2]. A comprehensive review of the current state of the art in the area of the BIPV technology is shown in [3]. Moreover, some studies have verified the validity of BIPV systems for the challenge of Zero Energy Buildings [4]. In [PERSON] et al. [5], it is demonstrated that the zero energy objective is technically feasible through the optimal interaction of all the building design variables, that can be studied in detail through advanced simulation and optimization models. In [6], a procedure for cost optimal and nZEB energy performance levels calculations is defined: the selection of the reference building, the definition of construction concepts based on building envelope optimization, the specification of building technical systems, the energy simulations for specified construction concepts (in this paper it is not a simulation, and it is based on a simplified model), economic calculations, and sensitivity analyses. The main goal of the present paper is showing a methodology to achieve the design of a nZEB, including passive elements and active elements, particularly, photovoltaic, and HVAC (Heating, Ventilation, and Air Conditioning) systems. The Energy Performance of Buildings Directive [7] lists the main end-uses to be included in a building, such as heating, domestic hot water, refrigeration, ventilation, and lighting, being heating and cooling the elements with the highest levels of energy consumption. To achieve an nZEB, finding out the optimal combination for a building design is necessary. To define the design elements, it is also important to consider the location and the climatic conditions. The climatic conditions and the elements define the energy demand for the heating and cooling period, based on the thermal characteristics of the passive elements. After the passive elements, active elements (as the application of photovoltaic panels) produce the necessary energy, and elements such as HVAC systems provide the required comfort level. Moreover, according to the efficiency of the passive elements and the active systems, a life cycle cost (LCC) could be defined. In [8], a recent review about the optimization and cost-optimal methodologies applied in the low-energy building design and environmental considerations is shown. In 2017, [PERSON] et al. Figure 1: From conventional buildings to ZEB. HVAC: Heating, Ventilation, and Air Conditioning; nZEB: nearly Zero Energy Buildings.