Skip to content

Commit

Permalink
Cleanup to gc2fo code.
Browse files Browse the repository at this point in the history
  • Loading branch information
lazersos committed Apr 13, 2024
1 parent a08ac3f commit 96c80c5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions BEAMS3D/beams3d_gc2part.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
% Maintained by: Samuel Lazerson ([email protected])
% Version: 1.0

% For plotting
lplot = 0;

% Save the dimension and vectorize
nsave = size(Rpart);
ntotal = prod(nsave);
Expand Down Expand Up @@ -62,10 +65,6 @@
BY = BY.*Binv;
BZ = BZ.*Binv;

plot3(X,Y,Z,'.r');
hold on;
quiver3(X(1),Y(1),Z(1),BX(1),BY(1),BZ(1),0.01,'filled','ro');

% Calculate Gyroradius
VPERP = sqrt(2.*B.*MU./M);
RGYRO = M.*VPERP.*Binv./C;
Expand All @@ -75,9 +74,11 @@
YGYRO = -BZ.*BY.*RGYRO;
ZGYRO = (BY.*BY+BX.*BX).*RGYRO;

BX(1).*XGYRO(1)+BY(1).*YGYRO(1)+BZ(1).*ZGYRO(1)

quiver3(X(1),Y(1),Z(1),XGYRO(1),YGYRO(1),ZGYRO(1),1,'filled','go');
if lplot
quiver3(X(1),Y(1),Z(1),BX(1),BY(1),BZ(1),0.01,'filled','ro');
hold on;
quiver3(X(1),Y(1),Z(1),XGYRO(1),YGYRO(1),ZGYRO(1),1,'filled','go');
end

% Generate a random gyrophase
PGYRO = (rand([1,ntotal])-0.5).*2.*pi;
Expand Down Expand Up @@ -115,7 +116,6 @@
RHOPERP = sqrt(XPERP.*XPERP+YPERP.*YPERP+ZPERP.*ZPERP);
RHOPERPinv = 1./RHOPERP;

quiver3(X(1),Y(1),Z(1),XPERP(1),YPERP(1),ZPERP(1),1,'filled','go');

% Step to particle position
X = X + XG;
Expand All @@ -131,9 +131,12 @@
VR = VX.*cos(PHI)+VY.*sin(PHI);
VPHI = -VX.*sin(PHI)+VY.*cos(PHI);

quiver3(X,Y,Z,VX-VLL.*BX,VY-VLL.*BY,VZ-VLL.*BZ,1','filled','ob');
quiver3(X,Y,Z,VLL.*BX,VLL.*BY,VLL.*BZ,1','filled','oc');
axis equal;
if lplot
quiver3(X,Y,Z,VX-VLL.*BX,VY-VLL.*BY,VZ-VLL.*BZ,1,'filled','ob');
quiver3(X(1),Y(1),Z(1),XPERP(1),YPERP(1),ZPERP(1),1,'filled','go');
quiver3(X,Y,Z,VLL.*BX,VLL.*BY,VLL.*BZ,1','filled','oc');
axis equal;
end

% Reshape
R = reshape(R,nsave);
Expand Down

0 comments on commit 96c80c5

Please sign in to comment.