function [LoadingRate, StandardError] = calculateLoadingRate(this, CaptureFraction, ClausingFactor, FinalDynamicalQuantities) NumberOfLoadedAtoms = zeros(1, this.NumberOfAtoms); AutocorrelationFunction = zeros(1, this.NumberOfAtoms); for i = 1:NumberOfLoadedAtoms FinalPosition = FinalDynamicalQuantities(i,1:3); DivergenceAngle = atan(sqrt((FinalPosition(1)^2+FinalPosition(3)^2)/(FinalPosition(2)^2))); if (DivergenceAngle <= this.MOTExitDivergence) && (FinalPosition(2) >= 0) if i == 1 NumberOfLoadedAtoms(1) = 1; else NumberOfLoadedAtoms(i) = NumberOfLoadedAtoms(i-1) + 1; end else if i == 1 NumberOfLoadedAtoms(1) = 0; else NumberOfLoadedAtoms(i) = NumberOfLoadedAtoms(i-1); end end end for i = 1:NumberOfLoadedAtoms-1 MeanLoadingRate = 0; MeanLoadingRateShifted = 0; for j = 1:NumberOfLoadedAtoms-i MeanLoadingRate = MeanLoadingRate + NumberOfLoadedAtoms(j)/j; MeanLoadingRateShifted = MeanLoadingRateShifted + (NumberOfLoadedAtoms(i+j))/(i+j); AutocorrelationFunction(i) = AutocorrelationFunction(i) + ((NumberOfLoadedAtoms(j)/j).*(NumberOfLoadedAtoms(i+j)/(i+j))); end AutocorrelationFunction(i) = ((NumberOfLoadedAtoms-i)^-1 * (AutocorrelationFunction(i)) - ((NumberOfLoadedAtoms-i)^-1 * MeanLoadingRate * MeanLoadingRateShifted)); end if AutocorrelationFunction(1)~=0 % In case no atom loading AutocorrelationFunction = AutocorrelationFunction./AutocorrelationFunction(1); x = linspace(1, NumberOfLoadedAtoms, NumberOfLoadedAtoms); [FitObject,~] = fit(x',AutocorrelationFunction',"exp(-x/n)",'Startpoint', 100); n = FitObject.n; % n is the autocorrelation factor MeanLoadingRate = 0; NumberOfBins = floor(NumberOfLoadedAtoms/(2*n+1)); LoadingRateError = zeros(1,NumberOfBins); BinNumberLimit = min(NumberOfBins-1,5); for i = 1:NumberOfBins-BinNumberLimit LoadingRateError(i) = NumberOfLoadedAtoms(NumberOfLoadedAtoms-ceil((i-1)*(2*n+1))) / ... (NumberOfLoadedAtoms-ceil((i-1)*(2*n+1))); MeanLoadingRate = MeanLoadingRate + LoadingRateError(i); end MeanLoadingRate = MeanLoadingRate /(NumberOfBins-BinNumberLimit); StandardError = 0; for i = 1:NumberOfBins-BinNumberLimit StandardError = StandardError + (MeanLoadingRate-LoadingRateError(i))^2; end StandardError = sqrt(StandardError/(NumberOfBins-BinNumberLimit)); LoadingRate = (MeanLoadingRate * this.FreeMolecularRegimeFlux() * CaptureFraction * ClausingFactor); else LoadingRate = 0; StandardError = 0; end end