Skip to content

Commit ec0e3df

Browse files
committed
Apply Black formatting to dedalus_sphere
1 parent 76955c8 commit ec0e3df

13 files changed

+1094
-997
lines changed
Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,62 @@
1-
import numpy as np
1+
import numpy as np
22
from . import jacobi
33

44
# The defalut configurations for the base Jacobi parameters.
5-
alpha = (-0.5,-0.5)
5+
alpha = (-0.5, -0.5)
66

7-
def quadrature(Nmax,alpha=alpha,**kw):
8-
return jacobi.quadrature(Nmax,alpha[0],alpha[1],**kw)
97

10-
def trial_functions(Nmax,z,alpha=alpha):
8+
def quadrature(Nmax, alpha=alpha, **kw):
9+
return jacobi.quadrature(Nmax, alpha[0], alpha[1], **kw)
1110

12-
init = 1/np.sqrt(jacobi.mass(alpha[0],alpha[1])) + 0*z
13-
return jacobi.recursion(Nmax,alpha[0],alpha[1],z,init)
1411

15-
def operator(dimension,op,Nmax,k,ell,radii,pad=0,alpha=alpha):
12+
def trial_functions(Nmax, z, alpha=alpha):
13+
14+
init = 1 / np.sqrt(jacobi.mass(alpha[0], alpha[1])) + 0 * z
15+
return jacobi.recursion(Nmax, alpha[0], alpha[1], z, init)
16+
17+
18+
def operator(dimension, op, Nmax, k, ell, radii, pad=0, alpha=alpha):
1619
# Pad the matrices by a safe amount before outputting the correct size.
17-
18-
if radii[1] <= radii[0]: raise ValueError('Inner radius must be greater than outer radius.')
19-
20-
gapwidth = radii[1] - radii[0]
21-
aspectratio = (radii[1] + radii[0])/gapwidth
22-
23-
a, b, N = k+alpha[0], k+alpha[1], Nmax + pad
24-
20+
21+
if radii[1] <= radii[0]:
22+
raise ValueError('Inner radius must be greater than outer radius.')
23+
24+
gapwidth = radii[1] - radii[0]
25+
aspectratio = (radii[1] + radii[0]) / gapwidth
26+
27+
a, b, N = k + alpha[0], k + alpha[1], Nmax + pad
28+
2529
# zeros
26-
if (op == '0'): return jacobi.operator('0',N,a,b)
27-
30+
if op == '0':
31+
return jacobi.operator('0', N, a, b)
32+
2833
# identity
29-
if (op == 'I'): return jacobi.operator('I',N,a,b)
30-
31-
Z = aspectratio*jacobi.operator('I',N+2,a,b)
32-
Z += jacobi.operator('J',N+2,a,b)
33-
34+
if op == 'I':
35+
return jacobi.operator('I', N, a, b)
36+
37+
Z = aspectratio * jacobi.operator('I', N + 2, a, b)
38+
Z += jacobi.operator('J', N + 2, a, b)
39+
3440
# r multiplication
35-
if op == 'R': return (gapwidth/2)*Z[:N+1,:N+1]
36-
37-
E = jacobi.operator('A+',N+2,a,b+1) @ jacobi.operator('B+',N+2,a,b)
38-
41+
if op == 'R':
42+
return (gapwidth / 2) * Z[: N + 1, : N + 1]
43+
44+
E = jacobi.operator('A+', N + 2, a, b + 1) @ jacobi.operator('B+', N + 2, a, b)
45+
3946
# conversion
40-
if op == 'E': return 0.5*(E @ Z)[:N+1,:N+1]
41-
42-
D = jacobi.operator('D+',N+2,a,b) @ Z
43-
47+
if op == 'E':
48+
return 0.5 * (E @ Z)[: N + 1, : N + 1]
49+
50+
D = jacobi.operator('D+', N + 2, a, b) @ Z
51+
4452
# derivatives
45-
if op == 'D+': return (D - (ell+k+1 )*E)[:N+1,:N+1]/gapwidth
46-
if op == 'D-': return (D + (ell-k+dimension-3)*E)[:N+1,:N+1]/gapwidth
47-
48-
# restriction
49-
if op == 'r=Ri': return jacobi.operator('z=-1',N,a,b)
50-
if op == 'r=Ro': return jacobi.operator('z=+1',N,a,b)
53+
if op == 'D+':
54+
return (D - (ell + k + 1) * E)[: N + 1, : N + 1] / gapwidth
55+
if op == 'D-':
56+
return (D + (ell - k + dimension - 3) * E)[: N + 1, : N + 1] / gapwidth
5157

58+
# restriction
59+
if op == 'r=Ri':
60+
return jacobi.operator('z=-1', N, a, b)
61+
if op == 'r=Ro':
62+
return jacobi.operator('z=+1', N, a, b)

0 commit comments

Comments
 (0)