## 2 Dynamical Modeling
### In-Cylinder, Intake and Exhaust Oxygen Concentration  
Considering the IVC as the boundary of adjacent cycles. Thus, the contribution for in-cylinder gas mass includes residual gas mass, injection mass, aspirated gas mass, and exhaled gas mass. Hence the relationship between cycle \(k\) and cycle \(k+1\) is formulated as,  
\[m_{cyl}(k+1)=m_{res}(k)+m_{inj}(k)+m_{itc}(k)-m_{cte}(k) \tag{3}\]  
where, the residual gas mass is estimated by applying ideal gas law,  
\[m_{res}(k)=\frac{p_{irc}(k)V_{irc}(k)}{C_{dis}\hat{T}_{int}(k)}-\left[m_{itc}(k )+m_{f}(k)\right] \tag{4}\]  
where in Equation (4), \(\hat{T}_{int}\) is measured in the intake manifold. \(p_{irc}\) is in-cylinder pressure at intake valve closing time, which is measured in engine cylinder by in-cylinder pressure sensor. We apply mean temperature of intake manifold because the in-cylinder temperature can be hardly measured. The introduced error by this approximation is acceptable. Assuming the \(\hat{T}\) is 50 Kelvin less than the in-cylinder temperature, the residual fraction is 30%, and the combustion efficiency is 90%, then the estimation error for trapped unburned fuel mass is within 3%.  
For conventional dynamical model, the aspirated gas mass is calculated from the integral of its mass rate, also known as speed-density model,  
\[\hat{m}_{itc}=\frac{\eta_{cyl}P_{int}V_{d}N_{eng}}{120C_{dis}\hat{T}_{int}} \tag{5}\]  
where the volumetric efficiency \(\eta_{c}\) is a model uncertainty, demanding calibration.  
The in-cylinder oxygen concentration is the mass fraction for related parameters. the in-cylinder oxygen concentration of cycle \(k+1\) is expressed as,  
\[\Phi_{cyl}(k+1)=\frac{\Phi_{cyl}(k)m_{cyl}(k)-m_{f}(k)\lambda_{s}-m_{cte}(k) \Phi_{cte}(k)+\Phi_{int}(k)m_{itc}(k)}{m_{cyl}(k+1)} \tag{6}\]  
where, the relationship among the exhaust oxygen concentration, in-cylinder oxygen mass (before combustion), consumed oxygen mass, and injection mass are derived as,  
\[\Phi_{cte}(k)=\frac{\Phi_{cyl}(k)m_{cyl}(k)-m_{f}(k)\lambda_{s}}{m_{cyl}(k)+m _{inj}(k)} \tag{7}\]  
and, the exhaled gas mass is the difference of in-cylinder gas mass and residual gas mass,  
\[m_{cte}(k)=m_{cyl}(k)-m_{res}(k) \tag{8}\]  
The intake oxygen concentration of cycle \(k+1\) is computed from the intake gas oxygen mass, EGR gas oxygen mass, fresh air gas mass, and the overall gas mass,  
\[\Phi_{int}(k+1)= \tag{9}\] \[\frac{\Phi_{int}(k)[m_{int}(k)-m_{itc}(k)]+\Phi_{exh}(k)m_{cgr}(k )+\Phi_{air}\big{[}m_{com}(k)-m_{egr}(k)\big{]}}{m_{int}(k)+m_{com}(k)-m_{itc}( k)}\]  
The exhaust manifold oxygen concentration can be calculated from the previous manifold gas oxygen mass, the turbocharge gas oxygen mass, the exhaled gas oxygen mass and the overall gas mass,  
\[\Phi_{exh}(k+1)=\frac{\Phi_{exh}(k)[m_{exh}(k)-m_{tur}(k)]+\Phi_{cte}(k)m_{ cte}(k)}{m_{exh}(k)+m_{cte}(k)-m_{tur}(k)} \tag{10}\]  
where, \(m_{egr}\) is formulated as,When the flow is not choked \(\left(\frac{p_{d}}{p_{u}}>\left(\frac{2}{\gamma+1}\right)^{\gamma/(\gamma-1)}\right)\),  
\[\dot{m}=\frac{C_{dis}A_{\gamma r}p_{u}}{\sqrt{C_{gas}T_{u}}}\left(\frac{p_{d}}{p _{u}}\right)^{1/\gamma}\left[\frac{2\gamma}{\gamma-1}\left(1-\left(\frac{p_{d }}{p_{u}}\right)^{(\gamma-1)/\gamma}\right)\right]^{0.5} \tag{11}\]
* When the flow is choked \(\left(\frac{p_{d}}{p_{u}}\leq\left(\frac{2}{\gamma+1}\right)^{\gamma/(\gamma-1 )}\right)\),  
\[\dot{m}=\frac{C_{dis}A_{\gamma r}p_{u}}{\sqrt{C_{gas}T_{u}}}\sqrt{\gamma}\left( \frac{2}{\gamma+1}\right)^{0.5(\gamma+1)(\gamma-1)} \tag{12}\]  
Applying the ideal gas law, the intake/exhaust gas mass can be calculated,  
\[m_{int(exh)}(k)=\frac{\bar{P}_{int(exh)}(k)V_{int(exh)}}{C_{dis}\bar{T}_{int( exh)}} \tag{13}\]