• No results found

Differences Between The Revised Code (BMW2016) and van Bal-

3.3 A New PFSS code

3.3.3 Differences Between The Revised Code (BMW2016) and van Bal-

Here we list, for completeness, the differences between AVB1997 and BMW2016 even though some of the changes do not have a significant effect on the results.

Numerical Precision:

AVB1997 was written in IDL. It was also written using only single precision (32 bit) floating point numbers. BMW2016 has been written in Fortran in double precision (64 bit) although this could be increased to any numerical accuracy required. BMW2016 has also been parallelised.

Output Magnetic Field Grids:

AVB1997 calculates the magnetic field using a FFT with a grid of the same size in theφ direction as BMW2016 for a given L. Then AVB1997 uses a cubic spline interpolation to produce additional points on a new, finer grid, i.e. it produces a new grid point halfway between each original grid point. This essentially doubles the number of grid points in theφ direction and produces a new grid with

nφ= 4 (L+ 1) + 1 grid points with only half being analytical solutions to Laplace’s Equation. In the θ direction in AVB1997, to ensure the resolutions of the θ and φ grids are the same, no interpolation is required, simply more values θ

are calculated in the first place which is possible since their number if not limited by the FFT. So, again, the θ grid is doubled compared with BMW2016 and has

nθ = 2(L+ 1) + 1 grid points. The grid in ther direction in AVB1997 ranges from 1 to just under Rmax based on the unnormalised exponential function

3.3. A New PFSS code

section. Instead in BMW2016, all the radii are scaled to end exactly atRmax. For example, for L= 81, AVB1997 produces a grid of 48×165×329 whereas in BMW2016 the default grid is48×83×325. To get a similar grid resolution inθ

and φ, BMW2016 requires L= 161 which produces a grid of 95×163×325.

Analytic Form of the Model and Terms at Higher Order Harmonics:

During the calculation of theBlm and A m

l , AVB1997 uses the first forms forB m l and Aml given earlier by equations 3.29 and 3.31 whereas BMW2016 uses the second, mathematically equivalent forms in equations 3.30 and 3.32. An issue arises with the first forms of Blm and Aml (discovered when pushing the value of L

in the code above approximately 775 for 64 bit floating point numbers and approximately 100 for 32-bit floating point numbers) which means that the

(r/R)

l−1

term grows larger than the maximum value of the numerical floating point number and causes infinities in the final magnetic field. This issue is fixed using the forms ofBlm and Aml given in equations 3.30 and 3.32 where all radial terms are now decreasing withl. Given that in 1997 the available synoptic magnetogram data would have permittedL≈31at most with the AVB1997 default grid, this would not have been an issue at the time. But with current high resolution synoptic observations, this is a significant problem.

Another issue with AVB1997 is that the calculation of some of the individual terms is not done. In particular, the individual terms in the radially varying fraction within the first expression for Blm earlier in equation 3.29,

(l+ 1) r R −(l+2) +l r R l−1 R Rmax 2l+1 l+ 1 +l R Rmax 2l+1 ,

are not all calculated. Each of these radial ratio terms are calculated separately for each l within the code. The majority of these terms are decreasing with increasing l and tend to zero. AVB1997 sets all the ratio terms to zero forl above a threshold given by 10 log10Rmax .

ForRmax= 2.5, this threshold is equal to 25. Clearly, this is not ideal when L is large since all terms for l >25will be ignored.

explanation is that terms such as(R/Rmax) 2l+1

are very small for large enough l

that they are negligible in comparison to the terms for smalll, so they are ignored to save computational time. BMW2016 calculates these terms for all l. Ignoring the terms for largel may also have been done to avoid the earlier issue of infinities occurring whenl is about 100 for 32-bit floating point numbers.

Reversal of Summation:

In BMW2016, we have decided to reversed the order in which the summation over all the l subsums is done. The summation of floating point numbers of different orders of magnitude is more accurate if they are added in order of their absolute value and starting with the smallest. This ensures any truncation of the result due to numerical precision following the summation of terms is reduced as much as possible at each step of the summation. Given that the harmonics are small for largel, BMW2016 reverses the order of the summation inl to maximise accuracy of the final result. The inner summation is now done starting from

l=L and ending at l= 0. This summation cannot be reversed for m because of the FFT approach which is believed to be more accurate than direction

summation anyway.

Automation of the Gaussian Filter:

In AVB1997, the parametera used in the calculation of the Gaussian filter (equation 3.37) has to be manually chosen and any change must be hard coded whenL is changed. In BMW2016, it is now automated as described in section 3.3.2. However, if required, it can be chosen by input of a value on the command line when the code is executed.

Alteration in the Calculation of the Associated Legendre Polynomials:

AVB1997 did not take into account the negative sign in the first recursive

relationship forQml given in equation 3.10. This is fine due to the relationship for

Blm depending onQml ,

Blm(r) =

Z Z

S

Qml (θ)e−imφBr(r, θ, φ) dS,

because whenQml switches sign, then so will Blm. Thus the product of the two in the final summations, is always positive. Hence for calculating the PFSS model, the negative sign in equation 3.10 is not required and the correct result is obtained whether it is included in PFSS model code or not. However, the