% simple FP cavity, parameters for aLIGO
% derived from FFTIFOAcc, no AccSetup needed
%
%{
% example
% place 40m test mass in a folder Data0, and execute the following
% define FP by specifying the test mass maps
fp = FP40mAcc('ETMmap', './Data0/ETMU-07_S1_PostCoat.dat', 'ITMmap', './Data0/40m_ITM04_HR.opd');
% lock the FP cavity
fp.lock('errorLimit',1e-4);
% various cavity quantities
roundTripLoss = fp.roundtripLoss('ETM-HR-o')
lossOnITM = fp.optics.opticLoss(fp.fields.findNamedField('ITM-HR-i'))
lossOnETM = fp.optics.opticLoss(fp.fields.findNamedField('ETM-HR-i'))
% HG amplitudes of the field at HR side of ITM, going outward
fp.HGCoef('ITM-HR-o',0:3,0:3)
% main modes of the field at HR side of ETM, going outward
fp.mainHGsStr('ETM-HR-o')
% fraction of modes, HOM(3+1) = HG(3,0)+HG(2,1)+HG(1,2)+HG(0,3), HOM(11+1)=all modes with n+m>10
HOMfrac = fp.HGFrac('ETM-HR-o',-10,-1);
% power distribution of non 00 mode
[EHOM,xHOM] = fp.Non00Amp('ETM-HR-o');
pcolor(xHOM,xHOM,abs(EHOM).^2);shading flat; axis equal; colorbar;
%}
%
%
classdef FP40mAcc < FFTIFOAcc
    
    methods
        function obj = FP40mAcc( varargin )
            obj@FFTIFOAcc( varargin{:} );
        end
        
        function defineIFO( obj, varargin )
            % basic FP parameters
            % set these as runtime parameters, like fp = FPBase('A', 0.1)
            ATM = 0.075; % max mirror size
            Lcav = 38;
            TITM = 0.014;
            TETM = 160e-6;
            lamCR = 1.064e-6;
            invRoCITM = 1e-20;
            invRoCETM = 1/57.5;
            % default 40m data files
            ETMmap = './Data0/ETMU-07_S1_PostCoat.dat';
            ITMmap = './Data0/40m_ITM04_HR.opd';           
            res = 0;
            WfftUser = 0;
            
            eval( UtilTK.setVars( who, true, varargin{:} ) );
                        
            %% add optics
            % laser source
            obj.addLaser( 'src', 'lamCR', lamCR );
            
            % ITM
            obj.addMirror( 'ITM', 'invRoC', invRoCITM, 'Aperture', ATM, 'T', TITM, 'Thick', 0.025, 'removeTilt', true, 'resolution', res, 'WfftUser', WfftUser  );
            % ETM
            obj.addMirror( 'ETM', 'invRoC', invRoCETM, 'Aperture', ATM, 'T', TETM, 'removeTilt', true, 'WfftUser', WfftUser  );
            
            %% define connections among optics
            obj.addProp( '', 'src', 'ITM-AR' );
            obj.addProp( 'FPprop', 'ITM-HR', 'ETM-HR', Lcav);
            
            obj.setHRfiles( 'ITM', ITMmap, 'map', 0.02, 1/invRoCITM, 0 );           
            obj.setHRfiles( 'ETM', ETMmap, 'map', 0.02, 1/invRoCETM, 0 );           
        end
    end
end