Thermodynamic Optimization of a Geothermal Power Plant with a Genetic Algorithm in Two Stages

: Due to the harmful e ﬀ ects and depletion of non-renewable energy resources, the major concerns are focused on using renewable energy resources. Among them, the geothermal energy has a high potential in volcano regions such as the Middle East. The optimization of an organic Rankine cycle with a geothermal heat source is investigated based on a genetic algorithm having two stages. In the ﬁrst stage, the optimal variables are the depth of the well and the extraction ﬂow rate of the geothermal ﬂuid mass. The optimal value of the depth of the well, extraction mass ﬂow rate, and the geothermal ﬂuid temperature is found to be 2100 m, 15 kg / s, and 150 ◦ C. In the second stage, the e ﬃ ciency and output power of the power plant are optimized. To achieve maximum output power as well as cycle e ﬃ ciency, the optimization variable is the maximum organic ﬂuid pressure in the high-temperature heat exchanger. The optimum values of energy e ﬃ ciency and cycle power production are equal to 0.433 MW and 14.1%, respectively.


Introduction
Geothermal energy is heat from the inner part of the earth that is present in rocks and water in cracks and pores within the rock of the earth's crust. The temperature normally increases with depth, although not in a constant manner [1][2][3][4]. The benefits of geothermal energy include reduced pollution and avoidance of change in ecosystems' reliability and renewability. It can also provide development opportunities for remote areas. The disadvantages include causing instability in earth structures due to extensive use and corrosion caused by sulfur compounds in geothermal fluids [5][6][7][8].
Much research has been carried out on geothermal energy. Drozdz [9] analyzed methods of optimizing geothermal energy conversion. The optimization of the behavior of different types of geothermal energy sources, accounting for constant and dynamic parameters, was presented.
The results show that the variation of unit heat and electrical energy costs affects the optimal pumping intensity.
Jalilinasrabady et al. [10] optimized a single-circuit cycle of the Sabalan geothermal power plant, which is currently under development in northwestern Iran, with exergy methods. To obtain efficient optimal energy, a two-circuit cycle was also examined for power generation. Under these conditions, if the cycle higher pressure, lower pressure, and condenser pressure are 7.5, 1.1, and 0.1 bar respectively, the plant's energy efficiency can reach 49.7%. Figure 1 presents a schematic diagram of an organic Rankine cycle (ORC) with a geothermal heat source and the related temperature-entropy diagram [28]. The geothermal energy resource of the Damavand region is considered in this article.
According to Figure 1, the output saturated dry steam of the evaporator is directed to the turbine (point 1) and, in a constant temperature and pressure process, the dry saturated steam is expanded in the turbine (point 2) and generates power using a generator. This action reduces the steam pressure and temperature and can involve condensation. The exhaust wet steam from the turbine enters the regenerative system, where the temperature and pressure are reduced (point 3). The output wet saturated steam from the regenerator enters the condenser and is converted to a saturated fluid (point 4). The ORC working fluid is cooled by cooling water supplied from the cooling tower. By converting the saturated steam to liquid in a condenser, a turbine and a vacuum condenser are created, and the pressure drop behind the turbine increases the power plant efficiency and power output. The saturated liquid from the condenser is pumped to a higher pressure (points 4 and 5), and the output saturation fluid from the high-pressure pump enters the regenerator and is heated (point 6). The output high-pressure saturated fluid from the heat regenerator enters into a heat exchanger and is heated to a dry saturated vapor in a constant pressure process by the geothermal heat source. The dry saturated steam enters the turbine. The main assumptions used in this study are as follows [18,29,30]: (1) The process is a steady-state and continuous flow type.
(2) The processes in the turbine and the pump are polytropic.
(4) The isentropic efficiencies of the turbine and pump are both 80%.
A general equation for mass conservation is as follows [31]: where m is the mass flow rate (kg/s) and the subscripts in and out denote input and output. A general equation for energy conservation is as follows [31]: where Q . . is input heat rate (kW), W . . is work production rate (kW), h is specific enthalpy (kJ/kg), represents specific kinetic energy (m/s), gZ represents potential energy (m 2 /s 2 ), m is mass flow rate (kg/s), and . . is a time-dependent term denoting the energy storage rate in the control volume. For steady-state conditions, the last term becomes zero. Mass and energy conservation equations for the various components in the cycle are given in Table 1. In this table, W and ɳ are respectively the power produced (kW) and the energy efficiency, m is the mass flow rate (kg/s), h is the specific enthalpy (kJ/kg), Q is the rate of heat transfer (kW), and ε is the effectiveness of the regenerator. The main assumptions used in this study are as follows [18,29,30]: (1) The process is a steady-state and continuous flow type.
(2) The processes in the turbine and the pump are polytropic.
(4) The isentropic efficiencies of the turbine and pump are both 80%.
A general equation for mass conservation is as follows [31]: where . m is the mass flow rate (kg/s) and the subscripts in and out denote input and output. A general equation for energy conservation is as follows [31]: where . Q C.V. is input heat rate (kW), . W C.V. is work production rate (kW), h is specific enthalpy (kJ/kg), Q is the rate of heat transfer (kW), and ε rec is the effectiveness of the regenerator.
The cycle energy efficiency and the specific work output respectively can be written as follows [31]: Exergy analysis, which is based on the second law of thermodynamics, allows the irreversibility of a system to be considered and calculated. The exergy loss rate for a system at the steady-state process can be written as follows [31]: me (5) where . Ex d is the exergy loss rate (kW), . Ex Q and . Ex W are the exergy rates associated with the heat rate and work rate respectively, of the control volume (kW), . m is the mass flow rate (kg/s), and e is specific exergy (kJ/kg).
The exergy rates associated with heat and power, and the exergy destruction rate, can be expressed respectively as follows [31]: . .
Here, the subscript env denotes the state of the environment, and T and T env respectively, are the temperature and reference environment temperature (K).
The exergy flow rate and the specific exergy of mass flow can be written respectively as [31]: where, s and s 0 are the specific entropy and specific entropy at the reference environment state (kJ/kg·K), . E is the exergy flow rate (kW), e is specific exergy (kJ/kg), and h and h 0 respectively are specific enthalpy and specific enthalpy at the reference environment state (kJ/kg). The exergy loss rate in the form of exergy destruction is dependent on the total entropy generation rate of each of the system components, and can be written as follows [31]: S gen (11) Expressions for the exergy destruction rate for each system component are given in Table 2.  The total exergy destruction loss rate equation for the overall system can be expressed as follows [31]: The cycle exergy efficiency can be expressed as follows [31]: In the geothermal system considered, the outlet geothermal fluid temperature is the main variable that influences the performance of the system. By increasing the geothermal fluid temperature, the thermal efficiency of the power plant increases. As the geothermal fluid temperature increases to 63 • C, the plant's thermal efficiency increases by 5.9%. Based on these data, the relationship between the geothermal fluid temperature and the thermal (energy) efficiency of the power plant can be approximated as follows [32]: where, n th is the thermal efficiency of the power plant (%), and T is the geothermal fluid temperature ( • C). The geothermal fluid temperature is dependent on the geothermal well depth as follows [33]: where Z is the depth of well (m). With this relation, the effect of the geothermal well depth on the geothermal fluid temperature can be described in modeling the geothermal system. The fluid temperature also influences the output power of the system. The geothermal well depth is affected by many restrictions, such as the state of available technology and costs. A flow chart of the procedure used in the mathematical modeling of the cycle is shown in Figure 2.

