Added a switch to change between 2D and 3D MOT cases to allow for this code to be expanded and generalized in the future.

This commit is contained in:
Karthik 2021-07-11 06:18:21 +02:00
parent ba621f3c32
commit 1a8975c218

View File

@ -1,24 +1,28 @@
function ret = calculateCaptureVelocity(this, PositionVector, VelocityVector) function ret = calculateCaptureVelocity(this, PositionVector, VelocityVector)
switch this.SimulationMode
case "2D"
VelocityUnitVector = VelocityVector./norm(VelocityVector);
UpperLimit = 500;
LowerLimit = 0;
VelocityVector = VelocityVector./norm(VelocityVector); for Index = 1:500
UpperLimit = 500; InitialVelocity = (0.5 * (UpperLimit + LowerLimit)) * VelocityUnitVector;
LowerLimit = 0; ParticleDynamicalQuantities = this.solver(PositionVector, InitialVelocity);
this.AtomicBeamCollision = false; 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 if UpperLimit - LowerLimit < 1
InitialVelocity = 0.5 * (UpperLimit + LowerLimit) * VelocityVector; ret = (0.5 * (UpperLimit + LowerLimit)) * VelocityUnitVector;
[~, FinalDynamicalQuantities] = this.solver(PositionVector, InitialVelocity); break;
FinalPositionVector = FinalDynamicalQuantities(1:3); end
if rssq(FinalPositionVector) <= this.OvenDistance end
LowerLimit = 0.5 * (UpperLimit + LowerLimit); case "3D"
else % Development In progress
UpperLimit = 0.5 * (UpperLimit + LowerLimit);
end
if UpperLimit - LowerLimit < 1
ret = InitialVelocity;
break;
end
end end
end end