You are here: Home Education Computational Plasma Physics function - grad B drift

function - grad B drift

function - grad B drift

gradBfunc.m — Objective-C source code, 709 bytes

File contents

function x_res = gradBfunc(x_vect,t) % use this definition in *** Octave ***
% function x_res = gradBfunc(t, x_vect) % use this in *** Matlab ***

% x_vect(1) = x
% x_vect(2) = y
% x_vect(3) = z
% x_vect(4) = u
% x_vect(5) = v
% x_vect(6) = w

global Bx; global By; global Bz;
global Ex; global Ey; global Ez;
global qom;

x_res = zeros(6,1);

Bz = 1*x_vect(1);

x_res(1) = x_vect(4); % dx/dt = u
x_res(2) = x_vect(5); % dy/dt = v
x_res(3) = x_vect(6); % dz/dt = w
x_res(4) = qom*(Ex + x_vect(5)*Bz - x_vect(6)*By); % du/dt = qom*(vel x B)_x
x_res(5) = qom*(Ey + x_vect(6)*Bx - x_vect(4)*Bz); % dv/dt = qom*(vel x B)_y
x_res(6) = qom*(Ez + x_vect(4)*By - x_vect(5)*Bx); % dw/dt = qom*(vel x B)_z


endfunction