Genetic Algorithm
The genetic algorithm (GA) is one of the most important metaheuristic algorithms used for optimization for defined functions in a limited domain. In this algorithm, according to the inheritance of the algorithm, past information is extracted and used in the search process. The concepts of the genetic algorithm were developed by Goldberg in 1989. The simulation method discussed below is called an Evolutional Guideline. The Evolutional Guideline simulation method is a kind of neighborhood search method, which functions like a gene [34].
The reasons for selecting the GA are as follows [34]: • The nature of algorithm random searching in the problem space is somehow considered as a parallel search. Since each of the random chromosomes generated by the algorithm is considered as a new starting point for searching for a part of the state of the problem, the search is performed in all of the chromosomes simultaneously.

•
Due to the breadth and dispersion of the points that are being searched, the genetic algorithm yields a good result for objectives that have a great search space.

•
The genetic algorithm is considered as a kind of random search and is targeted, and it leads to different results and answers using different approaches.

•
The genetic algorithm may have no limit in line with searching and selection of random answers.

•
Because of the competition (struggle for existence), the answers and the best choices from the population with high probability will reach the total optimal level. • The genetic algorithm implementation is simple and requires no complex problem-solving procedures.

•
The optimization process can be performed for continuous and discrete variables.

Genetic Algorithm
The genetic algorithm (GA) is one of the most important metaheuristic algorithms used for optimization for defined functions in a limited domain. In this algorithm, according to the inheritance of the algorithm, past information is extracted and used in the search process. The concepts of the genetic algorithm were developed by Goldberg in 1989. The simulation method discussed below is called an Evolutional Guideline. The Evolutional Guideline simulation method is a kind of neighborhood search method, which functions like a gene [34].
The reasons for selecting the GA are as follows [34]: • The nature of algorithm random searching in the problem space is somehow considered as a parallel search. Since each of the random chromosomes generated by the algorithm is considered as a new starting point for searching for a part of the state of the problem, the search is performed in all of the chromosomes simultaneously.

