This is quite accurate formula for a single layer solenoid. Formula comes from the paper http://www.coe.ufrj.br/~acmq/tesla/maxwell.pdf and compares well with Kirchoffs and Maxwells formulas.
import numpy as np
import math
import matplotlib.pyplot as plt
import matplotlib
import scipy.special as special
a=0.486 #5e-2 # coil raduis
b=0.0921 #4e-2 # coil height
c=0.0095 #1.88e-3 # coil diameter
n=5 # number of coils
pi=np.pi
mi_0=4*pi*1e-7
p=2*a/b
theta=np.arctan(p)
k=np.sin(theta)
k1=np.cos(theta)
z=pi*n*c/b
K=special.ellipk(k) # elliptic integral of a first kind
E=special.ellipe(k) # elliptic integral of a second kind
%whos
Variable Type Data/Info --------------------------------- E float64 1.008021304684566 K float64 4.0961576922801575 L float64 1.98269910975166e-05 S1 float64 199.84660832730418 S2 float64 -0.6290450162020763 S3 float64 0.10305798056070045 S4 float64 0.31999368858514404 a float 0.486 b float 0.0921 c float 0.0095 k float64 0.9955409295862284 k1 float64 0.09433057573548517 math module <module 'math' (built-in)> matplotlib module <module 'matplotlib' from<...>/matplotlib/__init__.py'> mi_0 float 1.2566370614359173e-06 n int 5 np module <module 'numpy' from '/us<...>kages/numpy/__init__.py'> p float 10.553745928338762 pi float 3.141592653589793 plt module <module 'matplotlib.pyplo<...>es/matplotlib/pyplot.py'> special module <module 'scipy.special' f<...>ipy/special/__init__.py'> theta float64 1.4763252916068947 z float 1.6202567974540192
S1=8*n**2*a*pi/3*((K+(p**2-1)*E)/k-p*p)
S2=2*n*(1/4-np.log(z))+1/3*np.log(2*pi*n*a/b)-4/pi**2*(E/k-1)*(1+z**2/8)
S3=-2/3*((K-E)/k-k*K/2)-k1/(2*k)*(1-k1*theta/k)
S4=np.log((1+k1)/(1-k1))+k1*np.log(4)
L=mi_0/(4*pi)*(S1+2*pi*a*(S2+S3)+b*S4)
%whos
Variable Type Data/Info --------------------------------- E float64 1.008021304684566 K float64 4.0961576922801575 L float64 4.5368905947438836e-05 S1 float64 457.86893963105894 S2 float64 -0.6290450162020763 S3 float64 -0.7494305196721343 S4 float64 0.31999368858514404 a float 0.486 b float 0.0921 c float 0.0095 k float64 0.9955409295862284 k1 float64 0.09433057573548517 math module <module 'math' (built-in)> matplotlib module <module 'matplotlib' from<...>/matplotlib/__init__.py'> mi_0 float 1.2566370614359173e-06 n int 5 np module <module 'numpy' from '/us<...>kages/numpy/__init__.py'> p float 10.553745928338762 pi float 3.141592653589793 plt module <module 'matplotlib.pyplo<...>es/matplotlib/pyplot.py'> special module <module 'scipy.special' f<...>ipy/special/__init__.py'> theta float64 1.4763252916068947 z float 1.6202567974540192
4**2/2
8.0