Calculations/MOT Capture Process Simulation/test_MOTSimulator.m

173 lines
7.2 KiB
Mathematica
Raw Normal View History

%% - Create solver object with specified options
clc
%%
OptionsStruct = struct;
OptionsStruct.SimulationMode = '2D';
OptionsStruct.TimeStep = 50e-06; % in s
OptionsStruct.SimulationTime = 4e-03; % in s
OptionsStruct.SpontaneousEmission = true;
OptionsStruct.Sideband = true;
OptionsStruct.ZeemanSlowerBeam = false;
OptionsStruct.Gravity = true;
OptionsStruct.AtomicBeamCollision = true;
OptionsStruct.DebugMode = false;
OptionsStruct.SaveData = true;
OptionsStruct.SaveDirectory = 'C:\DY LAB\MOT Simulation Project\Calculations\Code\MOT Capture Process Simulation';
options = Helper.convertstruct2cell(OptionsStruct);
Simulator = MOTSimulator(options{:});
clear OptionsStruct
%% - Set Initial Conditions: Run with default values
Simulator.setInitialConditions();
%% - Set Initial Conditions: Set manually
OptionsStruct = struct;
OptionsStruct.NumberOfAtoms = 5000;
OptionsStruct.BluePower = 0.2; % in W
OptionsStruct.BlueDetuning = -1.5 * Helper.PhysicsConstants.BlueLinewidth; % in Hz
OptionsStruct.BlueBeamWaist = 0.016; % in m
OptionsStruct.SidebandPower = 0.2;
OptionsStruct.SidebandDetuning = -3 * Helper.PhysicsConstants.BlueLinewidth; % in Hz
OptionsStruct.SidebandBeamWaist = 0.010; % in m
OptionsStruct.PushBeamPower = 0.010; % in W
OptionsStruct.PushBeamDetuning = 0; % in Hz
OptionsStruct.PushBeamWaist = 0.005; % in m
options = Helper.convertstruct2cell(OptionsStruct);
Simulator.setInitialConditions(options{:});
clear OptionsStruct
%% - Run Simulation
[LoadingRate, ~] = Simulator.runSimulation();
%% - Plot initial distribution
NumberOfBins = 100;
Plotting.plotPositionAndVelocitySampling(Simulator, NumberOfBins);
%% - Plot Magnetic Field
XAxisRange = [-5 5];
YAxisRange = [-5 5];
ZAxisRange = [-5 5];
Plotting.visualizeMagneticField(Simulator, XAxisRange, YAxisRange, ZAxisRange)
%% - Plot MFP & VP for different temperatures
TemperatureinCelsius = linspace(750,1100,2000); % Temperature in Celsius
Plotting.plotMeanFreePathAndVapourPressureVsTemp(TemperatureinCelsius)
%% - Plot the Free Molecular Flux for different temperatures
Temperature = [900, 950, 1000, 1050, 1100]; % Temperature'
Plotting.plotFreeMolecularFluxVsTemp(Simulator,Temperature)
%% - Plot Angular Distribution for different Beta
Beta = [0.5, 0.1 , 0.05, 0.02, 0.01]; %Beta = 2 * radius / length of the tube
Plotting.plotAngularDistributionForDifferentBeta(Simulator, Beta)
%% - Plot Capture Velocity
Simulator.setInitialConditions();
Simulator.SimulationTime = 15*10^(-4);
Simulator.TimeStep = 1.5*10^(-6);
Simulator.MOTExitDivergence = 15/360*2*pi;
Simulator.MagneticGradient = 0.4;
Plotting.plotCaptureVelocityVsAngle(Simulator);
%% - Plot Phase Space with Acceleration Field
Simulator.NumberOfAtoms = 100;
MaximumVelocity = 150;
NumberOfBins = 200; %Along each axis
IncidentAtomDirection = 0*2*pi/360;
IncidentAtomPosition = 0;
Plotting.plotPhaseSpaceWithAccelerationField(Simulator, MaximumVelocity, NumberOfBins, IncidentAtomDirection, IncidentAtomPosition)
%% - Scan parameters
% ONE-PARAMETER SCAN
NumberOfPointsForParam = 20; %iterations of the simulation
% Scan Cooling Beam Power
PowerArray = linspace(0.1, 1.0, NumberOfPointsForParam) * Simulator.TotalPower;
% Scan Cooling Beam Detuning
% DetuningArray = linspace(-0.5,-10, NumberOfPointsForParam) * Helper.PhysicsConstants.BlueLinewidth;
OptionsStruct = struct;
OptionsStruct.ChangeInitialConditions = true;
OptionsStruct.ParameterNameArray = {'NumberOfAtoms'};
OptionsStruct.ParameterValueArray = {10000};
options = Helper.convertstruct2cell(OptionsStruct);
tStart = tic;
[LoadingRateArray, ~] = Simulator.doOneParameterScan('BluePower', PowerArray, options{:});
tEnd = toc(tStart);
fprintf('Total Computational Time: %0.1f seconds. \n', tEnd);
clear OptionsStruct
% - Plot results
ParameterArray = PowerArray .* Simulator.TotalPower;
QuantityOfInterestArray = LoadingRateArray;
OptionsStruct = struct;
OptionsStruct.RescalingFactorForParameter = 1000;
OptionsStruct.XLabelString = 'Cooling Beam Power (mW)';
OptionsStruct.RescalingFactorForYQuantity = 1e-16;
OptionsStruct.ErrorsForYQuantity = false;
OptionsStruct.YLabelString = 'Loading rate (x 10^{16} atoms/s)';
OptionsStruct.TitleString = sprintf('Magnetic Gradient = %.0f (G/cm)', Simulator.MagneticGradient * 100);
options = Helper.convertstruct2cell(OptionsStruct);
Plotting.plotResultForOneParameterScan(ParameterArray, QuantityOfInterestArray, options{:})
clear OptionsStruct
%% TWO-PARAMETER SCAN
NumberOfPointsForParam = 20; %iterations of the simulation
NumberOfPointsForSecondParam = 10;
% Scan Sideband Detuning and Power Ratio
DetuningArray = linspace(-0.5,-6, NumberOfPointsForParam) * Helper.PhysicsConstants.BlueLinewidth;
SidebandPowerArray = linspace(0.1,0.9, NumberOfPointsForSecondParam) * Simulator.TotalPower;
BluePowerArray = Simulator.TotalPower - SidebandPowerArray;
OptionsStruct = struct;
OptionsStruct.ChangeRelatedParameter = true;
OptionsStruct.Order = 2; %Change after first parameter = 1, Change after second parameter = 2
OptionsStruct.RelatedParameterName = 'BluePower';
OptionsStruct.RelatedParameterArray = BluePowerArray;
OptionsStruct.ChangeInitialConditions = true;
OptionsStruct.ParameterNameArray = {'NumberOfAtoms'};
OptionsStruct.ParameterValueArray = {10000};
options = Helper.convertstruct2cell(OptionsStruct);
tStart = tic;
[LoadingRateArray, StandardErrorArray] = Simulator.doTwoParameterScan('SidebandDetuning', DetuningArray, 'SidebandPower', SidebandPowerArray, options{:});
tEnd = toc(tStart);
fprintf('Total Computational Time: %0.1f seconds. \n', tEnd);
clear OptionsStruct
% - Plot results
FirstParameterArray = DetuningArray;
SecondParameterArray = SidebandPowerArray;
QuantityOfInterestArray = LoadingRateArray;
OptionsStruct = struct;
OptionsStruct.RescalingFactorForFirstParameter = (Helper.PhysicsConstants.BlueLinewidth)^-1;
OptionsStruct.XLabelString = 'Sideband Detuning (\Delta/\Gamma)';
OptionsStruct.RescalingFactorForSecondParameter = 1000;
OptionsStruct.YLabelString = 'Sideband Power (mW)';
OptionsStruct.RescalingFactorForQuantityOfInterest = 1e-16;
OptionsStruct.ZLabelString = 'Loading rate (x 10^{16} atoms/s)';
OptionsStruct.TitleString = sprintf('Magnetic Gradient = %.0f (G/cm)', Simulator.MagneticGradient * 100);
options = Helper.convertstruct2cell(OptionsStruct);
Plotting.plotResultForTwoParameterScan(FirstParameterArray, SecondParameterArray, QuantityOfInterestArray, options{:})
clear OptionsStruct