Code covered by the BSD License  

Highlights from
OSCAR

image thumbnail
from OSCAR by Jerome Degallaix
An optical FFT code to simulate Fabry Perot cavities with arbitrary mirror profiles

Interface
classdef Interface
    %     Interface() Create a interface between 2 media of different refractive
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %     Interface(Grid,RofC) create an interface with a radius of curvature
    %     'RofC'
    %     Interface(Grid,RofC,diam) create an interface with a radius of curvature
    %     'RofC'. The interface has finite size and the diameter is 'diam'.
    %     Interface(Grid,RofC,diam,T,L) create an interface with a radius of curvature
    %     'RofC'. The interface has finite size and the diameter is 'diam'. with
    %     a transmission in power T and a loss L (also in power)
    %     Interface(Grid,RofC,diam,T,L,n1,n2) create an interface with a radius of curvature
    %     'RofC'. The interface has finite size and the diameter is 'diam'. with
    %     a transmission in power T and a loss L (also in power) and the
    %     interface separates media of refractive index n1,n2
    %
    %     RofC > 0 for a concave mirror (surface view from n1 toward n2)
    %     RofC < 0 for a convex mirror  (surface view from n1 toward n2)
    %     
    %     If the interface is used as a lens with RofC < 0 and n2 > n1 it
    %     will be equivalent to a convergent lens
    %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    properties
        Grid
        
        surface
        mask
        T
        L
        n1
        n2
        
        t
        r
    end
    
    methods
        
        function I = Interface(varargin)
            
            switch nargin
                case {0,1}
                    error('Interfaces(): at least 2 arguments must be given: the grid and the radius of curvature of the surface')
                case 2
                    if  ~isa(varargin{1}, 'Grid')
                        error('E_Field(): the first argument must be an instance of the class grid')
                    end
                    I.Grid = varargin{1};
                    RofC =  varargin{2};
                    
                    % sagitta change of the surface
                    I.surface =  -(RofC - sign(RofC)*sqrt(RofC^2 - I.Grid.D2_square));
                    
                    % No aperture
                    I.mask = ones(I.Grid.Num_point,I.Grid.Num_point,'double');
                    
                    I.n1 = 1;
                    I.n2 = 1.45;
                    
                    I.T = 0.9;
                    I.L = 0;
                    
                    I.t = 1i*sqrt(I.T);
                    I.r = sqrt(1-(I.T + I.L));
                    
                case 3
                    I.Grid = varargin{1};
                    RofC = varargin{2};
                    diam = varargin{3};
                    
                    
                    % sagitta change of the surface
                    I.surface =  -(RofC - sign(RofC)*sqrt(RofC^2 - I.Grid.D2_square));
                    
                    % Mirror mask
                    mask_index = I.D2_r < (diam/2);
                    I.mask = zeros(I.Grid.Num_point,I.Grid.Num_point,'double');
                    I.mask(mask_index) = 1;
                    
                    I.T = 0.9;
                    I.L = 0;
                    
                    I.t = 1i*sqrt(I.T);
                    I.r = sqrt(1-(I.T + I.L));
                    
                case 5
                    I.Grid = varargin{1};
                    RofC = varargin{2};
                    diam = varargin{3};
                    I.T = varargin{4};
                    I.L = varargin{5};
                    
                    if (I.L > (1-I.T))
                        disp('Interface(): Loss superior to transmission... results will be wrong')
                    end
                    %sagitta change of the surface
                    I.surface =  -(RofC - sign(RofC)*sqrt(RofC^2 - I.Grid.D2_square));
                    
                    %Mirror mask
                    mask_index = I.Grid.D2_r < (diam/2);
                    I.mask = zeros(I.Grid.Num_point,I.Grid.Num_point,'double');
                    I.mask(mask_index) = 1;
                    
                    I.n1 = 1;
                    I.n2 = 1.45;
                    
                    I.t = 1i*sqrt(I.T);
                    I.r = sqrt(1-(I.T + I.L));
                    
                case 7
                    I.Grid = varargin{1};
                    RofC = varargin{2};
                    diam = varargin{3};
                    I.T = varargin{4};
                    I.L = varargin{5};
                    I.n1 =  varargin{6};
                    I.n2 = varargin{7};
                    
                    %sagitta change of the surface
                    I.surface =  -(RofC - sign(RofC)*sqrt(RofC^2 - I.Grid.D2_square));
                    
                    % Mirror mask
                    mask_index = I.Grid.D2_r < (diam/2);
                    I.mask = zeros(I.Grid.Num_point,I.Grid.Num_point,'double');
                    I.mask(mask_index) = 1;
                    
                    I.t = 1i*sqrt(I.T);
                    I.r = sqrt(1-(I.T + I.L));
                    
                otherwise
                    disp('Interfaces(): invalid number of input arguments, no surface has been created created')
                    return
            end
        end
        
        
    end
    
end

Contact us at files@mathworks.com