Cosmetic changes only, changed a few variable names, dynamical quantities for all atoms across the full simulation time are now returned instead of just the final values.

This commit is contained in:
Karthik 2021-07-11 14:43:36 +02:00
parent bc10c207f6
commit a41ae74cb7

View File

@ -1,22 +1,16 @@
function [ParticleTrajectory, FinalDynamicalQuantities] = solver(this, InitialPosition, InitialVelocity)
function ParticleDynamicalQuantities = solver(this, InitialPosition, InitialVelocity)
if this.Gravity
g = [0,0,-Helper.PhysicsConstants.GravitationalAcceleration];
else
g = 0;
end
% Probability of Background Collisions
collision = rand(1);
CollisionProbability = 1 - exp(-this.SimulationTime/this.CollisionTime);
if collision >= CollisionProbability || this.AtomicBeamCollision == false %flag for skipping the background collision
ParticleTrajectory = zeros(int64(this.SimulationTime/this.TimeStep),9);
ParticleDynamicalQuantities = zeros(int64(this.SimulationTime/this.TimeStep),6);
for i=1:int64(this.SimulationTime/this.TimeStep)
ParticleTrajectory(i,1:3) = InitialPosition;
ParticleTrajectory(i,4:6) = InitialVelocity;
ParticleDynamicalQuantities(i,1:3) = InitialPosition;
ParticleDynamicalQuantities(i,4:6) = InitialVelocity;
rt = InitialPosition;
vt = InitialVelocity;
@ -41,14 +35,7 @@ function [ParticleTrajectory, FinalDynamicalQuantities] = solver(this, InitialPo
InitialPosition = InitialPosition + (gv1+2*(gv2+gv3)+gv4)./6;
InitialVelocity = InitialVelocity + this.TimeStep*(ga1+2*(ga2+ga3)+ga4)./6;
ParticleTrajectory(i,7:9) = (ga1+2*(ga2+ga3)+ ga4)./6;
end
FinalDynamicalQuantities = ParticleTrajectory(end,:);
else
ParticleTrajectory = zeros(int64(this.SimulationTime/this.TimeStep),9);
FinalDynamicalQuantities = -500*ones(1,9); % -500 is a flag for giving up this trajectory
%Acceleration = (ga1+2*(ga2+ga3)+ ga4)./6;
end
end