%---------------- p a r a m C 1 DRMI . m ---------------------
% Struct of optical parameters in Caltech 40m interferomter
%
%  created by Kiwamu Izumi (July 20th 2011)
%
%--------------------------------------------------------
%
%[Description]
% This function defines all the optical parameters such as
%   * cavity length
%   * modulation frequencies and their depth
%   * Mirror properties (reflectiviries, RoC, losses and etc.)
%   * Microscopic offsets in the positions of the mirrors
%   * Mechanical responses of the suspensions
%   * Laser wavelength
%   * Demodulation phases
%   
% example usage : 
%              par = paramC1;
%              opt = optC1(par);
%   where 'opt' is an optic model instance which is created based on
%   this parameter structure function.
%
%--------------------------------------------------------
%
% [Notes]
% In the current setting PR3, SR2 and SR3 are omitted for simplicity.
% However PR2 is included as a high reflective beam splitter so that
% the POP2 (light coming from BS to PRM) signal can be obtained.
% 
% - remainging refinements
%  1. implementation of PR3, SR2 and SR3
%  2. Mismatch in the input beams, PRCL and SRCL
%
% Modified by KK 25 Jan 2012
%
%


function par = paramC1(par)

% basic constants
lambda = 1064e-9;   % laser wavelength 
c = 299792458;      % speed of light, of course !

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Detector Geometry (distances in meters)
% Lengths (designed) see the 40m wiki page for details
lPRC  = 6.75380;    % PRCL: lPRC = lPR + (lIX + lIY) / 2
lSRC  = 5.39915;    % SRCL: lSRC = lSR + (lIX + lIY) / 2  
lasy  = 0.0342;     % Schnupp Asy: lasy = lIX - lIY
lmean = 4.0;        % (lIX + lIY) / 2

% Mirror curvatures (all dimensions in meters)
Ri = 1e9;             % input mirrors (IX and IY)
Re = 57.37;           % end mirrors (EX and EY)
Rpr = 115.5;          % power recycling mirror
Rsr = 142.0;          % signal recycling mirror


% Put together all the length parameters into the 'par' variable
par.Length.IX = lmean + lasy / 2;  % distance [m] from BS to IX
par.Length.IY = lmean - lasy / 2;  % distance [m] from BS to IY
par.Length.EX = 37.7974;           % length [m] of the X arm
par.Length.EY = 37.7974;           % length [m] of the Y arm
par.Length.PR = lPRC - lmean;      % distance from PR to BS
par.Length.SR = lSRC - lmean;      % distance from SR to BS
par.Length.PR_PR2 = 1.0;           % distance from PR to PR2
par.Length.PR2_BS = par.Length.PR - par.Length.PR_PR2;           % distance from PR2 to BS

% Put together all the Radius of Curvature [1/m] 
par.IX.ROC = 1 / Ri;
par.IY.ROC = 1 / Ri;
par.EX.ROC = 1 / Re;
par.EY.ROC = 1 / Re;
par.BS.ROC = 0;
par.PR.ROC = 1 / Rpr;
par.SR.ROC = 1 / Rsr;
par.PR2.ROC = 0;                    % 40m doesn't use curved mirrors for PRC folding

% Microscopic length offsets
dETM = 0;            % DARM offset, for DC readout - leave this as zero
par.IX.pos = 0;
par.IY.pos = 0;
par.EX.pos = 0;      % Set DARMoffset in your own scripts, not here.
par.EY.pos = 0;
par.BS.pos = 0;
par.PR.pos = 0;
par.SR.pos = lambda/4; % pos = lambda/4 for signal recycling. pos = 0 for broadband signal extraction
par.PR2.pos = 0;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Mirror Parameters

% HR Transmissivities 
%par.IX.T = 0.014;     % T = 1.4% for ITMX
%par.IY.T = 0.014;     % T = 1.4% for ITMY
par.IX.T = 0;     % T = 1.4% for ITMX
par.IY.T = 0;     % T = 1.4% for ITMY


par.BS.T = 0.5;       % T = 50%  for BS
par.EX.T = 1;     % T = 1 for DRMI (T = 15ppm)
par.EY.T = 1;     % T = 1 for DRMI (T = 15ppm)

par.PR.T = 0.0575;    % T = 5.75% for PRM
%par.PR.T = 1;    % T = 5.75% for PRM
par.SR.T = 0.10;      % T = 10% for SRM
%par.SR.T = 1;      % T = 10% for SRM
par.PR2.T = 25e-6;    % 25 ppm (assumption)

