Commit 2ae5099ce4f9fc7e6ea0edff2924ea1d040acda8

Authored by bmarechal
1 parent 223950810a
Exists in master

first commit

Showing 14 changed files with 927 additions and 0 deletions Side-by-side Diff

  1 +from sympy import *
  2 +from sympy.simplify.fu import *
  3 +
  4 +init_printing()
  5 +
  6 +#constants
  7 +E0, E1, W, t, dphi, kphi = symbols('E0, E1, Omega, t, Delta_phi, k_phi', real=True, imaginary=False)
  8 +
  9 +#define LO and RF
  10 +LO_I = E0*cos(W*t)
  11 +LO_Q = E0*cos(W*t+pi/2)
  12 +RF = E1*cos(W*t+dphi)
  13 +
  14 +#mixer
  15 +IF_I = 2*kphi*LO_I*RF
  16 +IF_I = expand(TR8(IF_I))
  17 +IF_Q = 2*kphi*LO_Q*RF
  18 +IF_Q = expand(TR8(IF_Q))
  1 +#!/usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +'''Pound-Drever-Hall setup
  5 +
  6 + ----- ---
  7 +------------|EOM|------|/|-----( )
  8 + w_laser ----- --- cavity
  9 + ^ |
  10 + | U
  11 + | |
  12 + | v
  13 + |------->(X) π/2
  14 + (w_pdh) |
  15 + -----
  16 + |LPF|
  17 + -----
  18 + |
  19 + v eps_pdh
  20 +
  21 +'''
  22 +
  23 +from time import time
  24 +tic = time()
  25 +
  26 +from sympy import *
  27 +from sympy.simplify.fu import *
  28 +
  29 +init_printing()
  30 +
  31 +#constants
  32 +E0, J0, J1, w_laser, w_pdh, t, c = symbols('E0, J0, J1, omega_laser, Omega_pdh, t, c', imaginary=False, real=True)
  33 +
  34 +'''laser and phase-mod laser
  35 +E_laser = E0*exp(I*(w_laser*t))
  36 +
  37 +E_inc = \
  38 +E0*( \
  39 + J0*exp(I*((w_laser )*t)) \
  40 ++ J1*exp(I*((w_laser+w_pdh)*t)) \
  41 +- J1*exp(I*((w_laser-w_pdh)*t)) \
  42 + )'''
  43 +
  44 +#reflection near resonance
  45 +dnu, w_cav = symbols('delta_nu, omega_cav', imaginary=False, real=True)
  46 +def F(phi):
  47 + dw = phi.diff(t) - w_cav
  48 + return -(I/pi)*(dw/dnu)
  49 +
  50 +#reflected phase-mod laser
  51 +v_x, d_x = symbols('v_x, delta_x', imaginary=False, real=True)
  52 +dx = v_x*t + d_x
  53 +E_ref = \
  54 +E0*( \
  55 + F( (w_laser )*t - w_laser*dx/c ) \
  56 + *J0*exp(I*( (w_laser )*t - 2*w_laser*dx/c ) ) \
  57 ++ -1*J1*exp(I*( (w_laser+w_pdh)*t - 2*w_laser*dx/c ) ) \
  58 +- -1*J1*exp(I*( (w_laser-w_pdh)*t - 2*w_laser*dx/c ) ) \
  59 + )
  60 +
  61 +#intensity of reflected phase-mod laser
  62 +I_pdh = abs(E_ref)**2
  63 +I_pdh = expand(TR8(expand(expand_complex(I_pdh))))
  64 +
  65 +#demodulation of I_pdh at Omega_pdh
  66 +kphipdh = symbols('k_phi_pdh', imaginary=False, real=True)
  67 +eps_pdh = 2 * kphipdh * I_pdh * cos(w_pdh*t-pi/2)
  68 +eps_pdh = expand(TR8(TR7(expand(eps_pdh))))
  69 +
  70 +toc = time()
  71 +print('Elapsed time : %fs'%(toc-tic))
  72 +
  73 +'''low-passed demodulated I_pdh signal
  74 +
  75 +eps_pdh =
  76 + 2 ⎛ ω_laser ⎞
  77 + 4⋅E₀ ⋅J₀⋅J₁⋅k_φ_pdh⋅⎜ω_laser - ω_cav - ───────⋅vₓ⎟
  78 + ⎝ c ⎠
  79 + + ──────────────────────────────────────────────────
  80 + π⋅δ_ν
  81 +'''
PDH_doppler_mach-zender/PDH_doppler_mach-zender_eom_amont.py
  1 +#!/usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +'''Pound-Drever-Hall setup
  5 + Mach-Zender with one photodiode
  6 +
  7 + ----- --- ---
  8 +---------|EOM|-|\|------------|/|-----------( )
  9 + w_laser ----- --- --- cavity
  10 + | |
  11 + | |
  12 + | ----- ---
  13 + \-|AOM|-------|\|
  14 + ----- ---
  15 + ^ |
  16 + | U
  17 + | |
  18 + | V
  19 + |-------->(X)
  20 + | | -----
  21 + (W_aom) |---|LPF|--> eps_dop
  22 + V -----
  23 + (W_pdh)---------->(X)
  24 + |
  25 + |
  26 + V eps_pdh
  27 +
  28 +
  29 +
  30 +'''
  31 +
  32 +from time import time
  33 +tic = time()
  34 +
  35 +from sympy import *
  36 +from sympy.simplify.fu import *
  37 +
  38 +init_printing()
  39 +
  40 +#constants
  41 +E0, J0, J1, w_laser, w_pdh, w_aom, t = symbols('E0, J0, J1, omega_laser, Omega_pdh, Omega_aom, t', imaginary=False, real=True)
  42 +v_x, d_x = symbols('v_x, delta_x', imaginary=False, real=True)
  43 +c = symbols('c', imaginary=False, real=True)
  44 +
  45 +#laser and phase-mod laser
  46 +E_laser = E0*exp(I*(w_laser*t))
  47 +
  48 +E_aom_eom = \
  49 +E0*( \
  50 + J0*exp(I*( ( w_laser+w_aom )*t) ) \
  51 ++ J1*exp(I*( ( w_laser+w_aom+w_pdh )*t) ) \
  52 +- J1*exp(I*( ( w_laser+w_aom-w_pdh )*t) ) )
  53 +
  54 +
  55 +E_eom = \
  56 +E0*( \
  57 + J0*exp(I*( ( w_laser )*t ) ) \
  58 ++ J1*exp(I*( ( w_laser+w_pdh )*t ) ) \
  59 +- J1*exp(I*( ( w_laser-w_pdh )*t ) ) )
  60 +
  61 +#approximation of F(w) near a resonance
  62 +dnu, w_cav = symbols('delta_nu, omega_cav', imaginary=False, real=True)
  63 +def F(phi):
  64 + dw = phi.diff(t) - w_cav
  65 + return -(I/pi)*(dw/dnu)
  66 +
  67 +#reflected phase-mod laser and dephased by doppler effect and by actuator
  68 +dx = v_x*t + d_x
  69 +E_ref = \
  70 +E0*( \
  71 + F( w_laser*t - w_laser*(dx)/(2*pi*c) ) \
  72 + *J0*exp( I*( (w_laser )*t - 2*w_laser*dx/c ) ) \
  73 ++ -1*J1*exp( I*( (w_laser+w_pdh)*t - 2*w_laser*dx/c ) ) \
  74 +- -1*J1*exp( I*( (w_laser-w_pdh)*t - 2*w_laser*dx/c ) ) \
  75 + )
  76 +
  77 +#optical mixer
  78 +E_mz = sqrt(2)/2 * E_aom_eom + sqrt(2)/2 * E_ref
  79 +
  80 +#intensity of mixed wave
  81 +I_mz = abs(E_mz)**2
  82 +I_mz = expand(TR8(expand(expand_complex(I_mz))))
  83 +
  84 +
  85 +#Q demodulation of I_mz at Omega_aom for doppler error signal obtention
  86 +kphidop = symbols('k_phi_doppler', real=True)
  87 +eps_dop = 2 * kphidop * I_mz * cos(w_aom*t-pi/2)
  88 +eps_dop = expand(TR8(TR7(expand(eps_dop))))
  89 +
  90 +#Q demodulation of I_mich at Omega_pdh for doppler error signal obtention
  91 +kphipdh = symbols('k_phi_pdh', real=True)
  92 +eps_pdh = 2 * kphipdh * eps_dop * cos(w_pdh*t)
  93 +eps_pdh = expand(TR8(TR7(expand(eps_pdh))))
  94 +
  95 +toc = time()
  96 +print('Elapsed time : %fs'%(toc-tic))
  97 +
  98 +'''results
  99 +
  100 +### EOM sur un bras
  101 +
  102 +eps_pdh =
  103 +
  104 +0
  105 +
  106 +eps_dop =
  107 +
  108 + 2 ⎛ ω_laser⋅vₓ⎞ ⎛2⋅δₓ⋅ω_laser 2⋅ω_laser⋅t⋅vₓ⎞
  109 + E₀ ⋅J₀ ⋅k_φ_doppler⋅⎜ω_laser - ω_cav - ──────────⎟⋅cos⎜──────────── + ──────────────⎟
  110 + ⎝ c ⎠ ⎝ c c ⎠
  111 +- ─────────────────────────────────────────────────────────────────────────────────────
  112 + π⋅δ_ν
  113 +
  114 + 2 2 ⎛ δₓ⋅ω_laser ω_laser⋅t⋅vₓ⎞
  115 ++ 2⋅E₀ ⋅J₁ ⋅k_φ_doppler⋅sin⎜2⋅────────── + 2⋅────────────⎟
  116 + ⎝ c c ⎠
  117 +
  118 +'''
PDH_doppler_mach-zender/PDH_doppler_mach-zender_eom_arm.py
  1 +#!/usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +'''Pound-Drever-Hall setup
  5 + Mach-Zender with one photodiode
  6 +
  7 + --- ----- ---
  8 +----------|\|---|EOM|---------|/|-----------( )
  9 + w_laser --- ----- --- cavity
  10 + | |
  11 + | |
  12 + | ----- ---
  13 + \----|AOM|---------|\|
  14 + ----- ---
  15 + ^ |
  16 + | U
  17 + | |
  18 + | V
  19 + |---------->(X)
  20 + | | -----
  21 + (W_aom) |---|LPF|--> eps_dop
  22 + V -----
  23 + (W_pdh)---------->(X)
  24 + |
  25 + |
  26 + V eps_pdh
  27 +
  28 +
  29 +
  30 +'''
  31 +
  32 +from time import time
  33 +tic = time()
  34 +
  35 +from sympy import *
  36 +from sympy.simplify.fu import *
  37 +
  38 +init_printing()
  39 +
  40 +#constants
  41 +E0, J0, J1, w_laser, w_pdh, w_aom, t = symbols('E0, J0, J1, omega_laser, Omega_pdh, Omega_aom, t', imaginary=False, real=True)
  42 +v_x, d_x = symbols('v_x, delta_x', imaginary=False, real=True)
  43 +c = symbols('c', imaginary=False, real=True)
  44 +
  45 +#laser and phase-mod laser
  46 +E_laser = E0*exp(I*(w_laser*t))
  47 +
  48 +E_aom = E0*exp(I*((w_laser+w_aom)*t))
  49 +
  50 +E_eom = \
  51 +E0*( \
  52 + J0*exp(I*( ( w_laser )*t ) ) \
  53 ++ J1*exp(I*( ( w_laser+w_pdh)*t ) ) \
  54 +- J1*exp(I*( ( w_laser-w_pdh)*t ) ) )
  55 +
  56 +#approximation of F(w) near a resonance
  57 +dnu, w_cav = symbols('delta_nu, omega_cav', imaginary=False, real=True)
  58 +def F(phi):
  59 + dw = phi.diff(t) - w_cav
  60 + return -(I/pi)*(dw/dnu)
  61 +
  62 +#reflected phase-mod laser and dephased by doppler effect and by actuator
  63 +dx = v_x*t + d_x
  64 +E_ref = \
  65 +E0*( \
  66 + F( w_laser *t - w_laser*dx/c ) \
  67 + *J0*exp( I*( w_laser *t - 2*w_laser*dx/c ) ) \
  68 ++ -1*J1*exp( I*( (w_laser+w_pdh)*t - 2*w_laser*dx/c ) ) \
  69 +- -1*J1*exp( I*( (w_laser-w_pdh)*t - 2*w_laser*dx/c ) ) \
  70 + )
  71 +
  72 +#optical mixer
  73 +E_mz = sqrt(2)/2 * E_aom + sqrt(2)/2 * E_ref
  74 +
  75 +#intensity of mixed wave
  76 +I_mz = abs(E_mz)**2
  77 +I_mz = expand(TR8(expand(expand_complex(I_mz))))
  78 +
  79 +
  80 +#Q demodulation of I_mz at Omega_aom for doppler error signal obtention
  81 +kphidop = symbols('k_phi_doppler', real=True)
  82 +eps_dop = 2 * kphidop * I_mz * cos(w_aom*t-pi/2)
  83 +eps_dop = expand(TR8(TR7(expand(eps_dop))))
  84 +
  85 +#Q demodulation of I_mich at Omega_pdh for doppler error signal obtention
  86 +kphipdh = symbols('k_phi_pdh', real=True)
  87 +eps_pdh = 2 * kphipdh * eps_dop * cos(w_pdh*t)
  88 +eps_pdh = expand(TR8(TR7(expand(eps_pdh))))
  89 +
  90 +toc = time()
  91 +print('Elapsed time : %fs'%(toc-tic))
  92 +
  93 +'''results
  94 +
  95 +### EOM sur un bras
  96 +
  97 +eps_pdh =
  98 +0
  99 +
  100 +eps_dop =
  101 + 2 ⎛ ω_laser⋅vₓ⎞ ⎛2⋅δₓ⋅ω_laser 2⋅ω_laser⋅t⋅vₓ⎞
  102 + E₀ ⋅J₀ ⋅k_φ_doppler⋅⎜ω_laser - ω_cav - ──────────⎟⋅cos⎜──────────── + ──────────────⎟
  103 + ⎝ c ⎠ ⎝ c c ⎠
  104 +- ─────────────────────────────────────────────────────────────────────────────────────
  105 + π⋅δ_ν
  106 +'''
PDH_doppler_michelson/PDH_doppler_michelson_with_pzt.py
  1 +#!/usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +'''Pound-Drever-Hall setup
  5 + Michelson with piezo actuator in cavity arm and AOM in reference arm
  6 +
  7 + -----
  8 + (2*W_aom)-->(X)---|LPF|--->
  9 + | ----- eps_dop
  10 + O
  11 + |
  12 + ----- --- ---
  13 +------------|EOM|---|\|---|/|-----------( )
  14 + w_laser ----- --- --- cavity
  15 + ^ | |
  16 + | ----- U
  17 + | |AOM| |
  18 + | ----- |
  19 + | _|_ |
  20 + | //// |
  21 + | v
  22 + |---------->(X)
  23 + (W_pdh) |
  24 + -----
  25 + |LPF|
  26 + -----
  27 + |
  28 + v eps_pdh
  29 +
  30 +'''
  31 +
  32 +from time import time
  33 +tic = time()
  34 +
  35 +from sympy import *
  36 +from sympy.simplify.fu import *
  37 +
  38 +init_printing()
  39 +
  40 +#constants
  41 +E0, J0, J1, w_laser, w_pdh, w_aom, t, c = symbols('E0, J0, J1, omega_laser, Omega_pdh, Omega_aom, t, c', imaginary=False, real=True)
  42 +
  43 +'''#laser and phase-mod laser
  44 +E_laser = E0*exp(I*(w_laser*t))
  45 +
  46 +E_eom = \
  47 +E0*( \
  48 + J0*exp(I*(w_laser*t)) \
  49 ++ J1*exp(I*((w_laser+w_pdh)*t)) \
  50 +- J1*exp(I*((w_laser-w_pdh)*t)) \
  51 + )'''
  52 +
  53 +#aom double shifted phase-mod wave in reference arm
  54 +E_aom = \
  55 +E0*( \
  56 + J0*exp(I*((w_laser +2*w_aom)*t)) \
  57 ++ J1*exp(I*((w_laser+w_pdh+2*w_aom)*t)) \
  58 +- J1*exp(I*((w_laser-w_pdh+2*w_aom)*t)) \
  59 + )
  60 +
  61 +#approximation of F(w) near a resonance
  62 +dnu, w_cav = symbols('delta_nu, omega_cav', imaginary=False, real=True)
  63 +def F(phi):
  64 + dw = phi.diff(t) - w_cav
  65 + return -(I/pi)*(dw/dnu)
  66 +
  67 +#reflected phase-mod laser and dephased by doppler effect
  68 +v_x, d_x, v_u, d_u = symbols('v_x, delta_x, v_u, delta_u', imaginary=False, real=True)
  69 +dx = v_x*t + d_x
  70 +du = v_u*t + d_u
  71 +E_ref = \
  72 +E0*( \
  73 + F( w_laser *t - (dx+du)*(w_laser)/c ) \
  74 + *J0*exp( I*( w_laser *t - 2*(dx+du)*(w_laser)/c ) ) \
  75 ++ -1*J1*exp( I*( (w_laser+w_pdh)*t - 2*(dx+du)*(w_laser)/c ) ) \
  76 +- -1*J1*exp( I*( (w_laser-w_pdh)*t - 2*(dx+du)*(w_laser)/c ) ) \
  77 + )
  78 +
  79 +#intensity of reflected wave
  80 +I_pdh = abs(E_ref)**2
  81 +I_pdh = expand(TR8(expand(expand_complex(I_pdh))))
  82 +
  83 +#optical mixer
  84 +E_mich = sqrt(2)/2 * E_aom + sqrt(2)/2 * E_ref
  85 +
  86 +#intensity of mixed wave
  87 +I_mich = abs(E_mich)**2
  88 +I_mich = expand(TR8(expand(expand_complex(I_mich))))
  89 +
  90 +#Q demodulation of I_pdh at Omega_pdh for PDH error signal obtention
  91 +kphipdh = symbols('k_phi_pdh', real=True)
  92 +eps_pdh = 2 * kphipdh * I_pdh * cos(w_pdh*t-pi/2)
  93 +eps_pdh = expand(TR8(TR7(expand(eps_pdh))))
  94 +
  95 +#Q demodulation of I_mich at 2*Omega_aom for doppler error signal obtention
  96 +kphidop = symbols('k_phi_doppler', real=True)
  97 +eps_dop = 2 * kphidop * I_mich * cos(2*w_aom*t-pi/2)
  98 +eps_dop = expand(TR8(TR7(expand(eps_dop))))
  99 +
  100 +toc = time()
  101 +print('Elapsed time : %fs'%(toc-tic))
  102 +
  103 +'''results
  104 +
  105 +eps_pdh =
  106 + 2 ⎛ ω_laser ⎞
  107 + 4⋅E₀ ⋅J₀⋅J₁⋅k_φ_pdh⋅⎜ω_laser - ω_cav - ───────⋅(vₓ+vᵤ)⎟
  108 + ⎝ c ⎠
  109 + + ───────────────────────────────────────────────────────
  110 + π⋅δ_ν
  111 +
  112 +eps_dop =
  113 + 2 2 ⎛ ω_laser ⎞ ⎛2⋅[(δₓ+t⋅vₓ)+(δᵤ+t⋅vᵤ)]⋅ω_laser⎞
  114 + E₀ ⋅J₀ ⋅k_φ_doppler⋅⎜ω_laser - ω_cav - ───────⋅(vₓ+vᵤ)⎟⋅cos⎜───────────────────────────────⎟
  115 + ⎝ c ⎠ ⎝ c ⎠
  116 +- ────────────────────────────────────────────────────────────────────────────────────────────
  117 + π⋅δ_ν
  118 +
  119 + 2 2 ⎛2⋅[(δₓ+t⋅vₓ)+(δᵤ+t⋅vᵤ)]⋅ω_laser⎞
  120 ++ 2⋅E₀ ⋅J₁ ⋅k_φ_doppler⋅sin⎜───────────────────────────────⎟
  121 + ⎝ c ⎠
  122 +'''
PDH_doppler_michelson/PDH_doppler_michelson_without_pzt.py
  1 +#!/usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +'''Pound-Drever-Hall setup
  5 + Michelson with piezo actuator and AOM in cavity arm
  6 +
  7 + -----
  8 + (2*W_aom)-->(X)---|LPF|--->
  9 + | ----- eps_dop
  10 + O
  11 + |
  12 + ----- --- --- -----
  13 +------------|EOM|---|\|---|/|---|AOM|---( )
  14 + w_laser ----- --- --- ----- cavity
  15 + ^ | |
  16 + | | U
  17 + | | |
  18 + | | |
  19 + | _|_ |
  20 + | //// |
  21 + | v
  22 + |---------->(X)
  23 + (W_pdh) |
  24 + -----
  25 + |LPF|
  26 + -----
  27 + |
  28 + v eps_pdh
  29 +
  30 +'''
  31 +
  32 +from time import time
  33 +tic = time()
  34 +
  35 +from sympy import *
  36 +from sympy.simplify.fu import *
  37 +
  38 +init_printing()
  39 +
  40 +#constants
  41 +E0, J0, J1, w_laser, w_pdh, t = symbols('E0, J0, J1, omega_laser, Omega_pdh, t', imaginary=False, real=True)
  42 +v_x, d_x, c = symbols('v_x, delta_x, c', imaginary=False, real=True)
  43 +w_aom, dw, dphi = symbols('Omega_aom, delta_Omega, delta_phi', imaginary=False, real=True)
  44 +
  45 +phi_u = dw*t #+ dphi
  46 +phi = w_aom*t + phi_u
  47 +
  48 +'''#
  49 +#laser
  50 +E_laser = E0*exp(I*(w_laser*t))
  51 +'''
  52 +
  53 +#phase-mod laser
  54 +E_eom = \
  55 +E0*( \
  56 + J0*exp(I*((w_laser )*t)) \
  57 ++ J1*exp(I*((w_laser+w_pdh)*t)) \
  58 +- J1*exp(I*((w_laser-w_pdh)*t)) \
  59 + )
  60 +
  61 +#approximation of F(w) near a resonance
  62 +dnu, w_cav = symbols('delta_nu, omega_cav', imaginary=False, real=True)
  63 +def F(phi):
  64 + dw = phi.diff(t) - w_cav
  65 + return -(I/pi)*(dw/dnu)
  66 +
  67 +#reflected phase-mod laser and dephased by doppler effect with double aom shift
  68 +dx = v_x*t + d_x
  69 +E_ref = \
  70 +E0*( \
  71 + F( (w_laser )*t - dx*(w_laser+phi.diff(t))/c + phi ) \
  72 + * J0*exp( I*( (w_laser )*t - 2*dx*(w_laser+phi.diff(t))/c + 2*phi ) ) \
  73 ++ -1*J1*exp( I*( (w_laser+w_pdh)*t - 2*dx*(w_laser+phi.diff(t))/c + 2*phi ) ) \
  74 +- -1*J1*exp( I*( (w_laser-w_pdh)*t - 2*dx*(w_laser+phi.diff(t))/c + 2*phi ) ) \
  75 + )
  76 +
  77 +#intensity of reflected wave
  78 +I_pdh = abs(E_ref)**2
  79 +I_pdh = expand(TR8(expand(expand_complex(I_pdh))))
  80 +
  81 +#optical mixer
  82 +E_mich = sqrt(2)/2 * E_eom + sqrt(2)/2 * E_ref
  83 +
  84 +#intensity of mixed wave
  85 +I_mich = abs(E_mich)**2
  86 +I_mich = expand(TR8(expand(expand_complex(I_mich))))
  87 +
  88 +#Q demodulation of I_pdh at Omega_pdh for PDH error signal obtention
  89 +kphipdh = symbols('k_phi_pdh', real=True)
  90 +eps_pdh = 2 * kphipdh * I_pdh * cos(w_pdh*t-pi/2)
  91 +eps_pdh = expand(TR8(TR7(expand(eps_pdh))))
  92 +
  93 +#Q demodulation of I_mich at 2*Omega_aom for doppler error signal obtention
  94 +kphidop = symbols('k_phi_doppler', real=True)
  95 +eps_dop = 2 * kphidop * I_mich * cos(2*w_aom*t-pi/2)
  96 +#eps_dop = 2 * kphidop * I_mich * cos(2*phi.diff(t)*t-pi/2)
  97 +eps_dop = expand(TR8(TR7(expand(eps_dop))))
  98 +
  99 +toc = time()
  100 +print('Elapsed time : %fs'%(toc-tic))
  101 +
  102 +'''results
  103 +
  104 +eps_pdh =
  105 + 2 ⎛ ω_laser + Ω_aom + δ_Ω ⎞
  106 + 4⋅E₀ ⋅J₀⋅J₁⋅k_φ_pdh⋅⎜ω_laser + Ω_aom - ω_cav + δ_Ω - ─────────────────────⋅vₓ⎟
  107 + ⎝ c ⎠
  108 + + ──────────────────────────────────────────────────────────────────────────────
  109 + π⋅δ_ν
  110 +
  111 +eps_dop =
  112 + 2 2 ⎛ ω_laser + Ω_aom + δ_Ω ⎞ ⎛ 2⋅(ω_laser + Ω_aom + δ_Ω)⋅(vₓ⋅t+δₓ)⎞
  113 + E₀ ⋅J₀ ⋅k_φ_dop⋅⎜ω_laser + Ω_aom - ω_cav + δ_Ω - ─────────────────────⋅vₓ⎟⋅cos⎜2⋅δ_Ω⋅t - ───────────────────────────────────⎟
  114 + ⎝ c ⎠ ⎝ c ⎠
  115 + ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  116 + π⋅δ_ν
  117 +
  118 + 2 2 ⎛ 2⋅(ω_laser + Ω_aom + δ_Ω)⋅(vₓ⋅t+δₓ)⎞
  119 ++ 2⋅E₀ ⋅J₁ ⋅k_φ_dop⋅sin⎜2⋅δ_Ω⋅t - ───────────────────────────────────⎟
  120 + ⎝ c ⎠
  121 +'''
PDH_doppler_michelson/PDH_doppler_michelson_without_pzt_eom.py
  1 +#!/usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +'''pseudo Pound-Drever-Hall setup
  5 +
  6 + -----
  7 + (2*W_aom)-->(X)---|LPF|--->
  8 + | ----- eps
  9 + O
  10 + |
  11 + ---
  12 +--------------------|\|-----------------( )
  13 + w_laser --- cavity
  14 + |
  15 + -----
  16 + |AOM|
  17 + -----
  18 + _|_
  19 + ////
  20 +
  21 +'''
  22 +
  23 +from time import time
  24 +tic = time()
  25 +
  26 +from sympy import *
  27 +from sympy.simplify.fu import *
  28 +
  29 +init_printing()
  30 +
  31 +#constants
  32 +E0, J0, J1, w_laser, w_pdh, t = symbols('E0, J0, J1, omega_laser, Omega_pdh, t', imaginary=False, real=True)
  33 +v_x, d_x, c = symbols('v_x, delta_x, c', imaginary=False, real=True)
  34 +w_aom = symbols('Omega_aom', imaginary=False, real=True)
  35 +
  36 +#laser and phase-mod laser
  37 +E_laser = E0*exp(I*(w_laser*t))
  38 +
  39 +#aom shifted phase-mod wave
  40 +E_aom = \
  41 + E0*exp(I*((w_laser+2*w_aom)*t))
  42 +
  43 +#approximation of F(w) near a resonance
  44 +dnu, w_cav = symbols('delta_nu, omega_cav', imaginary=False, real=True)
  45 +def F(phi):
  46 + dw = phi.diff(t) - w_cav
  47 + return -(I/pi)*(dw/dnu)
  48 +
  49 +#reflected phase-mod laser and dephased by doppler effect with double aom shift
  50 +dx = v_x*t + d_x
  51 +E_ref = \
  52 + F( (w_laser)*t - (w_laser)*(dx)/(2*pi*c) ) * E0*exp( I*( (w_laser)*t - (w_laser)*(2*dx)/c ) )
  53 +
  54 +#optical mixer
  55 +E_mich = sqrt(2)/2 * E_aom + sqrt(2)/2 * E_ref
  56 +
  57 +#intensity of mixed wave
  58 +I_mich = abs(E_mich)**2
  59 +I_mich = expand(TR8(expand(expand_complex(I_mich))))
  60 +
  61 +#Q demodulation of I_mich at 2*Omega_aom for doppler error signal obtention
  62 +kphi = symbols('k_phi', real=True)
  63 +eps = 2 * kphi * I_mich * cos(2*w_aom*t-pi/2)
  64 +eps = expand(TR8(TR7(expand(eps))))
  65 +
  66 +toc = time()
  67 +print('Elapsed time : %fs'%(toc-tic))
  68 +
  69 +'''results
  70 +
  71 +eps =
  72 +
  73 + 2 ⎛ ω_laser ⎞ ⎛2⋅δₓ⋅ω_laser 2⋅ω_laser⋅t⋅vₓ⎞
  74 + 2⋅E₀ ⋅J₀⋅J₁⋅k_φ_pdh⋅⎜ω_laser - ω_cav - ───────⋅vₓ⎟⋅cos⎜──────────── + ──────────────⎟
  75 + ⎝ c ⎠ ⎝ c c ⎠
  76 + - ─────────────────────────────────────────────────────────────────────────────────────
  77 + π⋅δ_ν
  78 +
  79 +'''
compensated_link/compensated_link.py
  1 +from sympy import *
  2 +from sympy.simplify.fu import *
  3 +
  4 +init_printing()
  5 +
  6 +#constants
  7 +E0, w_laser, W_aom, t = symbols('E0, omega_laser, Omega_aom, t', real=True, imaginary=False)
  8 +dphi, dW = symbols('Delta_phi, Delta_Omega', real=True, imaginary=False)
  9 +c, dx = symbols('c, Delta_x', real=True, imaginary=False)
  10 +
  11 +phi_u = dW*t + dphi
  12 +phi = W_aom*t + phi_u
  13 +
  14 +#laser
  15 +E_laser = E0*exp(I*(w_laser*t))
  16 +
  17 +#reflected wave and dephased by doppler and noise and double shifted
  18 +E_aom_ref = E0*exp(I*( w_laser*t + 2*dx*(w_laser+phi.diff(t))/c + 2*phi ))
  19 +
  20 +#reflected wave on the reference arm of michelson
  21 +E_ref = E_laser
  22 +
  23 +#optical mixer
  24 +E_mix = sqrt(2)/2*E_ref + sqrt(2)/2*E_aom_ref
  25 +
  26 +#intensity of mixed waves
  27 +I_mix = abs(E_mix)**2
  28 +I_mix = expand(TR8(expand(expand_complex(I_mix))))
  29 +
  30 +#Q demodulation
  31 +kphi = symbols('k_phi', real=True, imaginary=False)
  32 +#eps = 2 * kphi * I_mix * cos(2*phi.diff(t)*t-pi/2)
  33 +eps = 2 * kphi * I_mix * cos(2*W_aom*t-pi/2)
  34 +eps = expand(TR8(TR7(expand(eps))))
  1 +from sympy import *
  2 +from sympy.simplify.fu import *
  3 +
  4 +init_printing()
  5 +
  6 +#constants
  7 +A, B, w, t, kphi, c = symbols('A, B, omega, t, k_phi, c', imaginary=False, real=True)
  8 +dx = symbols('delta_x', cls=Function)
  9 +#wave vector
  10 +k = w/c
  11 +
  12 +#reflected wave
  13 +E1 = A*cos(w*t-2*k*dx(t))
  14 +
  15 +#demodulation of E1 at omega in quadrature
  16 +E2 = B*cos(w*t-pi/2)
  17 +Vmix = 2 * kphi * E1 * E2
  18 +Vmix = expand(TR8(TR7(expand(Vmix))))
  19 +print('V_mixer = \n' + pretty(Vmix))
mich_psd_calculations/calc.py
  1 +from numpy import log, log10, pi
  2 +
  3 +#constants
  4 +c = 3E8
  5 +nu = c/1542E-9
  6 +f = 1
  7 +
  8 +#allan deviation aimed
  9 +sigma_y = 1E-17
  10 +
  11 +#PSD of frequency fluctuations (frequency flicker) in dB.Hz^-1
  12 +Sy = 10*log10(sigma_y**2/(2*log(2)))
  13 +
  14 +#PSD of phase fluctuations in dB.rad^2.Hz^-1
  15 +Sphi = Sy + 20*log10(nu) - 20*log10(f)
  16 +
  17 +#PSD of time delay fluctuations in dB.s^2.Hz^-1
  18 +Sx = Sphi - 20*log10(2*pi*nu)
  19 +
  20 +#PSD of position fluctuations in dB.m^2.Hz^-1
  21 +Su = Sphi + 20*log10(c) - 20*log10(2*pi*nu) -20*log10(2)
michelson_w_AOM/michelson_w_AOM.py
  1 +from sympy import *
  2 +from sympy.simplify.fu import *
  3 +
  4 +init_printing()
  5 +
  6 +#constants
  7 +E0, E1, w, W, t, dphi, kphi = symbols('E0, E1, omega, Omega, t, Delta_phi, k_phi', real=True, imaginary=False)
  8 +dx, du, c = symbols('Delta_x, Delta_u, c', real=True, imaginary=False)
  9 +
  10 +#reference wave
  11 +Eb0 = E0*exp(I*(w*t))
  12 +
  13 +#double Omega shifted and dphi dephased wave
  14 +Eb1 = E1*exp(I*((w+2*W)*t -2*w*(dx+2*du)/c))
  15 +
  16 +#optical mixer
  17 +Emix = sqrt(2)/2 * Eb0 + sqrt(2)/2 * Eb1
  18 +
  19 +#intensity of mixed waves
  20 +Imix = simplify(expand_complex(abs(Emix)**2))
  21 +
  22 +#demodulation Q at 2 * Omega
  23 +Vmix = 2 * kphi * Imix * cos(2*W*t-pi/2)
  24 +Vmix = expand(TR8(TR7(expand(Vmix))))
  25 +print(pretty(Vmix))
  1 +from sympy import *
  2 +from sympy.simplify.fu import *
  3 +
  4 +init_printing()
  5 +
  6 +A, B, w, t, dphi = symbols('A, B, omega, t, Delta_phi', real=True, imaginary=False)
  7 +
  8 +#polynimial approach of RF mixer
  9 +k1, k2, k3 = symbols('k1, k2, k3', real=True, imaginary=False)
  10 +e = A*cos(w*t) + B*cos(w*t+dphi-pi/2)
  11 +Vmix_poly = k1*e + k2*e**2
  12 +Vmix_poly = expand(TR8(TR7(expand(Vmix_poly))))
  13 +
  14 +print('Polynomial result :\n' + pretty(Vmix_poly) + '\n')
  15 +
  16 +#product approach of RF mixer
  17 +kphi = symbols('k_phi', real=True, imaginary=False)
  18 +Vmix_prod = 2 * kphi * A*cos(w*t) * B*cos(w*t+dphi-pi/2)
  19 +Vmix_prod = expand(TR8(TR7(expand(Vmix_prod))))
  20 +print('Product result :\n' + pretty(Vmix_prod))
tf_cavity/tf_cavity.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 +from sympy import *
  24 +
  25 +init_printing()
  26 +
  27 +w, r, L, c = symbols('omega, r, L, c', imaginary=False, real=True)
  28 +
  29 +tau = L/c
  30 +fsr = 1/(2*tau)
  31 +
  32 +#TF of cavity in reflection
  33 +def Fr(w):
  34 + s = 1j*w
  35 + return r*(exp(-2*tau*s)-1)/(1-r**2*exp(-2*tau*s))
  36 +
  37 +dw = symbols('dw', imaginary=False, real=True)
  38 +Fr_dw_0 = simplify(simplify(Fr(2*pi*fsr+dw).series(dw, 0, 2).expand().coeff(dw))*dw)
  39 +
  40 +'''results
  41 +
  42 + ⎛ -2.0⋅ⅈ⋅L⋅ω ⎞
  43 + ⎜ ───────────⎟
  44 + ⎜ c ⎟
  45 + r⋅⎝-1 + ℯ ⎠
  46 +F(w) = ─────────────────────
  47 + -2.0⋅ⅈ⋅L⋅ω
  48 + ───────────
  49 + 2 c
  50 + - r ⋅ℯ + 1
  51 +
  52 +'''
tf_cavity/tf_cavity_num.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.99
  59 +L = 140e-3
  60 +c = 299792458
  61 +
  62 +tau = L/c
  63 +fsr = 1/(2*tau)
  64 +
  65 +f0 = (193e12//fsr)*fsr
  66 +f = linspace(f0-0.1*fsr, f0+0.1*fsr, 1e5)
  67 +
  68 +#TF of cavity in reflection
  69 +def Fr(w):
  70 + s = 1j*w
  71 + return r*(exp(-2*tau*s)-1)/(1-r**2*exp(-2*tau*s))
  72 +
  73 +G = Fr(2*pi*f)
  74 +
  75 +#plot bode of F(w)
  76 +ax1 = plt.subplot(3, 1, 1)
  77 +ax1.set_ylabel('Magnitude')
  78 +ax1.plot(f, abs(G))
  79 +ax1.grid()
  80 +
  81 +ax2 = plt.subplot(3, 1, 2, sharex = ax1)
  82 +ax2.set_ylabel('Phase (deg)')
  83 +ax2.set_xlabel('omega (rad.s$^{-1}$)')
  84 +ax2.plot(f, angle(G, deg = True))
  85 +ax2.grid()
  86 +
  87 +
  88 +#nyquist
  89 +ax3 = plt.subplot(3, 1, 3)
  90 +ax3.set_ylabel('$j\omega$')
  91 +ax3.set_xlabel('$\sigma$')
  92 +ax3.plot(real(G), imag(G))
  93 +ax3.grid()
  94 +ax3.axis('equal')
  95 +
  96 +#plt.savefig('fig.pgf')
  97 +plt.show()
  98 +
  99 +'''results
  100 +
  101 + ⎛ -2.0⋅ⅈ⋅L⋅ω ⎞
  102 + ⎜ ───────────⎟
  103 + ⎜ c ⎟
  104 + r⋅⎝-1 + ℯ ⎠
  105 +F(w) = ─────────────────────
  106 + -2.0⋅ⅈ⋅L⋅ω
  107 + ───────────
  108 + 2 c
  109 + - r ⋅ℯ + 1
  110 +
  111 +'''