def optFP(eng, opt_name, par): """Make an Optickle Fabry Perot cavity Inputs: eng: the matlab engine opt_name: name of the optickle model par: parameter dictionary Returns: opt: the model """ fmod = par['Mod']['fmod'] gmod = par['Mod']['gmod'] vRF = np.array([-fmod, 0, fmod]) opt = pyt.Optickle(eng, opt_name, vRF=vRF, lambda0=par['lambda0']) # Make the cavity # In this case it's very simple, but in more complicated models you can # easily loop through all of the optics if you've defined the parameters # in a dictionary mirrors = ['EX', 'IX'] for mirror in mirrors: # add the mirror and set the optic properties opt.addMirror(mirror, **par[mirror]['opt']) # set the mechanical response pmech = par[mirror]['mech'] poles = np.array( resRoots(2 * np.pi * pmech['f0'], pmech['Q'], Hz=False)) opt.setMechTF(mirror, [], poles, 1 / pmech['mass']) opt.addLink('IX', 'fr', 'EX', 'fr', par['Lcav']) opt.addLink('EX', 'fr', 'IX', 'fr', par['Lcav']) opt.setCavityBasis('IX', 'EX') # add input opt.addSource('Laser', np.sqrt(par['Pin']) * (vRF == 0)) opt.addRFmodulator('Mod', fmod, 1j * gmod) opt.addLink('Laser', 'out', 'Mod', 'in', 0) opt.addLink('Mod', 'out', 'IX', 'bk', 0) # add DC and RF photodiodes opt.addSink('REFL') opt.addLink('IX', 'bk', 'REFL', 'in', 0) opt.addReadout('REFL', fmod, 0) return opt
def katFP(par): """Make a Finesse Fabry Perot cavity Inputs: par: parameter dictionary Returns: kat: the model """ fmod = par['Mod']['fmod'] gmod = par['Mod']['gmod'] kat = pykat.finesse.kat() kat.lambda0 = par['lambda0'] # set the laser wavelength # Make the cavity # In this case it's very simple, but in more complicated models you can # easily loop through all of the optics if you've defined the parameters # in a dictionary mirrors = ['EX', 'IX'] for mirror in mirrors: # add the mirror and set the optic properties fin.addMirror(kat, mirror, **par[mirror]['opt']) # set the mechanical response pmech = par[mirror]['mech'] poles = np.array( resRoots(2 * np.pi * pmech['f0'], pmech['Q'], Hz=False)) fin.setMechTF(kat, mirror, [], poles, 1 / pmech['mass']) fin.addSpace(kat, 'IX_fr', 'EX_fr', par['Lcav']) fin.setCavityBasis(kat, 'IX_fr', 'EX_fr') # add input fin.addLaser(kat, 'Laser', par['Pin']) fin.addModulator(kat, 'Mod', fmod, gmod, 1, 'pm') fin.addSpace(kat, 'Laser_out', 'Mod_in', 0) fin.addSpace(kat, 'Mod_out', 'IX_bk', 0) # add DC and RF photodiodes fin.addReadout(kat, 'REFL', 'IX_bk', fmod, 0) return kat
# Define the probes that will be used to sense each DOF. DARM = dict(EX=1 / 2, EY=-1 / 2) CARM = dict(EX=1 / 2, EY=1 / 2) probesDARM = {'AS_Q': 1 / np.abs(katFR.getTF('AS_Q', DARM)[0])} probesCARM = {'REFL_I': 1 / np.abs(katFR.getTF('REFL_I', CARM)[0])} probesBS = {'REFL_Q': 1 / np.abs(katFR.getTF('REFL_Q', 'BS')[0])} ############################################################################## # define control system ############################################################################## # define the DOF filters filtDARM = ctrl.Filter( ctrl.catzp(ctrl.resRoots(2, 1), ctrl.resRoots(5, 1)), ctrl.catzp(0, 0, 0, ctrl.resRoots(0.5, 1), ctrl.resRoots(110, 1)), -1, 20) filtCARM = filtDARM filtBS = ctrl.Filter( ctrl.catzp(ctrl.resRoots(1, 1), ctrl.resRoots(3, 1)), ctrl.catzp(0, 0, 0, ctrl.resRoots(0.3, 1), ctrl.resRoots(90, 1)), -1, 15) # simple constant feedforward filter filtFF = ctrl.Filter([], [], -4.98e-3) # Define control system cs = ctrl.ControlSystem() DARM_dof = ctrl.DegreeOfFreedom(DARM, 'pos', probesDARM, 'DARM')
npts = 100 DARM = dict(EX=1 / 2, EY=-1 / 2) M = 100 Q = 50 f0 = 1 Pin = 50e3 Ti = 0.14 Larm = 4e3 lm = 3 ls = 0.01 lx = lm + ls / 2 ly = lm - ls / 2 fmod = 55e6 gmod = 0.1 poles = np.array(resRoots(f0, Q, Hz=False)) def katFPMI(sqAng, sqdB, rf=True): kat = pykat.finesse.kat() fin.addMirror(kat, 'EX') fin.addMirror(kat, 'EY') fin.addMirror(kat, 'IX', Thr=Ti) fin.addMirror(kat, 'IY', Thr=Ti) fin.addBeamSplitter(kat, 'BS') kat.BS.phi = np.sqrt(2) * 45 Tpo = 1 - 1 / Pin fin.addBeamSplitter(kat, 'LO_PO', Thr=Tpo, aoi=45, comp=True)
class TestFilters: z1 = np.array([1, 2 + 3j, 2 - 3j]) p1 = np.array([8, 3 + 2j, 3 - 2j]) k1 = 4 z2 = [] p2 = ctrl.resRoots(42, 238) k2 = 6 f4 = 10 # reference frequency g4 = 3 # gain at reference frequency ff = np.logspace(0, 4, 500) filt1a = ctrl.Filter(z1, p1, k1) filt1b = ctrl.Filter(-2*np.pi*z1, -2*np.pi*p1, k1, Hz=False) filt1c = ctrl.Filter(dict(zs=z1, ps=p1, k=k1)) filt1d = ctrl.Filter(dict(zs=-2*np.pi*z1, ps=-2*np.pi*p1, k=k1), Hz=False) filt2a = ctrl.Filter(z2, p2, k2) # filt2b = ctrl.Filter( # lambda ss: k2/((ss + 2*np.pi*p2[0])*(ss + 2*np.pi*p2[1]))) filt3a = ctrl.Filter( ctrl.catzp(z1, z2), ctrl.catzp(p1, p2), k1*k2) filt3b = ctrl.catfilt(filt1a, filt2a) filt3c = ctrl.catfilt(filt1b, filt2a) # filt3d = ctrl.catfilt(filt1a, filt2b) filt4 = ctrl.Filter(z2, p2, g4, f4) data1 = h5py.File('test_filters.hdf5', 'w') filt1a.to_hdf5('filt1', data1) filt2a.to_hdf5('filt2', data1) data1.close() data2 = h5py.File('test_filters.hdf5', 'r') filt1r = ctrl.filt_from_hdf5('filt1', data2) filt2r = ctrl.filt_from_hdf5('filt2', data2) data2.close() os.remove('test_filters.hdf5') def test_1a(self): zpk1 = self.filt1a.get_zpk(Hz=True) assert np.all(check_zpk_equality(zpk1, (self.z1, self.p1, self.k1))) def test_1freq(self): zpk1 = self.filt1a.get_zpk(Hz=True) zpk2 = self.filt1b.get_zpk(Hz=True) assert np.all(check_zpk_equality(zpk1, zpk2)) def test_1s(self): zpk1 = self.filt1a.get_zpk() zpk2 = self.filt1b.get_zpk() assert np.all(check_zpk_equality(zpk1, zpk2)) def test_1c(self): zpk1 = self.filt1a.get_zpk() zpk2 = self.filt1c.get_zpk() assert np.all(check_zpk_equality(zpk1, zpk2)) def test_1d(self): zpk1 = self.filt1a.get_zpk() zpk2 = self.filt1d.get_zpk() assert np.all(check_zpk_equality(zpk1, zpk2)) def test_2(self): k2 = self.k2 p2 = self.p2 filt2b = ctrl.Filter( lambda ss: k2/((ss + 2*np.pi*p2[0])*(ss + 2*np.pi*p2[1]))) data1 = self.filt2a.computeFilter(self.ff) # data2 = self.filt2b.computeFilter(self.ff) data2 = filt2b.computeFilter(self.ff) assert close.allclose(data1, data2) def test_cat1(self): assert check_filter_equality(self.filt3a, self.filt3b) def test_cat2(self): assert check_filter_equality(self.filt3a, self.filt3c) def test_cat3(self): k2 = self.k2 p2 = self.p2 filt2b = ctrl.Filter( lambda ss: k2/((ss + 2*np.pi*p2[0])*(ss + 2*np.pi*p2[1]))) filt3d = ctrl.catfilt(self.filt1a, filt2b) data1 = self.filt3a.computeFilter(self.ff) # data2 = self.filt3d.computeFilter(self.ff) data2 = filt3d.computeFilter(self.ff) assert close.allclose(data1, data2) def test_gain(self): mag = np.abs(self.filt4.computeFilter(self.f4)) assert close.isclose(mag, self.g4) def test_ss1(self): ss = self.filt1a.get_state_space() data1 = self.filt1a.computeFilter(self.ff) _, data2 = sig.freqresp(ss, 2*np.pi*self.ff) assert close.allclose(data1, data2) def test_ss2(self): ss = self.filt2a.get_state_space() data1 = self.filt2a.computeFilter(self.ff) _, data2 = sig.freqresp(ss, 2*np.pi*self.ff) assert close.allclose(data1, data2) def test_ss3(self): ss = self.filt3a.get_state_space() data1 = self.filt3a.computeFilter(self.ff) _, data2 = sig.freqresp(ss, 2*np.pi*self.ff) assert close.allclose(data1, data2) def test_1r(self): zpk1 = self.filt1a.get_zpk() zpk2 = self.filt1r.get_zpk() assert np.all(check_zpk_equality(zpk1, zpk2)) def test_2r(self): zpk1 = self.filt2a.get_zpk() zpk2 = self.filt2r.get_zpk() assert np.all(check_zpk_equality(zpk1, zpk2))
fmod = 11e3 gmod = 0.1 Pin = 10e3 Ti = 0.014 Lcav = 40e3 Ri = 34e3 Re = 36e3 gi = 1 - Lcav / Ri ge = 1 - Lcav / Re r = 2 / ((gi - ge) + np.sqrt((gi - ge)**2 + 4)) I = 25 f0 = 1 Q = 100 poles = np.array(ctrl.resRoots(2 * np.pi * f0, Q, Hz=False)) kat = pykat.finesse.kat() # make the cavity fin.addMirror(kat, 'EX', Chr=1 / Re) fin.addMirror(kat, 'IX', Thr=Ti, Chr=1 / Ri) fin.addSpace(kat, 'IX_fr', 'EX_fr', Lcav) fin.setCavityBasis(kat, 'IX_fr', 'EX_fr') # set the pitch response fin.setMechTF(kat, 'EX', [], poles, 1 / I, doftype='pitch') fin.setMechTF(kat, 'IX', [], poles, 1 / I, doftype='pitch') # add input fin.addLaser(kat, 'Laser', Pin)