% Optickle input file for Advanced Virgo 

function opt = adVirgo3

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % PARAMETERS
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  % input power
  Pin = 100;
  
  % modulation frequencies
  fMod1 = 175548765.3;
  fMod2 = 112852777.7;
  fMod3 = 168234233.5;
  
  % Lengths
  Lcav  = 3000.0821;
  Lprc  =   11.954;
  Delta =    0.8543;
  Lsrc  =   11.954;
  Lprbs =    5.884;
  
  % Mechanics
  w = 2 * pi * 0.6;      % pendulum resonance frequency
  mI = 40;               % mass of input mirror
  mE = 40;               % mass of end mirror
  mPRM = 30;
  mSRM = 30;
  mBS  = 20;
  dampRes = [0.001 + 1i, 0.001 - 1i];
  
  % mirror parameters
  tIMX = 0.005;
  tEMX = 10e-6;
  tIMY = 0.005;
  tEMY = 10e-6;
  tPRM = 0.07;
  tSRM = 0.07;
  tBS  = 0.5;
  
  rarBS  = 100e-6;
  rarIMX = 100e-6;
  rarIMY = 100e-6;
  
  lIMX = 40e-6;
  lEMX = 50e-6;
  lIMY = 40e-6;
  lEMY = 50e-6;
  lPRM = 50e-6;
  lSRM = 50e-6;
  lBS  = 50e-6;
  
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % create model
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  vFrf = [-fMod2, -fMod3, -fMod1, 0, fMod1, fMod3, fMod2];
  opt = Optickle(vFrf);
  
  % laser source (no IMC)
  opt = addSource(opt, 'Laser', sqrt(Pin) * (vFrf == 0));
  
  % Modulators
  gamma = 0.1;
  opt = addRFmodulator(opt, 'Mod1', fMod1, i * gamma);
  opt = addRFmodulator(opt, 'Mod2', fMod2, i * gamma);
  opt = addRFmodulator(opt, 'Mod3', fMod3, i * gamma);
  
  opt = addLink(opt, 'Laser', 'out', 'Mod1', 'in', 0.1);
  opt = addLink(opt, 'Mod1',  'out', 'Mod2', 'in', 0.1);
  opt = addLink(opt, 'Mod2',  'out', 'Mod3', 'in', 0.1);
  
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%% X cavity
  
  % input mirror with pick-off port
  opt = addBeamSplitter(opt, 'IMX_AR', 1, 0, 1-rarIMX, 0, 0);
  %                          angle, 1/Rcurv, THR,  LHR
  opt = addMirror(opt, 'IMX', 0,    1/1910, tIMX, lIMX);
  %                          angle, 1/Rcurv, THR,  LHR
  opt = addMirror(opt, 'EMX', 0,    1/1910, tEMX, lEMX);

  opt = addLink(opt, 'IMX_AR', 'bkA', 'IMX', 'bk', 0);
  opt = addLink(opt, 'IMX', 'bk', 'IMX_AR', 'bkB', 0);
  
  opt = addLink(opt, 'IMX', 'fr', 'EMX', 'fr', Lcav);
  opt = addLink(opt, 'EMX', 'fr', 'IMX', 'fr', Lcav);
  opt = setCavityBasis(opt, 'IMX', 'EMX');
  
  
  opt = setMechTF(opt, 'IMX', zpk([], -w * dampRes, 1 / mI));
  opt = setMechTF(opt, 'EMX', zpk([], -w * dampRes, 1 / mE));

  %%%%%%%%%%%%%%%%%%%%%%%%%%% Y cavity
  % input mirror with pick-off port
  opt = addBeamSplitter(opt, 'IMY_AR', 1, 0, 1-rarIMY, 0, 0);
  %                          angle, 1/Rcurv, THR,  LHR
  opt = addMirror(opt, 'IMY', 0,    1/1910, tIMY, lIMY);
  %                          angle, 1/Rcurv, THR,  LHR
  opt = addMirror(opt, 'EMY', 0,    1/1910, tEMY, lEMY);

  opt = addLink(opt, 'IMY_AR', 'bkA', 'IMY', 'bk', 0);
  opt = addLink(opt, 'IMY', 'bk', 'IMY_AR', 'bkB', 0);
  
  opt = addLink(opt, 'IMY', 'fr', 'EMY', 'fr', Lcav);
  opt = addLink(opt, 'EMY', 'fr', 'IMY', 'fr', Lcav);
  opt = setCavityBasis(opt, 'IMY', 'EMY');
  
  opt = setMechTF(opt, 'IMY', zpk([], -w * dampRes, 1 / mI));
  opt = setMechTF(opt, 'EMY', zpk([], -w * dampRes, 1 / mE));
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%% Recycling cavities
  % power recycling
  opt = addMirror(opt, 'PRM', 0, 0, tPRM, lPRM);
  % signal recycling
  opt = addMirror(opt, 'SRM', 0, 0, tSRM, lSRM);
  
  % beam splitter
  opt = addBeamSplitter(opt, 'BS', 45, 0, tBS, lBS, rarBS);
  
  opt = setMechTF(opt, 'PRM', zpk([], -w * dampRes, 1 / mPRM));
  opt = setMechTF(opt, 'SRM', zpk([], -w * dampRes, 1 / mSRM));
  opt = setMechTF(opt, 'BS', zpk([], -w * dampRes, 1 / mBS));
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%% Links

  opt = addLink(opt, 'Mod3',  'out', 'PRM', 'bk', 1);
  
  opt = addLink(opt, 'PRM',  'fr',  'BS',  'frA', Lprbs);
  opt = addLink(opt, 'BS',   'frB', 'PRM', 'fr', Lprbs);
  
  opt = addLink(opt, 'SRM',  'fr',  'BS', 'bkA', Lsrc - (Lprc - Lprbs));
  opt = addLink(opt, 'BS',   'bkB', 'SRM', 'fr', Lsrc - (Lprc - Lprbs));
  
  opt = addLink(opt, 'BS',  'frA', 'IMY_AR', 'frA', (Lprc - Lprbs) - Delta/2);
  opt = addLink(opt, 'IMY_AR', 'frB',  'BS', 'frB', (Lprc - Lprbs) - Delta/2);
  
  opt = addLink(opt, 'BS',  'bkA', 'IMX_AR', 'frA', (Lprc - Lprbs) + Delta/2);
  opt = addLink(opt, 'IMX_AR', 'frB',  'BS', 'bkB', (Lprc - Lprbs) + Delta/2);
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%% Sinks
  
  opt = addSink(opt, 'XP');
  opt = addLink(opt, 'EMX', 'bk', 'XP', 'in', 2);
  
  opt = addSink(opt, 'YP');
  opt = addLink(opt, 'EMY', 'bk', 'YP', 'in', 2);
  
  opt = addSink(opt, 'SYM');
  opt = addLink(opt, 'PRM', 'bk', 'SYM', 'in', 2);
  
  opt = addSink(opt, 'ASY');
  opt = addLink(opt, 'SRM', 'bk', 'ASY', 'in', 2);
  
  opt = addSink(opt, 'POBS');
  opt = addLink(opt, 'BS', 'piB', 'POBS', 'in', 2);
    
  opt = addSink(opt, 'POX');
  opt = addLink(opt, 'IMX_AR', 'frA', 'POX', 'in', 2);
  
  opt = addSink(opt, 'POY');
  opt = addLink(opt, 'IMY_AR', 'frA', 'POY', 'in', 2);
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%% Detectors
  opt = addProbeAt(opt, 'XP_DC', 'XP', 'in',  0, 0);
  opt = addProbeAt(opt, 'XP_SB1_P', 'XP', 'in',  fMod1, 0); 
  opt = addProbeAt(opt, 'XP_SB1_Q', 'XP', 'in',  fMod1, 90); 
  opt = addProbeAt(opt, 'XP_SB2_P', 'XP', 'in',  fMod2, 0); 
  opt = addProbeAt(opt, 'XP_SB2_Q', 'XP', 'in',  fMod2, 90); 
  opt = addProbeAt(opt, 'XP_SB3_P', 'XP', 'in',  fMod3, 0); 
  opt = addProbeAt(opt, 'XP_SB3_Q', 'XP', 'in',  fMod3, 90); 
  
  opt = addProbeAt(opt, 'YP_DC',    'YP', 'in',  0, 0);
  opt = addProbeAt(opt, 'YP_SB1_P', 'YP', 'in',  fMod1, 0); 
  opt = addProbeAt(opt, 'YP_SB1_Q', 'YP', 'in',  fMod1, 90); 
  opt = addProbeAt(opt, 'YP_SB2_P', 'YP', 'in',  fMod2, 0); 
  opt = addProbeAt(opt, 'YP_SB2_Q', 'YP', 'in',  fMod2, 90); 
  opt = addProbeAt(opt, 'YP_SB3_P', 'YP', 'in',  fMod3, 0); 
  opt = addProbeAt(opt, 'YP_SB3_Q', 'YP', 'in',  fMod3, 90); 
  
  opt = addProbeAt(opt, 'SYM_DC',    'SYM', 'in',  0, 0);
  opt = addProbeAt(opt, 'SYM_SB1_P', 'SYM', 'in',  fMod1, 0); 
  opt = addProbeAt(opt, 'SYM_SB1_Q', 'SYM', 'in',  fMod1, 90); 
  opt = addProbeAt(opt, 'SYM_SB2_P', 'SYM', 'in',  fMod2, 0); 
  opt = addProbeAt(opt, 'SYM_SB2_Q', 'SYM', 'in',  fMod2, 90); 
  opt = addProbeAt(opt, 'SYM_SB3_P', 'SYM', 'in',  fMod3, 0); 
  opt = addProbeAt(opt, 'SYM_SB3_Q', 'SYM', 'in',  fMod3, 90); 
  
  opt = addProbeAt(opt, 'ASY_DC',    'ASY', 'in',  0, 0);
  opt = addProbeAt(opt, 'ASY_SB1_P', 'ASY', 'in',  fMod1, 0); 
  opt = addProbeAt(opt, 'ASY_SB1_Q', 'ASY', 'in',  fMod1, 90); 
  opt = addProbeAt(opt, 'ASY_SB2_P', 'ASY', 'in',  fMod2, 0); 
  opt = addProbeAt(opt, 'ASY_SB2_Q', 'ASY', 'in',  fMod2, 90); 
  opt = addProbeAt(opt, 'ASY_SB3_P', 'ASY', 'in',  fMod3, 0); 
  opt = addProbeAt(opt, 'ASY_SB3_Q', 'ASY', 'in',  fMod3, 90); 
  
  opt = addProbeAt(opt, 'POBS_DC',    'POBS', 'in',  0, 0);
  opt = addProbeAt(opt, 'POBS_SB1_P', 'POBS', 'in',  fMod1, 0); 
  opt = addProbeAt(opt, 'POBS_SB1_Q', 'POBS', 'in',  fMod1, 90); 
  opt = addProbeAt(opt, 'POBS_SB2_P', 'POBS', 'in',  fMod2, 0); 
  opt = addProbeAt(opt, 'POBS_SB2_Q', 'POBS', 'in',  fMod2, 90); 
  opt = addProbeAt(opt, 'POBS_SB3_P', 'POBS', 'in',  fMod3, 0); 
  opt = addProbeAt(opt, 'POBS_SB3_Q', 'POBS', 'in',  fMod3, 90); 
  
  opt = addProbeAt(opt, 'POX_DC',    'POX', 'in',  0, 0);
  opt = addProbeAt(opt, 'POX_SB1_P', 'POX', 'in',  fMod1, 0); 
  opt = addProbeAt(opt, 'POX_SB1_Q', 'POX', 'in',  fMod1, 90); 
  opt = addProbeAt(opt, 'POX_SB2_P', 'POX', 'in',  fMod2, 0); 
  opt = addProbeAt(opt, 'POX_SB2_Q', 'POX', 'in',  fMod2, 90); 
  opt = addProbeAt(opt, 'POX_SB3_P', 'POX', 'in',  fMod3, 0); 
  opt = addProbeAt(opt, 'POX_SB3_Q', 'POX', 'in',  fMod3, 90); 
  
  opt = addProbeAt(opt, 'POY_DC',    'POY', 'in',  0, 0);
  opt = addProbeAt(opt, 'POY_SB1_P', 'POY', 'in',  fMod1, 0); 
  opt = addProbeAt(opt, 'POY_SB1_Q', 'POY', 'in',  fMod1, 90); 
  opt = addProbeAt(opt, 'POY_SB2_P', 'POY', 'in',  fMod2, 0); 
  opt = addProbeAt(opt, 'POY_SB2_Q', 'POY', 'in',  fMod2, 90); 
  opt = addProbeAt(opt, 'POY_SB3_P', 'POY', 'in',  fMod3, 0); 
  opt = addProbeAt(opt, 'POY_SB3_Q', 'POY', 'in',  fMod3, 90); 
  
  




