## 3 Current Model and Numerical Algorithm
### Numerical Method
#### 3.2.3 Corrector Step  
The discrete equations in the _burning area_ in the corrector step respond to a Crank-Nicolson scheme:  
\[\frac{e^{n+1}-\bar{e}^{n}}{\Delta t}+\alpha\frac{u^{n+1}+u^{n}}{ 2}=\frac{r^{n+1/2}+r^{n}}{2}+\frac{q^{n+1/2}+q^{n}}{2} \tag{54}\] \[e^{n+1}\in G(u^{n+1}),\] (55) \[\frac{c^{n+1}-c^{n}}{\Delta\tau}=-g\bigg{(}\frac{u^{n+1}+u^{n}}{ 2}\bigg{)}\frac{c^{n+1}+c^{n}}{2} \tag{56}\]  
where we approximated \(r^{n+1}\) and \(q^{n+1}\) by \(r^{n+1/2}\) and \(q^{n+1/2}\), respectively, computed in terms of \(u^{n+1/2}\) and \(c^{n+1/2}\), the estimations obtained in the prediction steps, as at this point, \(u^{n+1}\) and \(c^{n+1}\) are not known. As in the prediction step, rearranging Equation (54), we have:  
\[u^{n+1}+\frac{2}{\alpha\Delta t}e^{n+1}=\frac{2}{\alpha\Delta t}e^{n}-u^{n}+ \frac{r^{n+1/2}+r^{n}}{\alpha}+\frac{q^{n+1/2}+q^{n}}{\alpha}. \tag{57}\]  
As in the predictor step, taking \(\mu=\frac{2}{\alpha\Delta t}\), the multivalued Equation (55) can be written as  
\[u^{n+1}=\int_{\frac{2}{\alpha\Delta t}}\left(\frac{2}{\alpha\Delta t}\bar{e}^{ n}-u^{n}+\frac{r^{n+1/2}+r^{n}}{\alpha}+\frac{q^{n+1/2}+q^{n}}{\alpha}\right) \tag{58}\]  
which it is equivalent to solving  
\[(\frac{2}{\alpha\Delta t}Id+G)u^{n+1}\
i\left(\frac{2}{\alpha\Delta t}\bar{e}^ {n}-u^{n}+\frac{r^{n+1/2}+r^{n}}{\alpha}+\frac{q^{n+1/2}+q^{n}}{\alpha}\right). \tag{59}\]  
Denoting now \(\mathbbm{e}^{n}=\frac{2}{\alpha\Delta t}\bar{e}^{n}-u^{n}+\frac{r^{n+1/2}+r^ {n}}{\alpha}+\frac{q^{n+1/2}+q^{n}}{\alpha}\), the value of \(u^{n+1}\) is given by  
\[\frac{\mathbbm{e}^{n}}{1+\frac{\alpha\Delta t}{2}} \text{ if }\quad\mathbbm{e}^{n}<(1+\frac{\alpha\Delta t}{2})\ u_{ \mathbbm{e}_{\mathbbm{J}}}\] \[u_{\mathbbm{J}} \text{ if }\quad\mathbbm{e}^{n}\in\big{[}(1+\frac{\alpha\Delta t}{2})\ u _{\mathbbm{J}_{\mathbbm{J}}}(1+\frac{\alpha\Delta t}{2})\ u_{\mathbbm{J}}+ \lambda_{\mathbbm{J}}\big{]},\] \[\frac{\mathbbm{e}^{n}-\lambda_{\mathbbm{J}}}{1+\frac{\alpha\Delta t }{2}} \text{ if }\quad\mathbbm{e}^{n}\in\big{[}(1+\frac{\alpha\Delta t}{2})\ u_{ \mathbbm{J}}+\lambda_{\mathbbm{J}}\big{]},\] \[u_{\mathbbm{J}} \text{ if }\quad\mathbbm{e}^{n}\in\big{[}(1+\frac{\alpha\Delta t}{2})\ u _{\mathbbm{J}}+\lambda_{\mathbbm{J}},\infty\big{]}. \tag{60}\]  
Again, once \(u^{n+1}\) has been obtained, we can update the enthalpy \(e^{n+1}\) from Equation (54) and the fuel \(c^{n+1}\) from Equation (56):  
\[e^{n+1}\in G(u^{n+1}),\]0 \[e^{n+1}\in G(u^{n+1}),\]1  
Once again, Equations (58), (61), and (62) can be solved simultaneously in all active nodes, so again, the parallel calculation allowed us to reduce the computational cost in the correction step. In the _burned zone_, only (54) needs to be taken into account, which can be simplified as well and solved explicitly:  
\[e^{n+1}\in G(u^{n+1}),\]2  
The computational cost was reduced by defining the _Active Nodes_, solving the equations only for the fire front, computing the _Radiation Matrix_ once out of the time loop, differentiating the burning zone from the burned zone, and adapting the numerical scheme and the corresponding code to parallel computing. We also introduced the fire-spotting index \(N_{q}\) to significantly reduce the computational cost of the set of possible firebrand receiver nodes, so that the term \(q^{n}\) is not calculated in all the time steps, but every \(N_{q}\) steps, although for greater clarity, we detailed the calculation of this term in each time step. Improving computational efficiency is crucial to obtain simulation results in times that are significantly lower than the real-time evolution of a fire. However, it is also of great importance to address other objectives in the design and improvement of this type of complex models, such as the sensitivity analysis or the parameter adjustment, which require a large number of model evaluations, as well as to improve simulation results through data assimilation. All these aspects have been analyzed for the PhyFire model in different previous works [32; 35; 41].