other relevant code:
function cap = gauss(n, m, h, f)
% Arguments:
% n = number of points in the x-direction (horizontal)
% m = number of points in the y-direction (vertical)
% h = cell size
% f = 2D-array with solution
% Returns:
% cap = capacitance per unit length [pF/m]
q=0;
for i = 1:n;
q=q+(f(i,m)+f(i+1,m))*0.5; % integrate along upper boundary
end
for j = 1:m;
q=q+(f(n,j)+f(n,j+1))*0.5; % integrate along right boundary
end
cap = q*4; % 4 quadrants
cap = cap*8.854187; % epsilon0*1e12 gives answer in pF/m
and
% --------------------------------------------------------------% Make one Seidel iteration
% -------------------------------------------------------------
function f = seidel(f, mask, n, m)
% Arguments:
% f = 2D-array with solution
% mask = 2D-array with relaxation
% n = number of points in the x-direction (horizontal)
% m = number of points in the y-direction (vertical)
% Returns:
% f = 2D-array with solution after Gauss-Seidel iteration
% Gauss seidel iteration
for i = 2:n
for j = 2:m
f(i,j) = f(i,j) + mask(i,j)* ...
(0.25*( f(i-1,j) + f(i+1,j) ...
+ f(i,j-1) + f(i,j+1)) - f(i,j));
end
end
% Symmetry on left boundary i-1 -> i+1
i=1;
for j = 2:m
f(i,j) = f(i,j) + mask(i,j)* ...
(0.25*( f(i+1,j) + f(i+1,j) ...
+ f(i,j-1) + f(i,j+1)) - f(i,j));
end
% Symmetry on lower boundary j-1 -> j+1
j=1;
for i = 2:n;
f(i,j) = f(i,j) + mask(i,j)* ...
(0.25*( f(i-1,j) + f(i+1,j) ...
+ f(i,j+1) + f(i,j+1)) - f(i,j));
end