Commit eb8647511df49e30b8b042a1d643271abac512ba
1 parent
07295cdf44
Exists in
master
add LPF behav of the cavity
Showing 2 changed files with 157 additions and 1 deletions Inline Diff
tf_cavity/tf_cavity_num.py
#!/usr/bin/python | 1 | 1 | #!/usr/bin/python | |
# -*- coding: utf-8 -*- | 2 | 2 | # -*- coding: utf-8 -*- | |
3 | 3 | |||
'''TF of FP cavity in reflection | 4 | 4 | '''TF of FP cavity in reflection | |
5 | 5 | |||
---------- | 6 | 6 | ---------- | |
X(s) ----- | -tau⋅s | | 7 | 7 | X(s) ----- | -tau⋅s | | |
-------------->|1-R|----->(X)----->|e |------ | 8 | 8 | -------------->|1-R|----->(X)----->|e |------ | |
| ----- ^ ---------- | | 9 | 9 | | ----- ^ ---------- | | |
| | | | 10 | 10 | | | | | |
| | V | 11 | 11 | | | V | |
---- ---- ---- | 12 | 12 | ---- ---- ---- | |
|-R| |-R| |-R| | 13 | 13 | |-R| |-R| |-R| | |
---- ---- ---- | 14 | 14 | ---- ---- ---- | |
| ^ | | 15 | 15 | | ^ | | |
| | ---------- | | 16 | 16 | | | ---------- | | |
Y(s) V ----- | | -tau⋅s | | | 17 | 17 | Y(s) V ----- | | -tau⋅s | | | |
<-----(X)<-----|1-R|<--------------|e |<----- | 18 | 18 | <-----(X)<-----|1-R|<--------------|e |<----- | |
----- ---------- | 19 | 19 | ----- ---------- | |
20 | 20 | |||
''' | 21 | 21 | ''' | |
22 | 22 | |||
'''import matplotlib as mpl | 23 | 23 | '''import matplotlib as mpl | |
mpl.use('pgf') | 24 | 24 | mpl.use('pgf') | |
25 | 25 | |||
def figsize(scale): | 26 | 26 | def figsize(scale): | |
fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth | 27 | 27 | fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth | |
inches_per_pt = 1.0/72.27 # Convert pt to inch | 28 | 28 | inches_per_pt = 1.0/72.27 # Convert pt to inch | |
golden_mean = (5.0**0.5-1.0)/2.0 # Aesthetic ratio (you could change this) | 29 | 29 | golden_mean = (5.0**0.5-1.0)/2.0 # Aesthetic ratio (you could change this) | |
fig_width = fig_width_pt*inches_per_pt*scale # width in inches | 30 | 30 | fig_width = fig_width_pt*inches_per_pt*scale # width in inches | |
fig_height = fig_width*golden_mean # height in inches | 31 | 31 | fig_height = fig_width*golden_mean # height in inches | |
fig_size = [fig_width,fig_height] | 32 | 32 | fig_size = [fig_width,fig_height] | |
return fig_size | 33 | 33 | return fig_size | |
34 | 34 | |||
pgf_with_latex = { # setup matplotlib to use latex for output | 35 | 35 | pgf_with_latex = { # setup matplotlib to use latex for output | |
"pgf.texsystem": "pdflatex", # change this if using xetex or lautex | 36 | 36 | "pgf.texsystem": "pdflatex", # change this if using xetex or lautex | |
"text.usetex": True, # use LaTeX to write all text | 37 | 37 | "text.usetex": True, # use LaTeX to write all text | |
"font.family": "serif", | 38 | 38 | "font.family": "serif", | |
"font.serif": [], # blank entries should cause plots to inherit fonts from the document | 39 | 39 | "font.serif": [], # blank entries should cause plots to inherit fonts from the document | |
"font.sans-serif": [], | 40 | 40 | "font.sans-serif": [], | |
"font.monospace": [], | 41 | 41 | "font.monospace": [], | |
"axes.labelsize": 10, # LaTeX default is 10pt font. | 42 | 42 | "axes.labelsize": 10, # LaTeX default is 10pt font. | |
"text.fontsize": 10, | 43 | 43 | "text.fontsize": 10, | |
"legend.fontsize": 8, # Make the legend/label fonts a little smaller | 44 | 44 | "legend.fontsize": 8, # Make the legend/label fonts a little smaller | |
"xtick.labelsize": 8, | 45 | 45 | "xtick.labelsize": 8, | |
"ytick.labelsize": 8, | 46 | 46 | "ytick.labelsize": 8, | |
"figure.figsize": figsize(0.9), # default fig size of 0.9 textwidth | 47 | 47 | "figure.figsize": figsize(0.9), # default fig size of 0.9 textwidth | |
"pgf.preamble": [ | 48 | 48 | "pgf.preamble": [ | |
r"\usepackage[utf8x]{inputenc}", # use utf8 fonts becasue your computer can handle it :) | 49 | 49 | r"\usepackage[utf8x]{inputenc}", # use utf8 fonts becasue your computer can handle it :) | |
r"\usepackage[T1]{fontenc}", # plots will be generated using this preamble | 50 | 50 | r"\usepackage[T1]{fontenc}", # plots will be generated using this preamble | |
] | 51 | 51 | ] | |
} | 52 | 52 | } | |
mpl.rcParams.update(pgf_with_latex) | 53 | 53 | mpl.rcParams.update(pgf_with_latex) | |
''' | 54 | 54 | ''' | |
from numpy import * | 55 | 55 | from numpy import * | |
import matplotlib.pyplot as plt | 56 | 56 | import matplotlib.pyplot as plt | |
57 | 57 | |||
r = 0.99998 | 58 | 58 | r = 0.99998 | |
L = 140e-3 | 59 | 59 | L = 140e-3 | |
c = 299792458 | 60 | 60 | c = 299792458 | |
61 | 61 | |||
tau = L/c | 62 | 62 | tau = L/c | |
fsr = 1/(2*tau) | 63 | 63 | fsr = 1/(2*tau) | |
finesse = pi*r/(1-r**2) | 64 | 64 | finesse = pi*r/(1-r**2) | |
print('Finesse = %f\n FSR = %f\n FSR/Finesse = %f'%(finesse, fsr, fsr/finesse)) | 65 | 65 | print(' Finesse = %f\n FSR = %f\n FSR/Finesse = %f'%(finesse, fsr, fsr/finesse)) | |
66 | 66 | |||
f0 = (193e12//fsr)*fsr | 67 | 67 | f0 = (193e12//fsr)*fsr | |
f = linspace(f0-0.1*fsr, f0+0.1*fsr, 1e5) | 68 | 68 | f = linspace(f0-0.1*fsr, f0+0.1*fsr, 1e5) | |
69 | 69 | |||
fm = 30e6 | 70 | 70 | fm = 30e6 | |
71 | 71 | |||
#TF of cavity in reflection | 72 | 72 | #TF of cavity in reflection | |
def Fr(w): | 73 | 73 | def Fr(w): | |
s = 1j*w | 74 | 74 | s = 1j*w | |
return r*(exp(-2*tau*s)-1)/(1-r**2*exp(-2*tau*s)) | 75 | 75 | return r*(exp(-2*tau*s)-1)/(1-r**2*exp(-2*tau*s)) | |
76 | 76 | |||
G = Fr(2*pi*f) | 77 | 77 | G = Fr(2*pi*f) | |
Glsb = Fr(2*pi*(f-fm)) | 78 | 78 | Glsb = Fr(2*pi*(f-fm)) | |
Gusb = Fr(2*pi*(f+fm)) | 79 | 79 | Gusb = Fr(2*pi*(f+fm)) | |
80 | 80 | |||
#plot setup | 81 | 81 | #plot setup | |
fig, axarr = plt.subplots(3, 2, sharex='col') | 82 | 82 | fig, axarr = plt.subplots(3, 2, sharex='col') | |
83 | 83 | |||
#plot bode of F(w) | 84 | 84 | #plot bode of F(w) | |
axarr[0, 1].set_ylabel('Magnitude') | 85 | 85 | axarr[0, 1].set_ylabel('Magnitude') | |
#axarr[0, 1].set_xlabel('Frequency (Hz)') | 86 | 86 | #axarr[0, 1].set_xlabel('Frequency (Hz)') | |
axarr[0, 1].plot(f, abs(G)) | 87 | 87 | axarr[0, 1].plot(f, abs(G)) | |
axarr[0, 1].grid() | 88 | 88 | axarr[0, 1].grid() | |
axarr[1, 1].set_ylabel('Phase (deg)') | 89 | 89 | axarr[1, 1].set_ylabel('Phase (deg)') | |
#axarr[1, 1].set_xlabel('Frequency (Hz)') | 90 | 90 | #axarr[1, 1].set_xlabel('Frequency (Hz)') | |
axarr[1, 1].plot(f, angle(G, deg = True)) | 91 | 91 | axarr[1, 1].plot(f, angle(G, deg = True)) | |
axarr[1, 1].grid() | 92 | 92 | axarr[1, 1].grid() | |
93 | 93 | |||
#PDH signal | 94 | 94 | #PDH signal | |
iG = (G*Gusb.conjugate()-G.conjugate()*Glsb).imag | 95 | 95 | iG = (G*Gusb.conjugate()-G.conjugate()*Glsb).imag | |
axarr[2, 1].set_ylabel('epsillon normalized') | 96 | 96 | axarr[2, 1].set_ylabel('epsillon normalized') | |
axarr[2, 1].set_xlabel('Frequency (Hz)') | 97 | 97 | axarr[2, 1].set_xlabel('Frequency (Hz)') | |
axarr[2, 1].xaxis.set_label_coords(0.5, -0.3) | 98 | 98 | axarr[2, 1].xaxis.set_label_coords(0.5, -0.3) | |
axarr[2, 1].plot(f, iG) | 99 | 99 | axarr[2, 1].plot(f, iG) | |
axarr[2, 1].grid() | 100 | 100 | axarr[2, 1].grid() | |
101 | 101 | |||
102 | 102 | |||
#nyquist | 103 | 103 | #nyquist | |
axarr[2, 0].set_ylabel('$j\omega$') | 104 | 104 | axarr[2, 0].set_ylabel('$j\omega$') | |
axarr[2, 0].set_xlabel('$\sigma$') | 105 | 105 | axarr[2, 0].set_xlabel('$\sigma$') | |
axarr[2, 0].plot(real(G), imag(G)) | 106 | 106 | axarr[2, 0].plot(real(G), imag(G)) | |
axarr[2, 0].grid() | 107 | 107 | axarr[2, 0].grid() | |
axarr[2, 0].axis('equal') | 108 | 108 | axarr[2, 0].axis('equal') | |
axarr[2, 0].set_xlim([-1.1, 1.1]) | 109 | 109 | axarr[2, 0].set_xlim([-1.1, 1.1]) | |
110 | 110 | |||
#layout | 111 | 111 | #layout |
tf_cavity/tf_cavity_num_lp.py
File was created | 1 | #!/usr/bin/python | ||
2 | # -*- coding: utf-8 -*- | |||
3 | ||||
4 | '''TF of FP cavity in reflection | |||
5 | ||||
6 | ---------- | |||
7 | X(s) ----- | -tau⋅s | | |||
8 | -------------->|1-R|----->(X)----->|e |------ | |||
9 | | ----- ^ ---------- | | |||
10 | | | | | |||
11 | | | V | |||
12 | ---- ---- ---- | |||
13 | |-R| |-R| |-R| | |||
14 | ---- ---- ---- | |||
15 | | ^ | | |||
16 | | | ---------- | | |||
17 | Y(s) V ----- | | -tau⋅s | | | |||
18 | <-----(X)<-----|1-R|<--------------|e |<----- | |||
19 | ----- ---------- | |||
20 | ||||
21 | ''' | |||
22 | ||||
23 | '''import matplotlib as mpl | |||
24 | mpl.use('pgf') | |||
25 | ||||
26 | def figsize(scale): | |||
27 | fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth | |||
28 | inches_per_pt = 1.0/72.27 # Convert pt to inch | |||
29 | golden_mean = (5.0**0.5-1.0)/2.0 # Aesthetic ratio (you could change this) | |||
30 | fig_width = fig_width_pt*inches_per_pt*scale # width in inches | |||
31 | fig_height = fig_width*golden_mean # height in inches | |||
32 | fig_size = [fig_width,fig_height] | |||
33 | return fig_size | |||
34 | ||||
35 | pgf_with_latex = { # setup matplotlib to use latex for output | |||
36 | "pgf.texsystem": "pdflatex", # change this if using xetex or lautex | |||
37 | "text.usetex": True, # use LaTeX to write all text | |||
38 | "font.family": "serif", | |||
39 | "font.serif": [], # blank entries should cause plots to inherit fonts from the document | |||
40 | "font.sans-serif": [], | |||
41 | "font.monospace": [], | |||
42 | "axes.labelsize": 10, # LaTeX default is 10pt font. | |||
43 | "text.fontsize": 10, | |||
44 | "legend.fontsize": 8, # Make the legend/label fonts a little smaller | |||
45 | "xtick.labelsize": 8, | |||
46 | "ytick.labelsize": 8, | |||
47 | "figure.figsize": figsize(0.9), # default fig size of 0.9 textwidth | |||
48 | "pgf.preamble": [ | |||
49 | r"\usepackage[utf8x]{inputenc}", # use utf8 fonts becasue your computer can handle it :) | |||
50 | r"\usepackage[T1]{fontenc}", # plots will be generated using this preamble | |||
51 | ] | |||
52 | } | |||
53 | mpl.rcParams.update(pgf_with_latex) | |||
54 | ''' | |||
55 | from numpy import * | |||
56 | import matplotlib.pyplot as plt | |||
57 | ||||
58 | r = 0.99998 | |||
59 | L = 140e-3 | |||
60 | c = 299792458 | |||
61 | ||||
62 | tau = L/c | |||
63 | fsr = 1/(2*tau) | |||
64 | finesse = pi*r/(1-r**2) | |||
65 | print(' Finesse = %f\n FSR = %f\n FSR/Finesse = %f'%(finesse, fsr, fsr/finesse)) | |||
66 | ||||
67 | f0 = (193e12//fsr)*fsr | |||
68 | f = linspace(f0-0.1*fsr, f0+0.1*fsr, int(1e5)) | |||
69 | ||||
70 | fm = 30e6 | |||
71 | ||||
72 | ff = linspace(1, 1e6, int(1e5)) | |||
73 | ||||
74 | #TF of cavity in reflection | |||
75 | def Fr(w): | |||
76 | s = 1j*w | |||
77 | return r*(exp(-2*tau*s)-1)/(1-r**2*exp(-2*tau*s)) | |||
78 | ||||
79 | #TF of cavity frequency-to-signal | |||
80 | def Ff2s(w): | |||
81 | s = 1j*w | |||
82 | return (1-exp(-2*tau*s))/(2*tau*s)*(1-r**2)/(1-r**2*exp(-2*tau*s)) | |||
83 | ||||
84 | ||||
85 | G = Fr(2*pi*f) | |||
86 | Glsb = Fr(2*pi*(f-fm)) | |||
87 | Gusb = Fr(2*pi*(f+fm)) | |||
88 | ||||
89 | Gf2s = Ff2s(2*pi*ff) | |||
90 | ||||
91 | #plot setup | |||
92 | fig, axarr = plt.subplots(3, 3, sharex='col') | |||
93 | ||||
94 | #plot bode of F(w) | |||
95 | axarr[0, 1].set_ylabel('Magnitude') | |||
96 | #axarr[0, 1].set_xlabel('Frequency (Hz)') | |||
97 | axarr[0, 1].plot(f, abs(G)) | |||
98 | axarr[0, 1].grid() | |||
99 | axarr[1, 1].set_ylabel('Phase (deg)') | |||
100 | #axarr[1, 1].set_xlabel('Frequency (Hz)') | |||
101 | axarr[1, 1].plot(f, angle(G, deg = True)) | |||
102 | axarr[1, 1].grid() | |||
103 | ||||
104 | #plot bode of Ff2s(w) | |||
105 | axarr[1, 2].set_ylabel('Magnitude') | |||
106 | #axarr[1, 2].set_xlabel('Frequency (Hz)') | |||
107 | axarr[1, 2].set_xscale('log') | |||
108 | axarr[1, 2].plot(ff, 20*log10(abs(Gf2s))) | |||
109 | axarr[1, 2].grid() | |||
110 | axarr[2, 2].set_ylabel('Phase (deg)') | |||
111 | axarr[2, 2].set_xlabel('Frequency (Hz)') | |||
112 | axarr[2, 2].set_xscale('log') | |||
113 | axarr[2, 2].xaxis.set_label_coords(0.5, -0.3) | |||
114 | axarr[2, 2].plot(ff, angle(Gf2s, deg = True)) | |||
115 | axarr[2, 2].grid() | |||
116 | ||||
117 | ||||
118 | #PDH signal | |||
119 | iG = (G*Gusb.conjugate()-G.conjugate()*Glsb).imag | |||
120 | axarr[2, 1].set_ylabel('epsillon normalized') | |||
121 | axarr[2, 1].set_xlabel('Frequency (Hz)') | |||
122 | axarr[2, 1].xaxis.set_label_coords(0.5, -0.3) | |||
123 | axarr[2, 1].plot(f, iG) | |||
124 | axarr[2, 1].grid() | |||
125 | ||||
126 | ||||
127 | #nyquist | |||
128 | axarr[2, 0].set_ylabel('$j\omega$') | |||
129 | axarr[2, 0].set_xlabel('$\sigma$') |