Source file hybrid.M
The source file hybrid.M contains the electron fluid part of the hybrid
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
cat hybrid.M | m4
Subroutines:
-
Subroutine stephybrid:
The subroutine stephybrid advances the magnetic field and the
electron pressure according to the hybrid equations
by dt/(2*substeps). As time stepping algorithm a trapezoidal leapfrog
scheme is used. One iteration consists of the following steps (only the
first half of the leapfrog time step is shown):
-
the quantity on the right hand side of the evolution equation for B'
is calculated (compare the hybrid equations):
E' = (j x B' - ji x B
-
grad pe)/n = [(curl B) x (1-de2
div
grad) B - ji x B - grad pe)]/n
-
B' is calculated from B: B'
= (1-de2 div grad) B
-
B' is advanced from t to t+dt/(2*substeps) using
dB'/dt
= E'
-
B at t+dt/(2*substeps) is calculated by inverting
the Helmholtz equation (1-de2 div
grad) B = B', call to subroutine helmholtz (source
file multigrid.M)
-
step the electron pressure (unless the switch isothermal is used)
-
apply fourth order hyper viscosities to the magnetic field and the electron
pressure
-
Subroutine divergence:
The subroutine divergence is called to fix the divergence of
the magnetic field (i.e. div
B = 0) at start up and uses
the same algorithm as described in the full-particle version of the subroutine
divergence
in the source file maxwell.M.
-
Subroutine calc_e:
The subroutine calc_e calculates the electric field that enters
the ion equation of motion (compare the hybrid equations):
E
= (je x B - grad pe)/n
-
Subroutine add_base_density:
Since in the hybrid equations the density appears at several location
in the denominator numerical problems arise if the ion particle density
becomes too small. To relax these problems an artificial homogeneous background
density can be added with the routine add_base_density. The magnitude
of the background density is defined by the parameter n_base.
Switches:
-
isothermal: If the switch #define isothermal is used the
electron pressure is determined from the density and the constant electron
temperature T_e.
-
n_base: The parameter n_base sets the small artificial background
density, for example #define n_base 0.1