2. Outer loop iteration

(2) Calculate the phase equilibrium constant *Ki,j* with a strict thermodynamic model, and then calculate parameters *Kb,j*, A, and B in the *K*-value model.

(3) Calculate the vapor–liquid phase enthalpy difference using a strict thermodynamic model, and fit the parameters *cj*, *dj*, *ej*, and *fj* in the approximate enthalpy model.

(4) Calculate the stripping factors *Sb,j*, relative volatility <sup>α</sup>*i,j*, liquid phase stripping factors *RL,j*, and vapor phase stripping factors *RV,j*.

(5) Calculate the reaction extent according to the reaction conditions. The chemical reaction can be a specified conversion rate or a kinetic reaction, and the kinetic reaction rate is calculated by a power law expression.

Power law expression:

*T*0 is not specified:

$$
\sigma = kT^n e^{-E/RT} \prod (\mathbb{C}\_i)^{a\_i}.\tag{35}
$$

*T*0 is specified:

$$\epsilon = k(T/T\_0)^n e^{-(E/R)(1/T - 1/T\_0)} \prod \left(\mathbb{C}\_i\right)^{a\_i} \tag{36}$$

$$R\_{j,r} = r\_{j,r} \times \Omega\_j. \tag{37}$$

(6) Outer convergence judgment conditions:

$$\sum\_{j}^{n} \left( \frac{K\_{b,j}^{n} - K\_{b,j}^{n-1}}{K\_{b,j}^{n-1}} \right)^{2} + \sum\_{j}^{n} \sum\_{i}^{c} \left( \frac{\alpha\_{i,j}^{n} - \alpha\_{i,j}^{n-1}}{\alpha\_{i,j}^{n-1}} \right)^{2} + \sum\_{j}^{n} \sum\_{r} \left( \frac{R\_{r,j}^{n} - R\_{r,j}^{n-1}}{R\_{r,j}^{n-1}} \right)^{2} < \varepsilon. \tag{38}$$

3. Inside loop iteration

(7) According to the material balance Equation (13), a tridiagonal matrix was constructed, and then the liquid flow rate *li,j* of each component was obtained by solving the matrix. Using the phase equilibrium Equation (14), the vapor phase flow rate *vi,j* of each component was obtained.

(8) The vapor–liquid flow rates *Vj* and *Lj* can be calculated by Equation (9), the vapor–liquid phase composition *xi,j* and *yi,j* can be calculated by Equation (8).

(9) Combining the bubble point equation *c <sup>i</sup>*=<sup>1</sup>*Kixi* = 1with Equation (9) to obtain Equation (39), a new set of *K* values *Kb,j* of the reference components can be calculated.

$$\mathcal{K}\_{b,j} = \frac{1}{\sum\_{i=1}^{c} \left( \alpha\_{i,j} \mathbf{x}\_{i,j} \right)}. \tag{39}$$

According to Equation (40), a new set of stage temperature can be calculated using the new *Kb,j* values.

$$T\_{\dot{j}} = \frac{1}{\left(\ln K\_{b,\dot{j}} - A\_{\dot{j}}\right) / B\_{\dot{j}} + 1 / T^\*}. \tag{40}$$

Now, the correction values of the vapor–liquid flow rate, composition, and temperature are obtained. They satisfy the material balance and phase equilibrium equation, but does not satisfy the enthalpy equilibrium equation. In the following, the iterative variable of the inside loop should be modified according to the deviation of the enthalpy balance Equation (10). Select lnSb,j as the inside loop iteration variable. If there are side products, the side stripping factors lnRL,j and lnRV,j should be added as the inside loop iteration variables. Taking the enthalpy balance equation as the objective function, the enthalpy balance equation of the first and last stage should be deleted and replaced with two operation equations of the reactive distillation column.

(11) Calculate the vapor–liquid phase enthalpy according to the simplified enthalpy model.

(12) Calculate the partial derivative of the objective function to the iterative variable and construct the Jacobian matrix. The Schubert method was used to calculate the modified value of the inside iteration variable [22,23]. Damping factors can be used if necessary.

(13) Using the new inside iteration variable value, repeat steps (7) to (9) to obtain the new stage flow, composition, and temperature, and calculate the error of the objective function. If the error was less than the convergence accuracy of the inside loop, return to the outer loop to continue the calculation, otherwise repeat the calculation from Step (11) to Step (13). The calculation block diagram of the improved Inside–Out method is shown in Figure 4.

**Figure 4.** Calculation of the block diagram of the improved Inside–Out method.
