The 2D code developed here has been written from scratch, and thus required some simple testing to check that it was working as intended. We assume a uniform medium which implies that ρ0 = 1. Rather than driving the system we take an initial profile for the
radial velocity componentux, given as
ux = cos(ωt) sin(πx) cos
π 2y , (2.5.1) ⇒ux(x, y,0) = sin(πx) cos π 2y ,
that will be allowed to relax over the course of the simulation. The wavenumber in x,kx, is set toπ such that there exists half a wavelength over the box domain ofx: 0→1. The wavenumber iny,ky is set toπ/2. From our choice ofux we infer the initial and boundary conditions for the other components. Integrating equation (2.2.23) in time yields
⇒bx = −
kz
ω sin(ωt) sin(πx) cos
π
2y
,
⇒bx(x, y,0) = 0.
The constant of integration is neglected as we are interested in the perturbation wave behaviour, not a constant background shift. The temporal relationship between the per- turbations ux and bx is realised here, as a maximum of one implies a node (zero) of the other. A nice analogy is a pendulum, which has a maximum velocity when vertical, just as with our oscillating field line. Hence the field line is initially straight and thus has a zerobx component.
Using (2.2.25) to develop an initial condition forbz yields
∂bz
∂t = −
πcos(ωt) cos(πx) cosπ 2y +∂uy ∂y .
We are left to assume an initial condition inuy. In order to isolate the Alfv´en mode, the above equation is balanced by setting
∂uy
∂y =−πcos(ωt) cos(πx) cos
π
2y
such thatbz is initially zero and invariant in time. The Alfv´en mode is studied merely as a test case for the code. What highlights this case as Alfv´enic is bz = 0. For a uniform background field, bz is the only first order component to the magnetic pressure. Alfv´en waves are driven by magnetic tension and hence without a perturbation pressure we lose the fast mode in this set up. Continuing with the algebra, integrating the above equation with respect toy produces
uy =−2 cos(ωt) cos(πx) sin
π 2y , ⇒uy(x, y,0) =−2 cos(πx) sin π 2y .
which completes the initial conditions, given that by(x, y,0) = 0 by nature of a sin(ωt) time dependence. To use the Leapfrog trapezoidal method outlined in Section 2.4, two adjacent time levels must be known. The above initial conditions define the first timestep for t = 0; the second is acquired using a forward time central space (FTCS or Euler) method, where 100 steps are taken between the first and second time levels to retain accuracy. To implement the centred differences on the boundaries, ghost cells are used in a manner preserving the boundary conditions.
The final pieces of the puzzle are to decide on the run specifications. We choose a dimen- sionless box width of 1 in x and length 2 in y, with 101 points in each dimension. The timestep ∆tis set to 0.001 and the run covers 5000 timesteps. In choosing the timestep and grid scales inxandy, the Courant-Friedrichs-Lewy (CFL) condition must be satisfied. This condition restricts the temporal and spatial scales such that motions are appropri- ately sampled. For example, a reduction in the grid scale will often require a reduction in the timestep, so that multiple grid points are not traversed by a disturbance over a single timestep. This condition can be stated generally as
∆tV
∆x <1,
where ∆tis the timestep, ∆x the grid spacing in x, andV a characteristic speed. In our case, the speed is the Alfv´en speed which is unity, ∆x= 10−2 and ∆t= 10−3 and hence we satisfy the CFL condition by a factor of ten.
The wavenumbers are set as kx=π,ky =π/2 andkz=π, which differs from the value of
kz discussed above in Section 2.2. This is just a test case and for most of the future cases,
kz =π/2.
Figure 2.5.1 shows a time series plot of ux at the location x = 0.3, y = 0.6. Evident is a clear wave period of 2. This can be determined using the Alfv´en dispersion relation
for a uniform medium,ω =kzVA. VA = 1 since the density is uniform and we are using normalised variables. The period is given by τ = 2π/ω which gives a period of 2 for the chosenkz equal toπ. Reproducing the predicted Alfv´en frequency is a simple check that suggests the numerical routines are behaving as expected.
Figure 2.5.1: Time series of ux for the Alfv´en mode at x= 0.3,y= 0.6.
We can investigate a fast mode wave for this uniform density case in a similar manner, by ensuringbz is non zero. The same initial form ofux is considered as given in equation (2.5.1) and the wavenumbers are also kept the same. By equation (2.2.23)bx is given by
bx =−
π
ω sin(ωt) sin(πx) cos
π
2y
.
Equation (2.2.26) will yieldbz as
−ωsin (ωt) cosπ 2y
sin(πx) = −π
2
ω sin(ωt) sin(πx) cos
π 2y −∂bz ∂x, ⇒ ∂bz ∂x = ω−π 2 ω
sin(ωt) sin(πx) cosπ 2y , ⇒bz = π ω − ω π
sin(ωt) cos(πx) cosπ 2y
.
ω2=kx2+ky2+k2z =π2+π 2 4 +π 2= 9π2 4 ⇒ω= 3π 2 .
Hence bz can be written as
bz =− 5
6sin(ωt) cos(πx) cos
π
2y
.
Equation (2.2.25) can now be used in a similar way to find the appropriate condition for
uy, namely
∂uy
∂y = π
4 cos(ωt) cos(πx) cos
π
2y
uy = 1
2cos(ωt) cos(πx) sin
π
2y
.
So the initial condition foruy for the fast mode becomes
uy(x, y,0) = 1 2cos(πx) sin π 2y .
The magnetic field components all have a time dependence of sin(ωt) and hence have no initial value. The wave period is given as
τ = 2π ω = 2π 3π ·2 = 4 3.
Figure 2.5.2 shows the time evolution ofux at a point in the waveguide for this fast mode frequency. It is clear that the period of the oscillation is indeed 43, which is another check of the reliability of the code.
A final simple test is for the case ky = 0 which will become an important limit in later work in this thesis. The fast mode dispersion relation yields a period of
ω2 =k2VA2= 2π2,
⇒ω =π√2,
Figure 2.5.2: Time sequence ofux for the fast mode at x= 0.3,y= 0.6. which is again nicely displayed in a time series plot ofux given in Figure 2.5.3.
Figure 2.5.3: Time sequence ofux for theky = 0 mode atx= 0.3,y= 0.6.
It is important to demonstrate that the code conserves energy. No energy is being put into the system as there is no flow across any of the boundaries of the simulation domain. There is also no dissipation either and hence we would expect the energy to remain constant over the course of the simulation. We follow the work of Mann et al. [1995] by checking that an energy invariant is conserved by the code. This invariant is formed by considering a wave
energy equation derived from the cold, linearised MHD equations (2.2.1)-(2.2.2) [e.g. Bray and Loughhead, 1974, pg 252]. The magnetic and kinetic energy densities can be formed in the equation ∂ ∂t ρ0 2 (u ∗·u) +(b∗·b) 2µ0 +∇· b∗ µ0 ×(u×B0) = 0, (2.5.2)
where b∗,u∗ are the complex conjugates of b,u respectively. This is in the form of a conservation equation, namely ∂W/∂t+∇·S = 0, where S is the Poynting vector. As stated above, there is no flow across any of the domain boundaries, and hence integrating equation (2.5.2) over the volume yields
∂ ∂t
Z
V
W dV = 0.
ThereforeW is the invariant that is followed in time. Performing this integration at each timestep yields a constant energy as shown in Figure 2.5.4, conserved to one part in 106
or better.
Figure 2.5.4: Energy density (dimensionless) divided by the initial energy density, minus 1, plotted over time for the fast mode simulation.