•
Due to the breadth and dispersion of the points that are being searched, the genetic algorithm yields a good result for objectives that have a great search space.

•
The genetic algorithm is considered as a kind of random search and is targeted, and it leads to different results and answers using different approaches.

•
The genetic algorithm may have no limit in line with searching and selection of random answers.

•
Because of the competition (struggle for existence), the answers and the best choices from the population with high probability will reach the total optimal level. • The genetic algorithm implementation is simple and requires no complex problem-solving procedures.

•
The optimization process can be performed for continuous and discrete variables.

•
There is no need to calculate derivative functions.

•
Complex cost functions can be optimized with this approach. Genetic algorithms use probabilistic transfer rules instead of definite transition rules, meaning that its movement at any point in the algorithm is possible.

•
In addition to analytical functions, the algorithm can work with generated numerical data and empirical data.

•
The genetic algorithm is capable of optimizing problems with a large number of variables.
Therefore, the genetic algorithm is chosen in this research for the implementation of the optimization problem. A flow chart of the genetic algorithm optimization is shown in Figure 3 [35]. After selection the initial population and lower and upper limits of variables, in the defined domain, the optimum variables are selected. The algorithm is not trapped in local extremes.

•
The genetic algorithm can encode variables and perform optimization with encoded variables.

•
Encoding speeds up the convergence rate of the algorithm.

•
Genetic algorithms use probabilistic transfer rules instead of definite transition rules, meaning that its movement at any point in the algorithm is possible.

•
In addition to analytical functions, the algorithm can work with generated numerical data and empirical data.

•
The genetic algorithm is capable of optimizing problems with a large number of variables.
Therefore, the genetic algorithm is chosen in this research for the implementation of the optimization problem. A flow chart of the genetic algorithm optimization is shown in Figure 3 [35]. After selection the initial population and lower and upper limits of variables, in the defined domain, the optimum variables are selected.

Results and Discussion
For the mathematical modeling of the cycle, one code is written in MATLAB software [36]. Refprob software [37] is used for the calculation of thermodynamic properties.

