## 3 Materials and Methods: Thermodynamic Model and Simulation  
### Thermodynamic Balance Equations  
The general thermodynamic balance equations, including mass and energy balance, entropy balance, and the exergy destruction rate, which are used in integrated systems, are discussed in this subsection. * Mass balance equation: Under steady-state conditions, the four balance equations for each component of the system were applied. A control volume can be regarded as any component that is modeled thermodynamically. Under steady-state conditions, the rate of mass change in the control volume is zero [11] \[\sum\limits_{in}\dot{m}_{in}-\sum\limits_{out}\dot{m}_{out}=\frac{dm_{CV}}{dt }=0\text{ or}\] (1) \[\sum\limits_{in}\dot{m}_{in}=\sum\limits_{out}\dot{m}_{out}\]  
where \(\dot{m}\) represents the mass flow rate. The rate of change of the total mass within a control volume (CV) is equal to subtraction of the total mass flow rate entering the control volume (CV) and the total mass flow rates exiting the control volume. * Energy balance equation: The first law of thermodynamics [10] was applied for energy conservation: \[\dot{Q}-\dot{W}+\sum\limits_{in}\dot{m}_{in}\left(h_{in}+\frac{V_{in}^{2}}{2 }+gZ_{in}\right)-\sum\limits_{out}\dot{m}_{out}\left(h_{out}\frac{V_{out}^{2}} {2}+gZ_{out}\right)=0\] (2) where \(\dot{Q}\), \(h\), and \(\dot{W}\) denote the heat transfer rate, specific enthalpy of the fluid, and mechanical power, respectively. Figure 2: Schematic of the SOFC–GT-SRC–ORC–KC system employing ammonia as fuel. In the thermodynamic analysis, the specific kinetic and potential energy values associated with the entering and exiting mass flow rates were assumed to be negligible and ignored [11]:  
\[\dot{Q}_{in}+\sum_{in}\dot{m}_{in}(\dot{n}_{in})=\dot{W}_{out}+\sum_{out}\dot{m}_ {out}(\dot{n}_{out}) \tag{3}\]  
Entropy and exergy balance equation:  
The second law of thermodynamics was applied to the entropy and exergy balance equations. Under steady-state conditions, the rate of change in entropy in a control volume is zero. \[ \begin{array}{c}\sum_{k}\frac{\dot{Q}_{k}}{T_{k}}+\sum_{in}\dot{m}_{in}(s_{ in})+\dot{S}_{gen}-\sum_{out}\dot{m}_{out}(s_{out})=\frac{dS_{CV}}{dt}=0\text{ or }\\ \sum_{k}\frac{\dot{Q}_{k}}{T_{k}}+\sum_{in}\dot{m}_{in}(s_{in})+\dot{S}_{gen}= \sum_{out}\dot{m}_{out}(s_{out})\end{array}  \tag{4}\]  
where \(T\), \(s\), and \(\dot{S}_{gen}\) denote the temperature (K), specific entropy, and entropy of the thermal process, respectively. Under steady-state conditions, the rate of change of exergy is also zero in the control volume. \[\sum_{k}(1-\frac{T_{0}}{T_{k}})\dot{Q}_{k}-\dot{W}_{out}+\sum_{in}\dot{m}_{in }(ex_{in})-\sum_{out}\dot{m}_{out}(ex_{out})-\dot{Ex}_{dest}=\frac{dEx_{CV}}{ dt}=0\text{ or } \tag{5}\]  
\[\sum_{k}(1-\frac{T_{0}}{T_{k}})\dot{Q}_{k}+\sum_{in}\dot{m}_{in}(ex_{in})= \sum_{out}\dot{m}_{out}(ex_{out})+\dot{W}_{out}+\dot{Ex}_{dest} \tag{6}\]  
Specific exergy values and the exergy destruction rate:  
The entropy generation rate from the entropy balance equation can be used to compute the exergy destruction rate for any control volume or component. \[\dot{Ex}_{dest}=T_{0}\dot{S}_{gen} \tag{7}\]  
Here, \(T_{0}\), \(ex\), and \(Ex_{dest}\) represent the ambient temperature of the surrounding area (K), specific exergy of the fluid, and the exergy destruction rate, respectively. The specific exergy values are calculated using the sum of the physical, chemical, kinetic, and potential exergy as follows:  
\[ex_{j}=ex_{j}^{ph}+ex_{j}^{ch}+ex_{j}^{ke}+ex_{j}^{pe} \tag{8}\]  
In this thermodynamic analysis, the kinetic and potential exergy were assumed to be negligible and ignored. A weighted average formula applicable to ideal gas combinations was used to calculate the specific enthalpy and entropy of the SOFC exhaust gases.