Source file maxwell.M
The source file maxwell.M contains the subroutines to solve Maxwell's equations
in the full-particle code. The file is preprocessed by the m4-macro processor,
which allows to write numerical expressions, e.g. finite differences,
in a compact form. To view the Fortran-90 program pipe the source file
through m4
Subroutines:
-
Subroutine stepfield:
The subroutine stepfield advances the elecric and the magnetic
field according to Faraday's and Ampere's laws by dt/(2*substeps).
The parameter substeps allows to treat the electromagnetic field at a reduced
time step. As numerical algorithm a trapezoidal leapfrog scheme is used.
-
Subroutine divergence:
The subroutine divergence is called to fix the divergence of
the electric and the magnetic field (i.e. the Poisson equation and div
B = 0).
-
calculate the defect, i.e. the violation of Poisson's equation: rhocorrect=c2
rho - div E
-
solve Poisson equation for the defect: div grad phi = rhocorrect
For this purpose the multigrid is used: call to subroutine poisson
(source file multigrid.M)
-
correct the electric field: Ecorrect
= E - grad phi. The corrected electric field now exactly satisfies
the Poisson equation div Ecorrect = c2
rho.
As an option the same algorithm can be used to enforce div B
= 0. This is usually done once at start-up.
Switches:
-
fourth_order: Usually all spatial derivatives are taken to second
order. With the switch #define fourth_order the spatial derivatives
in the interior of the processor's subdomain are calculated to fourth order.
At the boundaries derivatives are always only second order accurate since
only one layer of ghost cells is available. For normal operation second_order
operators are sufficient.