## 2 Methodology
### Cost Optimization  
For an LHTES unit, the \(\epsilon\)-NTU method approximates the performance of one set of design parameters at a time, but it does not guarantee an optimized design combination. Here we propose an optimization algorithm based on cost reduction to examine various design combinations and quickly produce the choice with minimized cost. The benefits of this optimization algorithm include: (1) it ensures the flexibility to deal with any number of variables; (2) users can define the boundaries and constraints of variables according to their interest and objectives; and (3) it saves time and computational resources in the preliminary design stage before complicated computational fluid dynamic and experimental studies. Since the levelized cost of the storage unit depends on the operational years, which are not certain at the design stage, here we consider minimizing the f.o.b. purchase cost of the storage unit. The f.o.b. purchase cost of a shell-and-tube LHTES contains two parts: the cost of the PCM, \(C_{\rm PCM}\), and the cost of the containment. The latter is assumed to be equal to that of a conventional shell-and-tube heat exchanger with the same configuration, \(C_{\rm HEX}\). Therefore, the total purchase cost is \(C_{\rm tot}=C_{\rm PCM}+C_{\rm HEX}\). It is worth mentioning that this methodology may overestimate the \(C_{\rm tot}\) if the LHTES unit also uses the PCM's sensible heat to store and release the thermal energy. It may also underestimate the \(C_{\rm tot}\) if the LHTES unit has some \"dead volume\" in which some of the PCM in the LHTES unit does not participate in the energy storage, which is neglected in this methodology. For shell-and-tube heat exchanger units, the f.o.b. purchase cost can be estimated using the method developed by [PERSON] et al. [36] based on various references as:  
\[C_{\rm HEX}=C_{\rm B}F_{\rm P}F_{\rm M}F_{\rm L} \tag{21}\]  
where \(C_{\rm B}\) is the cost of a base-case heat exchanger with a shell-side pressure lower than 700 kPa, which can be calculated in the following equations:  
\[C_{\rm B}=exp\Big{\{}11.0545-0.9228[\ln(10.7639A)]+0.09861[\ln(10.7639A)]^{2} \Big{\}} \tag{22}\]  
and for U-tube design,  
\[C_{\rm B}=exp\Big{\{}11.147-0.9186[\ln(10.7639A)]+0.09790[\ln(10.7639A)]^{2} \Big{\}} \tag{23}\]where \(A\) [m\({}^{2}\)] is the tube outside surface area, \(F_{\rm P},F_{\rm M}\), \(F_{\rm L}\) are the pressure, material, and length factor. For TES units operating at no or low gauge pressures, the pressure factor \(F_{\rm P}\) can be considered as equal to unity. \(F_{\rm M}\) is given as:  
\[F_{\rm M}=a+(10.7639A)^{b} \tag{24}\]  
where \(a\) and \(b\) are two constants, of which the values depend on the construction material. Table 2 briefly summarises the constant values for \(a\) and \(b\) with respect to some common construction materials. The extensive list is accessible in [PERSON] et al. [36]. The cost minimization is realized with a given set of variables using the _Matlab_ Generic Algorithm (GA) solver [37]. The GA solver generates a population of points in each of the iterations and searches for the local minimum within the population. Then, with random number generators, the GA solver selects the next population and compares the local optimal with the previous optimal until a global optimal is found. For the shell-and-tube LHTES cost optimization, to speed up the search, users are allowed to specify the boundaries and constraints of the variables. The variables involved in the optimization can be categorized into material properties, geometric parameters, and operational parameters, as listed in Table 4.  
Some of them can be set as fixed values, depending on the setup and operational limitations, while the others will be subject to constraints within certain boundaries. In