import numpy as np

def vortex_trans(lam=3.8e-6, vc_thick=0.03, vc_refl=0.06, ar_refl=0.01, **conf):
    '''
    vc_thick:
        vortex substrate thickness in cm
    vc_refl:
        vortex side reflection (AGPM worst case. over whole band)
    ar_refl = 0.01
        anti-reflective side reflection
    '''

    # extinction coefficient of diamond (range 2-25 µm)
    k_lams = [2.0358, 2.0665, 2.0874, 2.1034, 2.1347, 2.1755, 2.2032, 2.2392, 2.2732, 
            2.2969, 2.3163, 2.3544, 2.3902, 2.4113, 2.4436, 2.4786, 2.5088, 2.5144,
            2.5201, 2.5354, 2.5421, 2.558,  2.5668, 2.5767, 2.5969, 2.632,  2.6537, 
            2.6789, 2.7186, 2.7596, 2.7934, 2.8087, 2.848,  2.8847, 2.9395, 2.9983, 
            3.0511, 3.0738, 3.1204, 3.1886, 3.253,  3.408,  3.5044, 3.602,  3.7201, 
            3.7539, 3.7623, 3.7708, 3.7749, 3.8115, 3.854,  3.9274, 4.0135, 4.0545, 
            4.1087, 4.1397, 4.2087, 4.2856, 4.3529, 4.3824, 4.4706, 4.5534, 4.6339, 
            4.6498, 4.6726, 4.6784, 4.7139, 4.8172, 4.8404, 4.8678, 4.8957, 4.9397, 
            4.9998, 5.0534, 5.2306, 5.3313, 5.5022, 5.5356, 5.6445, 5.8979, 6.1065, 
            6.367,  6.5426, 6.6911, 7.0352, 7.3499, 7.6765, 7.8263, 8.167,  8.3903, 
            8.5778, 8.8072, 8.9467, 9.2365, 9.6185, 10.012, 10.33,  10.66,  10.933, 
            11.558, 12.106, 12.838, 13.494, 13.64,  13.888, 14.463, 14.996, 15.017, 
            15.471, 16.081, 16.5,   17.201, 18.218, 19.027, 19.117, 20.599, 22.596, 
            24.541]
    k_vals = [2.4723E-07, 2.1048E-07, 2.4480E-07, 3.0045E-07, 3.8205E-07, 4.9479E-07, 
            4.1148E-07, 3.8168E-07, 3.2728E-07, 4.3220E-07, 5.8587E-07, 5.5511E-07, 
            6.1334E-07, 4.2011E-07, 3.4714E-07, 2.7139E-07, 2.6336E-07, 4.5076E-07, 
            7.1402E-07, 1.1597E-06, 1.5834E-06, 2.7102E-06, 3.4240E-06, 4.8440E-06, 
            6.7161E-06, 1.3478E-05, 1.9287E-05, 2.8942E-05, 3.6541E-05, 4.0652E-05, 
            3.8279E-05, 3.4633E-05, 3.2113E-05, 3.3292E-05, 3.1559E-05, 3.4719E-05, 
            3.8800E-05, 4.2410E-05, 4.5690E-05, 4.3086E-05, 4.0238E-05, 3.5611E-05, 
            2.8626E-05, 2.3001E-05, 2.1228E-05, 2.4662E-05, 3.2301E-05, 4.1798E-05, 
            5.8142E-05, 8.8501E-05, 1.1921E-04, 1.5327E-04, 1.6227E-04, 1.5683E-04, 
            1.6136E-04, 1.5492E-04, 1.1969E-04, 8.5717E-05, 2.0848E-04, 2.8413E-04, 
            3.6571E-04, 4.5053E-04, 5.1683E-04, 4.7997E-04, 4.1478E-04, 3.6696E-04, 
            3.4705E-04, 3.7001E-04, 4.1697E-04, 4.8471E-04, 5.3476E-04, 5.4014E-04, 
            5.1992E-04, 5.5991E-04, 3.3232E-04, 2.6690E-04, 2.0475E-04, 1.5434E-04, 
            1.1225E-04, 7.3190E-05, 4.4380E-05, 2.9909E-05, 2.4684E-05, 2.0750E-05, 
            1.3236E-05, 1.0217E-05, 6.9525E-06, 4.3475E-06, 5.1041E-06, 4.6198E-06, 
            4.4066E-06, 4.6028E-06, 5.5759E-06, 6.7555E-06, 6.1608E-06, 5.0531E-06, 
            5.8652E-06, 5.5125E-06, 6.5151E-06, 6.5769E-06, 5.1462E-06, 2.7514E-06, 
            2.2581E-06, 1.7397E-06, 1.4255E-06, 1.4891E-06, 2.1781E-06, 5.2646E-06, 
            5.1996E-06, 8.2469E-06, 5.7506E-06, 6.4650E-06, 8.2071E-06, 1.0181E-05, 
            1.3749E-05, 1.8919E-05, 2.2791E-05, 2.9312E-05]

    k = np.interp(lam*1e6, k_lams, k_vals)
    alpha = 4*np.pi*k/lam/100 # cm^-1
    vc_trans = 1 - vc_refl
    ar_trans = 1 - ar_refl
    trans = vc_trans*ar_trans*np.exp(-alpha*vc_thick) \
          / (1 - vc_refl*ar_refl*np.exp(-2*alpha*vc_thick))
    
    return trans