Shifted some calculations in to other functions.
This commit is contained in:
parent
5e933b0324
commit
8327652883
@ -1,36 +1,6 @@
|
||||
function [LoadingRate, StandardError] = runSimulation(this)
|
||||
n = this.NumberOfAtoms;
|
||||
%% Calculate Background Collision Time --> Calculate Capture velocity --> Introduce velocity cutoff --> Calculate capture fraction
|
||||
function [LoadingRate, StandardError, ConfidenceInterval] = runSimulation(this)
|
||||
|
||||
this.CaptureVelocity = 1.05 * this.calculateCaptureVelocity([-this.OvenDistance,0,0], [1,0,0]); % Make 5% larger than the numerically obtained CV
|
||||
this.VelocityCutoff = this.CaptureVelocity(1); %Should be the magnitude of the 3-D velocity vector but since here the obtained capture
|
||||
%velocity is only along the x-axis, we take the first term which is the x-component of the velocity.
|
||||
%% Calculate the Clausing Factor
|
||||
|
||||
% Compute the angular distribution of the atomic beam
|
||||
ThetaArray = linspace(0.0001, pi/2, 1000);
|
||||
AngularDistribution = zeros(1,length(ThetaArray));
|
||||
parfor i = 1:length(ThetaArray)
|
||||
AngularDistribution(i) = this.angularDistributionFunction(ThetaArray(i));
|
||||
end
|
||||
|
||||
% Numerically integrate the angular distribution over the full solid angle
|
||||
NormalizationConstant = 0;
|
||||
for j = 1:length(ThetaArray)
|
||||
if ThetaArray(j) <= this.NozzleExitDivergence
|
||||
NormalizationConstant = NormalizationConstant + (2 * pi * sin(ThetaArray(j)) * AngularDistribution(j) * (ThetaArray(2)-ThetaArray(1)));
|
||||
end
|
||||
end
|
||||
|
||||
this.ClausingFactor = (1/pi) * NormalizationConstant; %The complete intergration will give pi * ClausingFactor.
|
||||
%Therefore, the Clausing Factor needs to be extracted from the
|
||||
%result of the above integration by dividing out pi
|
||||
|
||||
this.ThetaArray = ThetaArray;
|
||||
this.AngularDistribution = AngularDistribution;
|
||||
this.NormalizationConstantForAngularDistribution = NormalizationConstant;
|
||||
|
||||
%%
|
||||
%% - Sampling for initial positions and velocities
|
||||
% - sampling the position distribution
|
||||
this.InitialPositions = this.initialPositionSampling();
|
||||
% - sampling the velocity distribution
|
||||
@ -38,18 +8,18 @@ function [LoadingRate, StandardError] = runSimulation(this)
|
||||
|
||||
%% Solve ODE
|
||||
progressbar = Helper.parforNotifications();
|
||||
progressbar.PB_start(n,'Message',['Simulating capture process for ' num2str(n,'%.0f') ' atoms:']);
|
||||
progressbar.PB_start(this.NumberOfAtoms,'Message',['Simulating capture process for ' num2str(this.NumberOfAtoms,'%.0f') ' atoms:']);
|
||||
|
||||
% calculate the final position of the atoms
|
||||
FinalDynamicalQuantities = zeros(n,9);
|
||||
ParticleDynamicalQuantities = zeros(this.NumberOfAtoms,int64(this.SimulationTime/this.TimeStep),6);
|
||||
Positions = this.InitialPositions;
|
||||
Velocities = this.InitialVelocities;
|
||||
parfor Index = 1:n
|
||||
ret = this.solver(Positions(Index,:), Velocities(Index,:));
|
||||
FinalDynamicalQuantities(Index,:) = ret(end,:);
|
||||
parfor Index = 1:this.NumberOfAtoms
|
||||
ParticleDynamicalQuantities(Index,:, :) = this.solver(Positions(Index,:), Velocities(Index,:));
|
||||
progressbar.PB_iterate();
|
||||
end
|
||||
clear Index
|
||||
|
||||
%% Calculate the Loading Rate
|
||||
[LoadingRate, StandardError] = this.calculateLoadingRate(FinalDynamicalQuantities);
|
||||
[LoadingRate, StandardError, ConfidenceInterval] = this.calculateLoadingRate(ParticleDynamicalQuantities);
|
||||
end
|
Loading…
Reference in New Issue
Block a user