On the boundary conditions of magnetic field in OpenFOAM and a magnetic field solver for multi-region applications
This work begins with the discretization of the governing equations of magnetic field for different type of magnetic media over a two-dimensional rectangular domain using a Cartesian grid system. The basic rules that the coefficients of the discretization equation should obey, to ensure physical realism and overall balance, are discussed. In order to satisfy the rule, “consistency at control-volume faces,” the formulation of the permeability at the interface between two adjacent control volumes is derived. It reveals that the interface permeability is equal to the anti-linear interpolation of that on the cell centroids under the assumption of flux consistency at control-volume faces. For the purpose of effectively calculating magnetic fields using the FVM based OpenFOAM toolbox, the representations of boundary conditions on the interfaces between different type of media are for the first time derived. A C++ class named magPhiMixedFvPatchField describing the newly derived boundary conditions is defined based on OpenFOAM libraries. The new open-source solver labelled as magneticMultiRegionFoam, for the simulation of static magnetic field with multi-regions, based on FVM in the OpenFOAM framework is for the first time developed and validated. Comparison of the results of the predicted magnetic field for a cylindrical magnet in air with that obtained from Comsol software and the analytical method verifies the fidelity of the solver implementation. For the case of calculating the magnetic levitation forces exerted on a magnet immersed in ferrofluid, the results obtained from magneticMultiRegionFoam show better consistency with the experimental ones than Comsol software.