The Elk Code
 
Loading...
Searching...
No Matches
sphcover.f90
Go to the documentation of this file.
1
2! Copyright (C) 2008 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3! This file is distributed under the terms of the GNU Lesser General Public
4! License. See the file COPYING for license details.
5
6!BOP
7! !ROUTINE: sphcover
8! !INTERFACE:
9subroutine sphcover(n,tp)
10! !INPUT/OUTPUT PARAMETERS:
11! n : number of required points (in,integer)
12! tp : (theta, phi) coordinates (out,real(2,n))
13! !DESCRIPTION:
14! Produces a set of $N$ points which cover the unit sphere nearly optimally.
15! The points in spherical $(\theta,\phi)$ coordinates are generated using the
16! explicit `golden section' formula:
17! \begin{align*}
18! \theta_k&=\arccos\left[1-\left(k-\tfrac{1}{2}\right)\delta z\right] \\
19! \phi_k&=(k-1)\delta\phi,
20! \end{align*}
21! where $\delta z=2/n$ and $\delta\phi=\pi(1-\sqrt{5})$.
22!
23! !REVISION HISTORY:
24! Created April 2008 (JKD)
25! Improved covering, October 2009 (JKD)
26!EOP
27!BOC
28implicit none
29! arguments
30integer, intent(in) :: n
31real(8), intent(out) :: tp(2,n)
32! local variables
33integer k
34real(8), parameter :: pi=3.1415926535897932385d0
35real(8) z,dz,p,dp
36if (n < 1) then
37 write(*,*)
38 write(*,'("Error(sphcover): n < 1 : ",I8)') n
39 write(*,*)
40 stop
41end if
42dz=2.d0/dble(n)
43z=1.d0-dz/2.d0
44tp(1,1)=acos(z)
45dp=pi*(1.d0-sqrt(5.d0))
46p=0.d0
47tp(2,1)=p
48do k=2,n
49 z=z-dz
50 tp(1,k)=acos(z)
51 p=p+dp
52 tp(2,k)=mod(p,2.d0*pi)
53end do
54end subroutine
55!EOC
56
subroutine sphcover(n, tp)
Definition sphcover.f90:10