Results and Discussion
For the mathematical modeling of the cycle, one code is written in MATLAB software [36]. Refprob software [37] is used for the calculation of thermodynamic properties.
The analysis reported in this paper is based on the geothermal conditions of the city of Damavand, Iran. Damavand, with a longitude 35.7013 • N and latitude 52.0586 • E, is located near Tehran [38]. The temperature range of the geothermal fluid is about 120 to 170 • C, based on the geothermal production well. The range of pressure is about 3 to 8 bar [39,40].
The organic working fluid used for this cycle is R245fa, a non-flammable, organic fluid. This fluid has a low specific heat and specific volume and has thermodynamic properties suitable for energy recovery. R245fa is from a dry fluid family with good environmental properties, including zero ozone depletion potential and low heat capacity according to the Kigali Amendment to the Montreal Protocol [41].
For validation of the results, Reference [1] is considered. All of the input data and assumptions presented in that article are inserted into the computer program prepared for this article. Table 5 in Reference [1] that presented the cycle energy and exergy efficiencies is considered for comparison. Figure 4 shows a comparison between the results from mathematical modeling and Reference [1].
Tehran [38]. The temperature range of the geothermal fluid is about 120 to 170 °C, based on the geothermal production well. The range of pressure is about 3 to 8 bar [39,40].
The organic working fluid used for this cycle is R245fa, a non-flammable, organic fluid. This fluid has a low specific heat and specific volume and has thermodynamic properties suitable for energy recovery. R245fa is from a dry fluid family with good environmental properties, including zero ozone depletion potential and low heat capacity according to the Kigali Amendment to the Montreal Protocol [41].
For validation of the results, Reference [1] is considered. All of the input data and assumptions presented in that article are inserted into the computer program prepared for this article. Table 5 in Reference [1] that presented the cycle energy and exergy efficiencies is considered for comparison. Figure 4 shows a comparison between the results from mathematical modeling and Reference [1].  Table 3 lists the thermodynamic properties of the working fluid [41]. Table 4 provides the cycle parameter specifications. Table 5 gives the mass flow rates of the different fluids of the cycle. Table 6 lists the results for the Rankine cycle with the geothermal source. Figure 5 shows the amount of entropy produced by various components of the geothermal organic Rankine cycle. The highest entropy production is related to the evaporator and the lowest to the pump.   Table 3 lists the thermodynamic properties of the working fluid [41]. Table 4 provides the cycle parameter specifications. Table 5 gives the mass flow rates of the different fluids of the cycle. Table 6 lists the results for the Rankine cycle with the geothermal source.   Figure 5 shows the amount of entropy produced by various components of the geothermal organic Rankine cycle. The highest entropy production is related to the evaporator and the lowest to the pump.  The optimization process in this paper occurs in two stages. In the first stage, the optimal geothermal well depth and mass flow rate of geothermal fluid are calculated based on the maximum The optimization process in this paper occurs in two stages. In the first stage, the optimal geothermal well depth and mass flow rate of geothermal fluid are calculated based on the maximum energy efficiency and the minimum entropy generation rate. The output from this optimization stage is the optimal working point, including the temperature of the inlet fluid (and well depth) and its flow rate. The results of the first stage of optimization are used in the final stage, where the optimal design of the ORC for the calculated point of the previous stage is determined. In the first stage of optimization, the geothermal power output that can be obtained for a geothermal well depth and fluid mass flow rate that leads to the highest energy efficiency and the lowest amount of entropy production rate is determined. Naturally, the greater the depth of the well, the greater the geothermal fluid temperature and the output power. But, increasing the depth of the well increases the cost. So, there is an optimal well depth, for which suitable power is achieved and the costs are minimal. In this section, the optimization of the ORC with a geothermal source is performed using a genetic algorithm to increase efficiency and thus reduce geothermal fluid use. Note that the reduction of geothermal fluid consumption in this study means that the 'fuel' of a geothermal power plant is simply the outlet fluid from a geothermal well. The cost of this fuel is mainly the cost of constructing, maintaining, and operating the well, as well as any taxes relating to the utilization of geothermal fluids. The efficiency of the power plant is dependent on the geothermal fluid's temperature. The parameters and their ranges used in the first stage of optimization are as follows: 2000 m < z < 3000 m 10 kg/s < . m geo < 50 kg/s Target function : η en and . W net (16) Figure 6 shows the convergence of the genetic algorithm and the process of reducing energy efficiency with the population number. The depth of the well varies between 2000 and 3000 m and the fluid flow rate ranges between 10 and 50 kg/s. The number of the population is selected as 20 and the number of generations as 1000. As can be seen in Figure 6, after about 80 repetitions, the optimal value of the energy efficiency is obtained, and further, population number increases to ensure that the optimal point is not local and but instead is a global optimal point. is the optimal working point, including the temperature of the inlet fluid (and well depth) and its flow rate. The results of the first stage of optimization are used in the final stage, where the optimal design of the ORC for the calculated point of the previous stage is determined. In the first stage of optimization, the geothermal power output that can be obtained for a geothermal well depth and fluid mass flow rate that leads to the highest energy efficiency and the lowest amount of entropy production rate is determined. Naturally, the greater the depth of the well, the greater the geothermal fluid temperature and the output power. But, increasing the depth of the well increases the cost. So, there is an optimal well depth, for which suitable power is achieved and the costs are minimal. In this section, the optimization of the ORC with a geothermal source is performed using a genetic algorithm to increase efficiency and thus reduce geothermal fluid use. Note that the reduction of geothermal fluid consumption in this study means that the 'fuel' of a geothermal power plant is simply the outlet fluid from a geothermal well. The cost of this fuel is mainly the cost of constructing, maintaining, and operating the well, as well as any taxes relating to the utilization of geothermal fluids. The efficiency of the power plant is dependent on the geothermal fluid's temperature. The parameters and their ranges used in the first stage of optimization are as follows: 2000 m z 3000 m (16) 10 kg/s ṁ 50 kg/s Target function: ηen and Ẇnet Figure 6 shows the convergence of the genetic algorithm and the process of reducing energy efficiency with the population number. The depth of the well varies between 2000 and 3000 m and the fluid flow rate ranges between 10 and 50 kg/s. The number of the population is selected as 20 and the number of generations as 1000. As can be seen in Figure 6, after about 80 repetitions, the optimal value of the energy efficiency is obtained, and further, population number increases to ensure that the optimal point is not local and but instead is a global optimal point. In optimization problems, achieving global optimal points and not optimal local points (if any exist) is important. To do this, there are two general methods:

