-
Notifications
You must be signed in to change notification settings - Fork 0
/
fungenerators.py
83 lines (70 loc) · 3.54 KB
/
fungenerators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3
from scipy import special
import numpy as np
def tmfungen(λfree, n1, n2, a):
'''
This function returns the eigenvalue function for TM modes.
The expressions for the secular equations are generated in the
accompanying Mathematica notebook wavesight.nb.
Parameters
----------
λfree : float
Free space wavelength in μm.
n1 : float
Core refractive index.
n2 : float
Cladding refractive index.
a : float
Core radius in μm.
Returns
-------
tm : function
'''
def tm(kz):
return -(n1**2*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)*special.jv(1,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2))) - (n2**2*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2)*special.jv(0,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2))*special.kn(1,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)))/special.kn(0,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2))
return tm
def tefungen(λfree, n1, n2, a):
'''
This function returns the eigenvalue function for TE modes.
The expressions for the secular equations are generated in the
accompanying Mathematica notebook wavesight.nb.
Parameters
----------
λfree : float
Free space wavelength in μm.
n1 : float
Core refractive index.
n2 : float
Cladding refractive index.
a : float
Core radius in μm.
Returns
-------
te : function
'''
def te(kz):
return -(np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)*special.jv(1,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2))) - (np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2)*special.jv(0,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2))*special.kn(1,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)))/special.kn(0,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2))
return te
def hefungen(λfree, m, n1, n2, a):
'''
This function returns the eigenvalue function for HE(n,m) modes in
a step index waveguide.
Parameters
----------
λfree : float
Free space wavelength in μm.
n1 : float
Core refractive index.
n2 : float
Cladding refractive index.
a : float
Core radius in μm.
m : int
Order of the HE mode.
Returns
-------
he : function
'''
def he(kz):
return -((m**2*(1/(-kz**2 + (4*n1**2*np.pi**2)/λfree**2) + 1/(kz**2 - (4*n2**2*np.pi**2)/λfree**2))*(n1**2/(-kz**2 + (4*n1**2*np.pi**2)/λfree**2) + n2**2/(kz**2 - (4*n2**2*np.pi**2)/λfree**2)))/a**2) + ((special.jv(-1 + m,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2)) - special.jv(1 + m,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2)))/(2.*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2)*special.jv(m,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2))) + (-special.kn(-1 + m,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)) - special.kn(1 + m,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)))/(2.*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)*special.kn(m,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2))))*((n1**2*(special.jv(-1 + m,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2)) - special.jv(1 + m,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2))))/(2.*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2)*special.jv(m,a*np.sqrt(-kz**2 + (4*n1**2*np.pi**2)/λfree**2))) + (n2**2*(-special.kn(-1 + m,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)) - special.kn(1 + m,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2))))/(2.*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2)*special.kn(m,a*np.sqrt(kz**2 - (4*n2**2*np.pi**2)/λfree**2))))
return he