Commit eb8647511df49e30b8b042a1d643271abac512ba
1 parent
07295cdf44
Exists in
master
add LPF behav of the cavity
Showing 2 changed files with 157 additions and 1 deletions Side-by-side Diff
tf_cavity/tf_cavity_num.py
... | ... | @@ -62,7 +62,7 @@ |
62 | 62 | tau = L/c |
63 | 63 | fsr = 1/(2*tau) |
64 | 64 | finesse = pi*r/(1-r**2) |
65 | -print('Finesse = %f\n FSR = %f\n FSR/Finesse = %f'%(finesse, fsr, fsr/finesse)) | |
65 | +print(' Finesse = %f\n FSR = %f\n FSR/Finesse = %f'%(finesse, fsr, fsr/finesse)) | |
66 | 66 | |
67 | 67 | f0 = (193e12//fsr)*fsr |
68 | 68 | f = linspace(f0-0.1*fsr, f0+0.1*fsr, 1e5) |
tf_cavity/tf_cavity_num_lp.py
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$') | |
130 | +axarr[2, 0].plot(real(G), imag(G)) | |
131 | +axarr[2, 0].grid() | |
132 | +axarr[2, 0].axis('equal') | |
133 | +axarr[2, 0].set_xlim([-1.1, 1.1]) | |
134 | + | |
135 | +#layout | |
136 | +axarr[0, 0].axis('off') | |
137 | +axarr[1, 0].axis('off') | |
138 | +axarr[0, 2].axis('off') | |
139 | +fig.subplots_adjust(wspace=0.5) | |
140 | +plt.tight_layout() | |
141 | +#plt.savefig('fig.pgf') | |
142 | +plt.show() | |
143 | + | |
144 | +'''results | |
145 | + | |
146 | + ⎛ -2.0⋅ⅈ⋅L⋅ω ⎞ | |
147 | + ⎜ ───────────⎟ | |
148 | + ⎜ c ⎟ | |
149 | + r⋅⎝-1 + ℯ ⎠ | |
150 | +F(w) = ───────────────────── | |
151 | + -2.0⋅ⅈ⋅L⋅ω | |
152 | + ─────────── | |
153 | + 2 c | |
154 | + - r ⋅ℯ + 1 | |
155 | + | |
156 | +''' |