1-Restarting 2-Changing the initial point
The effect of restarting on the final result for the optimal point is given in Table 7. In optimization problems, achieving global optimal points and not optimal local points (if any exist) is important. To do this, there are two general methods:

1-Restarting 2-Changing the initial point
The effect of restarting on the final result for the optimal point is given in Table 7.  Table 7 shows that restarting the algorithm does not result in finding multiple optimal points; with every repeat, a point is reported with acceptable accuracy. In Table 7, pop and G denote the number of population and generation respectively, while pc and pm denote combination and mutations factors. Table 8 determines the effect of choosing different initial values on the final optimal result and confirms the lack of dependence of the algorithm on restarting the path and guessing the initial points. The number of considered genes is also analyzed in Table 9, from which it can be concluded that the number of genes has no significant effect on solving and that the solving procedure is almost independent of the number of selected genes in the algorithm. The results of the first stage of optimization indicate that: • The mass flow rate of the geothermal fluid into the cycle is 15 kg/s, • The depth of the geothermal well is 2100 m and, from Equation (14), the temperature is 150 • C.
The results of the second stage of optimization of the ORC with the geothermal heat source are determined with these inputs. As can be seen from the results of Tables 8 and 9, the cycle energy input is the geothermal fluid and coolant fluid. Geothermal water enters the cycle at a mass flow rate of 15 kg/s and a temperature of 150 • C and leaves the cycle at a temperature of 106.9 • C. The cooling water is introduced into the cycle at a mass flow rate of 6.35 kg/s and a temperature of 20 • C and leaves at a temperature of 43.1 • C. The heat input rate from the geothermal source is 2699.7 kW, of which about 250 kW leaves the cycle as useful power. In the second stage of optimization, the studied variable is the maximum organic fluid pressure in the high-temperature evaporator, and the target function is first selected as the output power of the cycle and then as the thermal efficiency of the cycle. Figure 7 shows that an increase in evaporator pressure to 600 kPa results in an improvement of the cycle power production to 433 kW, which represents the optimum output power for the cycle. By increasing the maximum pressure from the optimum value to the next level, while increasing the power consumption of the pump and decreasing the heat transfer between the geothermal fluid and the working fluid, the total output power of the cycle decreases. Figure 7 shows the effect of the high-pressure value in the power plant on the cycle output power. power consumption of the pump and decreasing the heat transfer between the geothermal fluid and the working fluid, the total output power of the cycle decreases. Figure 7 shows the effect of the high-pressure value in the power plant on the cycle output power. To achieve the best system efficiency, it is necessary to consider the thermal efficiency of the cycle along with the power output of the power plant. Table 10 presents the results of optimizing the ORC with the geothermal heat source. Optimum evaporator pressures for maximum energy efficiency and maximum power production are different. To better understand the results of this optimization, the change of target functions concerning an independent variable in graphical form is presented. Figure 8 shows the variation of energy efficiency with the evaporator pressure. It is observed in Figure 8 that the effect of increasing the evaporator pressure results in an improvement in the energy efficiency of the cycle. For an evaporator pressure of 2 MPa, the energy efficiency reaches 14.1%. Finally, the effect of varying the evaporator pressure results in: (1) An improvement in the thermal efficiency of the cycle up to pressure 2 MPa.
(2) An increase in the cycle output power up to a pressure of 0.6 MPa and a reduction in the cycle output power above a pressure 0.6 MPa.
As shown in Figure 8, increasing the higher pressure of the power plant leads to improved energy efficiency, but this does not always mean increasing output power. To achieve the best system efficiency, it is necessary to consider the thermal efficiency of the cycle along with the power output of the power plant. Table 10 presents the results of optimizing the ORC with the geothermal heat source. Optimum evaporator pressures for maximum energy efficiency and maximum power production are different. To better understand the results of this optimization, the change of target functions concerning an independent variable in graphical form is presented. Figure 8 shows the variation of energy efficiency with the evaporator pressure. It is observed in Figure 8 that the effect of increasing the evaporator pressure results in an improvement in the energy efficiency of the cycle. For an evaporator pressure of 2 MPa, the energy efficiency reaches 14.1%. Finally, the effect of varying the evaporator pressure results in: (1) An improvement in the thermal efficiency of the cycle up to pressure 2 MPa.
(2) An increase in the cycle output power up to a pressure of 0.6 MPa and a reduction in the cycle output power above a pressure 0.6 MPa.
As shown in Figure 8, increasing the higher pressure of the power plant leads to improved energy efficiency, but this does not always mean increasing output power. In an ORC driven by fossil fuels, achieving the maximum efficiency means optimal use of the energy source. But, in the geothermal ORC, since geothermal energy is a type of renewable energy, it is necessary to achieve the maximum production capacity to realize the economic objectives of the system. Table 11 lists the values of the main parameters of the cycle before and after optimization. In an ORC driven by fossil fuels, achieving the maximum efficiency means optimal use of the energy source. But, in the geothermal ORC, since geothermal energy is a type of renewable energy, it is necessary to achieve the maximum production capacity to realize the economic objectives of the system. Table 11 lists the values of the main parameters of the cycle before and after optimization.