% Power reflectivity on AR Surfaces
par.IX.Rar = 500e-6;  % designed value is 500 ppm
par.IY.Rar = 500e-6;  % designed value is 500 ppm
par.EX.Rar = 200e-6;  % designed value is less than 300 ppm
par.EY.Rar = 200e-6;  % designed value is less than 300 ppm
par.BS.Rar = 0;       % designed value is less than 600 ppm 
par.PR.Rar = 0;       % designed value is less than 300 ppm
par.SR.Rar = 0;       % designed value is less than 300 ppm
par.PR2.Rar = 0;

% HR Losses (50 ppm is assumed)
par.IX.L = 50e-6;
par.IY.L = 50e-6;
par.EX.L = 50e-6;
par.EY.L = 50e-6;
par.BS.L = 50e-6;
par.PR.L = 50e-6;
par.SR.L = 50e-6;
par.PR2.L = 50e-6;


%par.IX.L = 0;
%par.IY.L = 0;
%par.EX.L = 0;
%par.EY.L = 0;
%par.BS.L = 0;
%par.PR.L = 0;
%par.SR.L = 0;
%par.PR2.L = 0;

% mechanical parameters
par.w = 2 * pi * 1.0;       % resonance frequency of the mirror (rad/s)
par.mass  = 0.25;		    % mass of the mirror (kg)
par.w_pit = 2 * pi * 0.6;   % pitch mode resonance frequency


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Beam Parameters
par.Pin = 1;            % input power (W)
f1 = 11065399;          % first modulation frequency
f2 = 5 * f1;            % second modulation frequency

Nmod1 = 2;              % first modulation order
Nmod2 = 2;              % second modulation order

% construct modulation vectors 
n1 = (-Nmod1:Nmod1)';
n2 = (-Nmod2:Nmod2)';
vMod1 = n1*f1;
vMod2 = n2*f2;
  
 % make sidebands of sidebands
  for i=1:length(n1)                        % run through all the f1 components
      for j=1:length(n2)                    % run through all the f2 components
            index = j + (i-1)*length(n1);   % index for new arrays
            vFrf(index) = vMod1(i)+vMod2(j);    % frequency of sidebands and carrier
      end
  end
 vFrf = sortrows(vFrf');

 %vFrf = sortrows(f1*(-18:18)');

 % input amplitude is only carrier and zero ampliutde in sidebands.
% because two RF modulators are placed after the laser source
nCarrier = find(vFrf == 0, 1);
vArf = zeros(size(vFrf));
vArf(nCarrier) = sqrt(par.Pin);

par.Laser.vFrf = vFrf;
par.Laser.vArf = vArf;
par.Laser.Power = par.Pin;
par.Laser.Wavelength = lambda;

par.Mod.f1 = f1;
par.Mod.f2 = f2;
par.Mod.g1 = 0.1; %  first modulation depth (radians)
par.Mod.g2 = 0.1; % second modulation depth (radians)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adjustment of demodulation phase 
% Demodulation Phases -- tuned with newSensMat.m
% All the units are in 'degree'

par.phi.phREFL1 = -176.9563;          % f1 : adjusted for CARM, I-phase
par.phi.phREFL2 = -86;             % f2 : adjusted for CARM, I-phase
par.phi.phREFL31 = 9.1369+1.1006;            % 3*f1: adjusted for PRCL, I-phase
par.phi.phREFL32 = -138.5568;         % 3*f2: adjusted for SRCL, I-phase

par.phi.phAS1 = -87.6498 - 90.;       % f1 : adjusted for DARM, Q-pjase
par.phi.phAS2 = -165.9168 - 90.-2;      % f2 : adjusted for DARM, Q-phase
par.phi.phAS31 = 2.3937 - 90.;        % 3f1: adjusted for MICH, Q-phase
par.phi.phAS32 = -15.9515 - 90;

par.phi.phPOP1 = -9.9161;             % f1 : adjusted for PRCL, I-phase
par.phi.phPOP2 = 128.4403;            % f2 : adjusted for SRCL, I-phase
par.phi.phPOP31 = -10.7091;           % 3f1: adjusted for PRCL, I-phase
par.phi.phPOP32 = 24.2958;            % 3f2: adjusted for SRCL, I-phase

par.phi.phPOX1 = -86.3637;            % f1 : adjusted for PRCL, I-phase
par.phi.phPOX2 = 32.3234 - 90;        % f2 : adjusted for MICH, Q-phase
par.phi.phPOX31 = 120.3357;           % 3f1: adjusted for PRCL, I-phase
par.phi.phPOX32 = -85.8551 - 90;      % 3f2: adjusted for MICH, Q-phase

par.phi.phPOY1 = 0;
par.phi.phPOY2 = 0;
par.phi.phPOY31 = 0;
par.phi.phPOY32 = 0;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%