# Multi-Region OpenFOAM Solver Development for Compact Toroid Transport in Drift Tube
## 3 Program Verification
### The mhdMRF Solver Verification  
To verify the mhdMRF solver, based on the validations of the two individual solvers above, this study designs a one-dimensional analytical example to verify the correctness of the interface coupling boundary conditions. This model assumes a very small velocity field, so that magnetic field evolution in the fluid region approximately follows the magnetic diffusion equation. Then, the governing equation in both regions simplifies to  
\[\frac{\partial B(x,t)}{\partial t}=\frac{\partial}{\partial x}\left[\eta_{m} \frac{\partial B(x,t)}{\partial x}\right] \tag{25}\]  
where \(\eta_{m}=1/\mu\sigma\) is the magnetic diffusion coefficients. The computational domain is defined as \(x\in[-L,L]\), with the material interface at \(x=0\), and the electrical conductivities in the solid region \(x\in[-L,0]\) and fluid region \(x\in[0,L]\) are as follows:  
\[\sigma(x)=\begin{cases}\sigma_{1},&x\in[-L,0],\\ \sigma_{2},&x\in[0,L],\end{cases} \tag{26}\]  
Boundary conditions:  
\[B(-L,t)=0,\ B(L,t)=0 \tag{27}\]  
Figure 6: Comparison of numerical and analytical solutions for the magnetic diffusion problem in a conducting cylinder. (**a**) Magnetic flux density; (**b**) current density.  
At the interface, continuity of field and flux must be satisfied:  
\[B(0^{-},t) =B(0^{+},t) \tag{28}\] \[\eta_{m1}\frac{dB(0^{-},t)}{dx} =\eta_{m2}\frac{dB(0^{+},t)}{dx} \tag{29}\]  
Using the method of separation of variables, the analytical solution can be expressed as an eigenfunction expansion:  
\[B(x,t)=\sum\limits_{n=1}^{\infty}a_{n}X_{n}(x)e^{-\lambda_{n}t} \tag{30}\]  
The eigenfunction \(X_{n}(x)\) is expressed in the solid and fluid regions as  
\[X_{n}(x)=\begin{cases}A_{n}\sin[k_{1,n}(x+L)],&x\in[-L,0]\\ C_{n}\sin[k_{2,n}(L-x)],&x\in[0,L]\end{cases} \tag{31}\]  
where \(k_{1,n}=\sqrt{\lambda_{n}/\eta_{m1}}\), \(k_{2,n}=\sqrt{\lambda_{n}/\eta_{m2}}\), and coefficients \(A_{n}\), \(C_{n}\) are determined by interface matching conditions:  
\[A_{n}\sin(k_{1,n}L)=C_{n}\sin(k_{2,n}L) \tag{32}\]  
The eigenvalue \(\lambda_{n}\) is determined by the transcendental equation:  
\[\frac{\sin(k_{1,n}L)}{\sin(k_{2,n}L)}=-\sqrt{\frac{\eta_{m1}}{\eta_{m2}}} \frac{\cos(k_{1,n}L)}{\cos(k_{2,n}L)} \tag{33}\]  
The first eigenvalue is \(\lambda_{1}\approx 0.771\). Simulation parameters: \(L=1\), \(\mu=1\), \(\sigma_{1}=10\), \(\sigma_{2}=1\). Initial condition:  
\[B(x,0)=X(x)=\begin{cases}A\sin[k_{1}(x+L)],&x\in[-L,0]\\ C\sin[k_{2}(L-x)],&x\in[0,L]\end{cases} \tag{34}\]  
Taking \(C=0.1\), we find \(A\approx 0.216\) based on matching conditions. Other variables in the fluid region are set to small values to avoid interfering with magnetic field evolution.  
Figure 7 compares analytical and numerical solutions at \(t=0.4,\ 0.8,\ 1.2\); the blue solid line represents the numerical solution calculated by the solver, while the red dashed line corresponds to the analytical solution. The results show high spatial agreement. The relative error of magnetic induction is defined as follows:  
\[\delta_{N}(B)=\frac{\sum\limits_{i=1}^{N}\left|B_{i}^{anl}-B_{i}^{n\textbf{U} m}\right|}{\sum\limits_{i=1}^{N}\left|B_{i}^{anl}\right|} \tag{35}\]  
The error at each time point is approximately \(\delta_{N}(B)\approx 1\times 10^{-4}\). The continuity of field and flux is correctly implemented through the custom interface coupling boundary condition. This shows that the mhdMRF solver can accurately handle the dynamic matching of magnetic fields and fluxes at interfaces.