1C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
2C QGAUSS
3C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
4 SUBROUTINE QGAUSS(G0G,GINVG,SPHIG,B,R0,HS,AINT,Q,W2,A,I)
5C 10/15/26 MHP via Claude
6C code changed to take JSON from DIMENSIONS_MOD instead of declaring
7C PARAMETER(JSON=5000) here.
8 USE DIMENSIONS_MOD
9C 10/20/26 MHP via Claude
10C code changed to replace implicit typing with IMPLICIT NONE and
11C explicit declarations.
12 IMPLICIT NONE
13 REAL*8 A,AINT,B,DX,G,G0G,G2,GINVG,HS,Q,R0,S,S2,SPHIG,W,W2,X,XM,XR
14 INTEGER I,J
15
16C 10/13/26 MHP via Claude: removed the unused COMMON/CONSTANTS/ declaration
17C (no member referenced here; residue of the obsolete-option removals).
18 DIMENSION R0(JSON),HS(JSON)
19 DIMENSION X(5),W(5)
20 DATA X/.14887433898163D0,.43339539412925D0,.67940956829902D0,
21 * *.86506336668899D0,.97390652851717D0/
22 DATA W/.29552422471475D0,.26926671931D0,.21908636251598D0,
23 * *.14945134915058D0,.06667134430869D0/
24 SAVE
25
26 XM = 0.5D0*B
27 XR = XM
28 G0G = 0.0D0
29 GINVG = 0.0D0
30 SPHIG = 0.0D0
31 DO 10 J = 1,5
32 DX = XR*X(J)
33 CALL FUNC(XM+DX,G,S,R0,HS,AINT,Q,W2,A,I)
34 CALL FUNC(XM-DX,G2,S2,R0,HS,AINT,Q,W2,A,I)
35 G0G = G0G+W(J)*(G*S+G2*S2)
36 GINVG = GINVG+W(J)*(S/G+S2/G2)
37 SPHIG = SPHIG+W(J)*(S+S2)
38 10 10 CONTINUE
39 G0G = G0G*XR
40 GINVG = GINVG*XR
41 SPHIG = SPHIG*XR
42 RETURN
43 END
1"""Python version of qgauss.f (YREC 7be4133): ten-point Gauss-Legendre
2quadrature over the polar angle on one equipotential shell."""
3
4import numpy as np
5
6from pyrec.func import func
7
8# DATA: the five positive nodes and their weights of the 10-point rule
9# (Fortran lines 19–23).
10x = np.array([0.0, .14887433898163, .43339539412925, .67940956829902,
11 .86506336668899, .97390652851717])
12w = np.array([0.0, .29552422471475, .26926671931, .21908636251598,
13 .14945134915058, .06667134430869])
14
15
16def qgauss(g0g: float, ginvg: float, sphig: float, b: float, r0: np.ndarray, hs: np.ndarray, aint: float, q: float,
17 w2: float, a: float, i: int) -> tuple[float, float, float]:
18 """Integrate g dS, dS/g and dS over theta in [0, b] on shell i, with
19 FUNC giving the effective gravity g and the surface element S.
20
21 Translates: qgauss.f#QGAUSS (7be4133)
22
23 Arguments: g0g, ginvg, sphig (set); b, the upper limit; r0, hs, aint,
24 q, w2, a, i, passed through to FUNC. Returns (g0g, ginvg, sphig).
25
26 """
27
28 # The midpoint and half-width of the interval (Fortran lines 26–30).
29 xm = 0.5 * b
30 xr = xm
31 g0g = 0.0
32 ginvg = 0.0
33 sphig = 0.0
34 g = s = g2 = s2 = 0.0
35
36 # The ten points, in symmetric pairs (Fortran lines 31–41).
37 for j in range(1, 6):
38 dx = xr * x[j]
39 g, s = func(xm + dx, g, s, r0, hs, aint, q, w2, a, i)
40 g2, s2 = func(xm - dx, g2, s2, r0, hs, aint, q, w2, a, i)
41 g0g = g0g + w[j] * (g * s + g2 * s2)
42 ginvg = ginvg + w[j] * (s / g + s2 / g2)
43 sphig = sphig + w[j] * (s + s2)
44 g0g = g0g * xr
45 ginvg = ginvg * xr
46 sphig = sphig * xr
47 return g0g, ginvg, sphig