Vectotized Efficient C Tool fOr Rectangular-coil Coaxial Analytical Series Expansion of mutual inductance
This is the code that implements the two methods described in the following papers:
-
"Calculation of Mutual Inductance of Two Coaxial Thick Coils With Rectangular Cross Section by Using Cylindrical Multipole Expansion", The paper is available at IEEE Xplore, and can be cited as:
@ARTICLE{10856207, author={Vučić, Filip and Dobrota, Davor}, journal={IEEE Transactions on Magnetics}, title={Calculation of Mutual Inductance of Two Coaxial Thick Coils With Rectangular Cross Section by Using Cylindrical Multipole Expansion}, year={2025}, volume={61}, number={3}, pages={1-16}, doi={10.1109/TMAG.2025.3535634} } -
"Analytical Calculation of Mutual Inductance Between Two Coaxial Thick Coils With Rectangular Cross Section Using Modified Bessel and Hypergeometric Functions", The paper is available at IEEE Xplore, and can be cited as:
@ARTICLE{11352990, author={Vučić, Filip and Dobrota, Davor}, journal={IEEE Transactions on Magnetics}, title={Analytical Calculation of Mutual Inductance Between Two Coaxial Thick Coils With Rectangular Cross Section Using Modified Bessel and Hypergeometric Functions}, year={2026}, volume={}, number={}, pages={1-1}, keywords={Coils;Inductance;Accuracy;Green's function methods;Convergence;Vectors;Integral equations;Geometry;Current density;Azimuthal component;Coaxial coils;high performance;hypergeometric functions;modified Bessel functions;mutual inductance;radial cylindrical multipole expansion;thick coils with rectangular cross section}, doi={10.1109/TMAG.2026.3654058}}
The code is meant to be a header-only C library. This makes it easy to include in other projects, and to use in conjunction with other libraries as well as from other languages. For an example of this, see how to use the code from Python.
The code is written in C, and is intended to be used as a header-only library. It is vectorized and intended to be used with SSE, AVX, or AVX-512 instruction sets. To enable them, uncomment the appropriate line in src/settings.h or pass an appropriate definition to the compiler by some other means. Note that the most aggressive of the uncommented options is AVX-512 and it will be used even if other lines are uncommented. Be mindful whether your CPU supports the instruction set you are targeting.
One can generate lookup tables for the sums using the functions found in generate_lookup_tables.py. We provide headers with 64 terms along each direction as we find this a good balance between size and precision.
There is also an implementation of the method in Python, using the Decimal class to achieve adaptive precision. This is at the cost of some performance but eliminates all fears of overflow when using a large number of terms.
There is a demonstration of how the methods from the header files can be used in Python by means of the CFFI library in C_interface_demo.py. A more comprehensive implementation of a Python wrapper is also provided in vector_case_py directory. It is also based on CFFI, but is designed to expose a more Pythonic interface.
Finally, we implemented the method by Župan et al for comparison:
T. Župan, Ž. Štih, and B. Trkulja, “Fast and precise method for inductance calculation of coaxial circular coils with rectangular cross section using the one-dimensional integration of elementary functions applicable to superconducting magnets” (link to the paper)
We provide implementations in C and Mathematica. Note that the C implementation is very fast but due to the oscillatory nature of the integrand the Gauss-Legendre quadrature does not converge. The Gauss-Kronrod adaptive quadrature used by Mathematica seems to be more robust, but it too fails for some configurations.