2021-06-29 15:44:28 +02:00
|
|
|
function [LoadingRate, StandardError] = calculateLoadingRate(this, CaptureFraction, ClausingFactor, FinalDynamicalQuantities)
|
|
|
|
|
|
|
|
NumberOfLoadedAtoms = zeros(1, this.NumberOfAtoms);
|
|
|
|
AutocorrelationFunction = zeros(1, this.NumberOfAtoms);
|
|
|
|
|
2021-07-03 10:19:27 +02:00
|
|
|
for i = 1:this.NumberOfAtoms
|
2021-06-29 15:44:28 +02:00
|
|
|
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
|
|
|
|
|
2021-07-03 10:19:27 +02:00
|
|
|
for i = 1:this.NumberOfAtoms-1
|
2021-06-29 15:44:28 +02:00
|
|
|
MeanLoadingRate = 0;
|
|
|
|
MeanLoadingRateShifted = 0;
|
2021-07-03 10:19:27 +02:00
|
|
|
for j = 1:this.NumberOfAtoms-i
|
2021-06-29 15:44:28 +02:00
|
|
|
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
|
2021-07-03 10:19:27 +02:00
|
|
|
AutocorrelationFunction(i) = ((this.NumberOfAtoms-i)^-1 * (AutocorrelationFunction(i)) - ((this.NumberOfAtoms-i)^-1 * MeanLoadingRate * MeanLoadingRateShifted));
|
2021-06-29 15:44:28 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if AutocorrelationFunction(1)~=0 % In case no atom loading
|
|
|
|
|
|
|
|
AutocorrelationFunction = AutocorrelationFunction./AutocorrelationFunction(1);
|
2021-07-03 10:19:27 +02:00
|
|
|
x = linspace(1, this.NumberOfAtoms, this.NumberOfAtoms);
|
2021-06-29 15:44:28 +02:00
|
|
|
[FitObject,~] = fit(x',AutocorrelationFunction',"exp(-x/n)",'Startpoint', 100);
|
|
|
|
n = FitObject.n; % n is the autocorrelation factor
|
|
|
|
MeanLoadingRate = 0;
|
2021-07-03 10:19:27 +02:00
|
|
|
NumberOfBins = floor(this.NumberOfAtoms/(2*n+1));
|
2021-06-29 15:44:28 +02:00
|
|
|
LoadingRateError = zeros(1,NumberOfBins);
|
|
|
|
BinNumberLimit = min(NumberOfBins-1,5);
|
|
|
|
for i = 1:NumberOfBins-BinNumberLimit
|
2021-07-03 10:19:27 +02:00
|
|
|
LoadingRateError(i) = NumberOfLoadedAtoms(this.NumberOfAtoms-ceil((i-1)*(2*n+1))) / ...
|
|
|
|
(this.NumberOfAtoms-ceil((i-1)*(2*n+1)));
|
2021-06-29 15:44:28 +02:00
|
|
|
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));
|
|
|
|
|
2021-07-03 10:19:27 +02:00
|
|
|
LoadingRate = (MeanLoadingRate * this.calculateFreeMolecularRegimeFlux() * CaptureFraction * ClausingFactor);
|
2021-06-29 15:44:28 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
LoadingRate = 0;
|
|
|
|
StandardError = 0;
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|