## 2 Materials and Methods
### Optimization and Comparison of the \"Base\" Schemes
#### 2.4.2 Optimization  
The approach to optimization used in this study was to conduct the optimization outside of HYSYS using a link to MATLAB [26]. This link allowed the two-way transfer of process parameters between MATLAB and HYSYS and the implementation of the optimization algorithms directly in MATLAB.  
The optimization algorithms used in MATLAB were fminsearch and GA. fminsearch uses a simplex algorithm that is suitable for unconstrained, multi-variable, non-linear optimization problems. A benefit of this method is that it will usually quickly converge to a solution; a downside is that in some cases a local minimum may be obtained. A drawback specific to the application of this algorithm in this study is that an unconstrained search can also lead HYSYS to non-viable solutions (e.g., where temperature crossing is inevitable in heat exchangers), which pauses the HYSYS solver and requires a time-consuming re-set of the optimization process. The GA algorithm can solve smooth or non-smooth optimization problems with or without constraints. It is a stochastic, population-based, algorithm, which is generally slower than fminsearch to reach a solution, but more reliable in solving the global minimum.  
The objective of the optimization work was to minimize the energy consumption, which can be expressed as the sum of all compressor and expander stage energy consumptions:  
\[\text{min}f(P_{i})=\sum W_{comp}-\sum W_{exp}\quad for\quad i=1,\ \ldots,\ n, \tag{1}\]  
where \(P_{i}\) is the compressor discharge pressure level that is optimized, \(W_{comp}\) is the compression stage energy flows (CO\({}_{2}\) and NH\({}_{3}\) compressor stages are not differentiated here), \(W_{exp}\) is the expander stage energy flows (only relevant where an expander forms part of the process scheme), and \(n\) is the number of variable pressure specifications, which varies from case-to-case, as described in more detail below.  
In Case 1, the condensing pressure in the CO\({}_{2}\) refrigeration loop is set by the NH\({}_{3}\) refrigeration process and the evaporating pressure is set by the liquefaction process; the maximum pressure in the NH\({}_{3}\) refrigeration loop is set by the condensing temperature; and the discharge pressure from the first NH\({}_{3}\) compressor stage is set by the liquefaction process. This leaves the two remaining pressure levels in the NH\({}_{3}\) refrigeration compressor and the inter-stage pressure for the CO\({}_{2}\) feed compressor as variables that can be optimized, giving \(n=3\).  
In Case 2, the pressure level used in the second and third stages of the NH\({}_{3}\) compressor are optimization variables along with the inter-stage pressure of the CO\({}_{2}\) feed compressor, also giving \(n=3\).  
In Case 3, the inter-stage pressure of the low pressure NH\({}_{3}\) compressor is an optimization variable along with the inter-stage pressure of the CO\({}_{2}\) feed compressor, making \(n=2\).  
In Case 4, the discharge pressure for each of the CO\({}_{2}\) compression stages is an optimization variable apart from the stage that occurs at the liquefaction pressure level, making \(n=4\).  
When using the GA routine, the compressor stage outlet temperature was set as a constraint in the optimization algorithm for all cases:  
\[T_{i}=f(P_{i})\leq 150\ ^{\circ}\text{C}\quad for\quad i=1,\ \ldots,\ n, \tag{2}\]  
where \(T_{i}\) is the temperature at each of the compressor discharge pressure levels that can be optimized. When fminsearch was used, \(T_{i}\) was checked manually and constrained, when necessary, by applying an appropriate constraint to an individual stage pressure level. Table 3 presents the results of the optimization work for the \"base\" process schemes (Cases 1 to 4).