Conclusions
An organic Rankine cycle using a geothermal heat source was successfully optimized using energy and exergy analyses. After analyzing the energy and exergy parameters of the geothermal cycle, a two-stage optimization procedure was carried out. In the first stage, the optimal operating point for the power plant was determined. This point is where the cost of the power plant is minimized regarding the optimum mass flow rate and depth of the geothermal well. For the drilling cost of the geothermal well in US$, the equation 16.5z 1.607 [42] (z in meter) is considered. This point is where the cost of the power plant is minimized. The output of this optimization stage leads to an optimal operating point, including the temperature of the inlet fluid (which correlates with the geothermal well depth) and its flow rate. The following results were obtained: • Optimal values for the depth of the geothermal well, the geothermal extraction mass flow rate, and the geothermal fluid temperature were found to be 2100 m, 15 kg/s, and 150 • C, respectively.

•
Values of the energy and exergy efficiencies, the net rate of entropy change, and the specific output power respectively, were determined to be 9.26%, 11.43%, 121.27 kW/K, and 19.21 kJ/kg for the ORC with the geothermal heat source, and 9.87%, 11.88%, 117.27 kW/K, and 20.12 kJ/kg for the optimized ORC with the geothermal heat source.

•
Increasing the high pressure of the organic fluid in the evaporator led to an improvement in the thermal efficiency of the cycle. The optimal thermal efficiency for the cycle at a pressure of 2 MPa was found to be 14.1%.