From 1a8975c218d6eccb5b3df46e4146587f56fa7058 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Sun, 11 Jul 2021 06:18:21 +0200 Subject: [PATCH] Added a switch to change between 2D and 3D MOT cases to allow for this code to be expanded and generalized in the future. --- .../@MOTSimulator/calculateCaptureVelocity.m | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/MOT Capture Process Simulation/@MOTSimulator/calculateCaptureVelocity.m b/MOT Capture Process Simulation/@MOTSimulator/calculateCaptureVelocity.m index 98b4a67..f235207 100644 --- a/MOT Capture Process Simulation/@MOTSimulator/calculateCaptureVelocity.m +++ b/MOT Capture Process Simulation/@MOTSimulator/calculateCaptureVelocity.m @@ -1,24 +1,28 @@ function ret = calculateCaptureVelocity(this, PositionVector, VelocityVector) + + switch this.SimulationMode + case "2D" + VelocityUnitVector = VelocityVector./norm(VelocityVector); + UpperLimit = 500; + LowerLimit = 0; - VelocityVector = VelocityVector./norm(VelocityVector); - UpperLimit = 500; - LowerLimit = 0; - this.AtomicBeamCollision = false; + for Index = 1:500 + InitialVelocity = (0.5 * (UpperLimit + LowerLimit)) * VelocityUnitVector; + ParticleDynamicalQuantities = this.solver(PositionVector, InitialVelocity); + FinalPositionVector = ParticleDynamicalQuantities(end, 1:3); + if rssq(FinalPositionVector) <= this.OvenDistance + LowerLimit = 0.5 * (UpperLimit + LowerLimit); + else + UpperLimit = 0.5 * (UpperLimit + LowerLimit); + end - for Index = 1:500 - InitialVelocity = 0.5 * (UpperLimit + LowerLimit) * VelocityVector; - [~, FinalDynamicalQuantities] = this.solver(PositionVector, InitialVelocity); - FinalPositionVector = FinalDynamicalQuantities(1:3); - if rssq(FinalPositionVector) <= this.OvenDistance - LowerLimit = 0.5 * (UpperLimit + LowerLimit); - else - UpperLimit = 0.5 * (UpperLimit + LowerLimit); - end - - if UpperLimit - LowerLimit < 1 - ret = InitialVelocity; - break; - end + if UpperLimit - LowerLimit < 1 + ret = (0.5 * (UpperLimit + LowerLimit)) * VelocityUnitVector; + break; + end + end + case "3D" + % Development In progress end end