## 2 Integrated Flow and Heat Transfer Model for Cavity and Wellbore
### The Thermal Transfer Model for Wellbore Flow  
Research indicates that, during the hydrogen injection and withdrawal cycle, temperature variations occur due to the compression and release of hydrogen. Given the temperature difference between the hydrogen within the wellbore and the surrounding rock, thermal exchange between the hydrogen and the surrounding formation ensues. Throughout the hydrogen injection and withdrawal process, this thermal exchange manifests through convective heat transfer within the wellbore and radial conductive heat transfer.  
A steady-state hydrogen flow model is established within the wellbore for the hydrogen injection and withdrawal process based on the assumptions stated earlier. The fluid control model for hydrogen within the wellbore is derived, encompassing the mass continuity equation, momentum principle, and energy conservation equation.  
The quality continuity equation:  
\[\rho\frac{dv}{dz}+v\frac{d\rho}{dz}=0 \tag{1}\]  
The gas momentum equation:  
\[\frac{dp}{dz}=\rho gs\dot{n}\theta-f\frac{\rho v|v|}{2d}-\rho v\frac{dv}{dz} \tag{2}\]  
The energy conservation equation:  
\[Q+A\rho v(\frac{dh}{dz}+\frac{vdv}{dz}-g)=0 \tag{3}\]  
In Equations (1)-(3), \(\rho\) is the fluid density, kg/m\({}^{3}\); \(v\) is the fluid velocity, m/s; \(z\) is the depth of the wellbore, m; \(p\) is the fluid pressure, Pa; \(g\) is the gravitational acceleration, 9.81 m/s\({}^{2}\); \(\theta\) is the well deviation angle, \({}^{\circ}\);\(f\) is the friction coefficient, dimensionless; \(d\) is the internal diameter of the wellbore, m; \(Q\) is the heat transfer rate of the fluid per unit length of the wellbore, J/(m-s); \(h\) is the specific enthalpy, J/kg; \(T\) is the temperature, K; \(A\) is the cross-sectional area of the tubing, m\({}^{2}\).  
Heat transfer between hydrogen gas and the inner walls of the well is governed by convective heat transfer. According to [PERSON]'s law of cooling, the heat transfer equation for hydrogen gas within the well can be defined based on the rate of heat transfer between the hydrogen gas and the well's inner wall:  
\[Q=2\pi r_{ii}h_{f}(T_{f}-T_{ti})\Delta L \tag{4}\]In Equation (4), \(h_{f}\) denotes the forced convective heat transfer coefficient for hydrogen gas within the borehole and its walls:  
\[h_{f}=\frac{k_{f}Nu_{f}}{2r_{ti}} \tag{5}\]  
In Equation (5), \(Nu_{f}\) denotes the Nusselt number for hydrogen:  
\[Nu_{f}=0.023 Re^{0.8}Pr_{f}{}^{0.4} \tag{6}\]  
In Equation (6), \(Pr_{f}\) denotes the Prandtl number of the injected fluid:  
\[Pr_{f}=\frac{c_{pf}\mu_{f}}{k_{f}} \tag{7}\]  
In Equations (7)-(10), \(r_{ti}\) is the radius of the borehole, m; \(k_{f}\) is the thermal conductivity of hydrogen, W/(m\(\cdot\)K); \(\mu_{f}\) is the dynamic viscosity of hydrogen, Pa\(\cdot\)s; \(c_{pf}\) is the specific heat capacity of hydrogen at constant pressure, J/(kg\(\cdot\)K).  
The radial heat conduction equation for the wellbore and surrounding rock:  
\[Q=-2\pi rk\frac{dT}{dr}\Delta L \tag{8}\]  
The convective heat transfer equation for hydrogen:  
\[Q=2\pi r_{to}h_{a}(T_{to}-T_{si})\Delta L \tag{9}\]  
In Equation (9), \(h_{a}\) represents the natural convective heat transfer coefficient for hydrogen:  
\[ha=\frac{0.049(Gr_{a}Pr_{a})^{1/3}Pr_{a}{}^{0.074}k_{a}}{r_{t0}ln(r_{si}/r_{t 0})} \tag{10}\]  
\[Pr_{a}=\frac{c_{pa}\mu_{a}}{k_{a}} \tag{11}\]  
In Equations (9)-(11), \(k_{a}\) is the thermal conductivity of hydrogen, W/(m\(\cdot\)K); \(\mu_{a}\) is the dynamic viscosity of hydrogen, Pa\(\cdot\)s; \(c_{pa}\) is the specific heat capacity of hydrogen at constant pressure, J/(kg\(\cdot\)K).